This is REST API server sample with golang.
Using gorilla/mux for Routing. Not using ORM.
Structure is a Layer Architecture like Clean Architecture.
- go v1.14
- mysql v5.7
In Heroku.
Use Container deploy and Github-Actions(.github/workflows/production-deploy.yml)
# Download this project
go get github.com/taka011002/go_sample_api_server
$ make up
$ docker-compose up
$ go run main.go
$ go run cmd/migrate/main.go && \
$ go run cmd/import_character_rarities/main.go other/csv/character_raryties.csv && \
$ go run cmd/import_characters/main.go other/csv/characters.csv
Please read doc/api-doc.yaml
shell
$ make bash
$ docker exec -it go_sample_api_server_app_1 /bin/ash
migrate
$ make migrate
$ docker exec -it go_sample_api_server_app_1 go run cmd/migrate/main.go
...
migrate
$ go run cmd/migrate/main.go
import character_rarities
$ go run cmd/import_character_rarities/main.go other/csv/character_raryties.csv
import characters
$ go run cmd/import_characters/main.go other/csv/characters.csv
migrate up
$ migrate -source file://app/infra/migrations/ -database 'mysql://username:secret@tcp(127.0.0.1:3306)/go_sample_api_server' up
migrate down
$ migrate -source file://app/infra/migrations/ -database 'mysql://username:secret@tcp(127.0.0.1:3306)/go_sample_api_server' down
Please read other/uml/table.puml