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/books
: get all booksGET /api/v1/books/:id
: get detail a book by idPOST /api/v1/books
: creates a new bookPOST /api/v1/books/:id/update
: update a book by idPOST /api/v1/books/:id/delete
: delete a book 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