# README
Vending Machine API
Creates a json REST API based on these requirements
Requirements
- Go >= 1.18
Setup and dependencies
cp .env.tmpl .env
Edit the values in .env
to match your environment.
# install go-swagger cli
go install github.com/swaggo/swag/cmd/[email protected]
# generate swagger docs
go generate ./...
Run
# check available command line options (provided defaults should work)
go run ./cmd/server/... -h
# run with defaults
go run ./cmd/server/...
# specify the listening address on the command line
go run ./cmd/server/... -l 127.0.0.1:9999
Build and run with Docker
docker login ghcr.io
docker-compose up -d --pull always && docker-compose logs -f vm
To test local changes add the --build
flag:
docker-compose up -d --build && docker-compose logs -f vm
Swagger UI
Available at http://<server>:<port>/swagger/index.html
Generate code coverage report
go test -coverprofile=cover.out ./internal/app/...
go tool cover -html=cover.out -o cover.html