{"id":13412978,"url":"https://github.com/xiaoxin01/typeregistry","last_synced_at":"2026-01-14T11:50:56.119Z","repository":{"id":44154491,"uuid":"233877277","full_name":"xiaoxin01/typeregistry","owner":"xiaoxin01","description":"create type dynamically in Golang","archived":false,"fork":false,"pushed_at":"2020-02-20T13:00:03.000Z","size":8,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:51:45.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/xiaoxin01.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}},"created_at":"2020-01-14T15:50:38.000Z","updated_at":"2023-09-30T04:55:03.000Z","dependencies_parsed_at":"2022-07-30T09:08:05.004Z","dependency_job_id":null,"html_url":"https://github.com/xiaoxin01/typeregistry","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/xiaoxin01/typeregistry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoxin01%2Ftyperegistry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoxin01%2Ftyperegistry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoxin01%2Ftyperegistry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoxin01%2Ftyperegistry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaoxin01","download_url":"https://codeload.github.com/xiaoxin01/typeregistry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoxin01%2Ftyperegistry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2024-07-30T20:01:31.855Z","updated_at":"2026-01-14T11:50:56.103Z","avatar_url":"https://github.com/xiaoxin01.png","language":"Go","readme":"# a library to create type dynamically\n\n[![Report](https://goreportcard.com/badge/github.com/xiaoxin01/typeregistry)](https://goreportcard.com/badge/github.com/xiaoxin01/typeregistry)\n[![Build Status](https://travis-ci.org/xiaoxin01/typeregistry.svg?branch=master)](https://travis-ci.org/xiaoxin01/typeregistry)\n\n## how to use\n\n```go\n// 1. define struct\ntype Student struct {\n\tAge  int\n\tName string\n}\n\n// 2. add reflect type\nkey := AddType(new(Student))\n\n// 3. create struct from registed key\nstudent := Make(key)\n```\n\n## custom registed key\n\n```go\nvar i interface{} = new(Student)\n\n// use lowercase struct name as key\nname := AddTypeWithKey(i, func(i interface{}) string {\n\ttpe := reflect.TypeOf(i).Elem()\n\treturn strings.ToLower(tpe.Name())\n})\n\nstudent, ok := Create(\"student\").(*Student)\n```\n\n## benchmark\n\n```bash\ngo.exe test -benchmem -run=^$ supperxin/typeregistry -bench ^BenchmarkMake$\n\ngoos: windows\ngoarch: amd64\npkg: supperxin/typeregistry\nBenchmarkMake-8   \t 8823256\t       138 ns/op\t      64 B/op\t       2 allocs/op\nPASS\nok  \tsupperxin/typeregistry\t1.551s\n```\n\n```bash\ngo.exe test -benchmem -run=^$ supperxin/typeregistry -bench ^BenchmarkCreateDirectly$\n\ngoos: windows\ngoarch: amd64\npkg: supperxin/typeregistry\nBenchmarkCreateDirectly-8   \t1000000000\t         0.593 ns/op\t       0 B/op\t       0 allocs/op\nPASS\nok  \tsupperxin/typeregistry\t0.857s\n```\n","funding_links":[],"categories":["Relational Databases","Generation and Generics","代码生成与泛型","Generators","发电机"],"sub_categories":["Advanced Console UIs","SQL 查询语句构建库","Search and Analytic Databases","检索及分析资料库","Utility/Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoxin01%2Ftyperegistry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaoxin01%2Ftyperegistry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoxin01%2Ftyperegistry/lists"}