{"id":13563977,"url":"https://github.com/ldez/tagliatelle","last_synced_at":"2025-05-15T18:05:53.664Z","repository":{"id":40227929,"uuid":"356970004","full_name":"ldez/tagliatelle","owner":"ldez","description":"A linter that handles struct tags.","archived":false,"fork":false,"pushed_at":"2025-03-25T03:24:51.000Z","size":65,"stargazers_count":52,"open_issues_count":3,"forks_count":9,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-08T01:34:31.648Z","etag":null,"topics":["go","golang","linter","struct-tag"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ldez.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"ldez","ko_fi":"ldez_oss","liberapay":"ldez","thanks_dev":"u/gh/ldez"}},"created_at":"2021-04-11T20:16:08.000Z","updated_at":"2025-03-25T03:24:55.000Z","dependencies_parsed_at":"2025-02-22T18:11:11.403Z","dependency_job_id":"a567ea99-da2c-45bb-b2a8-7b12fa37fef1","html_url":"https://github.com/ldez/tagliatelle","commit_stats":{"total_commits":29,"total_committers":7,"mean_commits":4.142857142857143,"dds":0.2068965517241379,"last_synced_commit":"5c0ee2f9edfe2beac7e8be2a43455eb5480fb0a1"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Ftagliatelle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Ftagliatelle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Ftagliatelle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Ftagliatelle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldez","download_url":"https://codeload.github.com/ldez/tagliatelle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394719,"owners_count":22063984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","linter","struct-tag"],"created_at":"2024-08-01T13:01:25.183Z","updated_at":"2025-05-15T18:05:53.612Z","avatar_url":"https://github.com/ldez.png","language":"Go","funding_links":["https://github.com/sponsors/ldez","https://ko-fi.com/ldez_oss","https://liberapay.com/ldez","https://thanks.dev/u/gh/ldez"],"categories":["Go"],"sub_categories":[],"readme":"# Tagliatelle\n\n[![Sponsor](https://img.shields.io/badge/Sponsor%20me-%E2%9D%A4%EF%B8%8F-pink)](https://github.com/sponsors/ldez)\n[![Build Status](https://github.com/ldez/tagliatelle/workflows/Main/badge.svg?branch=master)](https://github.com/ldez/tagliatelle/actions)\n\nA linter that handles struct tags.\n\nSupported string casing:\n\n- `camel`\n- `pascal`\n- `kebab`\n- `snake`\n- `upperSnake`\n- `goCamel` Respects [Go's common initialisms](https://github.com/golang/lint/blob/83fdc39ff7b56453e3793356bcff3070b9b96445/lint.go#L770-L809) (e.g. HttpResponse -\u003e HTTPResponse).\n- `goPascal` Respects [Go's common initialisms](https://github.com/golang/lint/blob/83fdc39ff7b56453e3793356bcff3070b9b96445/lint.go#L770-L809) (e.g. HttpResponse -\u003e HTTPResponse).\n- `goKebab` Respects [Go's common initialisms](https://github.com/golang/lint/blob/83fdc39ff7b56453e3793356bcff3070b9b96445/lint.go#L770-L809) (e.g. HttpResponse -\u003e HTTPResponse).\n- `goSnake` Respects [Go's common initialisms](https://github.com/golang/lint/blob/83fdc39ff7b56453e3793356bcff3070b9b96445/lint.go#L770-L809) (e.g. HttpResponse -\u003e HTTPResponse).\n- `header`\n- `upper`\n- `lower`\n\n| Source         | Camel Case     | Go Camel Case  |\n|----------------|----------------|----------------|\n| GooID          | gooId          | gooID          |\n| HTTPStatusCode | httpStatusCode | httpStatusCode |\n| FooBAR         | fooBar         | fooBar         |\n| URL            | url            | url            |\n| ID             | id             | id             |\n| hostIP         | hostIp         | hostIP         |\n| JSON           | json           | json           |\n| JSONName       | jsonName       | jsonName       |\n| NameJSON       | nameJson       | nameJSON       |\n| UneTête        | uneTête        | uneTête        |\n\n| Source         | Pascal Case    | Go Pascal Case |\n|----------------|----------------|----------------|\n| GooID          | GooId          | GooID          |\n| HTTPStatusCode | HttpStatusCode | HTTPStatusCode |\n| FooBAR         | FooBar         | FooBar         |\n| URL            | Url            | URL            |\n| ID             | Id             | ID             |\n| hostIP         | HostIp         | HostIP         |\n| JSON           | Json           | JSON           |\n| JSONName       | JsonName       | JSONName       |\n| NameJSON       | NameJson       | NameJSON       |\n| UneTête        | UneTête        | UneTête        |\n\n| Source         | Snake Case       | Upper Snake Case | Go Snake Case    |\n|----------------|------------------|------------------|------------------|\n| GooID          | goo_id           | GOO_ID           | goo_ID           |\n| HTTPStatusCode | http_status_code | HTTP_STATUS_CODE | HTTP_status_code |\n| FooBAR         | foo_bar          | FOO_BAR          | foo_bar          |\n| URL            | url              | URL              | URL              |\n| ID             | id               | ID               | ID               |\n| hostIP         | host_ip          | HOST_IP          | host_IP          |\n| JSON           | json             | JSON             | JSON             |\n| JSONName       | json_name        | JSON_NAME        | JSON_name        |\n| NameJSON       | name_json        | NAME_JSON        | name_JSON        |\n| UneTête        | une_tête         | UNE_TÊTE         | une_tête         |\n\n| Source         | Kebab Case       | Go KebabCase     |\n|----------------|------------------|------------------|\n| GooID          | goo-id           | goo-ID           |\n| HTTPStatusCode | http-status-code | HTTP-status-code |\n| FooBAR         | foo-bar          | foo-bar          |\n| URL            | url              | URL              |\n| ID             | id               | ID               |\n| hostIP         | host-ip          | host-IP          |\n| JSON           | json             | JSON             |\n| JSONName       | json-name        | JSON-name        |\n| NameJSON       | name-json        | name-JSON        |\n| UneTête        | une-tête         | une-tête         |\n\n| Source         | Header Case      |\n|----------------|------------------|\n| GooID          | Goo-Id           |\n| HTTPStatusCode | Http-Status-Code |\n| FooBAR         | Foo-Bar          |\n| URL            | Url              |\n| ID             | Id               |\n| hostIP         | Host-Ip          |\n| JSON           | Json             |\n| JSONName       | Json-Name        |\n| NameJSON       | Name-Json        |\n| UneTête        | Une-Tête         |\n\n## Examples\n\n```go\n// json and camel case\ntype Foo struct {\n    ID     string `json:\"ID\"` // must be \"id\"\n    UserID string `json:\"UserID\"`// must be \"userId\"\n    Name   string `json:\"name\"`\n    Value  string `json:\"val,omitempty\"`// must be \"value\"\n}\n```\n\n## What this linter is about\n\nThis linter is about validating tags according to the rules you define.\nThe linter also allows you to fix tags according to the rules you defined.\n\nThis linter is not intended to validate the fact a tag is valid or not.\n\n## How to use the linter\n\n### As a golangci-lint linter\n\nDefine the rules, you want via your [golangci-lint](https://golangci-lint.run) configuration file:\n\n```yaml\nlinters:\n  enable:\n    - tagliatelle\n\n  settings:\n    tagliatelle:\n      # Checks the struct tag name case.\n      case:\n        # Defines the association between tag name and case.\n        # Any struct tag name can be used.\n        # Supported string cases:\n        # - `camel`\n        # - `pascal`\n        # - `kebab`\n        # - `snake`\n        # - `upperSnake`\n        # - `goCamel`\n        # - `goPascal`\n        # - `goKebab`\n        # - `goSnake`\n        # - `upper`\n        # - `lower`\n        # - `header`\n        rules:\n          json: camel\n          yaml: camel\n          xml: camel\n          toml: camel\n          bson: camel\n          avro: snake\n          mapstructure: kebab\n          env: upperSnake\n          envconfig: upperSnake\n          whatever: snake\n        # Defines the association between tag name and case.\n        # Important: the `extended-rules` overrides `rules`.\n        # Default: empty\n        extended-rules:\n          json:\n            # Supported string cases:\n            # - `camel`\n            # - `pascal`\n            # - `kebab`\n            # - `snake`\n            # - `upperSnake`\n            # - `goCamel`\n            # - `goPascal`\n            # - `goKebab`\n            # - `goSnake`\n            # - `header`\n            # - `lower`\n            # - `header`\n            #\n            # Required\n            case: camel\n            # Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms,\n            # and removes 'LHS', 'RHS' from initialisms.\n            # Default: false\n            extra-initialisms: true\n            # Defines initialism additions and overrides.\n            # Default: empty\n            initialism-overrides:\n              DB: true # add a new initialism\n              LHS: false # disable a default initialism.\n              # ...\n        # Uses the struct field name to check the name of the struct tag.\n        # Default: false\n        use-field-name: true\n        # The field names to ignore.\n        # Default: []\n        ignored-fields:\n          - Bar\n          - Foo\n        # Overrides the default/root configuration.\n        # Default: []\n        overrides:\n          -\n            # The package path (uses `/` only as a separator).\n            # Required\n            pkg: foo/bar\n            # Default: empty or the same as the default/root configuration.\n            rules:\n              json: snake\n              xml: pascal\n            # Default: empty or the same as the default/root configuration.\n            extended-rules:\n              # same options as the base `extended-rules`.\n            # Default: false (WARNING: it doesn't follow the default/root configuration)\n            use-field-name: true\n            # The field names to ignore.\n            # Default: [] or the same as the default/root configuration.\n            ignored-fields:\n              - Bar\n              - Foo\n            # Ignore the package (takes precedence over all other configurations).\n            # Default: false\n            ignore: true\n```\n\n#### Examples\n\nOverrides case rules for the package `foo/bar`:\n\n```yaml\nlinters:\n  settings:\n    tagliatelle:\n      case:\n        rules:\n          json: camel\n          yaml: camel\n          xml: camel\n        overrides:\n          - pkg: foo/bar\n            rules:\n              json: snake\n              xml: pascal\n```\n\nIgnore fields inside the package `foo/bar`:\n\n```yaml\nlinters:\n  settings:\n    tagliatelle:\n      case:\n        rules:\n          json: camel\n          yaml: camel\n          xml: camel\n        overrides:\n          - pkg: foo/bar\n            ignored-fields:\n              - Bar\n              - Foo\n```\n\nIgnore the package `foo/bar`:\n\n```yaml\nlinters:\n  settings:\n    tagliatelle:\n      case:\n        rules:\n          json: camel\n          yaml: camel\n          xml: camel\n        overrides:\n          - pkg: foo/bar\n            ignore: true\n```\n\nMore information here https://golangci-lint.run/usage/linters/#tagliatelle\n\n### Install and run it from the binary\n\nNot recommended.\n\n```shell\ngo install github.com/ldez/tagliatelle/cmd/tagliatelle@latest\n```\n\nthen launch it manually.\n\n## Rules\n\nHere are the default rules for the well-known and used tags, when using tagliatelle as a binary or [golangci-lint linter](https://golangci-lint.run/usage/linters/#tagliatelle):\n\n- `json`: `camel`\n- `yaml`: `camel`\n- `xml`: `camel`\n- `bson`: `camel`\n- `avro`: `snake`\n- `header`: `header`\n- `env`: `upperSnake`\n- `envconfig`: `upperSnake`\n\n### Custom Rules\n\nThe linter is not limited to the tags used in example, **you can use it to validate any tag**.\n\nYou can add your own tag, for example `whatever` and tells the linter you want to use `kebab`.\n\nThis option is only available via [golangci-lint](https://golangci-lint.run).\n\n```yaml\nlinters:\n  settings:\n    tagliatelle:\n      # Check the struck tag name case.\n      case:\n        rules:\n          # Any struct tag type can be used.\n          # Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`\n          json: camel\n          yaml: camel\n          xml: camel\n          toml: camel\n          whatever: kebab\n        # Use the struct field name to check the name of the struct tag.\n        # Default: false\n        use-field-name: true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldez%2Ftagliatelle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldez%2Ftagliatelle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldez%2Ftagliatelle/lists"}