From 7f5982e70846216891ab7b133f1c1f5c5e015e5e Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Mon, 1 Jan 2024 16:31:06 -0800 Subject: [PATCH] code-generator: Remove now unused helper function --- .../k8s.io/code-generator/pkg/util/build.go | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/staging/src/k8s.io/code-generator/pkg/util/build.go b/staging/src/k8s.io/code-generator/pkg/util/build.go index 53f93afe349..1cf4bbfcb92 100644 --- a/staging/src/k8s.io/code-generator/pkg/util/build.go +++ b/staging/src/k8s.io/code-generator/pkg/util/build.go @@ -17,40 +17,9 @@ limitations under the License. package util import ( - gobuild "go/build" - "path/filepath" "strings" ) -// CurrentPackage returns the go package of the current directory, or "" if it cannot -// be derived from the GOPATH. -func CurrentPackage() string { - for _, root := range gobuild.Default.SrcDirs() { - if pkg, ok := hasSubdir(root, "."); ok { - return pkg - } - } - return "" -} - -func hasSubdir(root, dir string) (rel string, ok bool) { - // ensure a tailing separator to properly compare on word-boundaries - const sep = string(filepath.Separator) - root = filepath.Clean(root) - if !strings.HasSuffix(root, sep) { - root += sep - } - - // check whether root dir starts with root - dir = filepath.Clean(dir) - if !strings.HasPrefix(dir, root) { - return "", false - } - - // cut off root - return filepath.ToSlash(dir[len(root):]), true -} - // Vendorless trims vendor prefix from a package path to make it canonical func Vendorless(p string) string { if pos := strings.LastIndex(p, "/vendor/"); pos != -1 {