Could not open Go module

Hey I’m trying to develop go modules following the documentation.

OS: Ubuntu 19.04
Go:

go version go1.13.6 linux/amd64

I ran this to get the nakama module:

go get -u "github.com/heroiclabs/nakama-common" 

I use Docker compose with this config:

version: '3'
services:
  cockroachdb:
    container_name: cockroachdb
    image: cockroachdb/cockroach:v19.1.5
    command: start --insecure --store=attrs=ssd,path=/var/lib/cockroach/
    restart: always
    volumes:
      - data:/var/lib/cockroach
    expose:
      - "8080"
      - "26257"
    ports:
      - "26257:26257"
      - "8080:8080"
  nakama:
    container_name: nakama
    image: heroiclabs/nakama:2.7.0
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
          /nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
          exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level debug #--runtime.path "./modules"
    restart: unless-stopped
    links:
      - "cockroachdb:db"
    depends_on:
      - cockroachdb
    volumes:
      - ./:/nakama/data
    expose:
      - "7349"
      - "7350"
      - "7351"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  data:

I encounter this error when running

sudo docker-compose -f docker-compose.yml up

Could not open Go module",“path”:"/nakama/data/modules/test.so",“error”:“plugin.Open(”/nakama/data/modules/test.so"): Error relocating /nakama/data/modules/test.so: __fprintf_chk: symbol not found",“stacktrace”:“github.com/heroiclabs/nakama/v2/server.openGoModule\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime_go.go:1899\ngithub.com/heroiclabs/nakama/v2/server.NewRuntimeProviderGo\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime_go.go:1823\ngithub.com/heroiclabs/nakama/v2/server.NewRuntime\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime.go:442\nmain.main\n\tmain.go:130\nruntime.main\n\truntime/proc.go:203”}
nakama | {“level”:“error”,“ts”:“2020-01-18T08:20:50.350Z”,“msg”:“Error initialising Go runtime provider”,“error”:“plugin.Open(”/nakama/data/modules/test.so"): Error relocating /nakama/data/modules/test.so: __fprintf_chk: symbol not found",“stacktrace”:“github.com/heroiclabs/nakama/v2/server.NewRuntime\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime.go:444\nmain.main\n\tmain.go:130\nruntime.main\n\truntime/proc.go:203”}
nakama | {“level”:“fatal”,“ts”:“2020-01-18T08:20:50.350Z”,“msg”:“Failed initializing runtime modules”,“error”:“plugin.Open(”/nakama/data/modules/test.so"): Error relocating /nakama/data/modules/test.so: __fprintf_chk: symbol not found",“stacktrace”:“main.main\n\tmain.go:132\nruntime.main\n\truntime/proc.go:203”}

In the same folder I have modules/test.go:

package main

import (
  "context"
  "database/sql"

  "github.com/heroiclabs/nakama-common/runtime"
)

func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
  logger.Info("module loaded")
  return nil
}

That I build with

go build -buildmode=plugin -trimpath -o ./test.so

Ah and I also ran (before)

go mod init "modules"

Did I do something wrong ?

Thanks a lot !

Hi @louis030195 welcome :wave:

You’ll need to use the Docker container which builds and links against the container architecture when you load the compiled shared object. Have a look at these instructions and let me know if you have any further issues: