aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/kisielk/gotool/internal/load/path.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey@google.com>2018-02-11 21:43:56 -0800
committerGitHub <noreply@github.com>2018-02-11 21:43:56 -0800
commit8b6cbfcca9d1f3fb5b05a91b4ac0bca66f75f19e (patch)
tree5f6fdc40c7518bc23a63fdac9a92b516dd0c6d36 /vendor/github.com/kisielk/gotool/internal/load/path.go
parentaebae1aae2fc61185a8bbc96313d8462727ad202 (diff)
parentb330463662825a7d7b22efabb2b7a40640d2b18e (diff)
Merge pull request #85 from google/depfix
Complete the new Build System
Diffstat (limited to 'vendor/github.com/kisielk/gotool/internal/load/path.go')
-rw-r--r--vendor/github.com/kisielk/gotool/internal/load/path.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/kisielk/gotool/internal/load/path.go b/vendor/github.com/kisielk/gotool/internal/load/path.go
new file mode 100644
index 0000000..74e15b9
--- /dev/null
+++ b/vendor/github.com/kisielk/gotool/internal/load/path.go
@@ -0,0 +1,27 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.9
+
+package load
+
+import (
+ "strings"
+)
+
+// hasPathPrefix reports whether the path s begins with the
+// elements in prefix.
+func hasPathPrefix(s, prefix string) bool {
+ switch {
+ default:
+ return false
+ case len(s) == len(prefix):
+ return s == prefix
+ case len(s) > len(prefix):
+ if prefix != "" && prefix[len(prefix)-1] == '/' {
+ return strings.HasPrefix(s, prefix)
+ }
+ return s[len(prefix)] == '/' && s[:len(prefix)] == prefix
+ }
+}