{"id":37885220,"url":"https://github.com/sleagon/g","last_synced_at":"2026-01-16T16:51:48.163Z","repository":{"id":50357150,"uuid":"515996963","full_name":"sleagon/g","owner":"sleagon","description":"go common functions like lodash/guava/underscore","archived":false,"fork":false,"pushed_at":"2023-11-16T17:20:37.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T10:20:32.331Z","etag":null,"topics":["go","golang","guava","lodash","underscore"],"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/sleagon.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":"2022-07-20T13:38:56.000Z","updated_at":"2023-12-05T07:24:56.000Z","dependencies_parsed_at":"2023-11-16T18:41:51.629Z","dependency_job_id":null,"html_url":"https://github.com/sleagon/g","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/sleagon/g","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleagon%2Fg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleagon%2Fg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleagon%2Fg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleagon%2Fg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sleagon","download_url":"https://codeload.github.com/sleagon/g/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleagon%2Fg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480081,"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":["go","golang","guava","lodash","underscore"],"created_at":"2026-01-16T16:51:48.059Z","updated_at":"2026-01-16T16:51:48.132Z","avatar_url":"https://github.com/sleagon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# G package\n\n\n\ncommonly used functions in go.package g.\n\n## Usage\n\n```go\nfunc main() {\n  g.Contains([]int{1, 2, 3}, 1)\n  g.Reverse([]int{1, 2, 3})\n}\n```\n\n## All functions\n\n```\n// import \"github.com/sleagon/g\"\n\n\nFUNCTIONS\n\nfunc Contains[T comparable](values []T, v T) bool\n    Contains check v is contained by values.\n\nfunc Filter[T any](values []T, f func(T, int) bool) []T\n    Filter is a filter operator, like java's filter.\n\nfunc Flat2[T any](values [][]T) []T\n    Flat2 flatten 2-dimensional array to 1-dimensional array.\n\nfunc Flat3[T any](values [][][]T) []T\n    Flat3 flatten 3-dimensional array to 1-dimensional array.\n\nfunc GroupBy[T any, K comparable](values []T, f func(T, int) K) map[K][]T\n    GroupBy is a group by operator, like guava's group by.\n\nfunc IndexOf[T comparable](values []T, v T) int\n    IndexOf find the index of v in values, return -1 if element not found.\n\nfunc IndexOfBy[T comparable](values []T, f func(T, int) bool) int\n    IndexOfBy find the index of v in values, return -1 if element not found.\n\nfunc Keys[K comparable, V any](values map[K]V) []K\n    Keys returns the keys of the map, order is not guaranteed.\n\nfunc LastIndexOf[T comparable](values []T, v T) int\n    LastIndexOf find the last index of v in values, return -1 if element not\n    found.\n\nfunc LastIndexOfBy[T comparable](values []T, f func(T, int) bool) int\n    LastIndexOfBy find the last index of v in values, return -1 if element not\n    found.\n\nfunc Map[F any, T any](values []F, f func(F, int) T) []T\n    Map is a map operator, like js/java's map.\n\nfunc MapEntries[K comparable, V any, T any](values map[K]V, f func(K, V) T) []T\n    MapEntries returns the f(entries) of the map, order is not guaranteed.\n\nfunc MapKeys[K comparable, V any, T any](values map[K]V, f func(K) T) []T\n    MapKeys returns the f(key)s of the map, order is not guaranteed.\n\nfunc MapValues[K comparable, V any, T any](values map[K]V, f func(V) T) []T\n    MapValues returns the f(value)s of the map, order is not guaranteed.\n\nfunc Max[T Numberic](values []T) T\n    Max returns the maximum value in the given slice.\n\nfunc MaxBy[T any](values []T, less func(T, T) bool) T\n    MaxBy returns the maximum value in the given slice, using the provided less\n    function to compare values.\n\nfunc MaxKey[K Numberic, V any](values map[K]V) K\n    MaxKey returns the maximum key of the map.\n\nfunc MaxKeyBy[K comparable, V any](values map[K]V, less func(K, K) bool) K\n    MaxKeyBy returns the maximum key of the map based on less method.\n\nfunc MaxValue[K comparable, V Numberic](values map[K]V) V\n    MaxValue returns the maximum value of the map.\n\nfunc MaxValueBy[K comparable, V any](values map[K]V, less func(V, V) bool) V\n    MaxValueBy returns the maximum value of the map based on less method.\n\nfunc Min[T Numberic](values []T) T\n    Min returns the minimum value in the given slice.\n\nfunc MinBy[T any](values []T, less func(T, T) bool) T\n    MinBy returns the minimum value in the given slice, using the provided less\n    function to compare values.\n\nfunc MinKey[K Numberic, V any](values map[K]V) K\n    MinKey returns the minimum key of the map.\n\nfunc MinKeyBy[K comparable, V any](values map[K]V, less func(K, K) bool) K\n    MinKeyBy returns the minimum key of the map based on less method.\n\nfunc MinValue[K comparable, V Numberic](values map[K]V) V\n    MinValue returns the minimum value of the map.\n\nfunc MinValueBy[K comparable, V any](values map[K]V, less func(V, V) bool) V\n    MinValueBy returns the minimum value of the map based on less method.\n\nfunc Must[T any](v T, err error) T\n    Must assert a condition, and if it fails, panic.\n\nfunc Must0(err error)\n    Must0 assert err is nil\n\nfunc Must1[T any](v T, err error) T\n    MustN assert n conditions, and if it fails, panic.\n\nfunc Must2[T1 any, T2 any](v1 T1, v2 T2, err error) (T1, T2)\n    MustN assert n conditions, and if it fails, panic.\n\nfunc Must3[T1 any, T2 any, T3 any](v1 T1, v2 T2, v3 T3, err error) (T1, T2, T3)\n    MustN assert n conditions, and if it fails, panic.\n\nfunc Must4[T1 any, T2 any, T3 any, T4 any](v1 T1, v2 T2, v3 T3, v4 T4, err error) (T1, T2, T3, T4)\n    MustN assert n conditions, and if it fails, panic.\n\nfunc Partition[T any](values []T, size int) [][]T\n    Partition is a partition operator, like java's partition.\n\nfunc PutAll[K comparable, V any](target map[K]V, elements map[K]V) map[K]V\n    PutAll add all elements to exist map, if the key is already exists, the\n    value will be overridden.\n\nfunc Reduce[F any, T any](values []F, f func(T, F, int) T) T\n    Reduce is a reduce operator, like js's reduce.\n\nfunc Reverse[T any](values []T) []T\n    Reverse reverse the order of elements in values.\n\nfunc ReverseS(s string) string\n    ReverseS returns a string with the reverse order of the given string.\n\nfunc Slice2Map[K comparable, V any](values []V, f func(V, int) K) map[K]V\n    Slice2Map transfer slice to a map base on given func.\n\nfunc Ternary[T any](cond bool, v1 T, v2 T) T\n    Ternary is a ternary operator, like C's ?:.\n\nfunc TernaryF[T any](cond bool, f1 func() T, f2 func() T) T\n    If is a if-else operator, like C's if-else.\n\nfunc Uniq[T comparable](values []T) []T\n    Uniq remove duplicated elements from values\n\nfunc ValueOf[T any](ptr *T) T\n    ValueOf returns the value of the given pointer.\n\nfunc Values[K comparable, V any](values map[K]V) []V\n    Values returns the values of the map, order is not guaranteed.\n\n\nTYPES\n\ntype Numberic interface {\n\t~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string\n}\n    Numberic is a numeric type, which can use \u003e\u003c= operators.\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleagon%2Fg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsleagon%2Fg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleagon%2Fg/lists"}