util/codegen: add -copyright to control presence of copyright headers

Fixes #7702

Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
pull/7710/head
Josh Bleecher Snyder 2 years ago committed by David Crawshaw
parent 7c99210e68
commit 3ba9f8dd04

@ -6,6 +6,7 @@ package codegen
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/token"
@ -20,6 +21,8 @@ import (
"tailscale.com/util/mak"
)
var flagCopyright = flag.Bool("copyright", true, "add Tailscale copyright to generated file headers")
// LoadTypes returns all named types in pkgName, keyed by their type name.
func LoadTypes(buildTags string, pkgName string) (*packages.Package, map[string]*types.Named, error) {
cfg := &packages.Config{
@ -104,7 +107,9 @@ func (it *ImportTracker) Write(w io.Writer) {
}
func writeHeader(w io.Writer, tool, pkg string) {
fmt.Fprint(w, copyrightHeader)
if *flagCopyright {
fmt.Fprint(w, copyrightHeader)
}
fmt.Fprintf(w, genAndPackageHeader, tool, pkg)
}

Loading…
Cancel
Save