Powered by Cookiecutter, Cookiecutter Golang is a framework for jumpstarting production-ready go projects quickly.
Makefilewith management commands
go dep(with optional go module support requires go 1.11)
modfor dependency management
This project now uses docker multistage builds, you need at least docker version v17.05.0-ce to use the docker file in this template, you can read more about multistage builds here.
This template uses docker multistage builds to make images slimmer and containers only the final project binary and assets with no source code whatsoever.
Apps run under non root user and also with dumb-init.
Let's pretend you want to create a project called "echoserver". Rather than starting from scratch maybe copying some files and then editing the results to include your name, email, and various configuration issues that always get forgotten until the worst possible moment, get cookiecutter to do all the work.
First, get Cookiecutter. Trust me, it's awesome:
$ pip install cookiecutter
Alternatively, you can install
cookiecutter with homebrew:
$ brew install cookiecutter
Finally, to run it based on this template, type:
$ cookiecutter https://github.com/lacion/cookiecutter-golang.git
You will be asked about your basic info (name, project name, app name, etc.). This info will be used to customize your new project.
Warning: After this point, change 'Luis Morales', 'lacion', etc to your own information.
Answer the prompts with your own desired options. For example:
full_name [Luis Morales]: Luis Morales github_username [lacion]: lacion app_name [mygolangproject]: echoserver project_short_description [A Golang project.]: Awesome Echo Server docker_hub_username [lacion]: lacion docker_image [lacion/docker-alpine:latest]: lacion/docker-alpine:latest docker_build_image [lacion/docker-alpine:gobuildimage]: lacion/docker-alpine:gobuildimage use_docker [y]: y use_git [y]: y use_logrus_logging [y]: y use_viper_config [y]: y use_cobra_cmd [y]: y Select use_ci: 1 - travis 2 - circle 3 - none Choose from 1, 2, 3 : 1
Enter the project and take a look around:
$ cd echoserver/ $ ls
make help to see the available management commands, or just run
make build to build your project.
$ make help $ make build $ ./bin/echoserver