{"id":18821616,"url":"https://github.com/octu0/unsafecgo","last_synced_at":"2026-05-15T12:31:52.800Z","repository":{"id":98859573,"uuid":"608188641","full_name":"octu0/unsafecgo","owner":"octu0","description":"cgo calls via assembly trampoline","archived":false,"fork":false,"pushed_at":"2023-03-23T11:25:59.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T17:55:28.811Z","etag":null,"topics":["assembly","cgo","goasm","golang","trampoline"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/octu0/unsafecgo","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/octu0.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":"2023-03-01T14:01:20.000Z","updated_at":"2023-12-29T07:55:03.000Z","dependencies_parsed_at":"2024-02-06T03:15:46.082Z","dependency_job_id":null,"html_url":"https://github.com/octu0/unsafecgo","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"8bb6a1c9c47721fda2a7e0d1b71e9a13e070814b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/octu0/unsafecgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Funsafecgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Funsafecgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Funsafecgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Funsafecgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octu0","download_url":"https://codeload.github.com/octu0/unsafecgo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Funsafecgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33067143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"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":["assembly","cgo","goasm","golang","trampoline"],"created_at":"2024-11-08T00:44:54.034Z","updated_at":"2026-05-15T12:31:52.784Z","avatar_url":"https://github.com/octu0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `unsafecgo`\n\n[![MIT License](https://img.shields.io/github/license/octu0/unsafecgo)](https://github.com/octu0/unsafecgo/blob/master/LICENSE)\n[![GoDoc](https://godoc.org/github.com/octu0/unsafecgo?status.svg)](https://godoc.org/github.com/octu0/unsafecgo)\n[![Go Report Card](https://goreportcard.com/badge/github.com/octu0/unsafecgo)](https://goreportcard.com/report/github.com/octu0/unsafecgo)\n[![Releases](https://img.shields.io/github/v/release/octu0/unsafecgo)](https://github.com/octu0/unsafecgo/releases)\n\n`unsafecgo` provides Cgo calls via assembly trampoline. Inspired by [rustgo](https://blog.filippo.io/rustgo/).\n\n## Installation\n\n```bash\ngo get github.com/octu0/unsafecgo\n```\n\n## Example\n\n```go\npackage main\n\n/*\n#include \u003cstdio.h\u003e\nvoid hello() {\n  fprintf(stderr, \"hello world\\n\");\n}\n*/\nimport \"C\"\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\t\"runtime\"\n\t\"unsafe\"\n\n\t\"github.com/octu0/unsafecgo\"\n)\n\nfunc cgo_helloworld() {\n\tfmt.Println(\"cgo\")\n\n\tC.hello()\n}\n\nfunc unsafecgo_helloworld() {\n\tfmt.Println(\"unsafecgo.Call\")\n\n\tp := unsafe.Pointer(reflect.ValueOf(C.hello).Pointer())\n\tunsafecgo.Call(p) // call C.hello()\n\truntime.KeepAlive(p)\n}\n\nfunc main() {\n\tcgo_helloworld()\n\tunsafecgo_helloworld()\n}\n```\n\n## Benchmark\n\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/octu0/unsafecgo/benchmark\ncpu: Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz\nBenchmarkUnsafecgo\nBenchmarkUnsafecgo/cgo/malloc_free\nBenchmarkUnsafecgo/cgo/malloc_free-4              971646              1236 ns/op            1024 B/op          1 allocs/op\nBenchmarkUnsafecgo/unsafecgo/malloc_free\nBenchmarkUnsafecgo/unsafecgo/malloc_free-4       1340142               910.4 ns/op             0 B/op          0 allocs/op\nBenchmarkUnsafecgo/cgo/calc\nBenchmarkUnsafecgo/cgo/calc-4                    3667410               311.5 ns/op             0 B/op          0 allocs/op\nBenchmarkUnsafecgo/unsafecgo/calc\nBenchmarkUnsafecgo/unsafecgo/calc-4             16357767                74.31 ns/op            0 B/op          0 allocs/op\nBenchmarkUnsafecgo/cgo/nop_call\nBenchmarkUnsafecgo/cgo/nop_call-4               17337052                65.60 ns/op            0 B/op          0 allocs/op\nBenchmarkUnsafecgo/unsafecgo/nop_call\nBenchmarkUnsafecgo/unsafecgo/nop_call-4         369709251                3.211 ns/op           0 B/op          0 allocs/op\nPASS\n```\n\n# License\n\nMIT, see LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctu0%2Funsafecgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctu0%2Funsafecgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctu0%2Funsafecgo/lists"}