From a6a318322b6546853f337293f881a2d1c7a7f363 Mon Sep 17 00:00:00 2001 From: gedi Date: Thu, 16 Jun 2016 10:19:53 +0300 Subject: [PATCH] pkg may be nil at this point, assume main package --- builder.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builder.go b/builder.go index 8db1ff2..a43fa9a 100644 --- a/builder.go +++ b/builder.go @@ -234,6 +234,7 @@ func uniqStringList(strs []string) (unique []string) { func buildTestMain(pkg *build.Package) ([]byte, bool, error) { var contexts []string var importPath string + name := "main" if nil != pkg { ctxs, err := processPackageTestFiles( pkg.TestGoFiles, @@ -244,13 +245,14 @@ func buildTestMain(pkg *build.Package) ([]byte, bool, error) { } contexts = ctxs importPath = pkg.ImportPath + name = pkg.Name } data := struct { Name string Contexts []string ImportPath string - }{pkg.Name, contexts, importPath} + }{name, contexts, importPath} var buf bytes.Buffer if err := runnerTemplate.Execute(&buf, data); err != nil {