mirror of
https://github.com/golang/go
synced 2024-11-18 19:54:44 -07:00
go/packages: cleanup style
This change addresses some style issues pointed out by rsc in golang.org/cl/126177. It doesn't fix the comment on listfunc or the comment on the processing of the containing directories. Those will be handled in a separate cl. Change-Id: I2094ad1e5e2ee181a646466675f4d993bd69ff9b Reviewed-on: https://go-review.googlesource.com/128897 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
0167fde410
commit
aaa76ee82d
@ -44,18 +44,17 @@ func LoadRaw(ctx context.Context, cfg *raw.Config, patterns ...string) ([]string
|
||||
}
|
||||
// Determine files requested in contains patterns
|
||||
var containFiles []string
|
||||
{
|
||||
restPatterns := make([]string, 0, len(patterns))
|
||||
for _, pattern := range patterns {
|
||||
if containFile := strings.TrimPrefix(pattern, "contains:"); containFile != pattern {
|
||||
containFiles = append(containFiles, containFile)
|
||||
} else {
|
||||
restPatterns = append(restPatterns, pattern)
|
||||
}
|
||||
restPatterns := make([]string, 0, len(patterns))
|
||||
for _, pattern := range patterns {
|
||||
if strings.HasPrefix(pattern, "contains:") {
|
||||
containFile := strings.TrimPrefix(pattern, "contains:")
|
||||
containFiles = append(containFiles, containFile)
|
||||
} else {
|
||||
restPatterns = append(restPatterns, pattern)
|
||||
}
|
||||
containFiles = absJoin(cfg.Dir, containFiles)
|
||||
patterns = restPatterns
|
||||
}
|
||||
containFiles = absJoin(cfg.Dir, containFiles)
|
||||
patterns = restPatterns
|
||||
|
||||
// TODO(matloob): Remove the definition of listfunc and just use golistPackages once go1.12 is released.
|
||||
var listfunc func(ctx context.Context, cfg *raw.Config, words ...string) ([]string, []*raw.Package, error)
|
||||
|
@ -258,8 +258,8 @@ func newLoader(cfg *Config) *loader {
|
||||
ld.Context = context.Background()
|
||||
}
|
||||
if ld.Dir == "" {
|
||||
if cwd, err := os.Getwd(); err == nil {
|
||||
ld.Dir = cwd
|
||||
if dir, err := os.Getwd(); err == nil {
|
||||
ld.Dir = dir
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user