Skip to content

Commit

Permalink
Merge pull request #4 from ashmrtn/readme
Browse files Browse the repository at this point in the history
Add license and readme
  • Loading branch information
ashmrtn authored Jul 12, 2023
2 parents 3bfd0b9 + e848c00 commit ec675c3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <packages>` 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.

0 comments on commit ec675c3

Please sign in to comment.