Tip
Create, setup and extend a Golang project like a puzzle in seconds
go install github.com/waler4ik/kk@latest
After installation use kk
command in your shell.
Creates a Golang REST server project without endpoints. Chi is used as the default router.
kk init rest github.com/waler4ik/kk-example
kk init -r chi rest github.com/waler4ik/kk-example
Create a Golang REST server project with gin router.
kk init -r gin rest github.com/waler4ik/kk-example
Creates and wires a REST resource endpoint
kk add resource machines/data
Creates and wires a websocket endpoint. It's based on Melody project. See https://github.com/olahol/melody
kk add ws rest/ws
Creates and wires a prometheus metrics endpoint. See https://prometheus.io/docs/guides/go-application/
kk add metrics /metrics
Adds a secret manager provider based on environment variables.
kk add envsecretmanager
Adds a postgres provider.
kk add postgres
Adds a rabbitmq producer provider.
kk add rabbitmqproducer
REST resource endpoints added with kk add
come along with swaggo/swag annotations. So you can tell the world how your REST webservice works.
Possible workflow:
- Generate swagger 2.0 specification with swaggo/swag. Run
swag init -g internal/docs/docs.go
. - Generate a Golang client from previously generated swagger 2.0 specification with go-swagger and use it for your Golang client application or just test your previously generated webservice.
kk generates projects like this https://github.com/waler4ik/kk-example (chi router, REST endpoints).
After running kk init
, build and start your service with the commands below. Then check your endpoints using a tool of your choice.
docker compose build && docker compose up -d
- Add websocket command
- Generate swagger/openapi specification command
- Select router within init command (chi, gin, gorilla)
- Add cucumber godog tests for main workflows, see https://github.com/cucumber/godog
- Add kubernetes scripts command
- https://github.com/hay-kot/scaffold It's a more general approach. It gives you the possibility to write and use your own templates.