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

[SA1019] github.com/golang/protobuf/proto is still used by generated code #732

Closed
butonic opened this issue Apr 25, 2020 · 1 comment
Closed

Comments

@butonic
Copy link

butonic commented Apr 25, 2020

# go run honnef.co/go/tools/cmd/staticcheck -version                                   
staticcheck 2020.1.3
# go run honnef.co/go/tools/cmd/staticcheck -debug.version
staticcheck 2020.1.3

Compiled with Go version: go1.14.2
Main module:
        honnef.co/go/tools@v0.0.1-2020.1.3 (sum: h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=)
Dependencies:
        github.com/BurntSushi/toml@v0.3.1
        golang.org/x/tools@v0.0.0-20200130002326-2f3ba24bd6e7 (sum: h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=)
# go version
go version go1.14.2 linux/amd64
# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jfd/.cache/go-build"
GOENV="/home/jfd/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jfd/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jfd/Repositories/ocis-hello/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build254383978=/tmp/go-build -gno-record-gcc-switches"
  • Exactly which command you ran
# go run honnef.co/go/tools/cmd/staticcheck github.com/owncloud/ocis-hello/pkg/proto/v0
pkg/proto/v0/hello.pb.go:10:2: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (SA1019)
pkg/proto/v0/hello.pb.micro.go:8:2: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (SA1019)
pkg/proto/v0/hello.pb.web.go:14:2: package github.com/golang/protobuf/jsonpb is deprecated: Use the "google.golang.org/protobuf/encoding/protojson" package instead.  (SA1019)
exit status 1

AFAICT google introduced a new go api for protocol buffers: https://blog.golang.org/protobuf-apiv2 but the generated code still uses github.com/golang/protobuf/proto which is correct, because google tried to make a seamless transition: golang/protobuf#1032

In that thread @meling first reported problems with staticcheck: golang/protobuf#1032 (comment)

And it seems @GlenDC also ran into this issue and reported it: Google protobuf package deprecated - protocolbuffers#7383

An example PR is owncloud/ocis-hello#61 the branck is located at https://github.com/butonic/ocis-hello/tree/update-deps

Our build pipline is using drone and a failing build is documented at https://cloud.drone.io/owncloud/ocis-hello/186/1/5

I did update the protoc-gen-go to generate new go code: https://github.com/owncloud/ocis-hello/pull/61/files#diff-251ae76cdec9881313b569a5b3191f30R3 but as you can see, it still uses github.com/golang/protobuf/proto

The Makefile contains the exact command to generate the code: https://github.com/butonic/ocis-hello/blob/update-deps/Makefile#L169-L173

I think ... this is a false positive ... but would be happy to be proven wrong.

@butonic butonic added false-positive needs-triage Newly filed issue that needs triage labels Apr 25, 2020
@dominikh
Copy link
Owner

This was fixed in 7e758a3

@dominikh dominikh added noisy-positive and removed false-positive needs-triage Newly filed issue that needs triage labels Apr 25, 2020
butonic added a commit to butonic/protoc-gen-microweb that referenced this issue Apr 25, 2020
Google introduced a new protobuf API: https://blog.golang.org/protobuf-apiv2 causing the current release of staticckeck to barf on several related packages: dominikh/go-tools#732 ... fixed in dominikh/go-tools@7e758a3

Currently, protoc-gen-microweb uses `github.com/golang/protobuf/jsonpb` which is still reported:
```
make staticcheck
go run honnef.co/go/tools/cmd/staticcheck -tags '' github.com/owncloud/ocis-hello/cmd/ocis-hello github.com/owncloud/ocis-hello/pkg/assets github.com/owncloud/ocis-hello/pkg/command github.com/owncloud/ocis-hello/pkg/config github.com/owncloud/ocis-hello/pkg/flagset github.com/owncloud/ocis-hello/pkg/metrics github.com/owncloud/ocis-hello/pkg/proto/v0 github.com/owncloud/ocis-hello/pkg/server/debug github.com/owncloud/ocis-hello/pkg/server/grpc github.com/owncloud/ocis-hello/pkg/server/http github.com/owncloud/ocis-hello/pkg/service/v0 github.com/owncloud/ocis-hello/pkg/version
pkg/proto/v0/hello.pb.micro.go:8:2: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (SA1019)
pkg/proto/v0/hello.pb.web.go:14:2: package github.com/golang/protobuf/jsonpb is deprecated: Use the "google.golang.org/protobuf/encoding/protojson" package instead.  (SA1019)
exit status 1
make: *** [Makefile:73: staticcheck] Fehler 1
```

This PR should update the dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants