Git Product home page Git Product logo

allowtags's Introduction

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 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.

allowtags's People

Contributors

ashmrtn avatar meain avatar

Watchers

 avatar

Forkers

meain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.