### Install xgo Go Wrapper Source: https://github.com/karalabe/xgo/blob/master/README.md To simplify the usage of the xgo Docker container, a lightweight Go wrapper is provided. This command installs the wrapper, allowing xgo to be called as a single command. ```Go go get github.com/karalabe/xgo ``` -------------------------------- ### Cross-Compile Go Project with xgo Source: https://github.com/karalabe/xgo/blob/master/README.md This example demonstrates the basic usage of xgo to cross-compile a Go project. Simply provide the import path, and xgo will generate binaries for various target platforms and architectures, as shown by the 'ls -al' output. ```Shell $ xgo github.com/project-iris/iris ... $ ls -al -rwxr-xr-x 1 root root 9995000 Nov 24 16:44 iris-android-16-arm -rwxr-xr-x 1 root root 6776500 Nov 24 16:44 iris-darwin-10.6-386 -rwxr-xr-x 1 root root 8755532 Nov 24 16:44 iris-darwin-10.6-amd64 -rwxr-xr-x 1 root root 7114176 Nov 24 16:45 iris-ios-5.0-arm -rwxr-xr-x 1 root root 10135248 Nov 24 16:44 iris-linux-386 -rwxr-xr-x 1 root root 12598472 Nov 24 16:44 iris-linux-amd64 -rwxr-xr-x 1 root root 10040464 Nov 24 16:44 iris-linux-arm -rwxr-xr-x 1 root root 7516368 Nov 24 16:44 iris-windows-4.0-386.exe -rwxr-xr-x 1 root root 9549416 Nov 24 16:44 iris-windows-4.0-amd64.exe ``` -------------------------------- ### Cross-Compile Go with CGO Dependencies and Arguments for iOS Source: https://github.com/karalabe/xgo/blob/master/README.md Demonstrates how to pass additional arguments to the configure script of C/C++ dependencies using `--depsargs` during `xgo` cross-compilation for iOS targets. This allows fine-grained control over how the dependency is built, for example, disabling assembly optimizations. ```Shell xgo --deps=https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 \ --targets=ios/* --depsargs=--disable-assembly \ github.com/ethereum/go-ethereum/cmd/geth ``` -------------------------------- ### Cross-Compile Go with CGO Dependencies for Windows Source: https://github.com/karalabe/xgo/blob/master/README.md Example of using `xgo` to cross-compile a Go program that requires external C/C++ dependencies, such as the GNU Multiple Precision Arithmetic Library (GMP), for Windows targets. The `--deps` argument specifies the URL of the dependency tarball. ```Shell xgo --deps=https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 \ --targets=windows/* github.com/ethereum/go-ethereum/cmd/geth ``` -------------------------------- ### Select Repository Branch for xgo Compilation Source: https://github.com/karalabe/xgo/blob/master/README.md Similar to `go get`, `xgo` defaults to the `master` branch. This snippet shows how to use the `--branch` argument to specify a different Git branch for source code retrieval before compilation. The example compiles `golang.org/x/tools/cmd/goimports` from the `release-branch.go1.4`. ```shell $ xgo --branch release-branch.go1.4 golang.org/x/tools/cmd/goimports ``` -------------------------------- ### Select Specific Package within a Repository for xgo Source: https://github.com/karalabe/xgo/blob/master/README.md When using branch or remote selection, the default Go path might fail to locate the desired package. The `--pkg` parameter allows specifying an exact package path within a repository root, honoring prior branch and remote selections. The example compiles `cmd/goimports` from the `golang.org/x/tools` repository. ```shell $ xgo --pkg cmd/goimports golang.org/x/tools ``` -------------------------------- ### Customize xgo Output File Prefix Source: https://github.com/karalabe/xgo/blob/master/README.md Learn how to use the `-out` flag to override the default output file prefix for cross-compiled binaries. This allows specifying a custom name for the generated executables across various platforms. The example demonstrates compiling the `github.com/project-iris/iris` package and naming the output files `iris-v0.3.2`. ```shell $ xgo -out iris-v0.3.2 github.com/project-iris/iris ``` -------------------------------- ### Limit xgo Cross-Compilation Targets Source: https://github.com/karalabe/xgo/blob/master/README.md `xgo` by default builds for all supported platforms and architectures. This snippet demonstrates how to use the comma-separated `--targets` CLI argument to restrict the build to only a few target systems. Examples include building for specific OS/architecture combinations, all architectures for a given OS, or a specific architecture across all OSes. Supported platforms are `android`, `darwin`, `ios`, `linux`, `windows`, and architectures are `386`, `amd64`, `arm-5`, `arm-6`, `arm-7`, `arm64`, `mips`, `mipsle`, `mips64`, `mips64le`. ```shell xgo --targets=linux/arm golang.org/x/tools/cmd/goimports xgo --targets=windows/*,darwin/* golang.org/x/tools/cmd/goimports xgo --targets=*/arm golang.org/x/tools/cmd/goimports xgo --targets=*/* golang.org/x/tools/cmd/goimports ``` -------------------------------- ### Inject iOS Simulator SDK for Mobile Libraries Source: https://github.com/karalabe/xgo/blob/master/README.md Instructions for extending the `xgo` Docker image to include the iOS Simulator SDK. This enables `xgo` to bundle x86_64 simulator builds for iOS frameworks in addition to the default armv7 and arm64 architectures. ```Dockerfile FROM karalabe/xgo-latest ADD iPhoneSimulator9.3.sdk.tar.xz /iPhoneSimulator9.3.sdk.tar.xz $UPDATE_IOS /iPhoneSimulator9.3.sdk.tar.xz ``` -------------------------------- ### Pull xgo Docker Image Source: https://github.com/karalabe/xgo/blob/master/README.md This command downloads the pre-built xgo Docker container from Docker's container registry. It's the first step to using xgo without manual container building. ```Shell docker pull karalabe/xgo-latest ``` -------------------------------- ### Specify Target Platform Versions with xgo Source: https://github.com/karalabe/xgo/blob/master/README.md Demonstrates how to use the `--targets` argument with `xgo` to cross-compile binaries for specific operating system versions, ensuring compatibility with newer system dependencies. This allows targeting the lowest possible versions for portability or higher versions for specific dependency support. ```Shell xgo --targets=ios-8.1/* xgo --targets=android-16/* xgo --targets=darwin-10.9/* xgo --targets=windows-6.0/* ``` -------------------------------- ### Specify Remote Repository for xgo Compilation Source: https://github.com/karalabe/xgo/blob/master/README.md This section explains how to use the `--remote` argument to switch to a different repository remote while preserving the original import path. This is useful when the desired source code is hosted on a different remote than the one implied by the import path. ```shell $ xgo --remote github.com/golang/tools golang.org/x/tools/cmd/goimports ``` -------------------------------- ### Cross-Compile with Specific Go Release Source: https://github.com/karalabe/xgo/blob/master/README.md xgo supports compiling with different Go releases. Use the '-go' flag to specify a particular Go version, such as '1.6.1', 'latest', or 'develop', to ensure compatibility or leverage specific language features. ```Shell $ xgo -go 1.6.1 github.com/project-iris/iris ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.