diff --git a/cli/config/file.go b/cli/config/file.go index 9d8b8b34a0..908af1aac8 100644 --- a/cli/config/file.go +++ b/cli/config/file.go @@ -4,6 +4,7 @@ import ( "io" "os" "path/filepath" + "strings" "github.com/kirsle/configdir" "golang.org/x/xerrors" @@ -85,13 +86,14 @@ func (f File) Write(s string) error { return write(string(f), 0o600, []byte(s)) } -// Read reads the file to a string. +// Read reads the file to a string. All leading and trailing whitespace +// is removed. func (f File) Read() (string, error) { if f == "" { return "", xerrors.Errorf("empty file path") } byt, err := read(string(f)) - return string(byt), err + return strings.TrimSpace(string(byt)), err } // open opens a file in the configuration directory,