-
-
Couldn't load subscription status.
- Fork 2.9k
Description
The instructions on how to build and run the separate applications for the "Build an Application > Command line & package structure" were unclear.
For example, I was running go build from the root of my folder, expecting it to make a binary for each of my "main" packages. I incorrectly assumed it was rebuilding into my binary that I made in previous chapters (named "test-app" after my root folder and module name).
However, it turns out go build doesn't actually provide any output if it doesn't find anything to build (not even with the -v flag), and so running it wasn't doing anything at all.
I had to cd into the folders of each main (e.g. cd cmd/cli) and then run go build.
However, I then came across another issue. Running ./cli from within cmd/cli caused a new game.db.json to appear in that folder. Similarly, building and running from within cmd/webserver caused another in there, too.
To get the individual applications to update the original game.db.json in my root folder, I had to run the binaries from there (e.g. ./cmd/cli/cli and ./cmd/webserver/webserver).
Also - I looked up what cmd was and it looks like it's a golang convention to hold all your "mains" under this directory. It could be worth explaining this, too.