{"id":13786725,"url":"https://github.com/sashamelentyev/usestdlibvars","last_synced_at":"2025-05-11T22:33:17.779Z","repository":{"id":49382601,"uuid":"517569545","full_name":"sashamelentyev/usestdlibvars","owner":"sashamelentyev","description":"A linter that detect the possibility to use variables/constants from the Go standard library.","archived":false,"fork":false,"pushed_at":"2024-06-12T04:43:06.000Z","size":224,"stargazers_count":43,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-03T19:10:02.377Z","etag":null,"topics":["go","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sashamelentyev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-25T07:52:58.000Z","updated_at":"2024-06-28T18:09:30.000Z","dependencies_parsed_at":"2024-01-08T16:09:07.263Z","dependency_job_id":"675d3c36-e708-4050-b6bc-02c8af7c345a","html_url":"https://github.com/sashamelentyev/usestdlibvars","commit_stats":null,"previous_names":["sashamelentyev/reusestdlibvars"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashamelentyev%2Fusestdlibvars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashamelentyev%2Fusestdlibvars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashamelentyev%2Fusestdlibvars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashamelentyev%2Fusestdlibvars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sashamelentyev","download_url":"https://codeload.github.com/sashamelentyev/usestdlibvars/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225105768,"owners_count":17421791,"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"],"created_at":"2024-08-03T19:01:31.253Z","updated_at":"2024-11-17T23:30:20.757Z","avatar_url":"https://github.com/sashamelentyev.png","language":"Go","funding_links":[],"categories":["Code Analysis","代码分析"],"sub_categories":["Routers","路由器"],"readme":"\u003cimg align=\"right\" alt=\"usestdlibvars\" src=\"./assets/uslv_logo.svg\"\u003e\n\n# usestdlibvars\n\nA linter that detect the possibility to use variables/constants from the Go standard library.\n\n## Install\n\n### `go install`\n\n```bash\ngo install github.com/sashamelentyev/usestdlibvars@latest\n```\n\n### `golangci-lint`\n\n`usestdlibvars` is already integrated with\n[golangci-lint](https://github.com/golangci/golangci-lint).\n\n## Usage\n\n### Binary\n\n```console\n$ usestdlibvars -h\nusestdlibvars: A linter that detect the possibility to use variables/constants from the Go standard library.\n\nUsage: usestdlibvars [-flag] [package]\n\n\nFlags:\n  -V    print version and exit\n  -all\n        no effect (deprecated)\n  -c int\n        display offending line with this many lines of context (default -1)\n  -constant-kind\n        suggest the use of constant.Kind.String()\n  -cpuprofile string\n        write CPU profile to this file\n  -crypto-hash\n        suggest the use of crypto.Hash.String()\n  -debug string\n        debug flags, any subset of \"fpstv\"\n  -fix\n        apply all suggested fixes\n  -flags\n        print analyzer flags in JSON\n  -http-method\n        suggest the use of http.MethodXX (default true)\n  -http-status-code\n        suggest the use of http.StatusXX (default true)\n  -json\n        emit JSON output\n  -memprofile string\n        write memory profile to this file\n  -os-dev-null\n        suggest the use of os.DevNull\n  -rpc-default-path\n        suggest the use of rpc.DefaultXXPath\n  -source\n        no effect (deprecated)\n  -sql-isolation-level\n        suggest the use of sql.LevelXX.String()\n  -tags string\n        no effect (deprecated)\n  -test\n        indicates whether test files should be analyzed, too (default true)\n  -time-layout\n        suggest the use of time.Layout\n  -time-month\n        suggest the use of time.Month.String()\n  -time-weekday\n        suggest the use of time.Weekday.String()\n  -tls-signature-scheme\n        suggest the use of tls.SignatureScheme.String()\n  -trace string\n        write trace log to this file\n  -v    no effect (deprecated)\n```\n\n### `golangci-lint`\n\n```console\ngolangci-lint run --disable-all --enable usestdlibvars\n```\n\n## Examples\n\n```go\npackage response\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"net/http\"\n)\n\n// JSON marshals v to JSON, automatically escaping HTML,\n// setting the Content-Type header as \"application/json; charset=utf-8\",\n// sends an HTTP response header with the provided statusCode and\n// writes the marshaled v as bytes to the connection as part of an HTTP reply.\nfunc JSON(w http.ResponseWriter, statusCode int, v any) {\n\tvar buf bytes.Buffer\n\tenc := json.NewEncoder(\u0026buf)\n\tenc.SetEscapeHTML(true)\n\tif err := enc.Encode(v); err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.WriteHeader(statusCode)\n\tif _, err := w.Write(buf.Bytes()); err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n}\n```\n\n```bash\nusestdlibvars ./...\n```\n\n```console\nresponse.go:18:30: \"500\" can be replaced by http.StatusInternalServerError\nresponse.go:24:30: \"500\" can be replaced by http.StatusInternalServerError\n```\n\n## Sponsors\n\n[\u003cimg src=\"https://evrone.com/logo/evrone-sponsored-logo.png\"\u003e](https://evrone.com/?utm_source=usestdlibvars)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashamelentyev%2Fusestdlibvars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsashamelentyev%2Fusestdlibvars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashamelentyev%2Fusestdlibvars/lists"}