有没有一种方法可以停止使用旧版本的go进行go代码编译?

问题描述:

We have some internal command line tools written in Go, and we're using the vendor folder to control their dependencies.

However, if the tools are updated with go get using Go 1.4 or lower (or 1.5 without the vendor experiment flag), from what I understand the dependencies will be pulled separately into the gopath.

Is there a way to require a minimum version of the go compiler to compile a package, so we have a hard and fast way to ensure everyone has the minimum version we expect?

我们有一些用Go语言编写的内部命令行工具,并且我们使用供应商文件夹来控制它们的依赖关系。 p>

但是,如果使用Go 1.4或更低版本(或1.5,但没有供应商实验标志)使用 go get code>更新工具,据我所知 p>

是否有一种方法需要最低版本的go编译器来编译软件包,因此我们有一种快速而又可靠的方法来确保每个人都拥有最低的编译器 我们期望的版本? p> div>

We do this in rclone with a build constraint like this. All go compilers version >= 1.5 will set the go1.5 build constraint so this won't build with a compiler < 1.5 and will build with a compiler >= 1.5.

//+build !go1.5

package main

// Upgrade to Go version 1.5 to compile rclone.
func init() { Go_version_1_5_required_for_compilation() }