It’s still not working locally on my mac, but it worked on our Linux server on AWS. For Mac, I will (later) try to remove all the files and make a fresh attempt to see if it does. It must be some random link to a different version that I am not able to find and break.
Here is a detailed step-by-step of how I migrated from 2.6.0 to a 2.7.0+ version on my Linux server, in case it helps anyone else trying to do the same. @novabyte @zyro please correct me / add. Relevant only for another layman who builds from the source, like I do.
- Make a goprojects directory outside $GOPATH
$ mkdir $HOME/goprojects
- Clone nakama repo in this new folder and build it there
$ cd $HOME/goprojects $ git clone https://github.com/heroiclabs/nakama.git $ cd nakama $ git checkout v2.9.1 $ env CGO_ENABLED=1 go build -trimpath -mod=vendor
3 Copy / move / clone / (create new) project directory inside this folder
$ cp $GOPATH/src/pool $HOME/goprojects/
- Initialise a go module in this folder
$ cd $HOME/goprojects/pool $ go mod init "reingames.com/pool"
- Update the dependencies in the project to import nakama-common instead of nakama, e.g.
// In the go code, remove the following from your import list "github.com/heroiclabs/nakama/runtime" // replace it with "github.com/heroiclabs/nakama-common/runtime"
- Link any local packages that you may have with their physical local locations, e.g. this is how I linked my local reingames.com/common dependency
//In my plugin's go.mod require ( // all other dependencies here reingames.com/common v0.0.0 ) // The following line will link reingames.com/common package to it's local physical location replace reingames.com/common => ../../reingames
- Make sure that everything is set up nice and clean. And build
$ go mod tidy $ go mod vendor
- Build and run the code
$ go build -buildmode=plugin -trimpath -mod=vendor -o ./modules/pool.so $ $HOME/nakama/nakama --config ./config/conf.yml
- Check the version of dependency in the modules.txt file in the vendor folder (e.g. $HOME/gopath/pool/vendor/modules.txt)
- If the version you find here is different from the one that is in nakama’s folder, you could do the following:
- If the package x/y/z is imported directly in your source code, the package will be included in your plugin’s go.mod file. Set the version there to match the version that in nakama’s
- If the package x/y/z is not imported directly and not showing up in your plugin’s go.mod, force import it and set the version, i.e.
// In the import part of your main.go _ "x.y.z" // import this. Not the leading _ (underscore) // In go.mod file x.y.z v1.2.3 // match this version with the one in nakama's go.mod
I don’t know if it’s just basic stuff that is obvious to all, but still posting in the hope that this helps someone else as well.