安装
IDE: https://buf.build/docs/editor-integration/
插件:
这个不是buf官方,但能用 protoc-gen-es:https://github.com/wasilibs/go-protoc-gen-es
buf,grpcurl,protoc-gen-go,protoc-gen-connect-go https://connectrpc.com/docs/go/getting-started
go install github.com/bufbuild/buf/cmd/buf@latestgo install github.com/fullstorydev/grpcurl/cmd/grpcurl@latestgo install google.golang.org/protobuf/cmd/protoc-gen-go@latestgo install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest配置:
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yamlversion: v2lint: use: - STANDARD except: - FIELD_NOT_REQUIRED - PACKAGE_NO_IMPORT_CYCLE disallow_comment_ignores: true ignore: - internal/conf#deps: # 依赖的proto库# - buf.build/googleapis/googleapis# - buf.build/grpc-ecosystem/grpc-gateway# - buf.build/bufbuild/protovalidatebreaking: use: - FILE except: - EXTENSION_NO_DELETE - FIELD_SAME_DEFAULTbuf.gen.yaml
version: v2managed: enabled: true disable: - module: buf.build/googleapis/googleapis file_option: go_package_prefix # 禁用对 googleapis 模块的 go_package 重写 - file_option: go_package module: buf.build/bufbuild/protovalidate# - file_option: go_package# module: buf.build/grpc-ecosystem/grpc-gateway# override:# - file_option: go_package_prefix# value: connect-go-example/greetplugins:# - remote: buf.build/grpc/go# out: .# opt: paths=source_relative# - remote: buf.build/protocolbuffers/go# out: gen# opt: paths=source_relative - local: protoc-gen-go out: gen opt: paths=source_relative - local: protoc-gen-connect-go out: gen opt: paths=source_relative # This will invoke protoc-gen-es and write output to src/gen - local: protoc-gen-es out: gen/web # Also generate any imported dependencies include_imports: true # Add more plugin options here opt: target=ts