Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/helloworld: refresh .pb.go #3519

Closed
wants to merge 1 commit into from

Conversation

chalin
Copy link
Contributor

@chalin chalin commented Apr 11, 2020

As mentioned in #3516, "update .pb.go file due to changes in Go 1.14's gofmt and go-cmp.

cc @dfawley

As mentioned in grpc#3516, "update `.pb.go` file due to changes in Go 1.14's `gofmt` and `go-cmp`
@chalin chalin force-pushed the chalin-example-helloworld-200411 branch from c935036 to 874ad31 Compare April 11, 2020 20:17
@easwars
Copy link
Contributor

easwars commented Apr 13, 2020

Actually, we don't see any change in gofmt's formatting as far as this file is concerned. Surprising why you saw the change. Closing this PR since the change actually causes our vet script to fail.

@easwars easwars closed this Apr 13, 2020
@chalin
Copy link
Contributor Author

chalin commented Apr 13, 2020

If you rerun protoc, you should see the diff in this PR.

(I had assumed that changes to gofmt were the cause, but that might not be the case.)

@dfawley
Copy link
Member

dfawley commented Apr 13, 2020

Travis does regenerate all the .pb.go files in our nightly runs. It produces the same output as what is submitted. I'm not sure why you're seeing different output; make sure you're using Go 1.14.0 and recompile protoc-gen-go.

@chalin
Copy link
Contributor Author

chalin commented Apr 13, 2020

Great that Travis regenerates .pb.go files and commits any changes!

FWIW, I was running go version go1.14.2 linux/amd64 and github.com/golang/protobuf v1.3.3, though I'm pretty sure v1.3.5 was giving me the changed file too.

$ protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld
$ diff -u /home/chalin/go/pkg/mod/google.golang.org/grpc\@v1.28.1/examples/helloworld/helloworld /home/chalin/examples/hello_world/helloworld/helloworld.pb.go

Yields

--- /home/chalin/go/pkg/mod/google.golang.org/grpc@v1.28.1/examples/helloworld/helloworld/helloworld.pb.go      2020-04-11 13:46:16.090853787 +0000                                                                                                          
+++ /home/chalin/examples/hello_world/helloworld/helloworld.pb.go       2020-04-11 15:57:21.203040189 +0000                                                                                                                                                  
@@ -109,7 +109,9 @@
        proto.RegisterType((*HelloReply)(nil), "helloworld.HelloReply")                                                                                                                                                                                      
 }                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                             
-func init() { proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2) }                                                                                                                                                                     
+func init() {                                                                                                                                                                                                                                               
+       proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2)                                                                                                                                                                              
+}                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                             
 var fileDescriptor_17b8c58d586b62f2 = []byte{                                                                                                                                                                                                               
        // 175 bytes of a gzipped FileDescriptorProto                                                                                                                                                                                                        
                                                                                                                                                                                                                                                             
Diff finished.  Mon Apr 13 18:49:05 2020                                                                                                                                                                                                                     

@dfawley
Copy link
Member

dfawley commented Apr 14, 2020

Great that Travis regenerates .pb.go files and commits any changes!

Travis won't commit any changes -- it will just fail if it sees they are not up-to-date.

If you are interested, this is an example of it checking:
https://travis-ci.org/github/grpc/grpc-go/jobs/674409663#L344

Is it possible you have a different version of gofmt installed (though I thought it was used by protoc-gen-go via library)?

@chalin
Copy link
Contributor Author

chalin commented Apr 14, 2020

Travis won't commit any changes -- it will just fail if it sees they are not up-to-date.

👍

If you are interested, this is an example of it checking:

Thanks for the link -- and cool that we can anchor to a specific line, I hadn't used that feature before!

Is it possible you have a different version of gofmt installed ...

Not sure what it going on, but given that out-of-date .pb.go files are caught as part of CI, I'll move on to other things. Thanks!

@chalin chalin deleted the chalin-example-helloworld-200411 branch April 14, 2020 14:42
@menghanl
Copy link
Contributor

The format diff is usually caused by a standard package (go/printer I guess? gofmt uses it, and proto codegen also imports it).

The library is released with the language, so usually we see different format when there's a new major go release. But depending on which go version gofmt and codegen are built with, we may see different result, even between them. It's quite tricky to track.

@chalin
Copy link
Contributor Author

chalin commented Apr 14, 2020

Thanks for the explanation @menghanl!

@chalin
Copy link
Contributor Author

chalin commented Apr 15, 2020

Closing this PR since the change actually causes our vet script to fail.

Not that I wanted to continue harping about this but I was cleaning up my open tabs and noticed that Travis was actually happy with this PR -- it's green across the board as shown below.

For my own info, where were you seeing failures (so that I can spot them the next time 'round)?

image

@dfawley
Copy link
Member

dfawley commented Apr 15, 2020

Not that I wanted to continue harping about this but I was cleaning up my open tabs and noticed that Travis was actually happy with this PR -- it's green across the board as shown below.

Only our cron travis runs check the proto files. This is because we pull many .proto files from remote repositories, and we don't want to prevent someone from checking in when the remote repos are updated.

This is how it works:

In .travis.yml:

  - if [[ "${TRAVIS_EVENT_TYPE}" != "cron" ]]; then export VET_SKIP_PROTO=1; fi

In vet.sh:

# - Check that generated proto files are up to date.
if [[ -z "${VET_SKIP_PROTO}" ]]; then
  PATH="/home/travis/bin:${PATH}" make proto && \
    git status --porcelain 2>&1 | fail_on_output || \
    (git status; git --no-pager diff; exit 1)
fi

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants