{"id":13411635,"url":"https://github.com/twharmon/slices","last_synced_at":"2026-01-31T18:16:33.083Z","repository":{"id":41165032,"uuid":"435571637","full_name":"twharmon/slices","owner":"twharmon","description":"Pure functions for slices.","archived":false,"fork":false,"pushed_at":"2022-07-08T18:32:20.000Z","size":46,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-22T17:09:48.196Z","etag":null,"topics":["generics","go","golang"],"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/twharmon.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":"2021-12-06T16:39:12.000Z","updated_at":"2025-06-20T04:00:14.000Z","dependencies_parsed_at":"2022-09-12T07:20:33.919Z","dependency_job_id":null,"html_url":"https://github.com/twharmon/slices","commit_stats":null,"previous_names":["twharmon/slice"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/twharmon/slices","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twharmon%2Fslices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twharmon%2Fslices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twharmon%2Fslices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twharmon%2Fslices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twharmon","download_url":"https://codeload.github.com/twharmon/slices/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twharmon%2Fslices/sbom","scorecard":{"id":903715,"data":{"date":"2025-08-11","repo":{"name":"github.com/twharmon/slices","commit":"051e49e40bf9db169667c22baef620b5da0e8d62"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/11 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":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/twharmon/slices/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/twharmon/slices/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/twharmon/slices/test.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction 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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml: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":"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: 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":-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":"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"}},{"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"}}]},"last_synced_at":"2025-08-24T16:36:25.786Z","repository_id":41165032,"created_at":"2025-08-24T16:36:25.786Z","updated_at":"2025-08-24T16:36:25.786Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28949280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"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":["generics","go","golang"],"created_at":"2024-07-30T20:01:15.237Z","updated_at":"2026-01-31T18:16:33.064Z","avatar_url":"https://github.com/twharmon.png","language":"Go","funding_links":[],"categories":["Data Structures and Algorithms","数据结构与算法","Data Integration Frameworks","Generators"],"sub_categories":["Miscellaneous Data Structures and Algorithms","杂项数据结构和算法"],"readme":"# Slices\nPure functions for slices. Slices are never operated on \"in place\". Instead, new ones are returned.\n\n![](https://github.com/twharmon/slices/workflows/Test/badge.svg) [![](https://goreportcard.com/badge/github.com/twharmon/slices)](https://goreportcard.com/report/github.com/twharmon/slices) [![codecov](https://codecov.io/gh/twharmon/slices/branch/main/graph/badge.svg?token=K0P59TPRAL)](https://codecov.io/gh/twharmon/slices)\n\n## Documentation\nFor full documentation see [pkg.go.dev](https://pkg.go.dev/github.com/twharmon/slices).\n\n## Install\n`go get github.com/twharmon/slices`\n\n## Usage\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/twharmon/slices\"\n)\n\nfunc main() {\n\t// use plain go slices\n\ts := []string{\"foo\", \"ba\"}\n\n\t// append new item to end of slice\n\ts = slices.Append(s, \"b\")\n\tfmt.Println(s) // [foo ba b]\n\t\n\t// sort by string length, ascending\n\tsorted := slices.SortFunc(s, func(a, b string) bool {\n\t\treturn len(a) \u003c len(b)\n\t})\n\t// original slice is not chaged\n\tfmt.Println(s, sorted) // [foo ba b] [b ba foo]\n\n\t// sum the lengths of all the strings    \n\ttotalLen := slices.Reduce(s, func(cnt int, i string) int {\n\t\treturn cnt + len(i)\n\t})\n\tfmt.Println(totalLen) // 6\n\n\t// find the first item with length 2\n\tstr := slices.Find(s, func(item string) bool { return len(item) == 2 })    \n\tfmt.Println(str) // ba\n\n\t// map slice to new slice of different type\n\tints := slices.Map(s, func(item string) int { return len(s) })    \n\tfmt.Println(ints) // [3 2 1]\n}\n```\n\n## Benchmarks\n```\ngoos: darwin\ngoarch: arm64\npkg: github.com/twharmon/slices\n\nBenchmarkSortFunc/std_lib-10         \t  116497\t      9424 ns/op\t    4152 B/op\t       3 allocs/op\nBenchmarkSortFunc/slices-10          \t  101791\t     11479 ns/op\t    4096 B/op\t       1 allocs/op\nBenchmarkSort/std_lib-10             \t  125790\t      9441 ns/op\t    4120 B/op\t       2 allocs/op\nBenchmarkSort/slices-10              \t  113931\t     10162 ns/op\t    4096 B/op\t       1 allocs/op\n\nBenchmarkReverse-10                  \t 1631348\t       749.4 ns/op\t    4096 B/op\t       1 allocs/op\nBenchmarkConcat-10                   \t  275463\t      4259 ns/op\t   40960 B/op\t       1 allocs/op\nBenchmarkFilter-10                   \t 1000000\t      1018 ns/op\t    4096 B/op\t       1 allocs/op\n\nBenchmarkUnion/2x20-10               \t 3258876\t       361.2 ns/op\t      32 B/op\t       1 allocs/op\nBenchmarkUnion/20x2-10               \t  502176\t      2329 ns/op\t    1592 B/op\t       3 allocs/op\nBenchmarkUnion/20x2000-10            \t    1140\t   1054108 ns/op\t    1590 B/op\t       3 allocs/op\nBenchmarkUnion/2000x20-10            \t     714\t   1697117 ns/op\t  142481 B/op\t      39 allocs/op\n\nBenchmarkIntersection/2x20-10        \t 2380771\t       498.0 ns/op\t      48 B/op\t       1 allocs/op\nBenchmarkIntersection/20x2-10        \t  821226\t      1427 ns/op\t    1196 B/op\t       3 allocs/op\nBenchmarkIntersection/20x2000-10     \t    1178\t   1020620 ns/op\t    1282 B/op\t       3 allocs/op\nBenchmarkIntersection/2000x20-10     \t     938\t   1276258 ns/op\t  203294 B/op\t      58 allocs/op\n```\n\n## Contribute\nMake a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwharmon%2Fslices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwharmon%2Fslices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwharmon%2Fslices/lists"}