MCPcopy
hub / github.com/opentofu/opentofu / downloadProtoc

Function downloadProtoc

tools/protobuf-compile/protobuf-compile.go:140–159  ·  view source on GitHub ↗

downloadProtoc downloads the given version of protoc into the given directory.

(version string, localDir string)

Source from the content-addressed store, hash-verified

138// downloadProtoc downloads the given version of protoc into the given
139// directory.
140func downloadProtoc(version string, localDir string) error {
141 protocURL, err := protocDownloadURL(version)
142 if err != nil {
143 return err
144 }
145
146 log.Printf("downloading and extracting protoc v%s from %s into %s", version, protocURL, localDir)
147
148 // For convenience, we'll be using go-getter to actually download this
149 // thing, so we need to turn the real URL into the funny sort of pseudo-URL
150 // thing that go-getter wants.
151 goGetterURL := protocURL + "?archive=zip"
152
153 err = getter.Get(localDir, goGetterURL)
154 if err != nil {
155 return fmt.Errorf("failed to download or extract the package: %s", err)
156 }
157
158 return nil
159}
160
161// buildProtocGenGo uses the Go toolchain to fetch the module containing
162// protoc-gen-go and then build an executable into the working directory.

Callers 1

mainFunction · 0.85

Calls 3

protocDownloadURLFunction · 0.85
PrintfMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected