diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8b03463..d499565 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,11 +14,11 @@ jobs: # Setup - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: '^1.15' + go-version: '^1.16' - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install protoc uses: arduino/setup-protoc@v1 @@ -55,9 +55,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: '^1.16' - name: Check code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - run: go test -v diff --git a/Makefile b/Makefile index 064961d..e827aa7 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,12 @@ BQ_PLUGIN=bin/protoc-gen-bq-schema GO_PLUGIN=bin/protoc-gen-go -PROTOC_GEN_GO_PKG=github.com/golang/protobuf/protoc-gen-go +PROTOC_GEN_GO_PKG=google.golang.org/protobuf/cmd/protoc-gen-go GLOG_PKG=github.com/golang/glog PROTO_SRC=bq_table.proto bq_field.proto PROTO_GENFILES=protos/bq_table.pb.go protos/bq_field.pb.go -PROTO_PKG=github.com/golang/protobuf/proto -PKGMAP=Mgoogle/protobuf/descriptor.proto=$(PROTOC_GEN_GO_PKG)/descriptor +PROTO_PKG=google.golang.org/protobuf +PKGMAP=Mgoogle/protobuf/descriptor.proto=$(PROTO_PKG)/types/descriptorpb EXAMPLES_PROTO=examples/foo.proto install: $(BQ_PLUGIN) @@ -28,7 +28,7 @@ $(BQ_PLUGIN): $(PROTO_GENFILES) goprotobuf glog go build -o $@ $(PROTO_GENFILES): $(PROTO_SRC) $(GO_PLUGIN) - protoc -I. -Ivendor/protobuf --plugin=$(GO_PLUGIN) --go_out=$(PKGMAP):protos $(PROTO_SRC) + protoc -I. -Ivendor/protobuf --plugin=$(GO_PLUGIN) --go_out=$(PKGMAP):protos --go_opt=paths=source_relative $(PROTO_SRC) goprotobuf: go get $(PROTO_PKG) @@ -37,7 +37,6 @@ glog: go get $(GLOG_PKG) $(GO_PLUGIN): - go get $(PROTOC_GEN_GO_PKG) go build -o $@ $(PROTOC_GEN_GO_PKG) test: $(PROTO_SRC) @@ -53,4 +52,4 @@ realclean: distclean examples: $(BQ_PLUGIN) protoc -I. -Ivendor/protobuf --plugin=$(BQ_PLUGIN) --bq-schema_out=examples $(EXAMPLES_PROTO) -.PHONY: goprotobuf glog \ No newline at end of file +.PHONY: goprotobuf glog diff --git a/go.mod b/go.mod index 66b1feb..79c7b62 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,8 @@ module github.com/GoogleCloudPlatform/protoc-gen-bq-schema -go 1.15 +go 1.16 require ( - github.com/golang/glog v1.0.0 - github.com/golang/protobuf v1.5.2 - google.golang.org/protobuf v1.31.0 + github.com/golang/glog v1.2.0 + google.golang.org/protobuf v1.33.0 ) diff --git a/go.sum b/go.sum index 9c7380a..4e1de97 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,10 @@ -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= +github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/main.go b/main.go index 89b76af..0652b62 100644 --- a/main.go +++ b/main.go @@ -31,8 +31,8 @@ import ( "github.com/GoogleCloudPlatform/protoc-gen-bq-schema/pkg/converter" "github.com/golang/glog" - plugin "github.com/golang/protobuf/protoc-gen-go/plugin" "google.golang.org/protobuf/proto" + plugin "google.golang.org/protobuf/types/pluginpb" ) func main() { diff --git a/pkg/converter/comments.go b/pkg/converter/comments.go index 9bc88ae..6ce00bb 100644 --- a/pkg/converter/comments.go +++ b/pkg/converter/comments.go @@ -4,7 +4,7 @@ import ( "strconv" "strings" - "github.com/golang/protobuf/protoc-gen-go/descriptor" + descriptor "google.golang.org/protobuf/types/descriptorpb" ) const ( diff --git a/pkg/converter/convert.go b/pkg/converter/convert.go index cc9aec5..b15f1a0 100644 --- a/pkg/converter/convert.go +++ b/pkg/converter/convert.go @@ -4,18 +4,16 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "path" "sort" "strings" "github.com/GoogleCloudPlatform/protoc-gen-bq-schema/protos" "github.com/golang/glog" - plugin "github.com/golang/protobuf/protoc-gen-go/plugin" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" descriptor "google.golang.org/protobuf/types/descriptorpb" - "google.golang.org/protobuf/types/pluginpb" + plugin "google.golang.org/protobuf/types/pluginpb" ) var ( @@ -405,7 +403,7 @@ func Convert(req *plugin.CodeGeneratorRequest) (*plugin.CodeGeneratorResponse, e } res := &plugin.CodeGeneratorResponse{ - SupportedFeatures: proto.Uint64(uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)), + SupportedFeatures: proto.Uint64(uint64(plugin.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)), } for _, file := range req.GetProtoFile() { for msgIndex, msg := range file.GetMessageType() { @@ -432,7 +430,7 @@ func Convert(req *plugin.CodeGeneratorRequest) (*plugin.CodeGeneratorResponse, e // Returning a CodeGeneratorResponse containing either an error or the results of converting the given proto func ConvertFrom(rd io.Reader) (*plugin.CodeGeneratorResponse, error) { glog.V(1).Info("Reading code generation request") - input, err := ioutil.ReadAll(rd) + input, err := io.ReadAll(rd) if err != nil { glog.Error("Failed to read request:", err) return nil, err diff --git a/pkg/converter/plugin_test.go b/pkg/converter/plugin_test.go index 27e6f0b..c35f0d6 100644 --- a/pkg/converter/plugin_test.go +++ b/pkg/converter/plugin_test.go @@ -19,8 +19,8 @@ import ( "reflect" "testing" - plugin "github.com/golang/protobuf/protoc-gen-go/plugin" "google.golang.org/protobuf/encoding/prototext" + plugin "google.golang.org/protobuf/types/pluginpb" ) // schema is an internal representation of generated BigQuery schema diff --git a/protos/bq_field.pb.go b/protos/bq_field.pb.go index 0da75f2..f89665a 100644 --- a/protos/bq_field.pb.go +++ b/protos/bq_field.pb.go @@ -14,16 +14,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v3.21.12 +// protoc-gen-go v1.33.0 +// protoc v5.26.1 // source: bq_field.proto package protos import ( - descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" sync "sync" ) @@ -136,7 +136,7 @@ func (x *BigQueryFieldOptions) GetPolicyTags() string { var file_bq_field_proto_extTypes = []protoimpl.ExtensionInfo{ { - ExtendedType: (*descriptor.FieldOptions)(nil), + ExtendedType: (*descriptorpb.FieldOptions)(nil), ExtensionType: (*BigQueryFieldOptions)(nil), Field: 1021, Name: "gen_bq_schema.bigquery", @@ -145,7 +145,7 @@ var file_bq_field_proto_extTypes = []protoimpl.ExtensionInfo{ }, } -// Extension fields to descriptor.FieldOptions. +// Extension fields to descriptorpb.FieldOptions. var ( // BigQuery field schema generation options. // @@ -199,8 +199,8 @@ func file_bq_field_proto_rawDescGZIP() []byte { var file_bq_field_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_bq_field_proto_goTypes = []interface{}{ - (*BigQueryFieldOptions)(nil), // 0: gen_bq_schema.BigQueryFieldOptions - (*descriptor.FieldOptions)(nil), // 1: google.protobuf.FieldOptions + (*BigQueryFieldOptions)(nil), // 0: gen_bq_schema.BigQueryFieldOptions + (*descriptorpb.FieldOptions)(nil), // 1: google.protobuf.FieldOptions } var file_bq_field_proto_depIdxs = []int32{ 1, // 0: gen_bq_schema.bigquery:extendee -> google.protobuf.FieldOptions diff --git a/protos/bq_table.pb.go b/protos/bq_table.pb.go index e008187..54799f7 100644 --- a/protos/bq_table.pb.go +++ b/protos/bq_table.pb.go @@ -14,16 +14,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v3.21.12 +// protoc-gen-go v1.33.0 +// protoc v5.26.1 // source: bq_table.proto package protos import ( - descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" sync "sync" ) @@ -164,7 +164,7 @@ func (x *BigQueryMessageOptions) GetOutputFieldOrder() BigQueryMessageOptions_Fi var file_bq_table_proto_extTypes = []protoimpl.ExtensionInfo{ { - ExtendedType: (*descriptor.MessageOptions)(nil), + ExtendedType: (*descriptorpb.MessageOptions)(nil), ExtensionType: (*BigQueryMessageOptions)(nil), Field: 1021, Name: "gen_bq_schema.bigquery_opts", @@ -173,7 +173,7 @@ var file_bq_table_proto_extTypes = []protoimpl.ExtensionInfo{ }, } -// Extension fields to descriptor.MessageOptions. +// Extension fields to descriptorpb.MessageOptions. var ( // BigQuery message schema generation options. // @@ -240,7 +240,7 @@ var file_bq_table_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_bq_table_proto_goTypes = []interface{}{ (BigQueryMessageOptions_FieldOrder)(0), // 0: gen_bq_schema.BigQueryMessageOptions.FieldOrder (*BigQueryMessageOptions)(nil), // 1: gen_bq_schema.BigQueryMessageOptions - (*descriptor.MessageOptions)(nil), // 2: google.protobuf.MessageOptions + (*descriptorpb.MessageOptions)(nil), // 2: google.protobuf.MessageOptions } var file_bq_table_proto_depIdxs = []int32{ 0, // 0: gen_bq_schema.BigQueryMessageOptions.output_field_order:type_name -> gen_bq_schema.BigQueryMessageOptions.FieldOrder