kk

command module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 4 Imported by: 0

README

Go

kk - Golang boilerplate CLI tool

[!TIP] Create, setup and extend a Golang project like a puzzle in seconds

How to use it?

Install
go install github.com/waler4ik/kk@latest

After installation use kk command in your shell.

Init command

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
Add command

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

OpenAPI / Swagger interface

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.

Example project

kk generates projects like this https://github.com/waler4ik/kk-example (chi router, REST endpoints).

Testing locally

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

Upcoming features (commands)

  • 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

Similar approaches

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL