Artwork

Content provided by Dominic St-Pierre. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Dominic St-Pierre or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

009: Set variables at build time with -LDFLAGS

15:27
 
Share
 

Manage episode 337350769 series 3302141
Content provided by Dominic St-Pierre. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Dominic St-Pierre or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

Usage of -ldflags:

go build -ldflags "-X main.varName=from_build" -o mycli

Inside your code:

var varName string

func main() {
fmt.Println(varName) // prints "from_build"
}

Here's what I'm using for StaticBackend -v flag:

go build -ldflags \
"-X github.com/staticbackendhq/core/config.BuildTime=$(shell date +'%Y-%m-%d.%H:%M:%S') \
-X github.com/staticbackendhq/core/config.CommitHash=$(shell git log --pretty=format:'%h' -n 1) \
-X github.com/staticbackendhq/core/config.Version=$(shell git describe --tags)" \
-o staticbackend

Links:

  continue reading

39 episodes

Artwork
iconShare
 
Manage episode 337350769 series 3302141
Content provided by Dominic St-Pierre. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Dominic St-Pierre or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

Usage of -ldflags:

go build -ldflags "-X main.varName=from_build" -o mycli

Inside your code:

var varName string

func main() {
fmt.Println(varName) // prints "from_build"
}

Here's what I'm using for StaticBackend -v flag:

go build -ldflags \
"-X github.com/staticbackendhq/core/config.BuildTime=$(shell date +'%Y-%m-%d.%H:%M:%S') \
-X github.com/staticbackendhq/core/config.CommitHash=$(shell git log --pretty=format:'%h' -n 1) \
-X github.com/staticbackendhq/core/config.Version=$(shell git describe --tags)" \
-o staticbackend

Links:

  continue reading

39 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide