Simple golang boilerplate for building API
- Install all project dependencies
make install-dep
- Generate gobindata for migrations
make generate-migration
- Create new database
- Run this project
go run main.go -listen-port="9000" -db-url="postgres://postgres:postgres@localhost:5432/golang-simple-crud?sslmode=disable" -debug="true"
The application runs as an HTTP server at port 9000 (default). It provides some endpoints:
GET /api/v1/users
: get all usersGET /api/v1/users/:id
: get detail a user by idPOST /api/v1/users
: creates a new userPUT /api/v1/users/:id
: update a user by idDELETE /api/v1/users/:id
: delete a user by id
- Gin - HTTP web framework
- Pg - Golang ORM with focus on PostgreSQL features and performance
- Sql-migrate - SQL schema migration tool
- Go-bindata - Embedding binary data in a Go program