{"id":13764126,"url":"https://github.com/surullabs/lint","last_synced_at":"2026-01-11T22:58:17.921Z","repository":{"id":57483034,"uuid":"62943173","full_name":"surullabs/lint","owner":"surullabs","description":"Run linters from Go code - ","archived":false,"fork":false,"pushed_at":"2018-10-28T00:00:40.000Z","size":1327,"stargazers_count":67,"open_issues_count":2,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-16T23:32:37.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.timeferret.com/lint","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/surullabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-09T09:52:39.000Z","updated_at":"2024-06-05T11:43:35.000Z","dependencies_parsed_at":"2022-09-02T06:20:26.895Z","dependency_job_id":null,"html_url":"https://github.com/surullabs/lint","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surullabs%2Flint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surullabs%2Flint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surullabs%2Flint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surullabs%2Flint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surullabs","download_url":"https://codeload.github.com/surullabs/lint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253453361,"owners_count":21911083,"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":[],"created_at":"2024-08-03T15:01:14.816Z","updated_at":"2026-01-11T22:58:17.911Z","avatar_url":"https://github.com/surullabs.png","language":"Go","readme":"## Lint - run linters from Go\n\n[![Build Status](https://travis-ci.org/surullabs/lint.svg?branch=master)](https://travis-ci.org/surullabs/lint) [![GoDoc](https://godoc.org/github.com/surullabs/lint?status.svg)](https://godoc.org/github.com/surullabs/lint) [![Coverage Status](https://coveralls.io/repos/github/surullabs/lint/badge.svg?branch=master)](https://coveralls.io/github/surullabs/lint?branch=master)[![Go Report Card](https://goreportcard.com/badge/github.com/surullabs/lint)](https://goreportcard.com/report/github.com/surullabs/lint)\n\nLint makes it easy to run linters from Go code. This allows lint checks to be part of a regular `go build` + `go test` workflow. False positives are easily ignored and linters are automatically integrated into CI pipelines without any extra effort. Check the [project website](https://www.timeferret.com/lint) to learn more about how it can be useful.\n\n### Quick Start\n\nDownload using\n```\ngo get -t github.com/surullabs/lint\n```\nRun the default linters by adding a new test at the top level of your repository\n```\nfunc TestLint(t *testing.T) {\n    // Run default linters\n    err := lint.Default.Check(\"./...\")\n    \n    // Ignore lint errors from auto-generated files\n    err = lint.Skip(err, lint.RegexpMatch(`_string\\.go`, `\\.pb\\.go`))\n    \n    if err != nil {\n        t.Fatal(\"lint failures: %v\", err)\n    }\n}\n```\n\n### How it works\n\n`lint` runs linters using the excellent `os/exec` package. It searches all Go binary directories for the needed binaries and when they don't exist it downloads them using `go get`. Errors generated by running linters are split by newline and can be skipped as needed.\n\n### Default linters\n\n  - `gofmt` - [Run `gofmt -d` and report any differences as errors](https://golang.org/cmd/gofmt/)\n  - `govet` - [Run `go tool vet -shadow`](https://golang.org/cmd/vet/)\n  - `golint` - [https://github.com/golang/lint](https://github.com/golang/lint)\n  - `gosimple` - [Code simplification](https://github.com/dominikh/go-simple)\n  - `gostaticcheck` - [Verify function arguments](https://github.com/dominikh/go-staticcheck)\n  - `errcheck` - [Find ignored errors](https://github.com/kisielk/errcheck)\n  \n## Using `gometalinter`\n\n[Gometalinter](https://github.com/alecthomas/gometalinter) runs a number of linters concurrently. It also vendors each of these and uses the vendored versions automatically. A vendored version of `gometalinter` is included and can be used in the following manner. Please note that not all linters used by gometalinter have been tested.\n \n```\nimport (\n    \"testing\"\n    \"github.com/surullabs/lint/gometalinter\"\n)\n\nfunc TestLint(t *testing.T) {\n    // Run default linters\n    metalinter := gometalinter.Check{\n        Args: []string{\n            // Arguments to gometalinter. Do not include the package names here.\n        },\n    }\n    if err := metalinter.Check(\"./...\"); err != nil {\n        t.Fatal(\"lint failures: %v\", err)\n    }\n}\n\n```\n \n## Other available linters\n \n  - `varcheck` - [Detect unused variables and constants](https://github.com/opennota/check)\n  - `structcheck` - [Detect unused struct fields](https://github.com/opennota/check)\n  - `aligncheck` - [Detect suboptimal struct alignment](https://github.com/opennota/check)\n  - `dupl` - [Detect duplicated code](https://github.com/mibk/dupl)\n \n### Why `lint`?\n\nThere are a number of excellent linters available for Go and Lint makes it easy to run them from tests. While building our mobile calendar app [TimeFerret](https://www.timeferret.com), (which is built primarily in Go), including scripts that run linters as part of every repository grew tiresome very soon. Using `lint` to create tests that ran on each commit made the codebase much more stable, since any unneeded false positives were easily skipped. The main advantages of using `lint` over running tools manually is:\n\n  - Skip false positives explicitly in your tests - This makes it easy to run only needed checks.\n  - Enforce linter usage with no overhead - No special build scripts are needed to install linters on each developer machine as they are automatically downloaded.\n  - Simple CI integration - Since linters are run as part of tests, there are no extra steps needed to integrate them into your CI pipeline.\n\n### Adding a custom linter\n\nPlease check if you can use the [gometalinter](https://godoc.org/github.com/surullabs/lint/gometalinter) package first. If not, adding a new linter is made dead simple by the `github.com/surullabs/lint/checkers` package. The entire source for the `golint` integration is\n\n```\nimport \"github.com/surullabs/lint/checkers\"\n\ntype Check struct {\n}\n\nfunc (Check) Check(pkgs ...string) error {\n    return checkers.Lint(\"golint\", \"\", github.com/golang/lint/golint\", pkgs)\n}\n```\n\nThe `github.com/surullabs/lint/testutil` package contains utilities for testing custom linters.\n\nYou can also take a look at [this CL](https://github.com/surullabs/lint/commit/5e6be15e3b9964e8465655abb9759defd1c46af9) which adds `varcheck` for an example of how to add a linter.\n\nIf you'd like to vendor the linter source, please use the same method as the `gometalinter` package.\n\n### License\n\nLint is available under the Apache License. See the LICENSE file for details.\n\n### Contributing\n\nPull requests are always welcome! Please ensure any changes you send have an accompanying test case.\n","funding_links":[],"categories":["Code Analysis","代碼分析","Linters Helper Tools","代码分析","相关工具","Libraries for creating HTTP middlewares","相关工具`go相关工具和插件`"],"sub_categories":["Routers","路由","Misc","路由器","代码分析"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurullabs%2Flint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurullabs%2Flint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurullabs%2Flint/lists"}