go-build-tag-required

command module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MPL-2.0 Imports: 6 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis