Skip to content

Commit

Permalink
Stop emulating protobuf <-> golang field name conversion
Browse files Browse the repository at this point in the history
Use the implementation in protoc-gen-go itself
  • Loading branch information
yugui committed Jan 28, 2016
1 parent 0afff98 commit 8c91017
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ GO_PLUGIN=bin/protoc-gen-go
GO_PLUGIN_PKG=github.com/golang/protobuf/protoc-gen-go
SWAGGER_PLUGIN=bin/protoc-gen-swagger
SWAGGER_PLUGIN_SRC= utilities/doc.go \
utilities/name.go \
utilities/pattern.go \
utilities/trie.go \
protoc-gen-swagger/genswagger/generator.go \
protoc-gen-swagger/genswagger/template.go \
protoc-gen-swagger/main.go
Expand Down
8 changes: 4 additions & 4 deletions protoc-gen-grpc-gateway/descriptor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"

"github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/httprule"
"github.com/gengo/grpc-gateway/utilities"
descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
gogen "github.com/golang/protobuf/protoc-gen-go/generator"
)

// GoPackage represents a golang package
Expand Down Expand Up @@ -235,15 +235,15 @@ type FieldPathComponent struct {

// RHS returns a right-hand-side expression in go for this field.
func (c FieldPathComponent) RHS() string {
return utilities.PascalFromSnake(c.Name)
return gogen.CamelCase(c.Name)
}

// LHS returns a left-hand-side expression in go for this field.
func (c FieldPathComponent) LHS() string {
if c.Target.Message.File.proto2() {
return fmt.Sprintf("Get%s()", utilities.PascalFromSnake(c.Name))
return fmt.Sprintf("Get%s()", gogen.CamelCase(c.Name))
}
return utilities.PascalFromSnake(c.Name)
return gogen.CamelCase(c.Name)
}

var (
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-grpc-gateway/gengateway/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var _ codes.Code
var _ io.Reader
var _ = runtime.String
var _ = json.Marshal
var _ = utilities.PascalFromSnake
var _ = utilities.NewDoubleArray
`))

handlerTemplate = template.Must(template.New("handler").Parse(`
Expand Down
82 changes: 0 additions & 82 deletions utilities/name.go

This file was deleted.

22 changes: 0 additions & 22 deletions utilities/name_test.go

This file was deleted.

0 comments on commit 8c91017

Please sign in to comment.