diff options
Diffstat (limited to 'utils/string.go')
-rw-r--r-- | utils/string.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/utils/string.go b/utils/string.go new file mode 100644 index 0000000..b3cbb17 --- /dev/null +++ b/utils/string.go @@ -0,0 +1,14 @@ +package utils + +import ( + "fmt" + "strings" +) + +func Unprefix(path string, prefix string) (string, error) { + if !strings.HasPrefix(path, prefix) { + return path, fmt.Errorf("%q is not prefixed by %q", path, prefix) + } else { + return path[len(prefix):], nil + } +} |