# Go plugin build error with protobuf

**URL:** <https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629>\
**Category:** Local Setup\
**Created:** [April 12, 2020, 10:46am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629 "2020-04-12T10:46:51Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![irajsb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/irajsb/32/213_2.png) [@irajsb](https://forum.heroiclabs.com/u/irajsb)\
**Post date:** [April 12, 2020, 10:46am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/1 "2020-04-12T10:46:51Z")

</div>

Using minimal example  
Using DockerBuild in Windowsx64  
Builded using these commands:  
\*PS C:\Users\Administrator\plugin\_code\> go get -u “[github.com/heroiclabs/nakama-common](http://github.com/heroiclabs/nakama-common)” \*

- PS C:\Users\Administrator\plugin\_code\> docker run --rm -w “/builder” -v “${PWD}:/builder” heroiclabs/nakama-pluginbuilder:2.11.1 build -buildmode=plugin -trimpath -o ./modules/plugin\_code.so\*
- go: downloading heroiclabs/nakama-common v1.4.0\*
- go: downloading protobuf v1.3.4\*

Error:

“}  
nakama | {“level”:“fatal”,“ts”:“2020-04-12T06:12:13.539Z”,“msg”:“Failed initializing runtime modules”,“error”:“plugin.Open(”/nakama/data/modules/plugin\_code”): plugin was built with a different version of package [github.com/golang/protobuf/proto",“stacktrace”:"main.main\n\tmain.go:132\nruntime.main\n\truntime/proc.go:203](http://github.com/golang/protobuf/proto%22,%22stacktrace%22:%22main.main%5Cn%5Ctmain.go:132%5Cnruntime.main%5Cn%5Ctruntime/proc.go:203)"}

Nakama version : 2.11.1  
i had to remove github site from some errors because forums doesnt allow me to post links.

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [April 12, 2020, 3:02pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/2 "2020-04-12T15:02:45Z")

</div>

@irajsb The Nakama v2.11.1 release requires the protobuf v1.3.5 release. You can setup your dependencies to match like so:

```auto
env GO111MODULE=on go get "github.com/heroiclabs/nakama-common@v1.4.0"
env GO111MODULE=on go get "github.com/golang/protobuf@v1.3.5"
env GO111MODULE=on go mod edit -replace "github.com/golang/protobuf=github.com/golang/protobuf@v1.3.5"

```

Please try that and let me know if it resolves your issue. Your mod file should look somewhat like:

```auto
module games/project

go 1.14

require (
	github.com/golang/protobuf v1.3.5 // indirect
	github.com/heroiclabs/nakama-common v1.4.0
)

replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.5

```

The `replace` is used to force the version if another dependency you use tries to specify a different transitive version.

---

<div class="post-metadata">

**Author:** ![irajsb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/irajsb/32/213_2.png) [@irajsb](https://forum.heroiclabs.com/u/irajsb)\
**Post date:** [April 12, 2020, 3:34pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/3 "2020-04-12T15:34:38Z")

</div>

Worked like a charm !!thanks!

---

<div class="post-metadata">

**Author:** ![irajsb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/irajsb/32/213_2.png) [@irajsb](https://forum.heroiclabs.com/u/irajsb)\
**Post date:** [April 13, 2020, 11:05am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/4 "2020-04-13T11:05:44Z")

</div>

Didnt want to create another thread for this : is it possible to get client ip addres from a request with signature like this :  
func RegisterServer(ctx context.Context, logger runtime.Logger, db \*sql.DB, nk runtime.NakamaModule, payload string) (string, error)

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [April 13, 2020, 11:45am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/5 "2020-04-13T11:45:38Z")

</div>

This is not related to the current topic, so it should have been a new thread.

Have a look at the documentation for fields available in the context [here](https://heroiclabs.com/docs/runtime-code-basics/#register-hooks), one of them is the caller’s IP address.

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [April 13, 2020, 12:39pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/6 "2020-04-13T12:39:19Z")

</div>

I think @zyro is right but this is some quick code to show what you need in Go.

```go
clientIP, ok := ctx.Value(runtime.RUNTIME_CTX_CLIENT_IP).(string)
if !ok {
    // handle error
}

```

---

<div class="post-metadata">

**Author:** ![kburgin](https://avatars.discourse-cdn.com/v4/letter/k/e9bcb4/32.png) [@kburgin](https://forum.heroiclabs.com/u/kburgin)\
**Post date:** [August 11, 2020, 2:52pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/7 "2020-08-11T14:52:49Z")

</div>

Sorry to bring back an old thread, but this still seems to be an issue.

Running through the quickstart guide, with no prior usage of Go on our systems, we get to a point where protobuf-1.3.4 is listed rather than protobuf-1.3.5. We were able to build our module using the docker image you provide, however, this won’t run within Nakama server due to the incompatibility.

We were only able to solve this by finding this thread and fetching the new protobuf version. We note that some [Nakama repos](https://github.com/heroiclabs/nakama/blob/v2.11.0/go.mod) are still using protobuf-1.3.4, is that where the incorrect version is coming from?

Should the quickstart guide be updated to ensure the correct dependencies are installed?

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [August 12, 2020, 9:50pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/8 "2020-08-12T21:50:40Z")

</div>

@kburgin As you’ll see from the [Nakama 2.11.1 module definitions](https://github.com/heroiclabs/nakama/blob/v2.11.1/go.mod) the issue you’re describing is already resolved. I’d recommend updating to 2.12.0 if at all possible, it’s best to stay up to date with server releases.

Can you point me to the quickstart section that still mentions protobuf-1.3.4, or submit a Pull Request to the [documentation repository](https://github.com/heroiclabs/nakama-docs) to fix it?

---

<div class="post-metadata">

**Author:** ![kburgin](https://avatars.discourse-cdn.com/v4/letter/k/e9bcb4/32.png) [@kburgin](https://forum.heroiclabs.com/u/kburgin)\
**Post date:** [August 13, 2020, 9:22am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/9 "2020-08-13T09:22:34Z")

</div>

We were already using the fixed 2.11.1 image, so I think the issue is caused elsewhere.

It would seem the plugin sample is where it goes wrong: [https://github.com/heroiclabs/nakama/blob/master/sample\_go\_module/README.md](https://github.com/heroiclabs/nakama/blob/master/sample_go_module/README.md)

In here it tells you to use nakama-common:1.4.0, which still had proto:1.3.4 as you can see here: [https://github.com/heroiclabs/nakama-common/blob/v1.4.0/go.mod](https://github.com/heroiclabs/nakama-common/blob/v1.4.0/go.mod)

This obviously doesn’t fit with the rest of the environment, which all reference proto:1.3.5 as you say.

I’m not sure how you want to approach the plugin docs, whether to point at nakama-common:1.7.2 or maybe there’s a reason it’s pointing to an older version?

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [August 13, 2020, 9:40am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/10 "2020-08-13T09:40:11Z")

</div>

@kburgin Each release of the game server uses a specific release of the nakama-common Go package because the common package provides the interface for custom server logic implemented in plugin code. They must be binary compatible. You can see which release of Nakama uses which release of the nakama-common package in the release notes on GitHub.

The protobuf dependency is a direct dependency of the nakama-common Go package so it must match. We ensure that the server release uses the same version of protobuf as the nakama-common dependency defines. This prevents “minimal version selection” in Go modules from attempting to use a different version of the Protobuf runtime.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![kburgin](https://avatars.discourse-cdn.com/v4/letter/k/e9bcb4/32.png) [@kburgin](https://forum.heroiclabs.com/u/kburgin)\
**Post date:** [August 13, 2020, 10:18am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/11 "2020-08-13T10:18:39Z")

</div>

Ah I see. There just seems to be a bit of a mismatch around 2.11.1 if you look at the releases. 2.11.0 and 2.11.1 both seem to need nakama-common:1.4.0 yet 2.11.0 and 2.11.1 use different proto versions which makes that not possible.

If we run 2.12.0 and 1.5.1, then it’s all fine.

There are just quite a few sporadic references to the old versions which don’t match up. For example, the sample plugin references `heroiclabs/nakama-pluginbuilder:2.11.1` and then `heroiclabs/nakama-common@v1.4.0` which seems like it’s going to cause issues (and did for us) when we tried to run this with the sample docker-compose file in the quick start that lists `heroiclabs/nakama:2.11.1`.

Just needs a few version numbers matching up by the looks of it.

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [August 13, 2020, 2:34pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/12 "2020-08-13T14:34:42Z")

</div>

Probably the best way to find all dependencies you need to match with is the `vendor/modules.txt` for your chosen server release. For Nakama 2.11.1 that’s [here](https://github.com/heroiclabs/nakama/blob/v2.11.1/vendor/modules.txt). It effectively contains the dependency versions selected by the Go toolchain for the server build at the time of the release. Note that this is just a useful tool, as @novabyte pointed out there’s more to Go dependency version selection than that.

We can’t necessarily document the latest version every time. There will be new versions of nakama-common for example that are not yet used in a Nakama server release, and should not be documented as dependencies at those version numbers.

---

<div class="post-metadata">

**Author:** ![rajesh.jakhar](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@rajesh.jakhar](https://forum.heroiclabs.com/u/rajesh.jakhar)\
**Post date:** [November 26, 2020, 11:46am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/13 "2020-11-26T11:46:24Z")

</div>

Thanks for your Reply.I have build code successfully and running fine.

Regards,  
Rajesh

---

<div class="post-metadata">

**Author:** ![ameza](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ameza/32/573_2.png) [@ameza](https://forum.heroiclabs.com/u/ameza)\
**Post date:** [April 20, 2021, 5:19pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/14 "2021-04-20T17:19:45Z")

</div>

what are the package versions for Nakama 2.7.0?

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [April 20, 2021, 9:34pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/15 "2021-04-20T21:34:37Z")

</div>

@ameza Have a look at the [release notes](https://github.com/heroiclabs/nakama/releases) we cover which version of the common library is used with each server release there. But to answer your immediate question on Nakama 2.7.0 release you’ll want to use the v1.0.0 release of Nakama common:

```auto
go get "github.com/heroiclabs/nakama-common/runtime@v1.0.0"

```

---

<div class="post-metadata">

**Author:** ![mautoan11](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mautoan11](https://forum.heroiclabs.com/u/mautoan11)\
**Post date:** [January 30, 2022, 2:41am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/16 "2022-01-30T02:41:04Z")

</div>

Hi, Can you give a example to use grpc on Nakama 3.10.0 please.  
I tried env GO111MODULE=on go get “[github.com/golang/protobuf@v1.3.5](http://github.com/golang/protobuf@v1.3.5)” but I got the error:  
go: [google.golang.org/protobuf@v1.3.5:](http://google.golang.org/protobuf@v1.3.5:) reading [google.golang.org/protobuf/go.mod](http://google.golang.org/protobuf/go.mod) at revision v1.3.5: unknown revision v1.3.5

---

<div class="post-metadata">

**Author:** ![mofirouz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mofirouz/32/1523_2.png) [@mofirouz](https://forum.heroiclabs.com/u/mofirouz)\
**Post date:** [January 30, 2022, 9:04am UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/17 "2022-01-30T09:04:15Z")

</div>

@mautoan11 Firstly, at the time of writing this, the latest protnbuf release is v1.27.1, not sure where you are getting v1.3.5. Secondly, you need to align your protobuf deps with Nakama’s go.mod files:

> <https://github.com/heroiclabs/nakama/blob/master/go.mod#L30>

> <https://github.com/heroiclabs/nakama-common/blob/master/go.mod>

---

<div class="post-metadata">

**Author:** ![mautoan11](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mautoan11](https://forum.heroiclabs.com/u/mautoan11)\
**Post date:** [January 30, 2022, 1:06pm UTC](https://forum.heroiclabs.com/t/go-plugin-build-error-with-protobuf/629/18 "2022-01-30T13:06:08Z")

</div>

@mofirouz Thank you very much
