【发布时间】:2020-12-20 14:54:25
【问题描述】:
其实我想用c4来生成视频文件的c4 id ,所以我找到了下面的repo,它是为了做这件事而开发的,所以我克隆了这个repo
https://github.com/Avalanche-io/c4/tree/v0.7.0
现在正如堆栈溢出的答案中所建议的那样:Not able to install cmd version of c4 from github
我在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 https://github.com/Avalanche-io/c4/blob/v0.7.0/id/README.md 中定义的这个命令时
该命令是文件的go run main.go ```` Instead of getting the 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 开发人员可以帮助我。
【问题讨论】:
-
不是你的错,因为你只是按照说明操作,但你永远不应该使用
go run main.go。至于您的具体问题,文档似乎不完整和/或过时。根据自述文件,显然该包 (github.com/avalanche-io/c4/id) 已被弃用。我建议在 GitHub 问题跟踪器上询问相关项目,因为他们需要修复他们的文档。