{"id":38258932,"url":"https://github.com/jinzhongmin/goffi","last_synced_at":"2026-01-17T01:34:03.283Z","repository":{"id":142543926,"uuid":"610160734","full_name":"jinzhongmin/goffi","owner":"jinzhongmin","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-03T11:45:17.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-03T12:40:11.224Z","etag":null,"topics":["dlfcn","libffi"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jinzhongmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-03-06T08:06:38.000Z","updated_at":"2024-03-03T12:40:11.225Z","dependencies_parsed_at":"2024-02-04T03:20:04.344Z","dependency_job_id":"40772c3a-5075-4e0c-bf1c-eb4526aef9cd","html_url":"https://github.com/jinzhongmin/goffi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jinzhongmin/goffi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinzhongmin%2Fgoffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinzhongmin%2Fgoffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinzhongmin%2Fgoffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinzhongmin%2Fgoffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jinzhongmin","download_url":"https://codeload.github.com/jinzhongmin/goffi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinzhongmin%2Fgoffi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","response_time":107,"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":["dlfcn","libffi"],"created_at":"2026-01-17T01:34:03.212Z","updated_at":"2026-01-17T01:34:03.272Z","avatar_url":"https://github.com/jinzhongmin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gofii\r\n\r\n## Depend on\r\n\r\ndlfcn libffi\r\n\r\n## Windows\r\n\r\ninstall msys2\r\n\r\n``` shell\r\npacman -S mingw-w64-x86_64-dlfcn\r\npacman -S mingw-w64-x86_64-libffi\r\n```\r\n\r\n## example\r\n\r\n``` go\r\npackage main\r\n\r\n/*\r\ntypedef int (*opera_fn)(int ,int);\r\nint opera(void* fn, int a, int b){\r\n\topera_fn f = (opera_fn)(fn);\r\n\treturn f(a, b);\r\n}\r\n*/\r\nimport \"C\"\r\nimport (\r\n\t\"fmt\"\r\n\r\n\t\"github.com/jinzhongmin/goffi/pkg/c\"\r\n\t\"github.com/jinzhongmin/goffi/pkg/dlfcn\"\r\n\t\"github.com/jinzhongmin/usf\"\r\n)\r\n\r\nfunc main() {\r\n\r\n\t//###################\r\n\t// hello world.\r\n\t//###################\r\n\tstr := c.CStr(\"hello %s .\\n\")\r\n\tdefer usf.Free(str)\r\n\r\n\tworld := c.CStr(\"world\")\r\n\tdefer usf.Free(world)\r\n\r\n\tfnPrototype := \u0026c.FuncPrototype{\r\n\t\tName:    \"printf\",\r\n\t\tInTypes: []c.Type{c.Pointer, c.Pointer},\r\n\t\tOutType: c.Void,\r\n\t}\r\n\tfnPrototype.Create(dlfcn.DlsymDefault)\r\n\tfnPrototype.Call([]interface{}{\u0026str, \u0026world})\r\n\r\n\t//###################\r\n\t// callback\r\n\t//###################\r\n\r\n\t//define callback prototype\r\n\tcbprototype := c.DefineCallbackPrototype(c.AbiDefault, c.I32, []c.Type{c.I32, c.I32})\r\n\tdefer cbprototype.Free()\r\n\r\n\ta := C.int(100)\r\n\tb := C.int(200)\r\n\r\n\tadd_fun := cbprototype.CreateCallback(func(args []*c.Value, ret *c.Value) {\r\n\t\ta := args[0].I32()\r\n\t\tb := args[1].I32()\r\n\r\n\t\tret.SetI32(a + b)\r\n\t})\r\n\tadd := C.opera(add_fun.CFuncPtr(), a, b)\r\n\tfmt.Println(\"a + b = \", add)\r\n\tadd_fun.Free()\r\n\r\n\t//change opera_func to mul\r\n\tmul_fun := cbprototype.CreateCallback(func(args []*c.Value, ret *c.Value) {\r\n\t\ta := args[0].I32()\r\n\t\tb := args[1].I32()\r\n\r\n\t\tret.SetI32(a * b)\r\n\t})\r\n\r\n\tmul := C.opera(mul_fun.CFuncPtr(), a, b)\r\n\tfmt.Println(\"a * b = \", mul)\r\n\tmul_fun.Free()\r\n\r\n}\r\n\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinzhongmin%2Fgoffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjinzhongmin%2Fgoffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinzhongmin%2Fgoffi/lists"}