bananas

package module
v0.0.0-...-3b048be Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

README

bananas

bananas logo

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.

batteries
  • server with echo and graceful termination
  • cli
  • zerolog for logger
  • config setup
  • database setup
    • defaults to sqlx and sqlite3
  • redis connection setup
  • bcrypt and ulid for hashing and id generation.
  • protos this is where one writes their api, and the tool generates:
    • request, response models
    • dummy controller
    • automatic openapiv2 doc generation
usage

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.go

to use openapiv2


$> bananas init -n testproj -ov 2

to 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.go

change the compiled proto out path

$> mkdir -b brap/core
$> bananas gen:structs --grpc --out_path=brap/core

N.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'
building

make build.cli

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseFS embed.FS
View Source
var DbFS embed.FS
View Source
var MiddlewareFS embed.FS
View Source
var PkgFS embed.FS
View Source
var ScriptsFS embed.FS

Functions

func MustRenderTmpl

func MustRenderTmpl(
	templateFs embed.FS, templateFile string, data TemplData,
) (outPath string, content *bytes.Buffer, ok bool)

func WriteFile

func WriteFile(filePath string, content *bytes.Buffer) error

Types

type TemplData

type TemplData map[string]any

Directories

Path Synopsis
cmd
cli command

Jump to

Keyboard shortcuts

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