mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-19 19:38: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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
@ -20,6 +21,8 @@ import (
|
|||||||
"tailscale.com/util/mak"
|
"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.
|
// 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) {
|
func LoadTypes(buildTags string, pkgName string) (*packages.Package, map[string]*types.Named, error) {
|
||||||
cfg := &packages.Config{
|
cfg := &packages.Config{
|
||||||
@ -104,7 +107,9 @@ func (it *ImportTracker) Write(w io.Writer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeHeader(w io.Writer, tool, pkg string) {
|
func writeHeader(w io.Writer, tool, pkg string) {
|
||||||
fmt.Fprint(w, copyrightHeader)
|
if *flagCopyright {
|
||||||
|
fmt.Fprint(w, copyrightHeader)
|
||||||
|
}
|
||||||
fmt.Fprintf(w, genAndPackageHeader, tool, pkg)
|
fmt.Fprintf(w, genAndPackageHeader, tool, pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user