A standard-library focused Go JSON API server example with PostgreSQL persistence, full CRUD, authentication, and test coverage.
go get github.com/bcomnes/go-todoThis project requires a local PostgreSQL database.
Unit tests run by default:
make testIntegration (PostgreSQL) tests are skipped unless explicitly enabled:
make test TEST_FLAGS='-args -db'Or manually:
go test ./... -args -dbmake migrate-up
make migrate-downThe server and tests rely on the following environment variables (can be set in a .env file):
DATABASE_URL=postgres://postgres@localhost/go-todo?sslmode=disable
PORT=8080
HOST=0.0.0.0package main
import (
"fmt"
"github.com/bcomnes/go-todo"
)
func main() {
fmt.Println("hello world")
}See more examples on PkgGoDev.
See API docs on PkgGoDev.
MIT