main.go 找不到包

问题描述

实际上我想用c4来为视频文件生成c4 id ,所以我找到了下面的repo,它是为了做这件事而开发的,所以我克隆了这个{{ 1}} https://github.com/Avalanche-io/c4/tree/v0.7.0

现在正如堆栈溢出的这个答案所建议的:Not able to install cmd version of c4 from github

我在 repo 终端中执行以下命令

ubuntu

然后正如他们在如何使用此 go get github.com/Avalanche-io go get github.com/Avalanche-io/c4/id go get github.com/Avalanche-io/c4/cmd/c4

的示例中所示
repo

我只是复制了相同的示例并创建了一个 package main import ( "fmt" "io" "os" c4 "github.com/avalanche-io/c4/id" ) func main() { file := "main.go" f,err := os.Open(file) if err != nil { panic(err) } defer f.Close() // create a ID encoder. e := c4.NewEncoder() // the encoder is an io.Writer _,err = io.copy(e,f) if err != nil { panic(err) } // ID will return a *c4.ID. // Be sure to be done writing bytes before calling ID() id := e.ID() // use the *c4.ID String method to get the c4id string fmt.Printf("C4id of \"%s\": %s\n",file,id) return } 文件,当我运行他们在 main.go https://github.com/Avalanche-io/c4/blob/v0.7.0/id/README.md 中定义的这个命令时 该命令是文件README.mdc4 id```,如他们在示例中所示。我收到以下错误

go run main.go  ```` Instead of getting the 

我不懂 main.go:8:3: cannot find package "github.com/avalanche-io/c4/id" in any of: /usr/lib/go-1.13/src/github.com/avalanche-io/c4/id (from $GOROOT) /home/vinay/go/src/github.com/avalanche-io/c4/id (from $GOPATH) 语言,所以在这里解决问题对我来说变得非常困难,有没有 go 开发人员可以帮助我。

解决方法

pip install 文件无法在 main.go 中找到包 github.com/avalanche-io/c4/id,我可以看到您运行了以下 /home/vinay/go/src/github.com/avalanche-io/c4/id 命令

go get 

但他们都没有名字go get github.com/Avalanche-io go get github.com/Avalanche-io/c4/id go get github.com/Avalanche-io/c4/cmd/c4 所以根据我的说法,您需要执行以下命令

github.com/avalanche-io/c4/id

现在运行你的 main.go

go get github.com/avalanche-io/c4/id