The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
vevlins

采用 gomod 方式后 gopath 下的 bin 如何处理?

  •  
  •   vevlins · Mar 8, 2020 · 2787 views
    This topic created in 2280 days ago, the information mentioned may be changed or developed.

    go 新手沙雕问题。

    既然要贯彻 gomod,那 gopath 也要废除掉吗?

    如果废除掉,本来有些命令是 go get && go install 放到 bin 目录下,然后在构建过程中引用这些 /bin 目录。现在采用 gomod 怎么处理呢?

    换言之,原来 gopath 时有些构建时依赖是放在 bin 目录下管理的,现在 go mod 怎么处理?我看 github 有个可能相关的 issue https://github.com/golang/go/issues/27653

    4 replies    2020-03-09 11:27:35 +08:00
    reus
        1
    reus  
       Mar 8, 2020   ❤️ 1
    设 GOBIN 环境变量
    janxin
        2
    janxin  
       Mar 9, 2020   ❤️ 1
    现阶段 GOPATH 还是存在的,还是放在$GOPATH/bin 下。使用 go mod 安装的应用的可执行文件也是放在这个目录下。

    你也可以通过 GOBIN 定义具体的位置
    BlackBerry999
        3
    BlackBerry999  
       Mar 9, 2020
    现在是放在 GOPATH 下的 pkg/mod 目录下。你配置一下 GOBIN 就行了。
    BlackBerry999
        4
    BlackBerry999  
       Mar 9, 2020   ❤️ 1
    go mod init 后,在你引用新的依赖库时,可以直接 go mod tidy 命令自动下载会添加依赖到 go mod.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2759 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 05:27 · PVG 13:27 · LAX 22:27 · JFK 01:27
    ♥ Do have faith in what you're doing.