{"id":16939856,"url":"https://github.com/fd0/build-go","last_synced_at":"2025-04-11T19:21:02.589Z","repository":{"id":136285822,"uuid":"75466549","full_name":"fd0/build-go","owner":"fd0","description":"build.go - Program for building Go binaries without a GOPATH","archived":false,"fork":false,"pushed_at":"2019-07-29T07:24:16.000Z","size":25,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T15:13:36.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fd0.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":"2016-12-03T10:13:28.000Z","updated_at":"2024-04-01T16:38:38.000Z","dependencies_parsed_at":"2023-04-09T03:34:28.697Z","dependency_job_id":null,"html_url":"https://github.com/fd0/build-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fbuild-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fbuild-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fbuild-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fbuild-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fd0","download_url":"https://codeload.github.com/fd0/build-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465348,"owners_count":21108244,"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-10-13T21:05:38.813Z","updated_at":"2025-04-11T19:21:02.583Z","avatar_url":"https://github.com/fd0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repository contains a small and self-contained Go program called\n`build.go`. It used to compile a binary (package `main`) from either a checkout\nof the repository, or from an extracted release tar file. This enables\nend-users to compile the program without having to setup a `GOPATH`.\n\nFor it to function correctly, all dependencies need to be vendored, e.g. with\n`dep` or `go mod vendor`. Then, your build does not depend on any third-party\nresources on the Internet. For Go \u003e= 1.11, modules are used for building and\n`GOPROXY` is set to `off` so that no Internet is needed when building.\n\nThe program has a build tag that is not set normally (`ignore_build_go`) so it\nis not considered when compiling the other Go code in a repository.\n\nUsage\n=====\n\nIn order to use it, copy `build.go` to the root level into your repository and\nedit the configuration section at the top. You can see an example in the\n[restic repository](https://github.com/restic/restic/blob/master/build.go).\n\nInstruct your users to call `go run build.go` and it will produce a binary from\neither a checkout of the repository or from an extracted release tar file. For\nGo 1.11, it needs to be called as `go run -mod=vendor build.go` so that no\nnetwork access is needed.\n\nFor cross-compilation, the options `--goos` and `--goarch` can be used, e.g.\nlike this:\n```\n$ go run build.go --goos windows --goarch 386\n```\n\nThe tests can be run by specifying `--test`. By default, `cgo` is explicitly\ndisabled by passing `CGO_ENABLED=0` to `go build`, it can be re-enabled\nmanually by running `go run build.go --enable-cgo`.\n\nThe program will set the string variable `version` in package `main` to a\nversion string consisting of the contents of the file `VERSION` (if present)\nand the output of `git describe` (if available).\n\nThe version string can then be used e.g. in a `version` command, like with\nrestic:\n```\n$ ./restic version\nrestic 0.8.1 (v0.8.1-154-g74665a22)\n```\n\nThe version string consists of:\n * The contents of the `VERSION` file: `0.8.1`\n * The nearest tag (`v0.8.1`), the number of commits (`154`) and the Git commit hash (`74665a22`)\n\nBackground\n==========\n\nThe program `build.go` constructs a temporary `GOPATH` (for Go \u003c 1.11, or when\nno `go.mod` exists) in a temporary directory as configured at the beginning of\nthe program, then calls `go build` using the temporary `GOPATH`. This means\nthat end-users do not have to setup a `GOPATH` of their own.\n\nTesting\n=======\n\nThe tests need to be run with the build tag `ignore_build_go` set:\n```\n$ go test -tags ignore_build_go\nPASS\nok  \tgithub.com/fd0/build-go\t0.001s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffd0%2Fbuild-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffd0%2Fbuild-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffd0%2Fbuild-go/lists"}