1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:54:42 -07:00

go/build: fix field mismatch in unkeyed struct literal

Fixes #9409

Change-Id: I2404cd8bf3ebb07f4b6a2b3e1d58ab69b9f1e8d8
Reviewed-on: https://go-review.googlesource.com/2040
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Brad Fitzpatrick 2014-12-22 13:40:28 -08:00
parent 401b20234c
commit a824ffcc93
2 changed files with 15 additions and 2 deletions

View File

@ -688,7 +688,11 @@ Found:
p.Name = pkg
firstFile = name
} else if pkg != p.Name {
return p, &MultiplePackageError{p.Dir, []string{firstFile, name}, []string{p.Name, pkg}}
return p, &MultiplePackageError{
Dir: p.Dir,
Packages: []string{p.Name, pkg},
Files: []string{firstFile, name},
}
}
if pf.Doc != nil && p.Doc == "" {
p.Doc = doc.Synopsis(pf.Doc.Text())

View File

@ -94,9 +94,18 @@ func TestEmptyFolderImport(t *testing.T) {
func TestMultiplePackageImport(t *testing.T) {
_, err := Import(".", "testdata/multi", 0)
if _, ok := err.(*MultiplePackageError); !ok {
mpe, ok := err.(*MultiplePackageError)
if !ok {
t.Fatal(`Import("testdata/multi") did not return MultiplePackageError.`)
}
want := &MultiplePackageError{
Dir: "testdata/multi",
Packages: []string{"main", "test_package"},
Files: []string{"file.go", "file_appengine.go"},
}
if !reflect.DeepEqual(mpe, want) {
t.Errorf("got %#v; want %#v", mpe, want)
}
}
func TestLocalDirectory(t *testing.T) {