diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f439946 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 ashmrtn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a825a59 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# AllowTags + +AllowTags is a golang linter that checks all tags on struct fields have keys +matching one of the given set. Also does some validation of tag formatting. + +AllowTags provides more peace of mind when working with struct tags, especially +since the golang compiler won't report misspellings. + +## Installing +AllowTags is provided as a go module and can be installed by running +`go install github.com/ashmrtn/allowtags@latest` + +## Running +AllowTags uses a similar front-end to `go vet`. You can run AllowTags by +executing `allowtags --allow-key key1 --allow-key key2 ` after +installation. You can pass multiple packages to AllowTags by using the +`...` expression, just like you would with other tools. For example, to check +your whole project with AllowTags just run `allowtags --allow-key key1 ./...`. + +### Flags +AllowTags requires all tags that it allows be explicitly given. To specify +multiple tag keys pass the `--allow-key` flag multiple times, each time with a +different tag key. + +## Limitations +AllowTags uses a different parsing method than govet and the golang standard +library's tag parser. This means it may give different error messages compared +to govet and the standard library when run on malformed tags. However, AllowTags +is built to be fairly lenient when parsing tags and attempts to find key-value +pairs where possible. + +The rules that AllowTags parses by are loosely derived from documentation in the +golang standard library [reflect package](https://pkg.go.dev/reflect#StructTag) +empirical testing of the standard library's behavior, and the idea of trying to +find key-value pairs where possible even if the tag is not formatted as +expected.