go get
go getgo install
GO15VENDOREXPERIMENT当前项目目录/vendorgodepgodep
go get -u -v github.com/kardianos/govendor
vendorproj
package main
import (
"github.com/yeeuu/echoic"
)
func main() {
e := echoic.New()
e.SetDebug(true)
e.Run("127.0.0.1:4321")
}
执行一下命令就可以生成vendor文件夹:
$ govendor init
$ ls
main.go vendor
$ cd vendor/
$ ls
vendor.json
vendor.jsongodep
$ govendor add +external
updateremove
$ ls
github.com golang.org vendor.json
$ cat vendor.json
{
"comment": "",
"ignore": "test",
"package": [
{
"path": "github.com/yeeuu/echoic",
"revision": "a7d6994f92e2dc60cff071ae38b204fbd4bd2a3f",
"revisionTime": "2015-12-18T11:14:29+08:00"
},
{
"path": "golang.org/x/net/context",
"revision": "1d9fd3b8333e891c0e7353e1adcfe8a612573033",
"revisionTime": "2015-11-13T15:40:13-08:00"
}
]
}
$ cd github.com/yeeuu/echoic
$ ls
LICENSE context.go group.go router.go
README.md echoic.go response.go
GO15VENDOREXPERIMENT=1export GO15VENDOREXPERIMENT=1GO15VENDOREXPERIMENT=1 go build
通过这种方式就可以保证程序能够实现类似Python中Virtualenv的模式,实现不同程序使用不同版本依赖的目的。