mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-16 18:08:40 +00:00
util/codegen: add -copyright to control presence of copyright headers
Fixes #7702 Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
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…
x
Reference in New Issue
Block a user