{"id":34175539,"url":"https://github.com/cbednarski/gosloc","last_synced_at":"2026-03-12T01:02:49.550Z","repository":{"id":143180065,"uuid":"189703834","full_name":"cbednarski/gosloc","owner":"cbednarski","description":"A \"lines of code\" counter for Golang","archived":false,"fork":false,"pushed_at":"2024-05-04T05:44:54.000Z","size":5,"stargazers_count":9,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-18T09:42:14.855Z","etag":null,"topics":["go","golang","source-code-metrics","static-analysis"],"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/cbednarski.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":"2019-06-01T07:28:39.000Z","updated_at":"2025-11-28T13:27:20.000Z","dependencies_parsed_at":"2023-06-19T07:12:18.285Z","dependency_job_id":null,"html_url":"https://github.com/cbednarski/gosloc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cbednarski/gosloc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbednarski%2Fgosloc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbednarski%2Fgosloc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbednarski%2Fgosloc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbednarski%2Fgosloc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbednarski","download_url":"https://codeload.github.com/cbednarski/gosloc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbednarski%2Fgosloc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30410358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T00:40:14.898Z","status":"ssl_error","status_checked_at":"2026-03-12T00:40:08.439Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","source-code-metrics","static-analysis"],"created_at":"2025-12-15T12:13:19.122Z","updated_at":"2026-03-12T01:02:49.543Z","avatar_url":"https://github.com/cbednarski.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gosloc\n\n`gosloc` is a \"lines of code\" counter for Golang. It produces output like this:\n\n```\n$ gosloc github.com/lib/pq/\nScanned 40 go files in github.com/lib/pq/:\n  Source lines:    5143 (75.2%)\n  Comment lines:   908 (13.3%)\n  Blank lines:     784 (11.5%)\n  Test lines:      5496 (1.07 per line of code)\n  Total file size: 0.32 Mb\n```\n\nThe tool is not meant to be 100% precise (see details below) but instead to\ngive you a general idea of how much code there is in a particular project, and\ncompare the size of the code to the size of the source code documentation and\ntest suite.\n\nThese attributes are useful to know when you are auditing a codebase, either for\nsecurity purposes or before deciding to use it. Most code bases tend to grow\nover time as features are added, but smaller code bases are usually easier to\nmaintain.\n\nFor example, we can compare three popular PostgreSQL libraries for Go using this\ntool:\n\n```\n$ gosloc github.com/go-pg/pg/\nScanned 144 go files in github.com/go-pg/pg/:\n  Source lines:    13170 (81.2%)\n  Comment lines:   568 (3.5%)\n  Blank lines:     2486 (15.3%)\n  Test lines:      8005 (0.61 per line of code)\n  Total file size: 0.54 Mb\n$ gosloc github.com/jackc/pgx/\nScanned 251 go files in github.com/jackc/pgx/:\n  Source lines:    22145 (79.4%)\n  Comment lines:   1356 (4.9%)\n  Blank lines:     4396 (15.8%)\n  Test lines:      16911 (0.76 per line of code)\n  Total file size: 1.12 Mb\n$ gosloc github.com/lib/pq/\nScanned 40 go files in github.com/lib/pq/:\n  Source lines:    5143 (75.2%)\n  Comment lines:   908 (13.3%)\n  Blank lines:     784 (11.5%)\n  Test lines:      5496 (1.07 per line of code)\n  Total file size: 0.32 Mb\n```\n\nFrom this we can see that `lib/pq` has the highest ratio of tests and comments,\nas well as the smallest overall code size, so (based on these entirely arbitrary\ncriteria) this might be a good place to start.\n\n## Caveats / Notes\n\n- Only `.go` files are included.\n\n- `vendor` folders are excluded by default. You can include them with `-vendor`.\n\n- `testdata` folders are excluded.\n\n- Files generated by `go-bindata` are skipped. The tool will tell you when this\n  happens.\n\n- Files with particularly long lines (like those generated by tools similar to\n  `go-bindata`) are also skipped. The tool will tell you when this happens.\n\n- Go allows inline comments after a statement. These are counted as code lines,\n  not comment lines.\n\n- Comments in the form of `/**/` are currently counted as code. This is a bug.\n\n- Comments and blank lines in test files (ending in `_test.go`) are not counted.\n\n- Vendoring tools often omit tests so this will skew the test ratio.\n\n- The percentage scores (source, comment, blank) are calculated for source files\n  only (tests are excluded).\n\n## Other Tools\n\nOther Go tools for static analysis.\n\n- [golint](https://github.com/golang/lint)\n- [gocyclo](https://github.com/fzipp/gocyclo)\n- [ineffassign](https://github.com/gordonklaus/ineffassign)\n- [deadcode](https://github.com/remyoudompheng/go-misc/tree/master/deadcode)\n- [gometalinter](https://github.com/alecthomas/gometalinter)\n- [gometalinter linter list](https://github.com/alecthomas/gometalinter#supported-linters)\n- [golangci-lint](https://github.com/golangci/golangci-lint)\n- [list of static analysis tools](https://github.com/mre/awesome-static-analysis#go)\n- [Article discussing some of these tools](https://remy.io/blog/simple-tools-to-improve-your-go-code/)\n\nThere are many other resources and this list is just here to get you started.\nThanks to Go's 1.0 compatibility promise, many static analysis tools continue to\nwork even if they are a bit out of date.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbednarski%2Fgosloc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbednarski%2Fgosloc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbednarski%2Fgosloc/lists"}