首页 > Mac下golang编译出错

Mac下golang编译出错

bogon:golang zhaoqiaohua$ go build helloworld.go
go build runtime: exec: "/Users/zhaoqiaohua/go/pkg/tool/darwin_386/8g": stat /Users/zhaoqiaohua/go/pkg/tool/darwin_386/8g: no such file or directory

在Mac下编译报错,我的golang安装包直接从http://code.google.com/p/go下载安装的,哪位能帮忙看一下什么问题啊


1) 你有沒有下載對的Build? 64bits 還是32bits?
2) 你有沒有設好 PATH=$PATH:/usr/local/go/bin
3) 你有沒有設好 GOPATH=~/XXXXXXXX/ (你的開發路徑)


我是使用brew 安装的,步骤如下,供你参考:

我的:

➜  tree $GOPATH
/Users/shiweifu/go/
├── pkg
│   └── darwin_amd64
│       └── yaml.a
└── src
    └── yaml
        ├── Makefile
        ├── config.go
        ├── config_test.go
        ├── doc.go
        ├── parser.go
        ├── parser_test.go
        ├── types.go
        └── types_test.go

4 directories, 9 files
➜  ~GOROOT git:(master) ✗ tree $GOROOT -d -L 2
/usr/local/Cellar/go/1.0.3
├── api
├── bin
├── doc
│   ├── articles
│   ├── codewalk
│   ├── devel
│   ├── gopher
│   ├── play
│   └── progs
├── etc
│   └── bash_completion.d
├── lib
│   ├── godoc
│   └── time
├── misc
│   ├── IntelliJIDEA
│   ├── arm
│   ├── bbedit
│   ├── cgo
│   ├── chrome
│   ├── dashboard
│   ├── dist
│   ├── emacs
│   ├── fraise
│   ├── goplay
│   ├── kate
│   ├── notepadplus
│   ├── osx
│   ├── swig
│   ├── vim
│   └── xcode
├── pkg
│   ├── darwin_amd64
│   └── tool
├── share
│   └── zsh
├── src
│   ├── cmd
│   ├── lib9
│   ├── libbio
│   ├── libmach
│   └── pkg
└── test
    ├── bench
    ├── bugs
    ├── chan
    ├── dwarf
    ├── fixedbugs
    ├── interface
    ├── ken
    ├── safe
    └── syntax

52 directories

执行:

go run a.go
go build a.go

你是通过源码安装Go还是下载的编译好的Go?
可以试试通过源码安装Go

还有问题的话,可以看看这里:
http://bbs.studygolang.com/thread-67-...

【热门文章】
【热门文章】