{"id":17912653,"url":"https://github.com/danielgatis/go-ptrloop","last_synced_at":"2026-04-28T20:02:59.926Z","repository":{"id":79824981,"uuid":"267416441","full_name":"danielgatis/go-ptrloop","owner":"danielgatis","description":"A helper to iterate over unsafe pointers.","archived":false,"fork":false,"pushed_at":"2020-09-26T04:34:33.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T20:47:32.753Z","etag":null,"topics":["c","go","golang","pointer-arithmetic","unsafe-pointers"],"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/danielgatis.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":"2020-05-27T20:10:04.000Z","updated_at":"2023-06-12T16:08:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"34f671d7-6856-40fe-97da-fc35265e61ef","html_url":"https://github.com/danielgatis/go-ptrloop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ptrloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ptrloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ptrloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ptrloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgatis","download_url":"https://codeload.github.com/danielgatis/go-ptrloop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246952278,"owners_count":20859812,"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":["c","go","golang","pointer-arithmetic","unsafe-pointers"],"created_at":"2024-10-28T19:46:22.789Z","updated_at":"2026-04-28T20:02:59.860Z","avatar_url":"https://github.com/danielgatis.png","language":"Go","readme":"# go-ptrloop\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/danielgatis/go-ptrloop?style=flat-square)](https://goreportcard.com/report/github.com/danielgatis/go-ptrloop)\n[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/danielgatis/go-ptrloop/master/LICENSE)\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/danielgatis/go-ptrloop)\n\nA helper to iterate over unsafe pointers.\n\n## Install\n\n```bash\ngo get -u github.com/danielgatis/go-ptrloop\n```\n\nAnd then import the package in your code:\n\n```go\nimport \"github.com/danielgatis/go-ptrloop/ptrloop\"\n```\n\n### Example\n\nAn example described below is one of the use cases.\n\n```go\npackage main\n\n/*\n#include \u003cstdlib.h\u003e\n#include \u003cstrings.h\u003e\n\nchar** createArray(int n) {\n  char** array = (char **) malloc(n * sizeof(char *));\n\n  for (int i = 0; i \u003c n; ++i) {\n    array[i] = strdup(\"hello!\");\n  }\n\n  return array;\n}\n*/\nimport \"C\"\nimport (\n\t\"fmt\"\n\t\"unsafe\"\n\n\t\"github.com/danielgatis/go-ptrloop/ptrloop\"\n)\n\nfunc main() {\n\tn := 3\n\tarray := C.createArray(C.int(n))\n\n\tptrloop.Loop(unsafe.Pointer(array), int(n), func(ptr unsafe.Pointer, i int) bool {\n\t\ts := *(**C.char)(ptr)\n\t\tfmt.Printf(\"%v -\u003e %v\\n\", i, C.GoString(s))\n\t\treturn true\n\t})\n}\n```\n\n\n```\n❯ go run main.go\n0 -\u003e hello!\n1 -\u003e hello!\n2 -\u003e hello!\n```\n\n\n## License\n\nCopyright (c) 2020-present [Daniel Gatis](https://github.com/danielgatis)\n\nLicensed under [MIT License](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-ptrloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgatis%2Fgo-ptrloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-ptrloop/lists"}