How to implement go get within an app that has no internet?

huangapple go评论97阅读模式
英文:

How to implement go get within an app that has no internet?

问题

我正在玩一个使用martini的Go应用程序。每次运行应用程序时,我都必须运行"go get github.com/codegangsta/martini"。有没有办法不必这样做?无论如何,在离线环境中该如何工作?我正在考虑在没有互联网访问的离线环境中使用Go开发一个应用程序。

英文:

I am playing around with a Go app that imports martini for example. Every time I run the app, I have to run "go get github.com/codegangsta/martini". Any way to NOT have to do this? Either way, how would this work in an offline environment? I am considering Go for an app that will be offline with no internet access.

答案1

得分: 4

根据Go文档

Get命令会下载并安装由导入路径指定的包,以及它们的依赖项。

进一步解释一下:
go get命令会从代码库中克隆你请求的代码(在这种情况下是github.com/codegangsta/martini),以及该代码所导入的任何代码,并将其存储在本地的$GOPATH/src/目录中,然后进行构建并存储,以便可以通过import进行调用。因此,除非你的GOPATH正在更改,否则你不需要多次调用go get,并且在初始的go get之后,它应该始终在本地可用。

英文:

From the go documentation:

Get downloads and installs the packages named by the import paths, along with their dependencies.

To expand on that:
go get will clone the code you're requesting from the repository (in this case github.com/codegangsta/martini) as well as any code that that code imports and store it in your local $GOPATH/src/ directory then build it and store it so that is available to call via import, so you should never have to call go get more than once unless your GOPATH is being changed and it should always be available locally after the initial go get.

huangapple
  • 本文由 发表于 2014年2月19日 02:41:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/21862622.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定