我是golang的新手,正在尝试使用this tutorial.编写程序
但是我在编译它时抛出此错误。
6g: command not found
这是我尝试过的:
$ go version
go version go1.4.1 darwin/amd64
这是我的.bashrc的样子:
$ tail ~/.bashrc
export GOBIN=/Users/abhijeet/code/golang/go/bin
export GOROOT=/Users/abhijeet/code/golang/go
export GOPATH=/Users/abhijeet/code/golang/gopath
export GOOS="darwin"
export GOARCH="amd64"
export PATH="$GOBIN:$PATH"
外观如下:
[ -r $HOME/.bashrc ] && source $HOME/.bashrc
这是我运行“gcc --version”命令时得到的结果:
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
他们要求运行什么:
6g -I $GOPATH/pkg/linux_amd64 urlshortener.go
我正在运行:
6g -I $GOPATH/pkg/darwin_amd64 urlshortener.go
我所能找到的是
darwin_amd64
├───code.google.com
│ ├───p
│ │ └───google-api-go-client
│ │ └───googleapi
│ │ │ └─── <more folders and files here>
│ │ └───urlshortener
│ │ │ └───v1.a
│ │ └───googleapi.a
│ │
因此,我知道那里存在一些问题,但是我也知道,这可能不是导致我所看到的错误的原因,否则我会看到诸如“找不到文件”之类的错误。我只是想提及它作为其他数据。
因此,我对此表示感谢。请让我知道是否也应该提供其他数据。
最佳答案
这是一个内部命令,您可以使用go tool 6g
运行它。
话虽如此,该指南已经过时,不再适用。
替换为仅运行go build urlshortner.go
甚至go run urlshortner.go
很少要检查的资源:
关于go - 6克: command not found error while compiling external API code in Go,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28608216/