or maybe I should have called it go-bananas. This is a cli tool to setup an
opinionated golang base project.
The opinion being, write request, response using annotations in proto and service, and generate
- docs
- request, response models
- controllers
Rest of it is common setup needed for web dev.
serverwith echo and graceful terminationclizerologfor loggerconfigsetupdatabasesetup- defaults to sqlx and sqlite3
redisconnection setupbcryptand ulid for hashing and id generation.protosthis is where one writes their api, and the tool generates:request,responsemodelsdummy controller- automatic
openapiv2doc generation
Make sure the bananas executable is in $PATH.
$> mkdir -p testproj; cd testproj
$> go mod init testproj
$> bananas init -n testproj
# generates swagger.json
$> bananas gen:docs
# generate the pb.go files
$> bananas gen:structs
$> go run cmd/server/main.goto use openapiv2
$> bananas init -n testproj -ov 2to enable grpc use
$> bananas init -n testproj --grpc
# from here on, when need to update grpc structs and docs use
$> bananas gen:structs --grpc
$> bananas gen:docs
$> go run cmd/server/main.gochange the compiled proto out path
$> mkdir -b brap/core
$> bananas gen:structs --grpc --out_path=brap/coreN.B.: The --path flag for overriding protos/ directory is off. Will add that later
A default hello example has been provided. After running the server, test it with curl:
curl -XGET 'http://localhost:9001/hellow?name=DudePerfect'
curl -XDELETE 'http://localhost:9001/hellow?name=DudePerfect'make build.cli
