From ecd29d7d7d42ae4726bfd46cc214df2953f56f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Sat, 2 Apr 2022 03:42:44 +0200 Subject: [PATCH] generator: use filepath.IsAbs to check for absolute paths The implementation of filepath.IsAbs also checks for a string prefix so this doesn't entail any functional changes but seems a bit cleaner IMHO. --- generator/generator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generator/generator.go b/generator/generator.go index d198a5a6..0fedda51 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -5,7 +5,7 @@ import ( "fmt" "net" "os" - "strings" + "path/filepath" "time" "github.com/cavaliergopher/cpio" @@ -247,7 +247,7 @@ func (img *Image) appendInitBinary(initBinary string) error { func (img *Image) appendExtraFiles(binaries []string) error { for _, f := range binaries { - if !strings.HasPrefix(f, "/") { + if !filepath.IsAbs(f) { // simple names like "strace" are resolved as binaries under /usr/bin f = "/usr/bin/" + f }