windows下使用IDEA开发Linux系统syscall调用
- 首先是编译sys库
在命令行下输入:set GOOS=linux,回车
然后执行:go get golang.org/x/sys/unix,回车
就可以看到编译成功
- 在IDEA使用系统调用
打开IDEA,点击settings
在 “Languages & Frameworks” > "Go" > "Vendoring & Build Tags" 中设置OS为linux
applay之后,就可以出现提示了
使用mmap提示:permission denied
是由于open一个文件,默认是read_only。而mmap的时候使用了write权限导致。
如:fin, error := os.Open(mmapFile)
而mmap是:mmap, err := unix.Mmap(int(fin.Fd()), 0, 100, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED)
golang.org被墙解决
通过github.com下载源码,然后编译解决。这里以VSCode安装依赖为例
- 安装github.com/josharian/impl 会依赖golang.org/x/tools。先下载x/tools,地址:https://github.com/golang/tools.git
$ pwd
/home/myname/workspace/golang/go_ext/src
$ git clone https://github.com/golang/tools.git 'golang.org/x/tools'
....下载x/tools....
$ git clone https://github.com/josharian/impl.git 'github.com/josharian/impl'
....下载impl....
$ go install github.com/josharian/impl
$ ls ../bin
....可以看到impl安装成功....
2.安装dlv
$ git clone https://github.com/derekparker/delve.git 'github.com/derekparker/delve'
$ go install github.com/derekparker/delve/cmd/dlv
3.安装go-outline
$ git clone https://github.com/ramya-rao-a/go-outline.git github.com/ramya-rao-a/go-outline
$ go install github.com/ramya-rao-a/go-outline
4.安装godef
$ git clone https://github.com/rogpeppe/godef.git github.com/rogpeppe/godef
$ go install github.com/rogpeppe/godef
5.安装go-symbols
$ git clone https://github.com/acroca/go-symbols.git github.com/acroca/go-symbols
$ go install github.com/acroca/go-symbols
6.安装godoc goru gorename
$ go install golang.org/x/tools/cmd/godoc
$ go install golang.org/x/tools/cmd/gorn
$ go install golang.org/x/tools/cmd/gorename
7.安装sourcegraph.com/sqs/goreturns
$ git clone https://github.com/sqs/goreturns.git github.com/sqs/goreturns
$ go install github.com/sqs/goreturns
8.安装github.com/golang/lint/golint
$ git clone https://github.com/golang/lint.git github.com/golang/lint
$ go install github.com/golang/lint/golint
9.安装github.com/cweill/gotests
$ git clone https://github.com/cweill/gotests.git github.com/cweill/gotests
$ go install github.com/cweill/gotests/...
注意install的时候是三个点
cannot resolve file问题
在intellij 2017.1使用go1.10时,出现此问题。后来查找说插件不支持1.10,就降级到go1.9.5 然后在file-->settings-->Languages & Frameworks-->Go-->GOROOT 选择go的安装位置。 并且发现不能像之前,在project structure-->Platform Settings-->sdks中设置gosdk了