{"id":19757161,"url":"https://github.com/franpog859/index","last_synced_at":"2026-06-08T13:32:07.836Z","repository":{"id":57552400,"uuid":"151760370","full_name":"franpog859/index","owner":"franpog859","description":"📦📆 A little Go package with high level generic like functions for simple slices","archived":false,"fork":false,"pushed_at":"2019-04-13T06:35:58.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T09:20:55.323Z","etag":null,"topics":["generic","generics","golang","index","interface","package","reflect","slice","stackoverflow"],"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/franpog859.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-05T18:09:38.000Z","updated_at":"2019-10-11T21:10:47.000Z","dependencies_parsed_at":"2022-09-20T12:54:57.621Z","dependency_job_id":null,"html_url":"https://github.com/franpog859/index","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/franpog859/index","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franpog859%2Findex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franpog859%2Findex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franpog859%2Findex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franpog859%2Findex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franpog859","download_url":"https://codeload.github.com/franpog859/index/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franpog859%2Findex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34065349,"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-06-08T02:00:07.615Z","response_time":111,"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":["generic","generics","golang","index","interface","package","reflect","slice","stackoverflow"],"created_at":"2024-11-12T03:18:17.311Z","updated_at":"2026-06-08T13:32:07.817Z","avatar_url":"https://github.com/franpog859.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/franpog859/index/master/logo_index.png\"\u003e\n\u003c/p\u003e\n\n[![Documentation](https://godoc.org/github.com/franpog859/index?status.svg)](http://godoc.org/github.com/franpog859/index)\n[![Go Report Card](https://goreportcard.com/badge/github.com/franpog859/index)](https://goreportcard.com/report/github.com/franpog859/index)\n[![CircleCI](https://circleci.com/gh/franpog859/index.svg?style=shield)](https://circleci.com/gh/franpog859/index)\n\n## Description\n\nIndex is a little Go package. It provides high level generic like functions for simple slices.\n\nIt allows you to check on which indexes your item is positioned in the slice. Index also allows you to check if your item exist in the slice or how many of them are there. It works with every type of simple slices! There is a common Go problem to pass the slice with unknown type to the function. It is solved here with the [reflect](https://golang.org/pkg/reflect/) package and [this](https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go) idea turned out to be a very good solution.\n\n## Usage\n\nTo get this package and use it just type in your terminal `go get github.com/franpog859/index`. After that you just can simply import the package in your code `import \"github.com/franpog859/index\"` and use it as follows:\n\n```go\npackage main\nimport (\n  \"fmt\"\n  \"github.com/franpog859/index\"\n)\n\nfunc main() {\n  slice := []int{1, 2, 3, 1}\n  item := 1\n  \n  indexes, err := index.GetAll(slice, item)\n  if err != nil {\n    fmt.Println(err)\n  }\n    \n  fmt.Println(indexes)\n}\n```\n```\nOutput:\n[0 3]\n```\nRemember not to pass some complex slices like multidimensional slices or slices of maps. This package just does not deal with such complexity so remember to check the `err` value! \n\nIf you want to see examples of usage other functions go to [USAGE.md](https://github.com/franpog859/index/blob/master/USAGE.md) file.\n\n## Contribution\n\nIf you want to make this package better just fork this repository and prepare your pull request! Remember to keep the code clean and to test your implementation :wink: See also [CONTRIBUTING.md](https://github.com/franpog859/index/blob/master/CONTRIBUTING.md) file for more informations about preparing your pull request and the workflow.\n\nTo test this package run in your terminal: \n- `git clone https://github.com/franpog859/index.git`\n- `cd index` \n- `go test -cover ./...`\n\nIf you see some bug or bad habit feel free to tell me! \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranpog859%2Findex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranpog859%2Findex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranpog859%2Findex/lists"}