Alright, let's go! We'll keep this part short, so you can start building. 😎
First, make sure you have Go, git, and Docker installed. Then:
On your terminal in the project directory, run:
$ git remote add golangdk https://github.com/golangdk/canvas.git && git fetch golangdk
This will make it easier to keep up to date with changes from the original canvas repository.
You will now have a very basic Go project structure with a few config files, a Makefile, and the initial files for your Go program.
Everyone has different preferences for project structure, and there is no right way to do it. That said, in canvas we follow some conventions that work quite well:
Makefile, and more, are in the root folder.
cmd/server/directory has the
mainpackage and function that starts the server.
server/directory will hold the HTTP server setup and running code.
handlers/directory will have all the HTTP handlers.
Makefile is a convenience so that we have to type less. It uses the
go command for testing, coverage, and starting the server.
make start, and you should see a nerdy smiley on your terminal:
$ make start go run cmd/server/*.go 🤓
To run your tests and see coverage, run
make test cover:
$ make test cover go test -coverprofile=cover.out -short ./... ? canvas/cmd/server [no test files] ? canvas/handlers [no test files] ok canvas/server 0.286s coverage: [no statements] [no tests to run] go tool cover -html=cover.out
That's what you need to know for now. Next, let's write some code!
Get help at email@example.com.