/golang-simple-api

Golang Boilerplate for Building Simple API

Primary LanguageGo

Golang Simple API

Simple golang boilerplate for building API

How to Run

  1. Install all project dependencies
make install-dep
  1. Generate gobindata for migrations
make generate-migration
  1. Create new database
  2. Run this project
go run main.go -listen-port="9000" -db-url="postgres://postgres:postgres@localhost:5432/golang-simple-crud?sslmode=disable" -debug="true"

List of Routes

The application runs as an HTTP server at port 9000 (default). It provides some endpoints:

  • GET /api/v1/books: get all books
  • GET /api/v1/books/:id: get detail a book by id
  • POST /api/v1/books: creates a new book
  • POST /api/v1/books/:id/update: update a book by id
  • POST /api/v1/books/:id/delete: delete a book by id

Built With

  • 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