我是 golang 的新手,我正在嘗試使用本教程編寫程序。但是我在編譯它時(shí)拋出了這個(gè)錯(cuò)誤。6g: command not found這是我嘗試過的:$ go versiongo version go1.4.1 darwin/amd64我已經(jīng)正確設(shè)置了環(huán)境變量這是我的 .bashrc 的樣子: $ tail ~/.bashrcexport 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"我在 /etc/profile 下添加了以下行以獲取它這是它的外觀:[ -r $HOME/.bashrc ] && source $HOME/.bashrc如果我退出終端,再次啟動(dòng)它并回顯任何變量,它們就會(huì)起作用。我已經(jīng)安裝了 gcc。這是我運(yùn)行“gcc --version”命令時(shí)得到的結(jié)果:$ gcc --versionConfigured 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.1Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)Target: x86_64-apple-darwin14.1.0Thread model: posix如果我編寫任何其他 go 程序并運(yùn)行它,它就可以工作。例如,從這里第 1 節(jié)到第 5 節(jié),直到“Go Templates - Part 3 - Template Sets”的所有程序即使現(xiàn)在也能正常工作。只有這個(gè)特定的教程讓我感到不安。我剛剛提供鏈接的其他程序都不需要我運(yùn)行“6g”命令。但它們?nèi)匀辉谖业臋C(jī)器上運(yùn)行。關(guān)于出現(xiàn)錯(cuò)誤的那一行,我正在使用正確的那一行來反映我機(jī)器中的文件夾名稱。他們要求運(yùn)行的內(nèi)容:6g -I $GOPATH/pkg/linux_amd64 urlshortener.go我正在運(yùn)行的內(nèi)容:6g -I $GOPATH/pkg/darwin_amd64 urlshortener.go重要提示:我已按照教程中的所有步驟使用外部 api。但是,如果我查看 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│ │ 所以我知道那里存在一些問題,但我也知道這可能不是導(dǎo)致我看到的錯(cuò)誤的原因,否則我會(huì)看到“找不到文件”之類的錯(cuò)誤。我只是想將其作為附加數(shù)據(jù)提及。所以我很感激這方面的任何幫助。如果我還應(yīng)該提供任何其他數(shù)據(jù),請(qǐng)告訴我。
6g:在 Go 中編譯外部 API 代碼時(shí)找不到命令錯(cuò)誤
慕運(yùn)維8079593
2021-09-13 19:45:54