Using the -ldflags parameter can help set variable values at compile time.
Using the example provided here:
- Running make buildwill create abuildexecutable. Running it will result in:
$> ./build
no version (Mon YYYY)
$>Using the -ldflags parameter can help set variable values at compile time.
Using the example provided here:
make build will create a build executable. Running it will result in:$> ./build
no version (Mon YYYY)
$>| #!/usr/bin/env bash | |
| # fork from https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f | |
| changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)" | |
| check_run() { | |
| echo "$changed_files" | grep --quiet "$1" && eval "$2" | |
| } | |
| check_run package.json "npm prune && npm install" | 
| --[[ json.lua | |
| A compact pure-Lua JSON library. | |
| The main functions are: json.stringify, json.parse. | |
| ## json.stringify: | |
| This expects the following to be true of any tables being encoded: | |
| * They only have string or number keys. Number keys must be represented as | |
| strings in json; this is part of the json spec. | 
| #!/bin/bash -eu | |
| # Quote a single- or multi-line string for use in git's aliases | |
| # Copyright (c) 2016 Tom Hale under https://en.wikipedia.org/wiki/MIT_License | |
| quote() { | |
| printf %s "$1" | sed -r 's/(["\\])/\\\1/g'; | |
| } | |
| IFS=$(printf '\n') | 
| #!/usr/bin/env bash | |
| #copy this in a folder from path ex: /usr/local/bin | |
| #usage: docker-machine-rename default my-default | |
| # Authors | |
| # | |
| # alexproca initial script | |
| # eurythmia sed magic | 
| #!/bin/bash | |
| # | |
| #script to make it easier to git cherry-pick the latest commit to another branch | |
| numCommits=1 # but we can cherry-pick more than one if needs be | |
| red="\033[1;31m" | |
| norm="\033[0;39m" | |
| grey="\033[0;37m" | |
| green="\033[0;32m" | 
| package main | |
| import "fmt" | |
| import "bufio" | |
| import "os" | |
| func main() { | |
| f, _ := os.Create("outputgo.txt") | |
| reader := bufio.NewReader(os.Stdin) | |
| for { | |
| line, err := reader.ReadString('\n') | 
| #!/bin/sh | |
| # | |
| # a simple way to parse shell script arguments | |
| # | |
| # please edit and use to your hearts content | |
| # | |
| ENVIRONMENT="dev" | 
| function reverseFormatNumber(val,locale){ | |
| var parts = new Intl.NumberFormat(locale).formatToParts(1111.1); | |
| var group = parts.find(part => part.type === 'group').value; | |
| var decimal = parts.find(part => part.type === 'decimal').value; | |
| var reversedVal = val.replace(new RegExp('\\' + group, 'g'), ''); | |
| reversedVal = reversedVal.replace(new RegExp('\\' + decimal, 'g'), '.'); | |
| return Number.isNaN(reversedVal)?0:+reversedVal; | |
| } | |
| console.log(reverseFormatNumber('1,234.56','en')); | 
The set lines
set -euxo pipefail is short for:set -e
set -u