Commit a824ffcc authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

go/build: fix field mismatch in unkeyed struct literal

Fixes #9409

Change-Id: I2404cd8bf3ebb07f4b6a2b3e1d58ab69b9f1e8d8
Reviewed-on: https://go-review.googlesource.com/2040Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 401b2023
......@@ -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())
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment