RESTful API development template based on GIN framework for development purpose
- Go 1.13
- Rest API
- Swagger
- GIN 1.5
- Alpine 3.11
Before installing this project, please, make sure you have installed docker and docker-compose
To install docker execute:
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh
$ pip install docker-compose
Clone this project into your work directory:
$ git clone https://github.com/trydirect/go-rest.git
Then build it via docker-compose:
$ cd go-rest
$ docker-compose up -d
or
$ docker-compose -f docker-compose-debug.yml up
Now, let's check the result
$ curl http://localhost:8080/api/v1/accounts
[{"id":1,"name":"account_1","uuid":"00000000-0000-0000-0000-000000000000"},{"id":2,"name":"account_2","uuid":"00000000-0000-0000-0000-000000000000"},{"id":3,"name":"account_3","uuid":"00000000-0000-0000-0000-000000000000"}]
Go to page http://localhost:8080/swagger/index.html to see generated documentation.
-
Add comments to your API source code, See Declarative Comments Format.
-
Download swag by using:
$ go get -u github.com/swaggo/swag/cmd/swag
Or download a pre-compiled binary from the release page.
- Run
swag init
in the project's root folder. This will parse your comments and generate the required files (docs
folder anddocs/docs.go
).
$ swag init -g app/main.go
- Fork it (https://github.com/trydirect/go-rest/fork)
- Create your feature branch (git checkout -b feature/fooBar)
- Commit your changes (git commit -am 'Add some fooBar')
- Push to the branch (git push origin feature/fooBar)
- Create a new Pull Request