gostartup is my go-to starter project base for a golang project.
It is an opinionated collection of select packages and reference implementations for building a range of projects from small CLI utilities, independent microservices, to mono repo for multiple services of a SaaS backend.
In addition, it also serves me as a documented collection of thoughts on how to do common tasks around monitoring/deploying services and managing secrets.
- a cookiecutter similar to django cookiecutter. cookiecutter templates are more cleaner and abstract, but the purpose here is to get started quickly with reference/sample code, instead of providing clean abstractions
- a production-ready implementation of any feature. The goal is to have a project-base which will help get there quickly.
- There is no performance criterion as of yet, as there are no actual usecases yet. So frameworks, packages are chosen for extendability/ease of deployment, rather than performance. Also [[]premature optimization is the root of evil]
- Reference
user:account
data models in postgres and APIs supporting signup/login/account recovery usecases using authboss - permissions
- Reference
stats
service with API stats and basic rate limiting using redis - Reference JWT implementation for authentication along with basic auth for service authentication
- Reference notification implementation for posting payloads to urls using exponential back-off.
echo
based API server with reference middlewares.- A simple in-memory job queue using to asynchronously process lightweight workloads: using an example of notifying a URL with a payload
- Auto-generating OpenAPI[] specs using swagger for services provided
- env based config supporting 12 factor apps[]
- Feature flags
- Clean-ish Architecture[]
- Template for building multiple service/binaries based on mono repo
- go modules for package management
- CLI ready
- CI support
- Docker support
As with the
Use react-admin or vue-admin with apis
Use prest for converting uncovered models/tables to API. Use it with a whitelist, covering only tables which don't need admin usecases/business logic behind them. Another option is to mount prest using a custom backend and add additional admin endpoints
All the settings for the services are injected via environment variables in accordance with 12-factor[] app.
KMS + S3 Vault + Consul + https://github.com/hashicorp/envconsul
https://blog.digitalocean.com/cthulhu-organizing-go-code-in-a-scalable-repo/ https://gomonorepo.org/
- gRPC
- Install golang in your system(1.10 preferably)
- Set GOPATH. Export
$GOPATH=$ {HOME}/gopath. Add this to your bashrc/zshrc. - Initiate GOPATH. Go on install something:
go get -u gopkg.in/alecthomas/gometalinter.v2
- Clone repo under GOPATH.
cd $GOPATH/src; git clone [email protected]:westworld-ho/gostartup.git
- Install dep in your system. Either
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
orbrew install dep
- Install all project dependencies.
cd $GOPATH/src/gostartup; dep ensure
- That's It. Now edit code with your favorite editor.
- To run:
go run src/main.go -debug
.-debug
is used for local testing. - To run tests:
cd src; go test ./...
- Setup and install Postgres.
brew install postgresql
andbrew install pgcli
- Setup postgres for your user.
sudo -u postgres createuser -s ${USERNAME}
- Create hostdb and user.
createdb hostdb; createuser gostartup sweetwater
- Install redis.
brew install redis
orsudo apt install redis-server redis-tools
rest
- swagger
- monitor: jaegar tests
- bdd/table-driven: ginkgo
- mock: testify
- faker
- user:account(flask)
- login(post, delete logout)
- signup(post)
- recovery(password reset form + email link)
- emails
- auth/session validation
- rbac
- api doc
- payments: capture, charge, txn history, manage fi, balance??
- webhook(+jobq) for recording transaction
- notification for upstream services(callback url + backoff mechanism)
- cache? : redlock for charge id lock,, balance