ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
在nodejs中我们有npm,可以通过npm来下载安装一些依赖包。在go中也开发了类似的东西,那就是gopm。这玩意儿是七牛开发的。在这里说下,七牛公司大部分程序都是用go语言编写的,所以开发出这么一个方便的东西肯定也是合情合理的。 ### gopm 安装 ~~~ go get github.com/gpmgo/gopm go install github.com/gpmgo/gopm ~~~ 通过这个命令来安装插件,默认的会存放到GOBIN,如果没有配置%GOBIN%环境变量,那么会默认安装到%GOPATH%下的bin目录,为了我们操作方便,我们把GOBIN加到%PATH%下。 ### 使用说明 ~~~ NAME: Gopm - Go Package Manager USAGE: Gopm [global options] command [command options] [arguments...] VERSION: 0.8.8.0307 Beta COMMANDS: list list all dependencies of current project gen generate a gopmfile for current Go project get fetch remote package(s) and dependencies bin download and link dependencies and build binary config configure gopm settings run link dependencies and go run test link dependencies and go test build link dependencies and go build install link dependencies and go install clean clean all temporary files update check and update gopm resources including itself help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --noterm, -n disable color output --strict, -s strict mode --debug, -d debug mode --help, -h show help --version, -v print the version ~~~ ### exmaple ~~~ gopm get -g -v -u golang.org/x/tools/cmd/goimports ~~~ 通过`gopm get xxx`,可以将指定的包下载到gopm的本地仓库`~/.gopm/repos`(建议使用) 通过'gopm get -g xxx',可以将指定的包下载到GOPATH下。(建议使用) 通过'gopm get -l xxx',可以将指定的包下载到当前所在目录(不常用)