### Install Tagliatelle Binary Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Command to install the Tagliatelle linter binary using Go. This method is not recommended for general use. ```shell go install github.com/ldez/tagliatelle/cmd/tagliatelle@latest ``` -------------------------------- ### Ignore a Package with Tagliatelle Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Example of completely ignoring the 'foo/bar' package for Tagliatelle linting. ```yaml linters: settings: tagliatelle: case: rules: json: camel yaml: camel xml: camel overrides: - pkg: foo/bar ignore: true ``` -------------------------------- ### Go Struct with JSON Tags Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Example of a Go struct with JSON tags. Comments indicate the expected corrected tag values based on a linter's rules. ```go type Foo struct { ID string `json:"ID"` // must be "id" UserID string `json:"UserID"`// must be "userId" Name string `json:"name"` Value string `json:"val,omitempty"`// must be "value" } ``` -------------------------------- ### Configure Tagliatelle with Golangci-lint Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Define Tagliatelle rules in your golangci-lint configuration file. This example shows how to enable the linter and configure struct tag name casing rules, including extended rules and ignored fields. ```yaml linters: enable: - tagliatelle settings: tagliatelle: # Checks the struct tag name case. case: # Defines the association between tag name and case. # Any struct tag name can be used. # Supported string cases: # - `camel` # - `pascal` # - `kebab` # - `snake` # - `upperSnake` # - `goCamel` # - `goPascal` # - `goKebab` # - `goSnake` # - `upper` # - `lower` # - `header` rules: json: camel yaml: camel xml: camel toml: camel bson: camel avro: snake mapstructure: kebab env: upperSnake envconfig: upperSnake whatever: snake # Defines the association between tag name and case. # Important: the `extended-rules` overrides `rules`. # Default: empty extended-rules: json: # Supported string cases: # - `camel` # - `pascal` # - `kebab` # - `snake` # - `upperSnake` # - `goCamel` # - `goPascal` # - `goKebab` # - `goSnake` # - `header` # - `lower` # - `header` # # Required case: camel # Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms, # and removes 'LHS', 'RHS' from initialisms. # Default: false extra-initialisms: true # Defines initialism additions and overrides. # Default: empty initialism-overrides: DB: true # add a new initialism LHS: false # disable a default initialism. # ... # Uses the struct field name to check the name of the struct tag. # Default: false use-field-name: true # The field names to ignore. # Default: [] ignored-fields: - Bar - Foo # Overrides the default/root configuration. # Default: [] overrides: - # The package path (uses `/` only as a separator). # Required pkg: foo/bar # Default: empty or the same as the default/root configuration. rules: json: snake xml: pascal # Default: empty or the same as the default/root configuration. extended-rules: # same options as the base `extended-rules`. # Default: false (WARNING: it doesn't follow the default/root configuration) use-field-name: true # The field names to ignore. # Default: [] or the same as the default/root configuration. ignored-fields: - Bar - Foo # Ignore the package (takes precedence over all other configurations). # Default: false ignore: true ``` -------------------------------- ### Ignore Fields with Tagliatelle for a Specific Package Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Example of configuring Tagliatelle to ignore specific fields ('Bar', 'Foo') within the 'foo/bar' package. ```yaml linters: settings: tagliatelle: case: rules: json: camel yaml: camel xml: camel overrides: - pkg: foo/bar ignored-fields: - Bar - Foo ``` -------------------------------- ### Override Tagliatelle Case Rules for a Specific Package Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Example of overriding Tagliatelle's default case rules for JSON and XML tags within the 'foo/bar' package. ```yaml linters: settings: tagliatelle: case: rules: json: camel yaml: camel xml: camel overrides: - pkg: foo/bar rules: json: snake xml: pascal ``` -------------------------------- ### Configure Custom Tag Case Rules Source: https://github.com/ldez/tagliatelle/blob/main/readme.md Define custom case rules for struct tags like 'json', 'yaml', 'xml', 'toml', and 'whatever'. Supports various string cases and can use the struct field name for validation. ```yaml linters: settings: tagliatelle: # Check the struck tag name case. case: rules: # Any struct tag type can be used. # Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower` json: camel yaml: camel xml: camel toml: camel whatever: kebab # Use the struct field name to check the name of the struct tag. # Default: false use-field-name: true ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.