{"id":16440819,"url":"https://github.com/idevelopthings/collection","last_synced_at":"2026-07-02T17:04:03.333Z","repository":{"id":170179102,"uuid":"646298521","full_name":"iDevelopThings/collection","owner":"iDevelopThings","description":"Laravel-like collection for go","archived":false,"fork":false,"pushed_at":"2023-05-27T23:53:52.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-16T13:56:50.804Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iDevelopThings.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-05-27T23:42:03.000Z","updated_at":"2023-05-27T23:42:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c977cd2-e9d9-40bb-a6b1-4ddef139ed2f","html_url":"https://github.com/iDevelopThings/collection","commit_stats":null,"previous_names":["idevelopthings/collection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iDevelopThings/collection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDevelopThings%2Fcollection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDevelopThings%2Fcollection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDevelopThings%2Fcollection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDevelopThings%2Fcollection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iDevelopThings","download_url":"https://codeload.github.com/iDevelopThings/collection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDevelopThings%2Fcollection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35055546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"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":[],"created_at":"2024-10-11T09:13:08.323Z","updated_at":"2026-07-02T17:04:03.328Z","avatar_url":"https://github.com/iDevelopThings.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Collection\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/idevelopthings/collection)](https://goreportcard.com/report/github.com/idevelopthings/collection)\n\n`Collection` is a package for handling collections in Go. It provides a set of utilities for creating and manipulating collections of structs in an intuitive way.\n\n## Installation\n\nUse `go get` to install the package.\n\n```sh\ngo get github.com/idevelopthings/collection\n```\n\n## Usage\n\nFirst, import the package into your project:\n\n```go\nimport \"github.com/idevelopthings/collection\"\n```\n\nNext, you'll need to define the type of your item:\n\n```go\ntype MyItem struct {\n    Name string\n}\n```\n\nCreate a new collection of your type:\n\n```go\nitems := collection.New[*MyItem]()\n// Or pass items:\nitems := collection.New[*MyItem](\n\t\u0026MyItem{Name: \"one\"},\n\t\u0026MyItem{Name: \"two\"},\n)\n```\n\nNow you can manipulate the collection with the methods provided by the package:\n\n### Add\n\nAdd an item to the collection:\n\n```go\nitems.Add(\u0026MyItem{Name:\"Three\"}) // returns *collections.Collection[*MyItem]\n```\n\n### Remove\n\nRemove an item from the collection:\n\n```go\nitems.Remove(item MyItem) // returns *collections.Collection[*MyItem]\n```\n\n### Contains\n\nCheck if the collection contains a certain item:\n\n```go\nitems.Contains(item MyItem) // returns bool\n```\n\n### Items\n\nRetrieve all items in the collection:\n\n```go\nitems.Items() // returns []*MyItem\n```\n\n### Len\n\nGet the number of items in the collection:\n\n```go\nitems.Len() // returns int\n```\n\n### IsEmpty\n\nCheck if the collection is empty:\n\n```go\nitems.IsEmpty() // returns bool\n```\n\n### IsNotEmpty\n\nCheck if the collection is not empty:\n\n```go\nitems.IsNotEmpty() // returns bool\n```\n\n### First\n\nGet the first item in the collection:\n\n```go\nitems.First() // returns *MyItem\n```\n\n### Last\n\nGet the last item in the collection:\n\n```go\nitems.Last() // returns *MyItem\n```\n\n### AddRange\n\nAdd a range of items to the collection:\n\n```go\nitems.AddRange(items []MyItem) // returns *collections.Collection[*MyItem]\n```\n\n### Clear\n\nRemove all items from the collection:\n\n```go\nitems.Clear() // returns *collections.Collection[*MyItem]\n```\n\n### Where\n\nFind all items that satisfy a certain predicate:\n\n```go\nitems.Where(predicate func(item MyItem) bool) // returns *collections.Collection[*MyItem]\n```\n\n### Count\n\nCount the number of items that satisfy a certain predicate:\n\n```go\nitems.Count(predicate func(item MyItem) bool) // returns int\n```\n\n### Any\n\nCheck if any item in the collection satisfies a certain predicate:\n\n```go\nitems.Any(predicate func(item MyItem) bool) // returns bool\n```\n\n### All\n\nCheck if all items in the collection satisfy a certain predicate:\n\n```go\nitems.All(predicate func(item MyItem) bool) // returns bool\n```\n\n### FirstWhere\n\nFind the first item that satisfies a certain predicate:\n\n```go\nitems.FirstWhere(predicate func(item MyItem) bool) // returns **MyItem\n```\n\n### LastWhere\n\nFind the last item that satisfies a certain predicate:\n\n```go\nitems.LastWhere(predicate func(item MyItem) bool) // returns **MyItem\n```\n\n### Map\n\nTransform the collection using a mapping function \u0026 return a new collection(so the original isn't modified)\n\n```go\nitems.Map(mapFunc func(index int, item MyItem) MyItem) // returns *collections.Collection[*MyItem]\n```\n\n### ForEach\n\nIterate over the collection:\n\n```go\nitems.ForEach(forEachFunc func(index int, item MyItem)) // returns *collections.Collection[*MyItem]\n```\n\n### Set\n\nSet the value of an item at a specific index:\n\n```go\nitems.Set(index int, value MyItem) // returns *collections.Collection[*MyItem]\n```\n\n### IndexOf\n\nFind the index of an item:\n\n```go\nitems.IndexOf(item MyItem) // returns int\n```\n\n### Filter\n\nFilter the collection based on a predicate function:\n\n```go\nitems.Filter(filterFunc func(index int, item MyItem) bool) // returns *collections.Collection[*MyItem]\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidevelopthings%2Fcollection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidevelopthings%2Fcollection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidevelopthings%2Fcollection/lists"}