Golang Inject Build Time Variable
Clavin June

Clavin June @clavinjune

About: a bunch of perceptrons

Location:
Jakarta, Indonesia
Joined:
Oct 5, 2018

Golang Inject Build Time Variable

Publish Date: May 1 '22
8 0

Sunday Snippet #15 golang inject build time variable

package main

import . "fmt"

var foo = "not injected"

func main() {
    Println(foo)
}
Enter fullscreen mode Exit fullscreen mode
$ go run main.go
not injected
$ go run -ldflags "-X main.foo=injected" main.go
injected
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment