1 2 3 4 5 6 7 8 9 10 11 12 13 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 } }