mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
all: join a few chained ifs
I had been finding these over a year or so, but none were big enough changes to warrant CLs. They're a handful now, so clean them all up in a single commit. The smaller bodies get a bit simpler, but most importantly, the larger bodies get unindented. Change-Id: I5707a6fee27d4c9ff9efd3d363af575d7a4bf2aa Reviewed-on: https://go-review.googlesource.com/c/go/+/165340 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a125bdb49b
commit
340129e4c8
6 changed files with 41 additions and 55 deletions
|
|
@ -1303,20 +1303,18 @@ func toOutputDir(path string) string {
|
|||
if *outputDir == "" || path == "" {
|
||||
return path
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
// On Windows, it's clumsy, but we can be almost always correct
|
||||
// by just looking for a drive letter and a colon.
|
||||
// Absolute paths always have a drive letter (ignoring UNC).
|
||||
// Problem: if path == "C:A" and outputdir == "C:\Go" it's unclear
|
||||
// what to do, but even then path/filepath doesn't help.
|
||||
// TODO: Worth doing better? Probably not, because we're here only
|
||||
// under the management of go test.
|
||||
if len(path) >= 2 {
|
||||
letter, colon := path[0], path[1]
|
||||
if ('a' <= letter && letter <= 'z' || 'A' <= letter && letter <= 'Z') && colon == ':' {
|
||||
// If path starts with a drive letter we're stuck with it regardless.
|
||||
return path
|
||||
}
|
||||
// On Windows, it's clumsy, but we can be almost always correct
|
||||
// by just looking for a drive letter and a colon.
|
||||
// Absolute paths always have a drive letter (ignoring UNC).
|
||||
// Problem: if path == "C:A" and outputdir == "C:\Go" it's unclear
|
||||
// what to do, but even then path/filepath doesn't help.
|
||||
// TODO: Worth doing better? Probably not, because we're here only
|
||||
// under the management of go test.
|
||||
if runtime.GOOS == "windows" && len(path) >= 2 {
|
||||
letter, colon := path[0], path[1]
|
||||
if ('a' <= letter && letter <= 'z' || 'A' <= letter && letter <= 'Z') && colon == ':' {
|
||||
// If path starts with a drive letter we're stuck with it regardless.
|
||||
return path
|
||||
}
|
||||
}
|
||||
if os.IsPathSeparator(path[0]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue