aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2016-02-28 15:52:49 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2016-02-29 03:31:19 +0000
commit351c15f1cee364a91ef606ef9114d55247a6a0c2 (patch)
tree8dcea615817f3a640786e55a4ebcfe75306abe77 /src/os/exec
parent28ce6f3600fd87a1ae39c492ee56307f0be3c32f (diff)
downloadgo-351c15f1cee364a91ef606ef9114d55247a6a0c2.tar.xz
all: remove public named return values when useless
Named returned values should only be used on public funcs and methods when it contributes to the documentation. Named return values should not be used if they're only saving the programmer a few lines of code inside the body of the function, especially if that means there's stutter in the documentation or it was only there so the programmer could use a naked return statement. (Naked returns should not be used except in very small functions) This change is a manual audit & cleanup of public func signatures. Signatures were not changed if: * the func was private (wouldn't be in public godoc) * the documentation referenced it * the named return value was an interesting name. (i.e. it wasn't simply stutter, repeating the name of the type) There should be no changes in behavior. (At least: none intended) Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109 Reviewed-on: https://go-review.googlesource.com/20024 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/os/exec')
-rw-r--r--src/os/exec/lp_windows.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/os/exec/lp_windows.go b/src/os/exec/lp_windows.go
index 0b0712dcad..c76a5992fd 100644
--- a/src/os/exec/lp_windows.go
+++ b/src/os/exec/lp_windows.go
@@ -46,7 +46,7 @@ func findExecutable(file string, exts []string) (string, error) {
return f, nil
}
}
- return ``, os.ErrNotExist
+ return "", os.ErrNotExist
}
// LookPath searches for an executable binary named file
@@ -55,9 +55,9 @@ func findExecutable(file string, exts []string) (string, error) {
// LookPath also uses PATHEXT environment variable to match
// a suitable candidate.
// The result may be an absolute path or a path relative to the current directory.
-func LookPath(file string) (f string, err error) {
+func LookPath(file string) (string, error) {
x := os.Getenv(`PATHEXT`)
- if x == `` {
+ if x == "" {
x = `.COM;.EXE;.BAT;.CMD`
}
exts := []string{}
@@ -71,22 +71,23 @@ func LookPath(file string) (f string, err error) {
exts = append(exts, e)
}
if strings.ContainsAny(file, `:\/`) {
- if f, err = findExecutable(file, exts); err == nil {
- return
+ if f, err := findExecutable(file, exts); err == nil {
+ return f, nil
+ } else {
+ return "", &Error{file, err}
}
- return ``, &Error{file, err}
}
- if f, err = findExecutable(`.\`+file, exts); err == nil {
- return
+ if f, err := findExecutable(`.\`+file, exts); err == nil {
+ return f, nil
}
- if pathenv := os.Getenv(`PATH`); pathenv != `` {
+ if pathenv := os.Getenv(`PATH`); pathenv != "" {
for _, dir := range splitList(pathenv) {
- if f, err = findExecutable(dir+`\`+file, exts); err == nil {
- return
+ if f, err := findExecutable(dir+`\`+file, exts); err == nil {
+ return f, nil
}
}
}
- return ``, &Error{file, ErrNotFound}
+ return "", &Error{file, ErrNotFound}
}
func splitList(path string) []string {
@@ -115,7 +116,7 @@ func splitList(path string) []string {
// Remove quotes.
for i, s := range list {
if strings.Contains(s, `"`) {
- list[i] = strings.Replace(s, `"`, ``, -1)
+ list[i] = strings.Replace(s, `"`, "", -1)
}
}