Using Multiple .go files in my Runtime Module?


I’m trying to build some RPCs that do complex functions. It will make life easier to be able to split things across multiple .go files. I’ve got everything written and split across the following files:

main.go (contains initmodule function which registers the RPCs)
RPCs.go (where I define my RPCs)
subfunctions.go (where I define subfunctions that are called in my RPCs)
errors.go (where I define my custom errors)

Each of these files have “package main” at the top of them.

This is my first project in Go, but I understand that we don’t need to do anything to include files in main.go. “Package main” at the top is enough to link these files together. Visual Studio Code is not showing any syntax errors.

However, when I run “docker-compose up --build”, the build fails because the functions called in mentioned in initmodule are not declared. If I move those functions from rpc.go to main.go then I get errors that the subfunctions are not declared, and on and on.

If I put everything into main.go then nakama builds happily and all is well.

Is their something specific about the nakama go runtime module that requires everything to be in a single file? Am I missing some important syntax somewhere?

Thanks for any advice!

Nevermind. Just have to make sure to those additional files get copied in dockerfile.