Go开发问题集锦

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

  1. 首先是编译sys库

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

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

就可以看到编译成功

  1. 在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安装依赖为例

  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了

转载于:https://my.oschina.net/u/583362/blog/1512480

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值