{"id":13764144,"url":"https://github.com/inconshreveable/gonative","last_synced_at":"2025-04-07T05:10:51.272Z","repository":{"id":16578724,"uuid":"19332852","full_name":"inconshreveable/gonative","owner":"inconshreveable","description":"Build Go Toolchains /w native libs for cross-compilation","archived":false,"fork":false,"pushed_at":"2016-07-21T19:34:23.000Z","size":58,"stargazers_count":337,"open_issues_count":7,"forks_count":36,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-30T22:11:07.242Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inconshreveable.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}},"created_at":"2014-05-01T01:43:15.000Z","updated_at":"2025-02-19T18:58:05.000Z","dependencies_parsed_at":"2022-09-26T20:53:21.651Z","dependency_job_id":null,"html_url":"https://github.com/inconshreveable/gonative","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Fgonative","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Fgonative/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Fgonative/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Fgonative/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inconshreveable","download_url":"https://codeload.github.com/inconshreveable/gonative/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-08-03T15:01:16.365Z","updated_at":"2025-04-07T05:10:51.256Z","avatar_url":"https://github.com/inconshreveable.png","language":"Go","funding_links":[],"categories":["Software Packages","Go","Misc","软件包","Go Tools","DevOps Tools"],"sub_categories":["DevOps Tools","DevOps 工具","DevOps工具","Contents","devops 工具"],"readme":"# gonative\n\nCross compiled Go binaries are not suitable for production applications\nbecause code in the standard library relies on Cgo for DNS resolution\nwith the native resolver, access to system certificate roots, and parts of os/user.\n\ngonative is a simple tool which creates a build of Go that can cross compile\nto all platforms while still using the Cgo-enabled versions of the stdlib\npackages. It does this by downloading the binary distributions for each\nplatform and copying their libraries into the proper places. It sets\nthe correct mod time so they don't get rebuilt. It also copies\nsome auto-generated runtime files into the build as well. gonative does\nnot modify any Go that you have installed and builds a new installaion of \nGo in a separate directory (the current directory by default).\n\nOnce you have a toolchain for cross-compilation, you can use tools like\n[gox](https://github.com/mitchellh/gox) to cross-compile native builds easily.\n\ngonative will not help you if your own packages rely on Cgo\n\n### Installation\n\n    git clone https://github.com/inconshreveable/gonative\n    cd gonative\n    make\n\nAlternatively, you can install gonative via `go get` but the dependencies are not\nlocked down.\n\n    go get github.com/inconshreveable/gonative\n\n### Running\nThe 'build' command will build a toolchain in a directory called 'go' in your working directory.\n\n    gonative build\n\nTo build a particular version of Go (default is 1.4):\n\n    gonative build -version=1.3.3\n\nFor options and help:\n\n    gonative build -h\n\n### How it works\n\ngonative downloads the go source code and compiles it for your host platform.\nIt then bootstraps the toolchain for all target platforms (but does not compile the standard library).\nThen, it fetches the official binary distributions for all target platforms and copies\neach pkg/OS\\_ARCH directory into the toolchain so that you will link with natively-compiled versions\nof the standard library. It walks all of the copied standard library and sets their modtimes so that\nthey won't get rebuilt. It also copies some necessary auto-generated runtime source\nfiles for each platform (z\\*\\_) into the source directory to make it all work.\n\n### Example with gox:\n\nHere's an example of how to cross-compile a project:\n\n    $ go get github.com/mitchellh/gox\n    $ go get github.com/inconshreveable/gonative\n    $ cd /your/project\n    $ gonative build\n    $ PATH=$PWD/go/bin/:$PATH gox\n    \nThis isn't the most optimal way of doing things though. You only ever need one gonative-built \nGo toolchain. And with the proper GOPATH set up, you don't need to be\nin your project's working directory. I use it mostly like this:\n\n#### One time only setup:\n\n    $ go get github.com/mitchellh/gox\n    $ go get github.com/inconshreveable/gonative\n    $ mkdir -p /usr/local/gonative\n    $ cd /usr/local/gonative\n    $ gonative build\n    \n#### Building a project:\n\n    $ PATH=/usr/local/gonative/go/bin/:$PATH gox github.com/your-name/application-name\n    \n### Open Issues\n\n- gonative is untested on Windows\n\n### Caveats\n- no linux/arm support because there are no official builds of linux/arm\n- linux\\_386 binaries that use native libs depend on 32-bit libc/libpthread/elf loader. some 64-bit linux distributions might not have those installed by default\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finconshreveable%2Fgonative","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finconshreveable%2Fgonative","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finconshreveable%2Fgonative/lists"}