cmd/bundle: add blank line before package declaration
so that the bundled package doesn't clobber the package declaration of the host package. Also: minor comment tweaks. Change-Id: I28ab3aca2b02213edc95c6b12c0d1a2514453cfe Reviewed-on: https://go-review.googlesource.com/18040 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
4a5fb9938b
commit
99c318c742
|
@ -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))
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
// The package doc comment
|
||||
//
|
||||
|
||||
package dest
|
||||
|
||||
import (
|
||||
|
|
Loading…
Reference in New Issue