go-template
is a template repository for starting new Golang projects. It provides well tested packages that faciliate bare-minimum functionality needed in practically any application written in Golang. It's useful for both hobby projects and projects intended to run in production.
- cli package
- configuration management
- database management
- http middlewares
- release tooling
The following packages are provided which can be used when building new Golang applications
The cli
package can be used to build a new CLI using urfave/cli
, and comes with a configuration file generation command already written.
The config
package provides a YAML based configuration file system that can also read values from environment variables. It comes with database, and logging configuration objects. It also provides a helper function that enables returning an instance of the zap
logger.
The database
package provides helper functionality around gorm
. It allows for connecting to a variety of database backends currently supporting MySQL or Sqlite, however adding support for different databases is as simple as including an import of the given database driver. It supports basic migration capabilities, however for more complex database migrations you may want to consider a package like goose.
Provides basic http related functionality largely related to middleware
At the moment the only supported middleware is http/middleware/log
which provides a http logging middleware using Zap
The following miscellaneous features exist primarily to faciliate releasing your Golang application as a distributable cli or docker image.
Includes a script for cross-compiling the cli binary, and a Docker file for packaging the cli into a docker image. A docker compose file is included as well which can be customized to your needs.
To trigger release building which builds the CLI application and the docker image run make release
. Configuration of this is detailed below
Within scripts/release.sh
The TARGETS
variable specifies platform to cross-compile for. To compile for linux/amd64 set it to TARGETS="linux/amd64 darwin/amd64"
. To compile for linux/amd64 and darwin/adm64 set it to TARGETS="linux/amd64"
.
Everything is licensed under Apache 2.0