Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrvadl/gotaglint
Go linter to check missing //go:build tags
https://github.com/hrvadl/gotaglint
build build-tags go golang linter static-analysis
Last synced: 11 days ago
JSON representation
Go linter to check missing //go:build tags
- Host: GitHub
- URL: https://github.com/hrvadl/gotaglint
- Owner: hrvadl
- License: mit
- Created: 2024-10-19T13:42:33.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2024-10-24T18:18:00.000Z (13 days ago)
- Last Synced: 2024-10-25T15:56:05.789Z (12 days ago)
- Topics: build, build-tags, go, golang, linter, static-analysis
- Language: Go
- Homepage:
- Size: 4.47 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gotaglint
`gotaglint` is a program to check whether you have have defined all required build tags.
## Install
```sh
go install github.com/hrvadl/gotaglint/cmd/gotaglint@latest
```## Usage
To scan all packages run:
```sh
gotaglint --match=".*_test.go" --buildtags="integration,\!integration" ./...
```Where `--match` is the regex of files to check and `--buildtags` is required build tags, separated by comma.
## Example
Let's say you have following code:
```go
package examplesimport "testing"
func Test_sum(t *testing.T) {
t.Parallel()
type args struct {
a int
b int
}
tests := []struct {
name string
args args
want int
}{
{
name: "ShouldSumCorrectly",
args: args{
a: 1,
b: 1,
},
want: 2,
},
}for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := sum(tt.args.a, tt.args.b); got != tt.want {
t.Errorf("sum() = %v, want %v", got, tt.want)
}
})
}
}
```And run `gotaglint` with the following parameters:
```sh
gotaglint --match=".*_test.go" --buildtags="integration,\!integration" ./...
````gotaglint` will produce the following output:
```sh
/Users/vadym.hrashchenko/go/gotaglint/examples/example_test.go:3:9: required build tag is not found
```## Rules
It highlights you if you forgot to specify build tags. This can be particularly useful if you separate
unit and integration tests in your `Go` code by build tags. For example:```sh
//go:build integrationOR
//go:build !integration
```