{"id":13397009,"url":"https://github.com/orijtech/structslop","last_synced_at":"2026-02-09T02:36:06.926Z","repository":{"id":39374353,"uuid":"296542581","full_name":"orijtech/structslop","owner":"orijtech","description":"structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.","archived":false,"fork":false,"pushed_at":"2024-02-08T11:39:21.000Z","size":47,"stargazers_count":808,"open_issues_count":10,"forks_count":29,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-31T18:18:36.726Z","etag":null,"topics":["golang"],"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/orijtech.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":"2020-09-18T07:10:49.000Z","updated_at":"2024-07-31T14:05:19.000Z","dependencies_parsed_at":"2024-06-18T13:04:58.778Z","dependency_job_id":null,"html_url":"https://github.com/orijtech/structslop","commit_stats":{"total_commits":35,"total_committers":7,"mean_commits":5.0,"dds":0.2857142857142857,"last_synced_commit":"069644583b8bbf18946796db4ebd21c5ae8bbacb"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/orijtech/structslop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orijtech%2Fstructslop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orijtech%2Fstructslop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orijtech%2Fstructslop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orijtech%2Fstructslop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orijtech","download_url":"https://codeload.github.com/orijtech/structslop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orijtech%2Fstructslop/sbom","scorecard":{"id":712370,"data":{"date":"2025-08-11","repo":{"name":"github.com/orijtech/structslop","commit":"069644583b8bbf18946796db4ebd21c5ae8bbacb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":9,"reason":"Found 27/29 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yaml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yaml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yaml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yaml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yaml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yaml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yaml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/orijtech/structslop/go.yaml/master?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/go.yaml:40","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T08:31:19.129Z","repository_id":39374353,"created_at":"2025-08-22T08:31:19.129Z","updated_at":"2025-08-22T08:31:19.129Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29254316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T01:52:29.835Z","status":"online","status_checked_at":"2026-02-09T02:00:09.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["golang"],"created_at":"2024-07-30T18:01:09.236Z","updated_at":"2026-02-09T02:36:06.907Z","avatar_url":"https://github.com/orijtech.png","language":"Go","readme":"# structslop\n\n![Build status](https://github.com/orijtech/structslop/workflows/Go/badge.svg?branch=master)\n\nPackage structslop defines an [Analyzer](analyzer_link) that checks if struct fields can be re-arranged to optimize size.\n\n## Installation\n\nWith Go modules:\n\n```sh\ngo get github.com/orijtech/structslop/cmd/structslop\n```\n\nWithout Go modules:\n\n```sh\n$ cd $GOPATH/src/github.com/orijtech/structslop\n$ git checkout v0.0.6\n$ go get\n$ install ./cmd/structslop\n```\n\n## Usage\n\nYou can run `structslop` either on a Go package or Go files, the same way as\nother Go tools work.\n\nExample:\n\n```sh\n$ structslop github.com/orijtech/structslop/testdata/src/struct\n```\n\nor:\n\n```sh\n$ structslop ./testdata/src/struct/p.go\n```\n\nSample output:\n\n```text\n/go/src/github.com/orijtech/structslop/testdata/struct/p.go:30:9: struct has size 24 (size class 32), could be 16 (size class 16), you'll save 50.00% if you rearrange it to:\nstruct {\n\ty uint64\n\tx uint32\n\tz uint32\n}\n\n/go/src/github.com/orijtech/structslop/testdata/struct/p.go:36:9: struct has size 40 (size class 48), could be 24 (size class 32), you'll save 33.33% if you rearrange it to:\nstruct {\n\t_  [0]func()\n\ti1 int\n\ti2 int\n\ta3 [3]bool\n\tb  bool\n}\n\n/go/src/github.com/orijtech/structslop/testdata/struct/p.go:59:9: struct has size 40 (size class 48), could be 32 (size class 32), you'll save 33.33% if you rearrange it to:\nstruct {\n\ty uint64\n\tt *httptest.Server\n\tw uint64\n\tx uint32\n\tz uint32\n}\n\n/go/src/github.com/orijtech/structslop/testdata/struct/p.go:67:9: struct has size 40 (size class 48), could be 32 (size class 32), you'll save 33.33% if you rearrange it to:\nstruct {\n\ty uint64\n\tt *s\n\tw uint64\n\tx uint32\n\tz uint32\n}\n\n```\n\nExample, for the first report above, the output meaning:\n\n - The current struct size is `24`, the size that the Go runtime will allocate for that struct is `32`.\n - The optimal struct size is `16`, the size that the Go runtime will allocate for that struct is `16`.\n - The layout of optimal struct.\n - The percentage savings with new struct layout.\n \nThat said, some structs may have a smaller size, but for efficiency, the Go runtime will allocate them in the same size class,\nthen those structs are not considered sloppy:\n\n```go\ntype s1 struct {\n\tx uint32\n\ty uint64\n\tz *s\n\tt uint32\n}\n```\n\nand:\n\n```go\ntype s2 struct {\n\ty uint64\n\tz *s\n\tx uint32\n\tt uint32\n}\n```\n\nhave the same size class `32`, though `s2` layout is only `24` byte in size.\n\nHowever, you can still get this information when you want, using `-verbose` flag:\n\n```sh\n$ structslop -verbose ./testdata/src/verbose/p.go\n/go/src/github.com/orijtech/structslop/testdata/src/verbose/p.go:17:8: struct has size 0 (size class 0)\n/go/src/github.com/orijtech/structslop/testdata/src/verbose/p.go:19:9: struct has size 1 (size class 8)\n/go/src/github.com/orijtech/structslop/testdata/src/verbose/p.go:23:9: struct has size 32 (size class 32), could be 24 (size class 32), optimal fields order:\nstruct {\n\ty uint64\n\tz *s\n\tx uint32\n\tt uint32\n}\n```\n \n**Note**\n\nFor applying suggested fix, use `-apply` flag, instead of `-fix`.\n\n## Development\n\nGo 1.20+\n\n### Running test\n\nAdd test case to `testdata/src/struct` directory, then run:\n\n```shell script\ngo test\n```\n\n## Contributing\n\nTODO\n\n[analyzer_link]: https://pkg.go.dev/golang.org/x/tools/go/analysis#Analyzer\n","funding_links":[],"categories":["Go","Code formatters","Programming Languages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forijtech%2Fstructslop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forijtech%2Fstructslop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forijtech%2Fstructslop/lists"}