cmd/guru: avoid bug when -scope=""

strings.Split is not your friend.

Change-Id: I829f08f113f3340b2dd865aea47f5759a427f7c4
Reviewed-on: https://go-review.googlesource.com/22116
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Alan Donovan 2016-04-17 12:37:22 -04:00 committed by Alan Donovan
parent 0c4d9b3099
commit 5e468032ea
1 changed files with 7 additions and 1 deletions

View File

@ -194,11 +194,17 @@ func main() {
} }
} }
// Avoid corner case of split("").
var scope []string
if *scopeFlag != "" {
scope = strings.Split(*scopeFlag, ",")
}
// Ask the guru. // Ask the guru.
query := Query{ query := Query{
Pos: posn, Pos: posn,
Build: ctxt, Build: ctxt,
Scope: strings.Split(*scopeFlag, ","), Scope: scope,
PTALog: ptalog, PTALog: ptalog,
Reflection: *reflectFlag, Reflection: *reflectFlag,
Output: output, Output: output,