{"id":20977346,"url":"https://github.com/gontainer/reflectpro","last_synced_at":"2025-10-04T20:19:03.050Z","repository":{"id":225579270,"uuid":"766308531","full_name":"gontainer/reflectpro","owner":"gontainer","description":"A simple and elegant interface for GO's reflect.","archived":false,"fork":false,"pushed_at":"2024-03-28T19:40:20.000Z","size":77,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T14:22:58.180Z","etag":null,"topics":["go","golang","reflect","reflection","reflection-api","reflection-library"],"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/gontainer.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":"2024-03-02T22:35:01.000Z","updated_at":"2024-03-24T08:20:24.000Z","dependencies_parsed_at":"2024-03-07T21:29:20.071Z","dependency_job_id":"3e093be2-3e35-4405-bb2c-2d711c92488f","html_url":"https://github.com/gontainer/reflectpro","commit_stats":null,"previous_names":["gontainer/reflectpro"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gontainer%2Freflectpro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gontainer%2Freflectpro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gontainer%2Freflectpro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gontainer%2Freflectpro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gontainer","download_url":"https://codeload.github.com/gontainer/reflectpro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225297832,"owners_count":17452010,"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":["go","golang","reflect","reflection","reflection-api","reflection-library"],"created_at":"2024-11-19T04:58:26.890Z","updated_at":"2025-10-04T20:18:58.008Z","avatar_url":"https://github.com/gontainer.png","language":"Go","readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/gontainer/reflectpro.svg)](https://pkg.go.dev/github.com/gontainer/reflectpro)\n[![Tests](https://github.com/gontainer/reflectpro/actions/workflows/tests.yml/badge.svg)](https://github.com/gontainer/reflectpro/actions/workflows/tests.yml)\n[![Coverage Status](https://coveralls.io/repos/github/gontainer/reflectpro/badge.svg?branch=main)](https://coveralls.io/github/gontainer/reflectpro?branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gontainer/reflectpro)](https://goreportcard.com/report/github.com/gontainer/reflectpro)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=gontainer_reflectpro\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=gontainer_reflectpro)\n\n# Reflectpro\n\nSimple, elegant, and intuitive [callers](caller), [copiers](copier), [getters](getter) and [setters](setter).\n\n## Examples\n\n## Caller\n\nIn the following example, we have a pointer to `any` that stores a `struct`,\ninstead of having a direct pointer to a `struct`.\nThe receiver is a pointer, so eventually we cannot call the given method.\n`Caller` handles that by creating a pointer to a copy of that value.\n\n```go\ntype Person struct {\n\tname string\n\tage  int\n}\n\nfunc (p *Person) SetName(n string) {\n\tp.name = n\n}\n\nfunc Example() {\n\tvar p any\n\tp := \u0026Person{age: 25}\n\t_, _ = caller.CallMethod(p, \"SetName\", []any{\"Mary\"}, false)\n\tfmt.Printf(\"%+v\\n\", p)\n\t// Output: \u0026{name:Mary age:25}\n}\n```\n\n## Copier\n\n```go\nvar (\n    from = []any{int(1), uint(2), float32(3), float64(4)}\n    to   []uint64\n)\n_ = copier.Copy(from, \u0026to, true) // convert\nfmt.Printf(\"%#v\\n\", to)\n// Output: []uint64{0x1, 0x2, 0x3, 0x4}\n```\n\n## Getter\n\nIn the following example, we read an unexported field of the given struct.\n\n```go\nperson := struct {\n    name string\n}{\n    name: \"Mary\",\n}\nv, _ := getter.Get(person, \"name\")\nfmt.Println(v)\n// Output: Mary\n```\n\n## Setter\n\nIn the following example, we have a pointer to `any` that stores a `struct`,\ninstead of having a direct pointer to a `struct`. Since it is an `unaddressable value`,\nthe `reflect` package from the standard library does not allow assigning a new value to this field.\n`Setter` handles that by creating an addressable copy.\n\n```go\nvar person any\nperson = struct {\n    name string\n}{}\n_ = setter.Set(\u0026person, \"name\", \"Mary\", false)\nfmt.Println(person)\n// Output: {Mary}\n```\n","funding_links":[],"categories":["Reflection"],"sub_categories":["HTTP Clients","HTTP客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgontainer%2Freflectpro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgontainer%2Freflectpro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgontainer%2Freflectpro/lists"}