Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f65bd1

Browse files
authored
fix: ignore surronding whitespace for cli config (#12250)
* fix: ignore surronding whitespace for cli configCli config files break if you edit them manually with any editor.Editors drop a newline at the end, and we not break on this.If a developer manually edits a file, it should still work
1 parent475c365 commit3f65bd1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎cli/config/file.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"io"
55
"os"
66
"path/filepath"
7+
"strings"
78

89
"github.com/kirsle/configdir"
910
"golang.org/x/xerrors"
@@ -85,13 +86,14 @@ func (f File) Write(s string) error {
8586
returnwrite(string(f),0o600, []byte(s))
8687
}
8788

88-
// Read reads the file to a string.
89+
// Read reads the file to a string. All leading and trailing whitespace
90+
// is removed.
8991
func (fFile)Read() (string,error) {
9092
iff=="" {
9193
return"",xerrors.Errorf("empty file path")
9294
}
9395
byt,err:=read(string(f))
94-
returnstring(byt),err
96+
returnstrings.TrimSpace(string(byt)),err
9597
}
9698

9799
// open opens a file in the configuration directory,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp