1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 08:26:53 +00:00
kyverno/cmd/cli/kubectl-kyverno/path/path.go
shuting fb9c66f455
feat(perf): add new linter prealloc to enforce slice declarations best practice (#10250)
* feat(perf): add new linter prealloc to enforce slice declarations best practice

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* fix(linter): prealloac slices

Signed-off-by: ShutingZhao <shuting@nirmata.com>

---------

Signed-off-by: ShutingZhao <shuting@nirmata.com>
2024-05-20 14:46:35 +05:30

24 lines
430 B
Go

package path
import (
"path/filepath"
)
func GetFullPath(path string, basePath string) string {
if !filepath.IsAbs(path) {
return filepath.Join(basePath, path)
} else {
return path
}
}
func GetFullPaths(paths []string, basePath string, git bool) []string {
if git {
return paths
}
out := make([]string, 0, len(paths))
for _, path := range paths {
out = append(out, GetFullPath(path, basePath))
}
return out
}