{"id":20321395,"url":"https://github.com/openacid/genr","last_synced_at":"2026-05-11T17:32:20.185Z","repository":{"id":97578012,"uuid":"315197003","full_name":"openacid/genr","owner":"openacid","description":"generator for generic types","archived":false,"fork":false,"pushed_at":"2020-11-23T09:34:16.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-04T09:43:52.400Z","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/openacid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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-11-23T04:08:15.000Z","updated_at":"2020-11-23T09:32:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"20d76e5c-e5e7-47be-9a9d-992780bfa166","html_url":"https://github.com/openacid/genr","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"openacid/gotmpl","purl":"pkg:github/openacid/genr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgenr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgenr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgenr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgenr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openacid","download_url":"https://codeload.github.com/openacid/genr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgenr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32905830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-11T17:09:15.040Z","status":"ssl_error","status_checked_at":"2026-05-11T17:08:45.420Z","response_time":120,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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-11-14T19:14:51.577Z","updated_at":"2026-05-11T17:32:20.169Z","avatar_url":"https://github.com/openacid.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# genr\n\n[![Travis](https://travis-ci.com/openacid/genr.svg?branch=main)](https://travis-ci.com/openacid/genr)\n![test](https://github.com/openacid/genr/workflows/test/badge.svg)\n\n[![Report card](https://goreportcard.com/badge/github.com/openacid/genr)](https://goreportcard.com/report/github.com/openacid/genr)\n[![Coverage Status](https://coveralls.io/repos/github/openacid/genr/badge.svg?branch=main\u0026service=github)](https://coveralls.io/github/openacid/genr?branch=main\u0026service=github)\n\n[![GoDoc](https://godoc.org/github.com/openacid/genr?status.svg)](http://godoc.org/github.com/openacid/genr)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/openacid/genr)](https://pkg.go.dev/github.com/openacid/genr)\n[![Sourcegraph](https://sourcegraph.com/github.com/openacid/genr/-/badge.svg)](https://sourcegraph.com/github.com/openacid/genr?badge)\n\ngenr generates source code to emulate `generic type`.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [Synopsis](#synopsis)\n  - [Generate two types `U16` and `I64` with a template:](#generate-two-types-u16-and-i64-with-a-template)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\n# Synopsis\n\n## Generate two types `U16` and `I64` with a template:\n\n```go\npackage main\n\nimport (\n\t\"github.com/openacid/genr\"\n)\n\nvar implHead = `package intarray\nimport (\n\t\"encoding/binary\"\n)\n`\n\nvar implTemplate = `\ntype {{.Name}} struct {\n\tvals []{{.ValType}}\n\teltSize int\n\tfirst []byte\n}\n\nfunc New{{.Name}}(elts []{{.ValType}}) (a *{{.Name}}, err error) {\n\ta = \u0026{{.Name}}{\n\t\tvals: make([]{{.ValType}}, 10),\n\t\teltSize: {{.ValLen}},\n\t\tfirst: make([]byte, 0),\n\t}\n\n\tbinary.LittleEndian.Put{{.Codec}}(a.first, {{.EncodeCast}}(elts[0]))\n\treturn a, nil\n}\n`\n\nfunc main() {\n\n\timplfn := \"../intarray.go\"\n\n\timpls := []interface{}{\n\t\tgenr.NewIntConfig(\"U16\", \"uint16\"),\n\t\tgenr.NewIntConfig(\"I64\", \"int64\"),\n\t}\n\n\tgenr.Render(implfn, implHead, implTemplate, impls, []string{\"gofmt\", \"unconvert\"})\n\n}\n\n```\n\nThe generated codes looks like the following:\n\n```go\n// Code generated 'by go generate ./...'; DO NOT EDIT.\n\npackage intarray\n\nimport (\n\t\"encoding/binary\"\n)\n\ntype U16 struct {\n\tvals    []uint16\n\teltSize int\n\tfirst   []byte\n}\n\nfunc NewU16(elts []uint16) (a *U16, err error) {\n\ta = \u0026U16{\n\t\tvals:    make([]uint16, 10),\n\t\teltSize: 2,\n\t\tfirst:   make([]byte, 0),\n\t}\n\n\tbinary.LittleEndian.PutUint16(a.first, elts[0])\n\treturn a, nil\n}\n\ntype I64 struct {\n\tvals    []int64\n\teltSize int\n\tfirst   []byte\n}\n\nfunc NewI64(elts []int64) (a *I64, err error) {\n\ta = \u0026I64{\n\t\tvals:    make([]int64, 10),\n\t\teltSize: 8,\n\t\tfirst:   make([]byte, 0),\n\t}\n\n\tbinary.LittleEndian.PutUint64(a.first, uint64(elts[0]))\n\treturn a, nil\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenacid%2Fgenr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenacid%2Fgenr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenacid%2Fgenr/lists"}