main.go无法找到包
实际上,我想使用main.go无法找到包,go,c4,go-get,Go,C4,Go Get,实际上,我想使用c4为视频文件生成c4 id,所以我找到了下面的repo,它就是为了做这件事而开发的,所以我克隆了这个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 impo
c4
为视频文件生成c4 id
,所以我找到了下面的repo
,它就是为了做这件事而开发的,所以我克隆了这个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
文件,当我运行这个命令时,他们在README.md
命令是go run main.go```而不是像他们在示例中所示的那样获取文件的
c4 id`````。我得到以下错误
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语言,所以在这里解决问题变得非常困难,是否有任何
go
开发人员可以帮助我。main.go
文件无法在/home/vinay/go/src/github.com/avalanche-io/c4/id
中找到包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
因此,根据我的说法,您需要执行以下命令
go get github.com/avalanche-io/c4/id
现在就跑你的主要路线,走吧
go run main.go
这不是你的错,因为你只是在遵循指令,但你永远不应该使用
go run main.go
。至于您的具体问题,文档似乎不完整和/或过时。根据自述文件,显然该包()已被弃用。我建议询问相关项目的GitHub问题跟踪程序,因为他们需要修复文档。谢谢,它可以工作。我真傻,竟然错过了这件事。无论如何,谢谢你。