{"id":37172163,"url":"https://github.com/cafxx/mgo","last_synced_at":"2026-01-14T20:06:20.398Z","repository":{"id":162899297,"uuid":"637597742","full_name":"CAFxX/mgo","owner":"CAFxX","description":"Build and bundle multiple GOAMD64 variants in a single executable","archived":false,"fork":false,"pushed_at":"2025-08-22T05:37:28.000Z","size":1118,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-22T07:28:30.236Z","etag":null,"topics":["amd64","build","go","golang","runtime-detection"],"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/CAFxX.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,"zenodo":null}},"created_at":"2023-05-08T02:22:02.000Z","updated_at":"2025-04-04T02:46:55.000Z","dependencies_parsed_at":"2023-12-16T01:45:03.236Z","dependency_job_id":"d8946762-b2bb-4107-a630-446dabc18449","html_url":"https://github.com/CAFxX/mgo","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/CAFxX/mgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAFxX%2Fmgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAFxX%2Fmgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAFxX%2Fmgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAFxX%2Fmgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CAFxX","download_url":"https://codeload.github.com/CAFxX/mgo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAFxX%2Fmgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","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":["amd64","build","go","golang","runtime-detection"],"created_at":"2026-01-14T20:06:19.732Z","updated_at":"2026-01-14T20:06:20.385Z","avatar_url":"https://github.com/CAFxX.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mgo\n\nBuild your code for multiple [`GOAMD64` variants][1] and bundle all of them in a \nlauncher capable of picking at runtime the most appropriate variant for the\nprocessor in use.\n\nThis is mostly useful if you want to provide `GOAMD64` variants because of the extra\nruntime performance this yields, but you have no control over which processor \nmicroarchitecture the executable will be run on.\n\n## Install\n\n```\ngo install github.com/CAFxX/mgo@latest\n```\n\n## Usage\n\nWhen building your code just replace `go build [...]` with `mgo [...]`: the resulting\nexecutable will contain 4 variants, each optimized for one of `GOAMD64=v1`, `GOAMD64=v2`,\n`GOAMD64=v3` and `GOAMD64=v4`, and a launcher that will pick the appropriate one at\nruntime.\n\nAt runtime it is possible to override which variant is used by specifying in the\n`GOAMD64` environment variable one of the values `v1`, `v2`, `v3`, or `v4`.\n\nTo check which version is being executed you can add the `MGODEBUG=log` environment\nvariable when starting the compiled binary. In this case the launcher will print on\nstderr a line similar to the following at startup (in this example, to signal that\nthe `v3` variant is being used):\n\n```\n[mgo] launcher: starting variant GOAMD64=v3\n```\n\nOtherwise you can find out which version is being used by resolving the `/proc/\u003cPID\u003e/exe`\nsymlink, where `\u003cPID\u003e` is the process ID of the launched process:\n\n```\n$ PID=...\n$ readlink /proc/$PID/exe\n/memfd:/usr/bin/foobar [GOAMD64=v3] (deleted)\n```\n\nYou can extract a specific embedded executable using `MGODEBUG=extract` when starting the\ncompiled binary, e.g. `MGODEBUG=extract GOAMD64=v3` will dump to stdout the executable for\n`GOAMD64=v3` instead of starting it.\n\n## Notes\n\n- `mgo` requires Go \u003e= 1.20\n- The resulting executable will be over 4 times as large as a normal build output\n- Startup of the resulting executable is going to be a bit slower (tens of milliseconds)\n- Currently only `GOOS=linux` and `GOARCH=amd64` are supported, and only in\n  `buildmode`s that produce executables (not archives, plugins, or libraries)\n\n## TODO\n\n- Further minimize launcher overhead\n  - Start process with `GOMAXPROCS=1` and `GOGC=off` instead of setting them in `init`\n  - Avoid the `write` to the memfd (find ways to populate the new process directly from the binary in `RODATA`)\n- Embed build metadata of the built `v1` variant into the launcher, so that introspection\n  tools can use it\n- Support `GOARCH=arm` and [`GOARCH=arm64`](https://github.com/golang/go/issues/60905)\n\n## Quick sanity check\n\n```\nrm -f mgo* \u0026\u0026 \\\necho stage0 \u0026\u0026 go build \u0026\u0026 \\\necho stage1 \u0026\u0026 ./mgo -o mgo1 \u0026\u0026 sha1sum mgo1 \u0026\u0026 \\\necho stage2 \u0026\u0026 ./mgo1 -o mgo2 \u0026\u0026 sha1sum mgo2 \u0026\u0026 \\\necho stage3 \u0026\u0026 ./mgo2 -o mgo3 \u0026\u0026 sha1sum mgo3\n```\n\nThis command should succeed and produce three identical hashes.\n\n\n\n[1]: https://go.dev/wiki/MinimumRequirements#amd64\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafxx%2Fmgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafxx%2Fmgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafxx%2Fmgo/lists"}