strings

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseExpression

func ParseExpression(template string, context map[string]string) string

ParseExpression parses a string template with variables in the format ${myVariable} and uses values from the context map to replace them. The resulting string is the template string with replaced values.

Example
template := "{name} was born in {dob} in {location}. {name} hair is {hairColor}."
context := map[string]string{
	"dob":       "01/08/1956",
	"hairColor": "black",
	"location":  "Japan",
	"name":      "John",
}
fmt.Println(ParseExpression(template, context))
Output:

John was born in 01/08/1956 in Japan. John hair is black.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL