ON PROGRESS
- Go ver 1.19
- Postgres ver 14
- install swaggo
go install github.com/swaggo/swag/cmd/swag@latest
- install golang migrate
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
- copy .env.example to .env and fill based on your postgres configuration and set env as "dev"
- generate/refresh swagger.json
swag init
- migrate database
go run main.go migrate-db up
- init superuser
go run main.go init-superuser --username {username} --email {email} --password {password}
- run server
go run main.go runserver
- open swagger "http://{SERVER_HOST}:{SERVER_PORT}/docs/index.html"
- login using username and password
TODO
refrences https://github.com/golang-migrate/migrate/tree/master/cmd/migrate
- install golang migrate cli
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
migrate create -ext sql --dir ./migrations/migrations_files/ {migration name}
- Edit newly created up.sql and down.sql
- change every {} based on your postgresql configuration
migrate -source file://migrations/migrations_files/ -database postgres://{username}:{password}@{host}:{port}/{database}?sslmode={require/verify-full/verify-ca/disable} up
- see
go run main.go migrate-db --help
- run all testing
go test ./...
- run all test in folder
go test ./{folder name}/... ./{another folder name}/...
- run all test in file
go test ./{folder name}/{file name}
- run specific test function
go test --run '^{function name}$' ./{folder name}/{file name}
(Note: --run input is a regex) - run test verbosely (show log)
go test ./... -v
- remove all test cache
go clean -testcache
- disable parallel test
go test ./... -p 1