5

I have a problem with the command line go get or go get . in my Golang project. The error is

go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead.

I have tried step by step install package protobuf in this website enter link description here

but I can't resolve my problem.

Titanio Yudista
  • 241
  • 4
  • 8

1 Answers1

4

You can check your code if you import github.com/golang/protobuf somewhere.

If you don't use the import in your code, check which dependency imports it:

go mod graph | grep github.com/golang/protobuf

or

go mod why github.com/golang/protobuf

Basically you need to eliminate that import somehow either by removing it in your code, updating your dependencies or maybe even eliminate the dependency that hasn't updated to the new protobuf package yet. (Had to do that recently by kicking etcd which I used for election)

TehSphinX
  • 6,536
  • 1
  • 24
  • 34
  • 1
    `go mod why github.com/golang/protobuf` will show the full chain importing the package back to the direct dependency. – Bracken Sep 29 '21 at 14:16
  • 1
    Good point! Note that at least until recently `go mod why` did not always work for all dependencies. Example: https://forum.golangbridge.org/t/go-mod-has-not-need-package/17082 – TehSphinX Sep 29 '21 at 15:41