go - 构建时在 golang 中找不到包 "github.com/user../../"

标签 go github build glide-golang

我正在尝试从 github 源代码构建一个项目。我发现一些源代码导入了如下所示的包:

import (
    "os"

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

但是在构建项目时每次都会报错:

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)

如何构建这个项目。目前我正在尝试构建这个 project进入我的系统。

已编辑:

运行此命令后 go installgo 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

最佳答案

这个问题已经有几年了。我遇到了同样的问题。我的解决方案是我需要运行 go mod init [name_of_main_go_file],它会创建 go.mod 文件。然后你可以运行 go run .

https://golang.org/doc/tutorial/getting-started#call

关于go - 构建时在 golang 中找不到包 "github.com/user../../",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48005767/

相关文章:

git - 想要使用 git bash 推送到 GitHub 时如何修复 SSL 证书错误?

java - 我如何使用自定义 java 库(来自 github)

java - 找不到要构建的任何修订。验证此作业的存储库和分支配置。完成 : FAILURE

Android 发布构建错误 : "The value for this property cannot be changed any further."

goji/httpauth - 不能与标准 Golang 'net/http' 库一起使用

postgresql - PostgreSQL 的 "COPY table FROM file"语句可以在 Go 中使用吗?

两个不同文件夹中两个不同存储库之间的git diff

java - Drools 在 ant 构建期间无法解析 ObjectType

jquery - Ajax新手学习(golang jquery)

go - godoc 可播放示例上的 "cannot find package"错误