Go开发问题集锦

windows下使用IDEA开发Linux系统syscall调用

  1. 首先是编译sys库

在命令行下输入:set GOOS=linux,回车linux

而后执行:go get golang.org/x/sys/unix,回车git

就能够看到编译成功github

  1. 在IDEA使用系统调用

打开IDEA,点击settingsgolang

在 “Languages & Frameworks” > "Go" > "Vendoring & Build Tags" 中设置OS为linuxwindows

applay以后,就能够出现提示了app

使用mmap提示:permission denied

是因为open一个文件,默认是read_only。而mmap的时候使用了write权限致使。ui

如:fin, error := os.Open(mmapFile)spa

而mmap是:mmap, err := unix.Mmap(int(fin.Fd()), 0, 100, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED)插件

golang.org被墙解决

经过github.com下载源码,而后编译解决。这里以VSCode安装依赖为例命令行

  1. 安装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了

相关文章
相关标签/搜索