Go 语言环境和路径

标签 go

我从 github 克隆的应用程序很少,但不确定我做的是否正确。我最近安装了 go。

$ go
Go is a tool for managing Go source code.

Usage:

        go command [arguments]

The commands are:

        build       compile packages and dependencies
        clean       remove object files
        doc         show documentation for package or symbol
        env         print Go environment information
        fix         run go tool fix on packages
        fmt         run gofmt on package sources
        generate    generate Go files by processing source
        get         download and install packages and dependencies
        install     compile and install packages and dependencies
        list        list packages
        run         compile and run Go program
        test        test packages
        tool        run specified go tool
        version     print Go version
        vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

        c           calling between Go and C
        buildmode   description of build modes
        filetype    file types
        gopath      GOPATH environment variable
        environment environment variables
        importpath  import path syntax
        packages    description of package lists
        testflag    description of testing flags
        testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.

我已经相应地配置了一些东西(导出的变量等)也将它们添加到 ~/.bashrc 但是我仍然需要更改目录并转到我的 go/bin 文件夹..这是所有正在做的还是有我可以改变的东西。如果你能给我指点某种文档就太好了(请不要 go lang!)。

我在 Mac OS X 上。

最佳答案

验证您尝试运行的二进制文件是否在您的 $GOPATH/bin 目录中,例如它应该在你运行 ls $GOPATH/bin

时出现

接下来,验证 $GOPATH/bin 是否在您的 $PATH 中,例如它应该与 echo $PATH 一起出现。如果此 $GOPATH/bin 不在您的 $PATH 中,请添加它,例如export PATH=$GOPATH/bin:$PATH(您可能希望将其添加到您的 .bashrc)。

关于Go 语言环境和路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39172215/

相关文章:

go - 在 golang 中,编写 JSON 和 MySQL 查询字符串的好格式是什么?

go - 如何将数组处理分离到 goroutines 中?

json - 编码(marshal) map 到 JSON

linux - 执行并发 os/exec.Command.Wait() 时发生内存泄漏

go - 使用 time.Unix() 从 float 解析带小数的 unix 时间戳?

去 float 零除法编译器错误

go - Gin-Gonic 限制路由

go - 无法在 vscode 的文件夹 vendor 中找到包 - Golang

Golang var 和字面量用法

http - 使用 curl 调用 golang jsonrpc