2 years ago

#40190

test-img

null

Output path problem of custom plug-in of the protoc.exe tool

I want to use the custom plug-in tool of protocol to realize the generation pb. Go file while generating my own code file, but I encountered the problem of file output path.

command like this:protoc -I=. --go_out=. --plugin=protoc-gen-code=./my-plugin --code_out=./test ./hello.proto

my-plugin's main.go

func main() {
    protogen.Options{
        ParamFunc: flags.Set,
    }.Run(func(gen *protogen.Plugin) error {
        file := gen.NewGeneratedFile("/hello.my.go", "")
        // 'hello.my.go' will be generated to the path './test/hello.my.go'
        // but I can't get the option '--code_out' in there
        // other codes
    })
}

go

protoc

0 Answers

Your Answer

Accepted video resources