diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-06-10 00:15:26 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-06-10 00:15:26 +0200 |
| commit | 219586ede723e7b2161d37169ff9c3e9831a7c66 (patch) | |
| tree | cdd72e5d75af71fd55961f676718cec6486c1a32 | |
| parent | daeb9127764fc9dd469294f755e277fdfca09a00 (diff) | |
| download | gofu-da0759c7d772ee96e4270d107572a6418832e186.tar.gz | |
run `go fix ./...`v2026.1
| -rw-r--r-- | internal/prompt/pwd.go | 12 | ||||
| -rw-r--r-- | internal/rtree/index.go | 9 |
2 files changed, 10 insertions, 11 deletions
diff --git a/internal/prompt/pwd.go b/internal/prompt/pwd.go index b549a39..e10da84 100644 --- a/internal/prompt/pwd.go +++ b/internal/prompt/pwd.go @@ -9,7 +9,7 @@ import ( "strings" ) -//Directory contains all data about a directory that the prompt needs. +// Directory contains all data about a directory that the prompt needs. type Directory struct { Path string DisplayPath string //formatted for display in prompt line @@ -20,8 +20,7 @@ type Directory struct { NearestAccessiblePath string } -//CurrentDirectory prepares a Directory struct for the current working -//directory. +// CurrentDirectory prepares a Directory struct for the current working directory. func CurrentDirectory() Directory { cwd, err := os.Getwd() if err != nil { @@ -30,7 +29,7 @@ func CurrentDirectory() Directory { return NewDirectory(cwd) } -//NewDirectory prepares a Directory struct for the given path. +// NewDirectory prepares a Directory struct for the given path. func NewDirectory(path string) (dir Directory) { dir.Path = path dir.DisplayPath = path @@ -82,7 +81,7 @@ func NewDirectory(path string) (dir Directory) { return } -//This part can benefit from a "return" in the middle, so it's in a separate function. +// This part can benefit from a "return" in the middle, so it's in a separate function. func (dir *Directory) stripHomeDirFromDisplay() { if !strings.HasPrefix(dir.DisplayPath, "/") { return @@ -129,8 +128,7 @@ func getDirectoryField(dir Directory, tt *TerminalTitle) string { //cwd accessible -> highlight path elements inside the repo (if any) if dir.Repo != nil && dir.Repo.RootPath != dir.Path { rel, _ := filepath.Rel(dir.Repo.RootPath, dir.Path) - if strings.HasSuffix(dir.DisplayPath, rel) { - base := strings.TrimSuffix(dir.DisplayPath, rel) + if base, ok := strings.CutSuffix(dir.DisplayPath, rel); ok { txt = withColor("0;36", base) + withColor("1;36", rel) } } diff --git a/internal/rtree/index.go b/internal/rtree/index.go index 1432161..549b51c 100644 --- a/internal/rtree/index.go +++ b/internal/rtree/index.go @@ -312,12 +312,13 @@ func (i *Index) FindRepo(rawRemoteURL string, allowClone bool) (*Repo, error) { } //report the existing remotes, and ask for the name of the new remote - prompt := "Existing remotes:\n" + var prompt strings.Builder + prompt.WriteString("Existing remotes:\n") for remoteName, remote := range target.Remotes { - prompt += fmt.Sprintf("\t(%s) %s\n", remoteName, strings.Join(remote.CompactURLs(), " ")) + fmt.Fprintf(&prompt, "\t(%s) %s\n", remoteName, strings.Join(remote.CompactURLs(), " ")) } - prompt += fmt.Sprintf("Enter remote name for %s:", remoteURL) - remoteName, err := cli.Interface.ReadLine(prompt) + fmt.Fprintf(&prompt, "Enter remote name for %s:", remoteURL) + remoteName, err := cli.Interface.ReadLine(prompt.String()) if err != nil { return nil, err } |
