Skip to content

Commit

Permalink
Merge pull request #97 from UnderTreeTech/feat/remove_tool_proto
Browse files Browse the repository at this point in the history
[tool] replace github.com/golang/protobuf to google.golang.org/protobuf
  • Loading branch information
UnderTreeTech committed Aug 5, 2021
2 parents 52b00d7 + ef76b40 commit b6c0797
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
7 changes: 3 additions & 4 deletions tools/waterdrop/protoc/protobuf/pkg/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"os"
"strings"

// nolint:staticcheck
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
plugin "google.golang.org/protobuf/types/pluginpb"
)

// Generator ...
Expand Down
9 changes: 7 additions & 2 deletions tools/waterdrop/protoc/protobuf/pkg/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import (
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/naming"
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/typemap"
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/utils"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"github.com/pkg/errors"

plugin "google.golang.org/protobuf/types/pluginpb"

descriptor "google.golang.org/protobuf/types/descriptorpb"
)

type Base struct {
Expand Down Expand Up @@ -263,7 +265,9 @@ func (t *Base) IsOwnPackage(protoName string) bool {
def := t.Reg.MessageDefinition(protoName)
if def == nil {
gen.Fail("could not find message for", protoName)
return false
}

return def.File.GetPackage() == t.PackageName
}

Expand All @@ -273,6 +277,7 @@ func (t *Base) GoTypeName(protoName string) string {
def := t.Reg.MessageDefinition(protoName)
if def == nil {
gen.Fail("could not find message for", protoName)
return ""
}

var prefix string
Expand Down
2 changes: 1 addition & 1 deletion tools/waterdrop/protoc/protobuf/pkg/generator/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/tag"
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/typemap"

"github.com/golang/protobuf/protoc-gen-go/descriptor"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// GetJSONFieldName get name from the original name
Expand Down
9 changes: 3 additions & 6 deletions tools/waterdrop/protoc/protobuf/pkg/generator/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/typemap"

// nolint:staticcheck
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"google.golang.org/genproto/googleapis/api/annotations"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// HTTPInfo http info for method
Expand Down Expand Up @@ -112,10 +112,7 @@ func (t *Base) GetHttpInfoCached(file *descriptor.FileDescriptorProto,

// ParseBMMethod parse BMMethodDescriptor form method descriptor proto
func ParseBMMethod(method *descriptor.MethodDescriptorProto) (*googleMethodOptionInfo, error) {
ext, err := proto.GetExtension(method.GetOptions(), annotations.E_Http)
if err != nil {
return nil, fmt.Errorf("get extension error: %s", err)
}
ext := proto.GetExtension(method.GetOptions(), annotations.E_Http)
rule := ext.(*annotations.HttpRule)
var httpMethod string
var pathPattern string
Expand Down
2 changes: 1 addition & 1 deletion tools/waterdrop/protoc/protobuf/pkg/naming/go_naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package naming
import (
"path"

"github.com/golang/protobuf/protoc-gen-go/descriptor"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// GoFileName returns the output name for the generated Go file.
Expand Down
2 changes: 1 addition & 1 deletion tools/waterdrop/protoc/protobuf/pkg/naming/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"

"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/utils"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/pkg/errors"
"github.com/siddontang/go/ioutil2"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// GetVersionPrefix 鏍规嵁go鍖呭悕鑾峰彇api鐗堟湰鍓嶇紑
Expand Down
2 changes: 1 addition & 1 deletion tools/waterdrop/protoc/protobuf/pkg/tag/ext_tags.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tag

import (
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

func GetMoreTags(field *descriptor.FieldDescriptorProto) *string {
Expand Down
2 changes: 1 addition & 1 deletion tools/waterdrop/protoc/protobuf/pkg/typemap/typemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package typemap
import (
"strings"

"github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/pkg/errors"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// Registry is the place of descriptors resolving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/naming"
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/tag"
"github.com/UnderTreeTech/waterdrop/tools/waterdrop/protoc/protobuf/pkg/typemap"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
descriptor "google.golang.org/protobuf/types/descriptorpb"
plugin "google.golang.org/protobuf/types/pluginpb"
)

type swaggerGen struct {
Expand Down

0 comments on commit b6c0797

Please sign in to comment.