duanma8207 2013-03-18 21:13
浏览 17
已采纳

转到包/文件位置

From the looks of the go documentation, they make it seem like you have to put code you're working on under your $GOPATH-- is that correct?

I would like to set up a test project in a dir under my ~/Documents, but everytime i run go install example/newmath (like in the test example) it says the following--

λ MacBook-Air src → go install example/newmath
warning: GOPATH set to GOROOT (/usr/local/go) has no effect
can't load package: package example/newmath: import "example/newmath": cannot find package

Does that mean that i need to reset my $GOPATH/$GOROOT? I'm lost.

  • 写回答

1条回答 默认 最新

  • dongyao2022 2013-03-18 21:30
    关注

    No need to setup GOROOT in the common situation. GOPATH, OTOH, should be set (and exported).

    I would recommend to start with

       export GOPATH=$HOME
    

    Then just put a package having import "whatever" into $GOPATH/src/whatever.

    You can refine your GOPATH to your needs later, when you get used to how things work with the Go build system (go {build, install}). One can have even multiple items in $GOPATH, but I really don't think it's a concern in the beginning, and sometimes never.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动