doulou1989 2017-12-28 10:28
浏览 597

在构建时无法在golang中找到包“ github.com/user../../”

I am trying to build a project from github source code. I have found some source code importing a package something like below:

import (
    "os"

    "github.com/bivas/rivi/commands"
    "github.com/mitchellh/cli"
)

However, while building a project every time it throws an error:

user-MacBook-Pro:rivi user$ go build rivi.go
rivi.go:6:2: cannot find package "github.com/bivas/rivi/commands" in any of:
        /usr/local/Cellar/go/1.7.5/libexec/src/github.com/bivas/rivi/commands (from $GOROOT)
        ($GOPATH not set)
rivi.go:8:2: cannot find package "github.com/mitchellh/cli" in any of:
        /usr/local/Cellar/go/1.7.5/libexec/src/github.com/mitchellh/cli (from $GOROOT)
        ($GOPATH not set)

how to build this project. Currently I am trying to build this one project into my system.

EDITED:

After running this command go install or go get:

package github.com/bivas/rivi/commands: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/connectors/github: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/autoassign: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/automerge: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/commenter: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/labeler: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/locker: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/sizing: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/slack: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/status: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/bivas/rivi/engine/actions/trigger: cannot download, $GOPATH not set. For more details see: go help gopath
package github.com/mitchellh/cli: cannot download, $GOPATH not set. For more details see: go help gopath
  • 写回答

1条回答 默认 最新

  • duangou1551 2017-12-30 23:25
    关注

    This problem common if you haven't setup any go path yet. It is necessary.

    I am assuming from the command line snap of yours, that you are a UNIX user. Googles official doc recommend that you setup your go path manually . $GOROOT is optional but $GOPATH has to be set if you are trying to get third party libraries.

    Edit your ~/.bash_profile to add the following line:

    export GOPATH=$HOME/work
    

    Then logout and login or use source ~/.bash_profile You can read more from here. Assuming your Golang package directory is in work folder inside your home directory. The directory structure of work folder has to look like this,

    • work
      • src
      • pkg
      • bin
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器