diff --git a/cmd/bundle/main.go b/cmd/bundle/main.go index 35b16eb5..3d85d883 100644 --- a/cmd/bundle/main.go +++ b/cmd/bundle/main.go @@ -17,8 +17,8 @@ // - no file in the package imports "C", that is, uses cgo. // - no file in the package has GOOS or GOARCH build tags or file names. // - comments associated with the package or import declarations, -// or associated with no top-level declaration at all, -// may be discarded. +// may be discarded, as may comments associated with no top-level +// declaration at all. // - neither the original package nor the destination package contains // any identifiers starting with the designated prefix. // (This allows us to avoid various conflict checks.) @@ -31,8 +31,6 @@ // and embedded fields of renamed types. No methods are renamed, so we // needn't worry about preserving interface satisfaction. // -// TODO(adonovan): gofmt the result. -// package main import ( @@ -125,7 +123,7 @@ func bundle(w io.Writer, initialPkg, dest, prefix string) error { fmt.Fprintf(&out, "// Code generated by golang.org/x/tools/cmd/bundle command:\n") fmt.Fprintf(&out, "// $ bundle %s %s %s\n\n", initialPkg, dest, prefix) - // Concatenate package comments from of all files. + // Concatenate package comments from all files... for _, f := range info.Files { if doc := f.Doc.Text(); strings.TrimSpace(doc) != "" { for _, line := range strings.Split(doc, "\n") { @@ -133,6 +131,8 @@ func bundle(w io.Writer, initialPkg, dest, prefix string) error { } } } + // ...but don't let them become the actual package comment. + fmt.Fprintln(&out) // TODO(adonovan): don't assume pkg.name == basename(pkg.path). fmt.Fprintf(&out, "package %s\n\n", filepath.Base(dest)) diff --git a/cmd/bundle/testdata/out.golden b/cmd/bundle/testdata/out.golden index e8c439ae..5153d3fc 100644 --- a/cmd/bundle/testdata/out.golden +++ b/cmd/bundle/testdata/out.golden @@ -3,6 +3,7 @@ // The package doc comment // + package dest import (