const operator … const referenceOpener … const referenceCloser … // syntaxWrap returns the input string wrapped by the expansion syntax. func syntaxWrap(input string) string { … } type MappingFunc … // MakePrimitiveReplacer returns a MappingFunc that uses a map to do // replacements, and a histogram to count map hits. // // Func behavior: // // If the input key is NOT found in the map, the key is wrapped up as // as a variable declaration string and returned, e.g. key FOO becomes $(FOO). // This string is presumably put back where it was found, and might get replaced // later. // // If the key is found in the map, the value is returned if it is a primitive // type (string, bool, number), and the hit is counted. // // If it's not a primitive type (e.g. a map, struct, func, etc.) then this // function doesn't know what to do with it and it returns the key wrapped up // again as if it had not been replaced. This should probably be an error. func MakePrimitiveReplacer( counts map[string]int, someMap map[string]interface{ … } // DoReplacements replaces variable references in the input string // using the mapping function. func DoReplacements(input string, mapping MappingFunc) interface{ … } // tryReadVariableName attempts to read a variable name from the input // string and returns the content read from the input, whether that content // represents a variable name to perform mapping on, and the number of bytes // consumed in the input string. // // The input string is assumed not to contain the initial operator. func tryReadVariableName(input string) (string, bool, int) { … }