{"id":15694239,"url":"https://github.com/ldez/gomoddirectives","last_synced_at":"2025-04-06T22:09:50.384Z","repository":{"id":48692218,"uuid":"344962342","full_name":"ldez/gomoddirectives","owner":"ldez","description":"A linter that handle directives into `go.mod`.","archived":false,"fork":false,"pushed_at":"2025-03-25T03:17:26.000Z","size":49,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-30T21:07:52.990Z","etag":null,"topics":["go","go-modules","golang","linter"],"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-03-05T23:44:57.000Z","updated_at":"2025-03-29T01:39:50.000Z","dependencies_parsed_at":"2024-03-25T15:16:51.331Z","dependency_job_id":"c1c5d363-f3da-4504-a75c-95c063ceb95d","html_url":"https://github.com/ldez/gomoddirectives","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.025000000000000022","last_synced_commit":"5df57c24bd3201efce589a12b2c50169b94795ae"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fgomoddirectives","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fgomoddirectives/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fgomoddirectives/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fgomoddirectives/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldez","download_url":"https://codeload.github.com/ldez/gomoddirectives/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"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","go-modules","golang","linter"],"created_at":"2024-10-03T18:54:57.359Z","updated_at":"2025-04-06T22:09:50.360Z","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":[],"sub_categories":[],"readme":"# gomoddirectives\n\nA linter that handle directives into `go.mod`.\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/gomoddirectives/workflows/Main/badge.svg?branch=master)](https://github.com/ldez/gomoddirectives/actions)\n\n## Usage\n\n### Inside golangci-lint\n\nRecommended.\n\n```yml\nlinters:\n  enable:\n    - gomoddirectives\n\nlinters-settings:\n  gomoddirectives:\n    # Allow local `replace` directives.\n    # Default: false\n    replace-local: true\n    \n    # List of allowed `replace` directives.\n    # Default: []\n    replace-allow-list:\n      - launchpad.net/gocheck\n    # Allow to not explain why the version has been retracted in the `retract` directives.\n    # Default: false\n    retract-allow-no-explanation: true\n    \n    # Forbid the use of the `exclude` directives.\n    # Default: false\n    exclude-forbidden: true\n\n    # Forbid the use of the `toolchain` directive.\n    # Default: false\n    toolchain-forbidden: true\n\n    # Defines a pattern to validate `toolchain` directive.\n    # Default: '' (no match)\n    toolchain-pattern: 'go1\\.22\\.\\d+$'\n\n    # Forbid the use of the `tool` directives.\n    # Default: false\n    tool-forbidden: true\n\n    # Forbid the use of the `godebug` directive.\n    # Default: false\n    go-debug-forbidden: true\n\n    # Defines a pattern to validate `go` minimum version directive.\n    # Default: '' (no match)\n    go-version-pattern: '1\\.\\d+(\\.0)?$'\n```\n\n### As a CLI\n\n```\ngomoddirectives [flags]\n\nFlags:\n  -exclude\n        Forbid the use of exclude directives\n  -godebug\n        Forbid the use of godebug directives\n  -goversion string\n        Pattern to validate go min version directive\n  -h    Show this help.\n  -list value\n        List of allowed replace directives\n  -local\n        Allow local replace directives\n  -retract-no-explanation\n        Allow to use retract directives without explanation\n  -tool\n        Forbid the use of tool directives\n  -toolchain\n        Forbid the use of toolchain directive\n  -toolchain-pattern string\n        Pattern to validate toolchain directive\n```\n\n## Details\n\n### [`retract`](https://golang.org/ref/mod#go-mod-file-retract) directives\n\n- Force explanation for `retract` directives.\n\n```go\nmodule example.com/foo\n\ngo 1.22\n\nrequire (\n\tgithub.com/ldez/grignotin v0.4.1\n)\n\nretract (\n    v1.0.0 // Explanation\n)\n```\n\n### [`replace`](https://golang.org/ref/mod#go-mod-file-replace) directives\n\n- Ban all `replace` directives.\n- Allow only local `replace` directives.\n- Allow only some `replace` directives.\n- Detect duplicated `replace` directives.\n- Detect identical `replace` directives.\n\n```go\nmodule example.com/foo\n\ngo 1.22\n\nrequire (\n\tgithub.com/ldez/grignotin v0.4.1\n)\n\nreplace github.com/ldez/grignotin =\u003e ../grignotin/\n```\n\n### [`exclude`](https://golang.org/ref/mod#go-mod-file-exclude) directives\n\n- Ban all `exclude` directives.\n\n```go\nmodule example.com/foo\n\ngo 1.22\n\nrequire (\n\tgithub.com/ldez/grignotin v0.4.1\n)\n\nexclude (\n    golang.org/x/crypto v1.4.5\n    golang.org/x/text v1.6.7\n)\n```\n\n### [`tool`](https://golang.org/ref/mod#go-mod-file-tool) directives\n\n- Ban all `tool` directives.\n\n```go\nmodule example.com/foo\n\ngo 1.24\n\ntool (\n    example.com/module/cmd/a\n    example.com/module/cmd/b\n)\n```\n\n### [`toolchain`](https://golang.org/ref/mod#go-mod-file-toolchain) directive\n\n- Ban `toolchain` directive.\n- Use a regular expression to constraint the Go minimum version.\n\n```go\nmodule example.com/foo\n\ngo 1.22\n\ntoolchain go1.23.3\n```\n\n### [`godebug`](https://go.dev/ref/mod#go-mod-file-godebug) directives\n\n- Ban `godebug` directive.\n\n```go\nmodule example.com/foo\n\ngo 1.22\n\ngodebug default=go1.21\ngodebug (\n    panicnil=1\n    asynctimerchan=0\n)\n```\n\n### [`go`](https://go.dev/ref/mod#go-mod-file-go) directive\n\n- Use a regular expression to constraint the Go minimum version.\n\n```go\nmodule example.com/foo\n\ngo 1.22.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldez%2Fgomoddirectives","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldez%2Fgomoddirectives","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldez%2Fgomoddirectives/lists"}