Go has a bunch of handy tools in its link tool that allow us to pass pertinent data to an executable function. With this tool, the programmer has the ability to set a value for a string with a particular name and value pair. Using the cmd/link package in Go allows you to pass in information to the Go program at hand at link time. The way to pass this information from the toolchain to the executable is to utilize the build parameter:
go build -ldflags '-X importpath.name=value'
For example, if we were trying to take in a serial number for our program from the command line, we could do something like the following:
package main
import (
"fmt"
)
var SerialNumber = "unlicensed"
func main() {
if SerialNumber == "ABC123" {
fmt.Println("Valid Serial Number!")
} else {
fmt.Println("Invalid Serial Number"...