From 41620e6383a8767e5ef1bafdbefaa5bee8aeff38 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 7 Jul 2021 12:52:47 +0200 Subject: [PATCH] list: use homedir rather than os/user Signed-off-by: Andrea Luzzardi --- cmd/dagger/cmd/list.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/dagger/cmd/list.go b/cmd/dagger/cmd/list.go index ea29b2a5..e19589cf 100644 --- a/cmd/dagger/cmd/list.go +++ b/cmd/dagger/cmd/list.go @@ -3,11 +3,11 @@ package cmd import ( "fmt" "os" - "os/user" "path" "strings" "text/tabwriter" + "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" "github.com/spf13/viper" "go.dagger.io/dagger/cmd/dagger/cmd/common" @@ -48,14 +48,12 @@ var listCmd = &cobra.Command{ } func formatPath(p string) string { - usr, err := user.Current() + dir, err := homedir.Dir() if err != nil { // Ignore error return p } - dir := usr.HomeDir - if strings.HasPrefix(p, dir) { return path.Join("~", p[len(dir):]) }