dtzd65908
2017-11-08 03:59
浏览 627
已采纳

Golang错误:找不到包命令

I'm getting this error when running a .go file.

./instance.go: line 1: package: command not found
./instance.go: line 3: syntax error near unexpected token `newline'
./instance.go: line 3: `import ('

So far I've seen that the error normally means that GOPATH is not set, however, echo "$GOPATH" outputs /root/go and my path is currently /bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/go/bin:/root/go/bin:/bin:/root/go/bin .

Here's the first few lines of instance.go:

package webrun

import (
        "context"
        "crypto/hmac"
        "crypto/rand"

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

运行.go文件时出现此错误。

   ./ instance.go:第1行:包:找不到命令
./instance.go:第3行:意外令牌'newline'附近的语法错误
./instance.go:第3行:`import(  '
   
 
 

到目前为止,我已经看到该错误通常表示未设置GOPATH,但是, echo“ $ GOPATH” 输出 / root / go ,我的路径当前为 / bin:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ root / bin :/ usr / local / go / bin:/ root / go / bin:/ bin:/ root / go / bin

这是实例的前几行。 转到:

 程序包webrun 
 
import(
“上下文” 
“ crypto / hmac” 
“ crypto / rand” 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题