去环境和路径

时间:2016-08-26 18:01:36

标签: 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文件夹..这是所有正在做什么或有我可以改变的东西。如果你可以指点我某种文件(请不要去啦!)会很棒。

我在Mac OS X上。

3 个答案:

答案 0 :(得分:1)

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

时显示

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

答案 1 :(得分:0)

在Mac OS X中,打开终端

创建.profile文件

touch .profile

编辑

vim .profile

将此添加到第一行

export GOPATH=$HOME/work/或Go文件所在的目录

保存:w并退出:q

重启终端

更改为新的GOPATH / bin目录以确认

cd $GOPATH/bin

答案 2 :(得分:-1)

您可以运行go env来查看您的$GOPATH和一些环境变量