{"id":20532457,"url":"https://github.com/joshdk/meta","last_synced_at":"2026-05-27T21:31:59.029Z","repository":{"id":46616751,"uuid":"406966896","full_name":"joshdk/meta","owner":"joshdk","description":"✨ Common application metadata for use with go build and ldflags","archived":false,"fork":false,"pushed_at":"2021-10-21T01:55:48.000Z","size":65,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-11T12:24:39.498Z","etag":null,"topics":["go","golang","golang-library","hacktoberfest","ldflags","metadata"],"latest_commit_sha":null,"homepage":"https://jdk.sh/meta","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/joshdk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-16T00:44:39.000Z","updated_at":"2025-08-15T01:39:25.000Z","dependencies_parsed_at":"2022-08-31T13:21:00.190Z","dependency_job_id":null,"html_url":"https://github.com/joshdk/meta","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/joshdk/meta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fmeta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fmeta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fmeta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fmeta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshdk","download_url":"https://codeload.github.com/joshdk/meta/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fmeta/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33585203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","golang","golang-library","hacktoberfest","ldflags","metadata"],"created_at":"2024-11-16T00:15:00.672Z","updated_at":"2026-05-27T21:31:59.005Z","avatar_url":"https://github.com/joshdk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License][license-badge]][license-link]\n[![Go Reference][godoc-badge]][godoc-link]\n[![Go Report Card][goreportcard-badge]][goreportcard-link]\n[![Actions][github-actions-badge]][github-actions-link]\n[![Releases][github-release-badge]][github-release-link]\n\n# Go Build Metadata\n\n✨ Common application metadata for use with go build and ldflags\n\n## Motivations\n\nThe Go toolchain has a feature where you can specify the value for a named\nvariable at `go build`-time on the command line, and that value will be embedded\ninto that variable in the resulting binary.\n\nThis feature is primarily used for embedding a version string or git SHA, so\nthat the provenance of the resulting binary can be traced back to the exact ref\nfrom which it was produced.\n\nSee [this blog post from Cloudflare](https://blog.cloudflare.com/setting-go-variables-at-compile-time)\nfor an introduction.\n\nThis library provides three things:\n\n1. A number of appropriately named variables that can accept values when\n   running `go build`.\n2. The automatic conversion of string values into complex types (like\n   `url.URL`) where appropriate.\n3. Public functions for retrieving these typed values.\n\nThis library also has the capacity to accept a wide variety of relevant build\nvalues, and uses a short import path so that they can be succinctly configured\nas part of a `go build` command.\n\n## Installing\n\nThis library can be installed by running:\n\n```shell\ngo get -u jdk.sh/meta\n```\n\n## Usage\n\n### Example\n\nCreate a `main.go` file containing the following:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"jdk.sh/meta\"\n)\n\nfunc main() {\n    fmt.Println(\n        \"version\", meta.Version(),\n        \"built on\", meta.Date(),\n    )\n}\n```\n\nBuild your `main.go` into a binary using `go build`. Notice the usage of\n`-ldflags`, specifying values for the variables `jdk.sh/meta.version` and\n`jdk.sh/meta.date`:\n\n```shell\ngo build -ldflags \"\\\n    -X 'jdk.sh/meta.version=v1.2.3' \\\n    -X 'jdk.sh/meta.date=$(date -R)' \\\n  \" main.go\n```\n\nFinally, execute the program and observe that the given values are now \"baked\"\ninto the resulting binary:\n\n```shell\n./main\nversion v1.2.3 built on 2019-08-23 18:00:00 +0000 UTC\n```\n\n### Variables\n\n| Name                      | Purpose                                                                                                                                                                                        |\n| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `jdk.sh/meta.author`      | The name of the application author. May contain their name, email address, or optionally both.                                                                                                 |\n| `jdk.sh/meta.author_url`  | URL for the application author. Typically links to the author's personal homepage or Github profile.                                                                                           |\n| `jdk.sh/meta.copyright`   | The copyright for the application. Typically the name if the author or organization, sometimes prefixed with a year or year range.                                                             |\n| `jdk.sh/meta.date`        | The time that the application was built. Supports several common formats.                                                                                                                      |\n| `jdk.sh/meta.desc`        | Description for the application. Typically a longer statement describing what the application does.                                                                                            |\n| `jdk.sh/meta.dev`         | The development status for the application. An application in development mode may indicate that it's using experimental or untested features, and should be used with caution.                |\n| `jdk.sh/meta.docs`        | URL for application documentation. Typically links to a page where a user can find technical documentation.                                                                                    |\n| `jdk.sh/meta.license`     | The license identifier for the application. Should not the full license body, but one of the identifiers from https://spdx.org/licenses, so that the type of license can be easily determined. |\n| `jdk.sh/meta.license_url` | URL for the application license. Typically links to a page where the verbatim license body is available.                                                                                       |\n| `jdk.sh/meta.name`        | The name of the application. Typically named the same as the binary, or for display in an error or help message.                                                                               |\n| `jdk.sh/meta.note`        | An arbitrary message for the application. Can be used to store a message about the build environment, release, etc.                                                                            |\n| `jdk.sh/meta.sha`         | Git SHA that was used to build the application. A 40 character \"long\" SHA should be provided.                                                                                                  |\n| `jdk.sh/meta.src`         | URL for the application source code. Typically links to a repository where a user can browse or clone the source code.                                                                         |\n| `jdk.sh/meta.title`       | The title of the application. Typically a full or non-abbreviated form of the application name.                                                                                                |\n| `jdk.sh/meta.url`         | URL for the application homepage. Typically links to a page where a user can learn more about the application.                                                                                 |\n| `jdk.sh/meta.version`     | The version slug for the application. The value can be used to point back to a specific tag or release. Supports semver, see https://semver.org.                                               |\n\n## License\n\nThis code is distributed under the [MIT License][license-link], see [LICENSE.txt][license-file] for more information.\n\n[github-actions-badge]:  https://github.com/joshdk/meta/workflows/Build/badge.svg\n[github-actions-link]:   https://github.com/joshdk/meta/actions\n[github-release-badge]:  https://img.shields.io/github/release/joshdk/meta/all.svg\n[github-release-link]:   https://github.com/joshdk/meta/releases\n[godoc-badge]:           https://pkg.go.dev/badge/jdk.sh/meta.svg\n[godoc-link]:            https://pkg.go.dev/jdk.sh/meta\n[goreportcard-badge]:    https://goreportcard.com/badge/jdk.sh/meta\n[goreportcard-link]:     https://goreportcard.com/report/jdk.sh/meta\n[license-badge]:         https://img.shields.io/badge/license-MIT-green.svg\n[license-file]:          https://github.com/joshdk/meta/blob/master/LICENSE.txt\n[license-link]:          https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshdk%2Fmeta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshdk%2Fmeta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshdk%2Fmeta/lists"}