Skip to content

Commit

Permalink
Fix building for Go 1.11 (grpc-ecosystem#1062)
Browse files Browse the repository at this point in the history
* adding build-scoping for builds on earlier go versions (<1.12)

* updating `BUILD.bazel`
  • Loading branch information
marcusljx authored and johanbrandhorst committed Oct 14, 2019
1 parent ddfc00d commit 7d2dc5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions protoc-gen-swagger/genswagger/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ go_library(
srcs = [
"doc.go",
"generator.go",
"helpers.go",
"helpers_go111_old.go",
"template.go",
"types.go",
],
Expand Down
4 changes: 0 additions & 4 deletions protoc-gen-swagger/genswagger/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ func mergeTargetFile(targets []*wrapper, mergeFileName string) *wrapper {
return mergedTarget
}

func fieldName(k string) string {
return strings.ReplaceAll(strings.Title(k), "-", "_")
}

// Q: What's up with the alias types here?
// A: We don't want to completely override how these structs are marshaled into
// JSON, we only want to add fields (see below, extensionMarshalJSON).
Expand Down
9 changes: 9 additions & 0 deletions protoc-gen-swagger/genswagger/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//+build go1.12

package genswagger

import "strings"

func fieldName(k string) string {
return strings.ReplaceAll(strings.Title(k), "-", "_")
}
9 changes: 9 additions & 0 deletions protoc-gen-swagger/genswagger/helpers_go111_old.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//+build !go1.12

package genswagger

import "strings"

func fieldName(k string) string {
return strings.Replace(strings.Title(k), "-", "_", -1)
}

0 comments on commit 7d2dc5f

Please sign in to comment.