mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-07 08:26:53 +00:00
* 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>
24 lines
430 B
Go
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
|
|
}
|