doujiaoang69440
2012-12-11 23:40
浏览 151
已采纳

Golang-在SublimeText2中找不到包

when i try to execute my .go script with my package newmath i get following error in SublimeText2.

"test.go:5:2: import "newmath": cannot find package"

Thats my build-system in SublimeText2

{
"cmd": ["go","run", "${file}"],
"working_dir": "${file_path}",
"selector": "source.go, source.g"
}

but when i execute my script in the terminal the go-compiler can find the package and it is succesfully executed. And i have noticed that the GOPATH is reseted after reboot or after a while by itself :/

My Go env:

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/daggi/gocode/"
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CGO_ENABLED="1"

I think it is a path/environment problem of SublimeText2 but i dont know.

Thank you.

图片转代码服务由CSDN问答提供 功能建议

当我尝试使用包 newmath 执行我的.go脚本时,出现以下错误 在SublimeText2中。

 “ test.go:5:2:导入“ newmath”:找不到软件包“ 
   
 
 <  p> 那是我在SublimeText2中的构建系统  
 
 
  {
“ cmd”:[“ go”,“ run”,“ $ {file  }“],
” working_dir“:” $ {file_path}“,
”选择器“:” source.go,source.g“ 
} 
   
 
 <  p>但是当我在终端中执行脚本时,go编译器可以找到该包,并且该包 成功 被执行。 而且我已经注意到,GOPATH在重启后或一段时间后会被重置:/  
 
 

我的Go环境: < pre> GOARCH =“ amd64” GOBIN =“” GOCHAR =“ 6” GOEXE =“” GOGCCFLAGS =“-g -O2 -fPIC -m64 -pthread” GOHOSTARCH =“ amd64” GOHOSTOS = “LINUX” GOOS = “LINUX” GOPATH = “/家/ daggi / gocode /” GOROOT = “/ usr / lib中/走出去” GOTOOLDIR = “/ usr / lib中/去/包装/工具/ linux_amd64” \ nCGO_ENABLED =“ 1”

我认为这是SublimeText2的路径/环境问题,但我不知道。

谢谢 您。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题