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

add go_package, regenerate Go binding file #22

Merged
merged 1 commit into from
Jul 12, 2018

Conversation

flier
Copy link
Contributor

@flier flier commented Jul 10, 2018

When import the metrics.proto in a gRPC service definition, the protoc-gen-go will generate a wrong import path without the go_package

syntax = "proto3";
package api;

import "google/protobuf/empty.proto";

import "metrics.proto";

service Host {
    rpc Stats(google.protobuf.Empty) returns (StatsReply) {
        option (google.api.http) = {
            get: "/v1/admin/stats"
        };
    }
}

message StatsReply {
    repeated io.prometheus.client.MetricFamily metrics = 1;
}

2018/07/10 12:03:45 protoc-gen-go: error:bad Go source code was generated: 120:13: expected type, found '.' (and 4 more errors)
1 // Code generated by protoc-gen-go. DO NOT EDIT.
2 // source: api/admin.proto
3
4 package api
5
6 import proto "github.com/golang/protobuf/proto"
7 import fmt "fmt"
8 import math "math"
9 import "."

@beorn7
Copy link
Member

beorn7 commented Jul 10, 2018

Thanks. I'll have a look ASAP. In the meantime, you could add the DCO, see https://github.com/probot/dco#how-it-works

Signed-off-by: Flier Lu <flier.lu@gmail.com>
@beorn7
Copy link
Member

beorn7 commented Jul 11, 2018

@flier which protoc version have you used to regenerate the Go files? I tried 3.3.0 and 3.6.0 and got quite different results each time.

@flier
Copy link
Contributor Author

flier commented Jul 12, 2018

@beorn7 I use the protoc from homebrew, if you prefer to use special protoc version, I can regenerate it with your version, I just need the go_package in the metrics.proto file. :)

$ protoc --version
libprotoc 3.6.0

$ brew info protobuf
protobuf: stable 3.6.0 (bottled), HEAD
Protocol buffers (Google's data interchange format)
https://github.com/google/protobuf/
/usr/local/Cellar/protobuf/3.6.0 (256 files, 17.2MB) *
  Poured from bottle on 2018-06-22 at 14:49:31
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/protobuf.rb
==> Dependencies
Build: autoconf ✔, automake ✔, libtool ✔
Recommended: python@2 ✔
Optional: python ✔
==> Options
--with-python
	Build with python support
--with-test
	Run build-time check
--without-python@2
	Build without python2 support
--HEAD
	Install HEAD version
==> Caveats
Editor support and examples have been installed to:
  /usr/local/opt/protobuf/share/doc/protobuf

@beorn7
Copy link
Member

beorn7 commented Jul 12, 2018

Weirdly, I have used 3.6.0, too (the newest released version), and still the output differs quite a lot.
Perhaps the homebrew version is compiled with different flags than the binary provided by Google for Linux?

Anyway, I'll just merge this and then regenerate the go code again so that I don't flip back and forth during my own development.

@beorn7 beorn7 merged commit 5c3871d into prometheus:master Jul 12, 2018
@flier
Copy link
Contributor Author

flier commented Jul 13, 2018

Thanks, the pre-generated code will fine, because I always regenerate it on the building :)

@flier flier deleted the go_package branch July 13, 2018 02:38
thaJeztah added a commit to thaJeztah/containerd that referenced this pull request Jan 13, 2020
full diff: prometheus/client_model@99fa1f4...v0.1.0

- prometheus/client_model#22 add `go_package`, regenerate Go binding file
- prometheus/client_model#31 Support Go Modules
- prometheus/client_model#38 Remove all languages but Go and add a deprecation note

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah added a commit to thaJeztah/docker that referenced this pull request Jan 16, 2020
full diff: prometheus/client_model@6f38060...v0.1.0

- prometheus/client_model#22 add `go_package`, regenerate Go binding file
- prometheus/client_model#31 Support Go Modules
- prometheus/client_model#38 Remove all languages but Go and add a deprecation note

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Jan 17, 2020
full diff: prometheus/client_model@6f38060...v0.1.0

- prometheus/client_model#22 add `go_package`, regenerate Go binding file
- prometheus/client_model#31 Support Go Modules
- prometheus/client_model#38 Remove all languages but Go and add a deprecation note

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 9c99f8b9b3d16e1975f07ae08f418949f76e4a02
Component: engine
tussennet pushed a commit to tussennet/containerd that referenced this pull request Sep 11, 2020
full diff: prometheus/client_model@99fa1f4...v0.1.0

- prometheus/client_model#22 add `go_package`, regenerate Go binding file
- prometheus/client_model#31 Support Go Modules
- prometheus/client_model#38 Remove all languages but Go and add a deprecation note

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants