{"id":37840912,"url":"https://github.com/crosscode-nl/partition","last_synced_at":"2026-01-16T16:00:02.327Z","repository":{"id":57481372,"uuid":"174178064","full_name":"crosscode-nl/partition","owner":"crosscode-nl","description":"GO package for partitioning slices, arrays and strings. ","archived":false,"fork":false,"pushed_at":"2020-10-04T17:09:05.000Z","size":16,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-14T09:32:00.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/crosscode-nl.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":"2019-03-06T16:12:37.000Z","updated_at":"2023-11-30T04:19:14.000Z","dependencies_parsed_at":"2022-09-26T17:50:29.687Z","dependency_job_id":null,"html_url":"https://github.com/crosscode-nl/partition","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/crosscode-nl/partition","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crosscode-nl%2Fpartition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crosscode-nl%2Fpartition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crosscode-nl%2Fpartition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crosscode-nl%2Fpartition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crosscode-nl","download_url":"https://codeload.github.com/crosscode-nl/partition/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crosscode-nl%2Fpartition/sbom","scorecard":{"id":309529,"data":{"date":"2025-08-11","repo":{"name":"github.com/crosscode-nl/partition","commit":"eed6b01e51b630d79bdaed1c767432685d235894"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/16 approved changesets -- score normalized to 0","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"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":"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: MIT License: 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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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"}}]},"last_synced_at":"2025-08-17T22:54:15.326Z","repository_id":57481372,"created_at":"2025-08-17T22:54:15.326Z","updated_at":"2025-08-17T22:54:15.326Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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":[],"created_at":"2026-01-16T16:00:01.582Z","updated_at":"2026-01-16T16:00:02.316Z","avatar_url":"https://github.com/crosscode-nl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# partition [![Go Report Card](https://goreportcard.com/badge/github.com/crosscode-nl/partition)](https://goreportcard.com/report/github.com/crosscode-nl/partition)\nGO/golang package for partitioning slices, arrays and strings. \n\n## Introduction\n\nI needed a solution for partitioning a slice. I searched for an existing package, and found the following StackOverflow question: https://stackoverflow.com/questions/30242567/in-go-how-can-i-partition-a-slice-array-string-of-any-type\n\nThis pointed to a package which only has an implementation that uses chans. That has too much overhead to my liking so I wrote this package, but added more flexibility in how to use this package, each with its own performance or memory usage characteristics. \n\nThis package is fully unit tested and documented.\n\n### Usage\n\nDownload the package with the following command:\n\n~~~console\ngo get github.com/crosscode-nl/partition\n~~~\n\nUse the following import in your code to use the package.\n\n~~~go\nimport \"github.com/crosscode-nl/partition\"\n~~~\n\n## Performance\n\nThe following benchmarks show that the partition.ToFunc function is the fastest to use. \n~~~\nBenchmarkToChan100-4      \t   50000\t     25862 ns/op\nBenchmarkToChan10-4       \t  300000\t      4939 ns/op\nBenchmarkToChan0-4        \t  500000\t      2727 ns/op\nBenchmarkToFunc100-4      \t 5000000\t       230 ns/op\nBenchmarkToFunc10-4       \t30000000\t        46.5 ns/op\nBenchmarkToFunc0-4        \t100000000\t        14.6 ns/op\nBenchmarkToHandler100-4   \t  500000\t      3877 ns/op\nBenchmarkToHandler10-4    \t 1000000\t      1233 ns/op\nBenchmarkToHandler0-4     \t 3000000\t       478 ns/op\nBenchmarkToIndices10-4    \t 2000000\t       739 ns/op\nBenchmarkToIndices100-4   \t  500000\t      3241 ns/op\nBenchmarkToIndices0-4     \t50000000\t        26.5 ns/op\n~~~\n\n## Examples\n\n### partition.ToFunc\n\nThis func takes a func that receives all partitions one by one.\n\n~~~go\n\ta := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}\n\tpartition.ToFunc(len(a), 5, func(l int, h int) {\n\t\tfmt.Printf(\"Part: %v\\n\", a[l:h])\n\t})\n\t// Output:\n\t// Part: [1 2 3 4 5]\n\t// Part: [6 7 8 9]\n~~~\n\n### partition.ToChan\n\nThis func returns a chan that receives all partitions one by one.\n\n~~~go\n\ta := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}\n\tfor part := range partition.ToChan(len(a), 5) {\n\t\tfmt.Printf(\"Part: %v\\n\", a[part.Low:part.High])\n\t}\n\t// Output:\n\t// Part: [1 2 3 4 5]\n\t// Part: [6 7 8 9]\n~~~\n\n### partition.ToHandler\n\nThis func takes an implementation of the partition.Handler interface.  \n\n~~~go\n// Handler interface defines an interface for a partition handler that Partition accepts.\ntype Handler interface {\n\tHandle(lowIndex int, highIndex int)\n}\n~~~ \n\nThe example contains an implementation used by the unit tests partition.SliceHandler\n\n~~~go\n\ta := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}\n\ts := partition.SliceHandler{}\n\tpartition.ToHandler(len(a), 5, \u0026s)\n\tfor _, part := range s.Parts {\n\t\tfmt.Printf(\"Part: %v\\n\", a[part.Low:part.High])\n\t}\n\t// Output:\n\t// Part: [1 2 3 4 5]\n\t// Part: [6 7 8 9]\n~~~\n\n### partition.ToIndices\n\nThis func returns a slice with all partitions.\n\n~~~go\n\ta := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}\n\tfor _, part := range partition.ToIndices(len(a), 5) {\n\t\tfmt.Printf(\"Part: %v\\n\", a[part.Low:part.High])\n\t}\n\t// Output:\n\t// Part: [1 2 3 4 5]\n\t// Part: [6 7 8 9]\n~~~\n\n## License\n\nMIT License\n\nCopyright (c) 2019 CrossCode / P. Vollebregt\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrosscode-nl%2Fpartition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrosscode-nl%2Fpartition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrosscode-nl%2Fpartition/lists"}