Skip to content

Commit

Permalink
fix shell script for blog (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei committed Dec 24, 2023
1 parent 841799a commit ed67c56
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions marketing/content/blog/setting-go-version-information.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func main() {
}
```

## Using ldflags to insert Version Information
## Using ldflags to Insert Version Information

Now is the fun part, actually inserting the build information!
This is done by providing the `-X` flag to the `-ldflags` parameter.
Expand All @@ -129,8 +129,7 @@ BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
GIT_COMMIT="$(git rev-parse HEAD)"
VERSION="$(git describe --tags --abbrev=0 | tr -d '\n')"

go build -ldflags="-X 'github.com/example/internal/version.buildDate=$(BUILD_DATE)' -X 'github.com/example/internal/version.gitCommit=${GIT_COMMIT}' -X 'github.com/example/internal/version.gitVersion=${VERSION}'" *.go

go build -o bin/main -ldflags="-X 'github.com/example/internal/version.buildDate=${BUILD_DATE}' -X 'github.com/example/internal/version.gitCommit=${GIT_COMMIT}' -X 'github.com/example/internal/version.gitVersion=${VERSION}'" *.go
```

For success, make sure that your repo has at least one git tag.
Expand Down

1 comment on commit ed67c56

@vercel
Copy link

@vercel vercel bot commented on ed67c56 Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.