aboutsummaryrefslogtreecommitdiff
path: root/utils/string.go
blob: b3cbb17b8a2fbdc24502ee905b94ed05a8c58cf0 (plain)
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
	}
}