From 8218e45cbcc756333bee6b6245ef5a4c2aaa273f Mon Sep 17 00:00:00 2001 From: James Nugent Date: Wed, 17 May 2017 20:48:12 -0400 Subject: Add "replaceAll" function and documentation This commit adds a `replaceAll` function which takes three arguments - an original string, the substring to replace, and the string with which to replace it. This is of particular use when generating node names from IP addresses where the node name may not contain "." characters. --- stringfunc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 stringfunc.go (limited to 'stringfunc.go') diff --git a/stringfunc.go b/stringfunc.go new file mode 100644 index 00000000..ff51b80a --- /dev/null +++ b/stringfunc.go @@ -0,0 +1,10 @@ +package main + +import "strings" + +// stringFunc - string manipulation function wrappers +type stringFunc struct{} + +func (t stringFunc) replaceAll(old, new, s string) string { + return strings.Replace(s, old, new, -1) +} -- cgit v1.2.3