{"id":16587087,"url":"https://github.com/zchee/go-tips","last_synced_at":"2025-10-29T08:50:18.306Z","repository":{"id":77304678,"uuid":"70449689","full_name":"zchee/go-tips","owner":"zchee","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-23T05:58:23.000Z","size":19,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T19:49:22.030Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zchee.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-10-10T03:45:26.000Z","updated_at":"2019-11-21T22:46:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec9106a5-e783-494a-b5a7-bd81f04067d7","html_url":"https://github.com/zchee/go-tips","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/zchee%2Fgo-tips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zchee%2Fgo-tips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zchee%2Fgo-tips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zchee%2Fgo-tips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zchee","download_url":"https://codeload.github.com/zchee/go-tips/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242176115,"owners_count":20084519,"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-11T22:53:16.218Z","updated_at":"2025-10-29T08:50:18.187Z","avatar_url":"https://github.com/zchee.png","language":null,"readme":"Go Tips\n=======\n\nmultiple `-extldflags` arguments\n--------------------------------\n\n### Q:\n\n`-extldflags` is must be including `-ldflags` build flag.  \nBut if execute the `go build ...` command use some script(such as `Makefile`), sometimes failed go's `link` linker with below error.\n\n```sh\nflag provided but not defined: -fooflag'\n```\n\nbuild command is here.\n\n```sh\ngo bulid -ldflags=\"-w -s -extldflags='-static -fooflag' example.com/john/doe\"\n```\n\nHowever, will successful with `-extldflags=-static`.\n\n### A:\n\nIn this case, go `link` linker will recognizes `link -fooflag -extldflags='-static`.  \nTo be cleared, `link` passes flags to `extld` command(such as `ld`) `-static` only.\n\nAs in the [golang/go/issues/6234](https://github.com/golang/go/issues/6234) and [docker-library/golang/issues/152](https://github.com/docker-library/golang/issues/152), need\n\n```sh\n#  -d\tdisable dynamic executable\n#  -s\tdisable symbol table\n#  -w\tdisable DWARF generation\n\ngo build -ldflags=\"-d -s -w '-extldflags=-static'\" example.com/john/doe\n```\n\nActually, We must be bracketed to `-extldflags=...` by a comma(`'`).  \nAfter that, will passes all flags to C linker. Try and check with add `-v` to `-extldflags`.\n\nAvailable`#cgo` magic comment\n-----------------------------\n\nGo version: `devel +334cbe3 Sun Oct 9 22:50:12 2016 +0000`  \ndefined in `$GOROOT/src/go/build/build.go.saveCgo()` switch cases, available\n\n```sh\nCFLAGS\nCPPFLAGS\nCXXFLAGS\nFFLAGS\nLDFLAGS\npkg-config\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzchee%2Fgo-tips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzchee%2Fgo-tips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzchee%2Fgo-tips/lists"}