{"id":19071066,"url":"https://github.com/mokiat/gog","last_synced_at":"2025-04-28T15:23:18.286Z","repository":{"id":62916545,"uuid":"558737559","full_name":"mokiat/gog","owner":"mokiat","description":"A Go library with useful generic functions and types","archived":false,"fork":false,"pushed_at":"2025-03-19T11:15:08.000Z","size":85,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-18T17:19:36.032Z","etag":null,"topics":["generics","go","golang","library"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/mokiat/gog","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/mokiat.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,"zenodo":null}},"created_at":"2022-10-28T07:21:25.000Z","updated_at":"2025-03-26T19:27:42.000Z","dependencies_parsed_at":"2023-02-18T00:01:21.613Z","dependency_job_id":"2958a50c-64a5-4a31-917d-9ca13fc65fe1","html_url":"https://github.com/mokiat/gog","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fgog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fgog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fgog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fgog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mokiat","download_url":"https://codeload.github.com/mokiat/gog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251336652,"owners_count":21573241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","library"],"created_at":"2024-11-09T01:22:12.626Z","updated_at":"2025-04-28T15:23:18.245Z","avatar_url":"https://github.com/mokiat.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoG (Go Generics)\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/mokiat/gog.svg)](https://pkg.go.dev/github.com/mokiat/gog)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mokiat/gog)](https://goreportcard.com/report/github.com/mokiat/gog)\n\nGoG is a Go library with useful generic functions and types.\n\nSince the introduction of generics in Go 1.18, a number of useful and reusable\ndata structures, algorithms and utility functions are now possible. This library\nattempts to cover some of the most common use cases.\n\nIt avoids duplicating functions that are already provided by\n[slices](https://pkg.go.dev/slices) and\n[maps](https://pkg.go.dev/maps).\n\nFor a complete list on available functions and types, check the\ngodoc documentation for this project:\n\n- [gog](https://pkg.go.dev/github.com/mokiat/gog) - general utility functions\n- [gog/ds](https://pkg.go.dev/github.com/mokiat/gog/ds) - data structures\n- [gog/filter](https://pkg.go.dev/github.com/mokiat/gog) - data filtering\n- [gog/opt](https://pkg.go.dev/github.com/mokiat/gog) - optional fields and types\n\n\n## Examples\n\n**Converting slice values from one type to another:**\n\n```go\nsource := []int{1, 2, 3, 4}\ntarget := gog.Map(source, func(item int) float64 {\n  return float64(item) / 2.0\n})\n// target = []float64{0.5, 1.0, 1.5, 2.0}\n```\n\n**Removing duplicate items in a slice:**\n\n```go\nsource := []string{\"john\", \"bill\", \"eric\", \"john\", \"max\", \"eric\"}\ntarget := gog.Dedupe(source)\n// target = []string{\"john\", \"bill\", \"eric\", \"max\"}\n```\n\n**Finding an item in a slice:**\n\n```go\nsource := []string{\"user 01\", \"user 02\", \"user 05\", \"user 33\"}\nfoundItem, ok := gog.FindFunc(source, func(item string) bool {\n  return strings.Contains(item, \"02\")\n})\n// ok = true\n// foundItem = \"user 02\"\n```\n\n**Selecting specific slice items:**\n\n```go\nsource := []int{1, 2, 3, 4}\ntarget := gog.Select(source, func(item int) bool {\n  return item % 2 == 0\n})\n// target = []int{2, 4}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmokiat%2Fgog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmokiat%2Fgog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmokiat%2Fgog/lists"}