go-build-tag-required
This repository contains a helper library and command line application to assist
Go developers with maintaining Go build tags/constraints in a file, package or
module.
The CLI application checks that the files are configured to be excluded from the
build if the given tag is missing (it checks that the tag is required.)
For example, a file may have have build constraints which make a simple grep
unsuitable for solving this problem:
//go:build (linux && arm64) || (darwin && !arm64 && !cgo)
It's not necessarily obvious whether arm64 is required for this file to be
included in a build. It's even less obvious when using the legacy // +build
style tags.
Usage
$ go-build-tag-required % go run ./cmd/go_build_tag_required/main.go -h
Usage of /var/folders/xt/mkbtrj612rl66xkl5czwg6_r0000gn/T/go-build518224974/b001/exe/main:
-dir string
dir to check go files for required build tag
-file string
go file to check for required build tag
-recursive
descend into subdirectories; recursively check go files for required build tag
-tag string
required build constraint tag to check
If files with missing tags are identified, their names are printed to STDERR
and the process exits with nonzero return code.