猿问

安装 go 风景 - 无法使用 &SceneryDefinition

我已经安装好了。但是,当我这样做时:


go get -u github.com/dmlittle/scenery

我得到:


# github.com/dmlittle/scenery/pkg/parser

go/src/github.com/dmlittle/scenery/pkg/parser/parser.go:98:20: cannot use &SceneryDefinition literal (type *SceneryDefinition) as type lexer.Definition in argument to participle.Lexer:

    *SceneryDefinition does not implement lexer.Definition (wrong type for Lex method)

        have Lex(io.Reader) (lexer.Lexer, error)

        want Lex(string, io.Reader) (lexer.Lexer, error)

go/src/github.com/dmlittle/scenery/pkg/parser/parser.go:116:21: not enough arguments in call to p.ParseString

    have (string, *Plan)

    want (string, string, interface {}, ...participle.ParseOption)

go/src/github.com/dmlittle/scenery/pkg/parser/scanner.go:39:10: undefined: lexer.Errorf

go/src/github.com/dmlittle/scenery/pkg/parser/scanner.go:82:26: undefined: lexer.Errorf

有什么建议么?


蛊毒传说
浏览 94回答 1
1回答

潇湘沐

同样的问题,似乎prj使用dep。我已经修复了克隆 repo,然后配置 go 模块以找到正确的项目依赖项。然后再次运行 go get ,构建成功:~/go/src/github.com/dmlittle/scenery (master ✔) ᐅ go run main.go# github.com/dmlittle/scenery/pkg/parserpkg/parser/parser.go:98:20: cannot use &SceneryDefinition literal (type *SceneryDefinition) as type lexer.Definition in argument to participle.Lexer:    *SceneryDefinition does not implement lexer.Definition (wrong type for Lex method)        have Lex(io.Reader) (lexer.Lexer, error)        want Lex(string, io.Reader) (lexer.Lexer, error)pkg/parser/parser.go:116:21: not enough arguments in call to p.ParseString    have (string, *Plan)    want (string, string, interface {}, ...participle.ParseOption)pkg/parser/scanner.go:39:10: undefined: lexer.Errorfpkg/parser/scanner.go:82:26: undefined: lexer.Errorf初始化 go mod:~/go/src/github.com/dmlittle/scenery (master ✔) ᐅ go mod initgo: creating new go.mod: module github.com/dmlittle/scenerygo: copying requirements from Gopkg.lock检查依赖项:go mod tidygo: downloading github.com/spf13/cobra v0.0.3go: downloading github.com/fatih/color v1.7.0....安装包:go get -u github.com/dmlittle/scenery按预期工作:~/go/src/github.com/dmlittle/scenery (master ✘)✭ ᐅ ./sceneryUsage:  scenery [flags]Examples:  terraform plan | sceneryFlags:  -h, --help       help for scenery  -n, --no-color   Print output without color      --version    version for scenery
随时随地看视频慕课网APP

相关分类

Go
我要回答