{"id":36457367,"url":"https://github.com/aziule/filebuildtag","last_synced_at":"2026-01-11T23:06:03.004Z","repository":{"id":57534358,"uuid":"218949517","full_name":"aziule/filebuildtag","owner":"aziule","description":"Linter enforcing files to contain expected build tags, based on the file name.","archived":false,"fork":false,"pushed_at":"2024-11-14T09:37:25.000Z","size":774,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-14T10:22:46.643Z","etag":null,"topics":["ci","code-quality","developer-tools","go","golang","linter","static-analysis","static-code-analysis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aziule.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-01T08:54:49.000Z","updated_at":"2024-11-14T09:35:05.000Z","dependencies_parsed_at":"2022-09-26T18:20:21.177Z","dependency_job_id":null,"html_url":"https://github.com/aziule/filebuildtag","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/aziule/filebuildtag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziule%2Ffilebuildtag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziule%2Ffilebuildtag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziule%2Ffilebuildtag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziule%2Ffilebuildtag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aziule","download_url":"https://codeload.github.com/aziule/filebuildtag/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziule%2Ffilebuildtag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28326201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T22:11:01.104Z","status":"ssl_error","status_checked_at":"2026-01-11T22:10:58.990Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","code-quality","developer-tools","go","golang","linter","static-analysis","static-code-analysis"],"created_at":"2026-01-11T23:05:57.707Z","updated_at":"2026-01-11T23:06:03.000Z","avatar_url":"https://github.com/aziule.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# filebuildtag\nLinter enforcing files to contain expected build tags (`// +build` instruction), based on the file name.\n\n---\n\n[![GoDoc](https://godoc.org/github.com/aziule/filebuildtag?status.svg)](https://godoc.org/github.com/aziule/filebuildtag)\n[![Go Report Card](https://goreportcard.com/badge/github.com/aziule/filebuildtag)](https://goreportcard.com/report/github.com/aziule/filebuildtag)\n\n[Jump to Installation and usage](#installation-and-usage)\n\n## Real world use case\n\nLet's say you put integration tests in files named `*_integration_test.go` and you run them as part of your CI pipeline.\n\nYou might forget to add the `// +build integration` instruction on a newly created file, or you might remove it inadvertently,\nand it can have some consequences, such as never running during the CI pipeline.\n\nAs a consequence, you think your code works when it doesn't, because it is not tested, but you believe it is.\n\nThis linter can help with such issues and let you know when you forgot to add the expected build tags.\n\n## Features\n\n### Exact match\n\nExample: files named `foo.go` must include the `bar` build tag.\n\nFile: `foo.go`\n```go\n// +build bar\n\npackage foo\n```\n\n### Wildcard match\n\nExample: files ending with `_suffix.go` must include the `bar` build tag.\n\nFile: `a_suffix.go`\n```go\n// +build bar\n\npackage foo\n```\n\nFile: `b_suffix.go`\n```go\n// +build bar\n\npackage foo\n```\n\n### Go's `buildtag` linter support\n\n`filebuildtag` is built on top of the `buildtag` linter, hence it supports its features.\n\n### And also\n\n* Run it as a standalone command\n* Integrate it as a part of a runner using the provided `analysis.Analyzer`\n\n## Installation and usage\n\n**Install with Go install**\n\n```shell\ngo get github.com/aziule/filebuildtag/cmd/filebuildtag\n```\n\n**Install and build from source**\n1. Clone the repo\n2. Build the executable\n```shell\nmake build\n```\n\n**Usage**\n\n```shell\n// All files named \"foo.go\" must have the \"bar\" tag\nfilebuildtag --filetags foo.go:bar ./...\n\n// All files ending with \"_integration_test.go\" must have the \"integration\" tag\nfilebuildtag --filetags \"*_integration_test.go:integration\" ./...\n\n// Both of the above\nfilebuildtag --filetags \"foo.go:bar,*_integration_test.go:integration\" ./...\n\n// Only check that the `// +build` instructions are correct (no args to pass) \nfilebuildtag ./...\n```\n\n*Note: files naming patterns are matched using Go's `filepath.Match` method. Therefore, you can use any of its supported patterns.\nSee [File patterns](#file-patterns) for more information and examples.*\n\nHead to the [test scenarios](./filebuildtag_test.go) for more examples.\n\n## Using with linters runners\n\nThis linter exposes an `Analyzer` (accessible via `filebuildtag.Analyzer`), which is defined as \na `golang.org/x/tools/go/analysis/analysis.Analyzer` struct. \n\nMost of the linters runners expect linters to be defined like so, therefore you should not have much trouble integrating it\nfollowing the linters runner's doc.\n\n## File patterns\n\n### Syntax\n\nFrom the official `filepath.Match` doc, file patterns syntax is the following:\n\n```\npattern:\n\t{ term }\nterm:\n\t'*'         matches any sequence of non-Separator characters\n\t'?'         matches any single non-Separator character\n\t'[' [ '^' ] { character-range } ']'\n\t            character class (must be non-empty)\n\tc           matches character c (c != '*', '?', '\\\\', '[')\n\t'\\\\' c      matches character c\n\ncharacter-range:\n\tc           matches character c (c != '\\\\', '-', ']')\n\t'\\\\' c      matches character c\n\tlo '-' hi   matches character c for lo \u003c= c \u003c= hi\n```\n\n### Examples\n\n| file 👇 pattern 👉 | foo.go | *.go | ba?.go | *_test.go |\n|--------------------|--------|------|--------|-----------|\n| foo.go             | ✅     | ✅   | 🚫     | 🚫        |\n| bar.go             | 🚫     | ✅   | ✅     | 🚫        |\n| baz.go             | 🚫     | ✅   | ✅     | 🚫        |\n| a_test.go          | 🚫     | ✅   | 🚫     | ✅        |\n| something          | 🚫     | 🚫   | 🚫     | 🚫        |\n\n## Development\n\n\n\n**Run tests**\n\n```shell\nmake test\n```\n\n**Lint**\n\n```shell\nmake lint\n```\n\n## Roadmap\n\n* Support for folder name matching (`/pkg/**/foo.go`, `/pkg/foo/*.go`, etc.).\n\n## Contributing\n\nA bug to report? A feature to add? Please feel free to open an issue or to propose pull requests!\n\n## License\n\nSome of the code was copied from Go's `buildtag` linter and adapted to match the needs of the `filebuildtag` linter.\nThose files have the mandatory copyright header and their license can be found in `LICENSE.google`.\n\nYou can also find the original code [here](https://github.com/golang/tools/tree/master/go/analysis/passes/buildtag).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faziule%2Ffilebuildtag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faziule%2Ffilebuildtag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faziule%2Ffilebuildtag/lists"}