This library is a starter for an API implemented in GoLang. It comes with user login functionality, logging capablities, and environment-based configurations. If login functionality isn't required it can easily be used as an example and replaced with appropriate endpoint logic using the steps outlined below. Stack includes grpc, buf/connect-go, MySQL, and GORM. There is also an accompanying front-end starter built using Qwik to demo a typescript/client implementation of connect-go: qwik-client-starter (WIP)
1. Install Go and Dependencies
- Install Go
- Clone this repo, cd into directory and run
$ go get github.com/mvpoyatt/go-api/api $ go get github.com/mvpoyatt/go-api/configs $ go get github.com/mvpoyatt/go-api/database $ go mod tidy
2. Download MySQL and MySQL Workbench
- MySQL - Replace
db:password
in/configs/development.yaml
with password you enter here - MySQL Workbench - Create new schema named
testdb
or replacedb:dbname
in/configs/development.yaml
with name of new schema
3. Start Server
- In root directory of project run
$ go run main.go
- Install buf tools
- Install connect tools
- Remove existing code and re-generate
$ rm -rf gen/ $ buf generate
- This generates code in
gen/
folder. Delete and re-run after changing.proto
file.
- This generates code in
- Add new API folders to buf.work.yaml
- Update buf.gen.yaml for new:
- Code generating plugins
- External packages (exlude default go_option prefixes)
- In home directory of project run
$ rm -rf gen # reset existing generated code $ buf lint $ buf build $ buf generate