Template for golang restful API servers. Help you go up and running with Restful Go API server in no time.
- Clone the repository.
- Install dependencies.
govendor init
govendor add +external
- Format & Check syntax
$gofmt -w .
$go vet .
- Change the configs in "conf/app.ini"
- Build project
$go build .
If you want to deploy your API in Docker environment, you can use the Dockerfile given. Since it built from scratch image, you will need to compile executable manually first, then build the image:
//Run database container, use mysql for example (you might need to create external volume directory first.)
$docker run --name <your-db-name> -p <db-exposed-port>:3306 -e MYSQL_ROOT_PASSWORD -v <external-volume-path>:/var/lib/mysql -d mysql
//Compile executable for Dockerfile build
$CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o <your-excutable-name> .
//Build docker image from executable
$docker build -t <your-executable-name>
//Run container & link with database container
$docker run --link <your-db-container>:<your-db-container-alias-name> -p 8001:8001 <your-executable-name>
User Auth (jwt-go)
Logging
Pagination
Configuration Management (ini)
Cache (redis)
ORM (gorm)
Hot reload (endless)
API Docs (Swagger)
For More, see: https://github.com/EDDYCJY/go-gin-example
This repo is adapted from : https://github.com/EDDYCJY/go-gin-example