go-template

Golang server template

MIT License

Stars
13

go-template

SHORT_DESCRIPTION

Features

Setup

  1. Use the following command:

    docker run -d qmcgaw/go-template-docker
    

    You can also use docker-compose.yml with:

    docker-compose up -d
    
  2. You can update the image with docker pull qmcgaw/go-template-docker:latest or use one of the tags available

Environment variables

Environment variable Default Possible values Description
HTTP_SERVER_ADDRESS :8000 Valid address HTTP server listening address
HTTP_SERVER_ROOT_URL / URL path HTTP server root URL
HTTP_SERVER_LOG_REQUESTS on on or off Log requests and responses information
HTTP_SERVER_ALLOWED_ORIGINS CSV of addresses Comma separated list of addresses to allow for CORS
HTTP_SERVER_ALLOWED_HEADERS CSV of HTTP header keys Comma separated list of header keys to allow for CORS
METRICS_SERVER_ADDRESS :9090 Valid address Prometheus HTTP server listening address
LOG_LEVEL info debug, info, warning, error Logging level
STORE_TYPE memory memory, json or postgres Data store type
STORE_JSON_FILEPATH data.json Valid filepath JSON file to use if STORE_TYPE=json
STORE_POSTGRES_ADDRESS psql:5432 Valid address Postgres database address if STORE_TYPE=postgres
STORE_POSTGRES_USER postgres Postgres database user if STORE_TYPE=postgres
STORE_POSTGRES_PASSWORD postgres Postgres database password if STORE_TYPE=postgres
STORE_POSTGRES_DATABASE database Postgres database name if STORE_TYPE=postgres
HEALTH_SERVER_ADDRESS 127.0.0.1:9999 Valid address Health server listening address
TZ America/Montreal string Timezone

Development

You can setup your development environment with a Docker development container or locally:

  1. Install Go, Docker and Git

  2. Install Go dependencies with

    go mod download
    
  3. Install golangci-lint

  4. You might want to use an editor such as Visual Studio Code with the Go extension.

Commands available are:

# Build the binary
go build cmd/app/main.go
# Test the code
go test ./...
# Lint the code
golangci-lint run
# Build the Docker image
docker build -t qmcgaw/go-template-docker .

See Contributing for more information on how to contribute to this repository.

TODOs