Skip to content

Commit

Permalink
Upgrade golang/protobuf to v1.4.2 (#36)
Browse files Browse the repository at this point in the history
* upgrade github.com/golang/protobuf dependency to v1.4.2

* add protoc-go-inject-tag to code_gen.sh to test inject tags

* update vendor with new version of golang/protobuf for travis

* update travis with newer version of go

* update test case with regex for more stable tests
  • Loading branch information
binhnguyenduc authored Jun 17, 2020
1 parent b492d1d commit d0943c8
Show file tree
Hide file tree
Showing 74 changed files with 24,156 additions and 1,271 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ script:
- $GOPATH/bin/goveralls -service=travis-ci

go:
- "1.10.x"
- "1.13"
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module github.com/favadi/protoc-go-inject-tag

require (
github.com/golang/protobuf v1.1.0
golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a // indirect
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
)
go 1.13

require github.com/golang/protobuf v1.4.2
26 changes: 20 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
github.com/golang/protobuf v1.1.0 h1:0iH4Ffd/meGoXqF2lSAhZHt8X+cPgkfn/cb6Cce5Vpc=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a h1:8fCF9zjAir2SP3N+axz9xs+0r4V8dqPzqsWO10t8zoo=
golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
24 changes: 13 additions & 11 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"log"
"os"
"strings"
"regexp"
"testing"
)

Expand Down Expand Up @@ -69,8 +69,9 @@ func TestParseWriteFile(t *testing.T) {
if err != nil {
t.Fatal(err)
}
expectedExpr := "Address string `protobuf:\"bytes,1,opt,name=Address\" json:\"overrided\" valid:\"ip\" yaml:\"ip\"`"
if !strings.Contains(string(contents), expectedExpr) {
expectedExpr := "Address[ \t]+string[ \t]+`protobuf:\"bytes,1,opt,name=Address,proto3\" json:\"overrided\" valid:\"ip\" yaml:\"ip\"`"
matched, err := regexp.Match(expectedExpr, contents)
if err != nil || matched != true {
t.Error("file doesn't contains custom tag after writing")
t.Log(string(contents))
}
Expand Down Expand Up @@ -145,17 +146,18 @@ func TestContinueParsingWhenSkippingFields(t *testing.T) {
}

expectedExprs := []string{
"Address string `protobuf:\"bytes,1,opt,name=Address\" json:\"overrided\" valid:\"ip\" yaml:\"ip\"`",
"Address string `protobuf:\"bytes,1,opt,name=Address\" json:\"overrided\" valid:\"ip\" yaml:\"ip\"`",
"Scheme string `protobuf:\"bytes,1,opt,name=scheme\" json:\"scheme,omitempty\" valid:\"http|https\"`",
"Port int32 `protobuf:\"varint,3,opt,name=port\" json:\"port,omitempty\" valid:\"nonzero\"`",
"XXX_NoUnkeyedLiteral struct{} `json:\"-\" xml:\"-\"`",
"XXX_unrecognized []byte `json:\"-\" xml:\"-\"`",
"XXX_sizecache int32 `json:\"-\" xml:\"-\"`",
"Address[ \t]+string[ \t]+`protobuf:\"bytes,1,opt,name=Address,proto3\" json:\"overrided\" valid:\"ip\" yaml:\"ip\"`",
"Address[ \t]+string[ \t]+`protobuf:\"bytes,1,opt,name=Address,proto3\" json:\"overrided\" valid:\"ip\" yaml:\"ip\"`",
"Scheme[ \t]+string[ \t]+`protobuf:\"bytes,1,opt,name=scheme,proto3\" json:\"scheme,omitempty\" valid:\"http|https\"`",
"Port[ \t]+int32[ \t]+`protobuf:\"varint,3,opt,name=port,proto3\" json:\"port,omitempty\" valid:\"nonzero\"`",
"XXX_NoUnkeyedLiteral[ \t]+struct{}[ \t]+`json:\"-\" xml:\"-\"`",
"XXX_unrecognized[ \t]+[]byte[ \t]+`json:\"-\" xml:\"-\"`",
"XXX_sizecache[ \t]+int32[ \t]+`json:\"-\" xml:\"-\"`",
}

for i, expr := range expectedExprs {
if !strings.Contains(string(contents), expr) {
matched, err := regexp.Match(expr, contents)
if err != nil || matched != true {
t.Errorf("file doesn't contains custom tag #%d after writing", i+1)
t.Log(string(contents))
break
Expand Down
46 changes: 20 additions & 26 deletions pb/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pb/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ message URL {
string url = 2;
// @inject_tag: valid:"nonzero"
int32 port = 3;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/golang/protobuf/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/github.com/golang/protobuf/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions vendor/github.com/golang/protobuf/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions vendor/github.com/golang/protobuf/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d0943c8

Please sign in to comment.