Course Link: https://www.udacity.com/course/golang--cd11970
Project Layout Recommendations: https://github.com/golang-standards/project-layout
Given the times that I have worked with Go in a professional capacity have been sporadic, I started the Udacity course to make sure I didn't miss out on any of the fundamentals. I had never built a Go project from scratch and was always stepping into projects that were already mature.
So, with that, I wanted to stick to Go standard library as much as possible for this project. I know I could have reached for a lot of different packages to make my code more simplistic, but I wanted to be sure I understood the standard library concepts before getting into the abstractions too heavily.
air
: Needed for live reloading.pgx
: Needed for interfacing with postgres.godotenv
: Needed for .env file import.
I would definitely reach for a HTTP library to make building out of these REST API pieces easier and more concise. I would look at Gin or Chi mainly.
I am not interested in libraries that are bringing the "Javscript Problem" along like Fiber or Echo.
Needed alias air='$(go env GOPATH)/bin/air'
to get air init
to run properly.
- Import the
seed_data.sql
in your local Postgres client. - Create your .env file with
cp .env.example .env
. - Set your
POSTGRES_DB_URL
in the.env
. - Run
go get .
to download all external packages. - Run
air
from the root of the project to start up the server via hot reloading. Make sure you haveair
setup on your machine by runninggo install github.com/cosmtrek/air@latest
, then addingalias air='$(go env GOPATH)/bin/air'
to your bash or zshrc file, and finally re-sourcing the file.- You can also just run
go run ./main.go
if you don't want the hot reload server.
- You can also just run
- To build the binary, run
go build -o ./bin ./cmd/udacity-go-crm-backend
.