Makefile setup for our Golang projects.
111
stars
453
commits
Makefile
primary language
Sep 7, 2026
updated
Makego is our Makefile setup for our Golang projects. This repository also functions as a template repository for our Golang projects that use makego.
Makego supports our development workflow, which includes Golang, Docker, and Protobuf primarily. All
projects should result in make working out of the box, as long as the system has Golang >=1.13
installed, and Docker installed if Docker is used. All other dependences (except for a few that we
need to document that most systems will have, such as bash, curl, and git) are installed by makego
automatically and cached on a per-project basis, including all Golang module downloads.
Makego allows updating from this main (or your forked main) automatically, only copying the files you need.
Makego is primarily OSS as we use it in our OSS projects. Makego will likely have many breaking
changes, and we do not provide support for it in any form. You're obviously welcome
to fork it and/or use components of it, however - the MAKEGO_REMOTE variable controls the remote location
for make copyfrommakego.
If you do use this, you should get familiar with the actual Makefiles contained in this project.
Very alpha. This will change a bunch. The documentation is incomplete as well.
Buf uses this, and should be treated as the gold-standard example for makego usage.
The following are controlled by makego, and should not be edited directly:
Otherwise, you're free to choose your own layout, however you should generally do the following:
make/PROJECT/all.mk such as make/foo/all.mk that defines the
setup for your project. This should be the only file included in your Makefile.foo, you should have
cmd/foo, and add cmd/foo to GO_BINS such as in make/foo/all.mk.foo to DOCKER_BINS such as in make/foo/all.mk.gen. Makego treats gen directories as special,
primarily by not linting them or using them for code coverage.Other files of relevance:
.env - This directory contains your individual environment, if you want. You can back this
up to with make envbackup and restore with make envrestore. The special file .env/env.sh
will be included with make direnv, which direnv calls via .envrc..tmp - This directory is used for temporary files such as coverage files and makego temporary
clones.Assuming your actual remote is github.com/eng/hello:
git clone https://github.com/bufbuild/makego hello
cd ./hello
rm -rf .git
git init
git remote add origin https://github.com/eng/hello
Move make/foo to make/PROJECT:
mv make/foo make/hello
Then edit the Makefile:
# You can put make/go somewhere else if you want but we would not recommend it, however it
# should work as all Makefile in make/go use this variable to know where things are
MAKEGO := make/go
# Change to your fork. Do not use ours.
MAKEGO_REMOTE := https://github.com/eng/makego.git
# Your project name
PROJECT := hello
# The Golang module
GO_MODULE := github.com/eng/makego
# The Docker organization. Optimally this is your Docker Hub organization, but makego
# does not currently interact with Docker Hub.
DOCKER_ORG := eng
# The Docker project name, generally the same as PROJECT. The Docker image
# $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace will be created.
DOCKER_PROJECT := hello
# This changes from make/foo/all.mk to make/hello/all.mk
include make/hello/all.mk
Update everything and make sure everything builds:
# This also calls make generate and make all
make upgrade
Figure out the specific files you want (see "Basic Concepts" below), and only include
those files in make/hello/all.mk. When you're sure you are done, run make copyfrommakego
to delete unnecessary files.
make copyfrommakego
Then, delete everything in this readme except potentially the badge links at the top (but if you keep the badge links, update them for your repository). Also update the LICENSE for your use.
All projects should have a make/PROJECT/all.mk file that defines your actual setup. This
includes files from make/go that you need, as well as any custom build commands See
make/buf/all.mk for a
real-world example.
This file should all or some of these files, depending on what you need:
.dockerignore
file and any Dockerfiles.All other files are automatically included.
We are not documenting all development commands, however some important ones of note:
make all - This is the default goal, and runs linting and testing.make ci - This is the goal for CI, and downloads deps, and runs linting, testing, and code coverage.
Note that deps are downloaded automatically on a per-target basis, so the initial dep download really
shouldn't be needed.make generate - Do all generation.make lint - Do all linting.make build - Go build.make test - Go test.make cover - Go code coverage.make install - Install all Go binaries defined by GO_BINS.make dockerbuild - Build all Docker images defined by DOCKER_BINS.make copyfrommakego - Update from makego main.Makego is controlled by various environment variables. This list may get out of date, however as of this writing, this is what is required, settable, and settable at runtime.
These variables should be defined in your Makefile and are required.
MAKEGO - The location of the make/go directory. Generally you should have this as make/go,
however we did make it settable so you can put the files somewhere else.MAKEGO_REMOTE - The remote location for makego. You should point this at your fork. The
make target make copyfrommakego will copy makego to your current files.PROJECT - Your project name. This is used for many things such as your config and cache
locations.GO_MODULE - Your Golang module name.If you use Docker, the following are also required.
DOCKER_ORG - The Docker organization. Optimally this is your Docker Hub organization, but makego
does not currently interact with Docker Hub.DOCKER_PROJECT - The Docker project name, generally the same as PROJECT. The Docker image
$(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace will be created.These variables are settable in your Makefiles, but should be static, i.e. these are for project-specific settings and not intended to be set on the command line.
FILE_IGNORES - The relative paths to files to add to .dockerignore and .gitignore. By
default, makego will add .env, .tmp, and any Golang binaries.
Note if you set this, you should do so by including the current value ie FILE_IGNORES := $(FILE_IGNORES) .build/.CACHE_BASE - By default, makego caches to ~/.cache/$(PROJECT). Set this to change that.GO_BINS - The relative paths to your Golang main packages, For example cmd/foo.
Note if you set this, you should do so by including the current value ie GO_BINS := $(GO_BINS) cmd/bar.GO_GET_PKGS - Extra packages to get when running make upgrade.
For example, make/buf/all.mk
adds master for github.com/jhump/protoreflect.
Note if you set this, you should do so by including the current value ie GO_GET_PKGS := $(GO_GET_PKGS) github.com/foo/bar@v1.0.0.GO_LINT_IGNORES - Extra grep ignores for linting.
Note if you set this, you should do so by including the current value ie GO_LINT_IGNORES := $(GO_LINT_IGNORES) \/foobar\/.DOCKER_BINS - This sets any Dockerfiles that are to be built. There should be a matching
Dockerfile.binaryname for each value.
Note if you set this, you should do so by including the current value ie DOCKER_BINS := $(DOCKER_BINS) bar..*_VERSION - This sets the version for dependencies, such as ERRCHECK_VERSION := e14f8d59a22d460d56c5ee92507cd94c78fbf274. We update these once in a while, but you can set your own as well to make sure your own
builds are deterministic. See the dep_.* files for the individual variables.These variables are meant to be set when invoking make targets on the command line.
GOPKGS - This controls what packages to build for Go commands. By default, this is ./.... If
you only wanted to test ./internal/foo/... for example, you could run make test GOPKGS=./internal/foo/...COVEROPEN - This will result in the cover.html file being automatically opened after make cover is run, for example make cover COVEROPEN=1.Makefile
82.6%
Shell
12.4%
Go
5.0%
Makefile setup for our Golang projects.
111
stars
453
commits
Makefile
primary language
Sep 7, 2026
updated
Makego is our Makefile setup for our Golang projects. This repository also functions as a template repository for our Golang projects that use makego.
Makego supports our development workflow, which includes Golang, Docker, and Protobuf primarily. All
projects should result in make working out of the box, as long as the system has Golang >=1.13
installed, and Docker installed if Docker is used. All other dependences (except for a few that we
need to document that most systems will have, such as bash, curl, and git) are installed by makego
automatically and cached on a per-project basis, including all Golang module downloads.
Makego allows updating from this main (or your forked main) automatically, only copying the files you need.
Makego is primarily OSS as we use it in our OSS projects. Makego will likely have many breaking
changes, and we do not provide support for it in any form. You're obviously welcome
to fork it and/or use components of it, however - the MAKEGO_REMOTE variable controls the remote location
for make copyfrommakego.
If you do use this, you should get familiar with the actual Makefiles contained in this project.
Very alpha. This will change a bunch. The documentation is incomplete as well.
Buf uses this, and should be treated as the gold-standard example for makego usage.
The following are controlled by makego, and should not be edited directly:
Otherwise, you're free to choose your own layout, however you should generally do the following:
make/PROJECT/all.mk such as make/foo/all.mk that defines the
setup for your project. This should be the only file included in your Makefile.foo, you should have
cmd/foo, and add cmd/foo to GO_BINS such as in make/foo/all.mk.foo to DOCKER_BINS such as in make/foo/all.mk.gen. Makego treats gen directories as special,
primarily by not linting them or using them for code coverage.Other files of relevance:
.env - This directory contains your individual environment, if you want. You can back this
up to with make envbackup and restore with make envrestore. The special file .env/env.sh
will be included with make direnv, which direnv calls via .envrc..tmp - This directory is used for temporary files such as coverage files and makego temporary
clones.Assuming your actual remote is github.com/eng/hello:
git clone https://github.com/bufbuild/makego hello
cd ./hello
rm -rf .git
git init
git remote add origin https://github.com/eng/hello
Move make/foo to make/PROJECT:
mv make/foo make/hello
Then edit the Makefile:
# You can put make/go somewhere else if you want but we would not recommend it, however it
# should work as all Makefile in make/go use this variable to know where things are
MAKEGO := make/go
# Change to your fork. Do not use ours.
MAKEGO_REMOTE := https://github.com/eng/makego.git
# Your project name
PROJECT := hello
# The Golang module
GO_MODULE := github.com/eng/makego
# The Docker organization. Optimally this is your Docker Hub organization, but makego
# does not currently interact with Docker Hub.
DOCKER_ORG := eng
# The Docker project name, generally the same as PROJECT. The Docker image
# $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace will be created.
DOCKER_PROJECT := hello
# This changes from make/foo/all.mk to make/hello/all.mk
include make/hello/all.mk
Update everything and make sure everything builds:
# This also calls make generate and make all
make upgrade
Figure out the specific files you want (see "Basic Concepts" below), and only include
those files in make/hello/all.mk. When you're sure you are done, run make copyfrommakego
to delete unnecessary files.
make copyfrommakego
Then, delete everything in this readme except potentially the badge links at the top (but if you keep the badge links, update them for your repository). Also update the LICENSE for your use.
All projects should have a make/PROJECT/all.mk file that defines your actual setup. This
includes files from make/go that you need, as well as any custom build commands See
make/buf/all.mk for a
real-world example.
This file should all or some of these files, depending on what you need:
.dockerignore
file and any Dockerfiles.All other files are automatically included.
We are not documenting all development commands, however some important ones of note:
make all - This is the default goal, and runs linting and testing.make ci - This is the goal for CI, and downloads deps, and runs linting, testing, and code coverage.
Note that deps are downloaded automatically on a per-target basis, so the initial dep download really
shouldn't be needed.make generate - Do all generation.make lint - Do all linting.make build - Go build.make test - Go test.make cover - Go code coverage.make install - Install all Go binaries defined by GO_BINS.make dockerbuild - Build all Docker images defined by DOCKER_BINS.make copyfrommakego - Update from makego main.Makego is controlled by various environment variables. This list may get out of date, however as of this writing, this is what is required, settable, and settable at runtime.
These variables should be defined in your Makefile and are required.
MAKEGO - The location of the make/go directory. Generally you should have this as make/go,
however we did make it settable so you can put the files somewhere else.MAKEGO_REMOTE - The remote location for makego. You should point this at your fork. The
make target make copyfrommakego will copy makego to your current files.PROJECT - Your project name. This is used for many things such as your config and cache
locations.GO_MODULE - Your Golang module name.If you use Docker, the following are also required.
DOCKER_ORG - The Docker organization. Optimally this is your Docker Hub organization, but makego
does not currently interact with Docker Hub.DOCKER_PROJECT - The Docker project name, generally the same as PROJECT. The Docker image
$(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace will be created.These variables are settable in your Makefiles, but should be static, i.e. these are for project-specific settings and not intended to be set on the command line.
FILE_IGNORES - The relative paths to files to add to .dockerignore and .gitignore. By
default, makego will add .env, .tmp, and any Golang binaries.
Note if you set this, you should do so by including the current value ie FILE_IGNORES := $(FILE_IGNORES) .build/.CACHE_BASE - By default, makego caches to ~/.cache/$(PROJECT). Set this to change that.GO_BINS - The relative paths to your Golang main packages, For example cmd/foo.
Note if you set this, you should do so by including the current value ie GO_BINS := $(GO_BINS) cmd/bar.GO_GET_PKGS - Extra packages to get when running make upgrade.
For example, make/buf/all.mk
adds master for github.com/jhump/protoreflect.
Note if you set this, you should do so by including the current value ie GO_GET_PKGS := $(GO_GET_PKGS) github.com/foo/bar@v1.0.0.GO_LINT_IGNORES - Extra grep ignores for linting.
Note if you set this, you should do so by including the current value ie GO_LINT_IGNORES := $(GO_LINT_IGNORES) \/foobar\/.DOCKER_BINS - This sets any Dockerfiles that are to be built. There should be a matching
Dockerfile.binaryname for each value.
Note if you set this, you should do so by including the current value ie DOCKER_BINS := $(DOCKER_BINS) bar..*_VERSION - This sets the version for dependencies, such as ERRCHECK_VERSION := e14f8d59a22d460d56c5ee92507cd94c78fbf274. We update these once in a while, but you can set your own as well to make sure your own
builds are deterministic. See the dep_.* files for the individual variables.These variables are meant to be set when invoking make targets on the command line.
GOPKGS - This controls what packages to build for Go commands. By default, this is ./.... If
you only wanted to test ./internal/foo/... for example, you could run make test GOPKGS=./internal/foo/...COVEROPEN - This will result in the cover.html file being automatically opened after make cover is run, for example make cover COVEROPEN=1.Makefile
82.6%
Shell
12.4%
Go
5.0%