downloadProtoc downloads the given version of protoc into the given directory.
(version string, localDir string)
| 138 | // downloadProtoc downloads the given version of protoc into the given |
| 139 | // directory. |
| 140 | func 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. |
no test coverage detected