Fix message in generated code.

This commit is contained in:
monopole
2021-02-09 07:22:50 -08:00
parent 7cdc6cbe2f
commit bbccee0219
22 changed files with 94 additions and 89 deletions

View File

@@ -20,6 +20,7 @@ type Copier struct {
spec *ModuleSpec
goModCache string
topPackage string
pwdPackage string
srcDir string
pgmName string
}
@@ -29,7 +30,7 @@ func (c Copier) replacementPath() string {
}
func (c Copier) subPath() string {
return filepath.Join("internal", c.pgmName)
return filepath.Join("internal", c.pwdPackage)
}
func (c Copier) Print() {
@@ -37,6 +38,7 @@ func (c Copier) Print() {
fmt.Printf(" replacementPath: %s\n", c.replacementPath())
fmt.Printf(" goModCache: %s\n", c.goModCache)
fmt.Printf(" topPackage: %s\n", c.topPackage)
fmt.Printf(" pwdPackage: %s\n", c.pwdPackage)
fmt.Printf(" subPath: %s\n", c.subPath())
fmt.Printf(" srcDir: %s\n", c.srcDir)
fmt.Printf(" apiMachineryModSpec: %s\n", c.spec.Name())
@@ -44,10 +46,11 @@ func (c Copier) Print() {
fmt.Printf(" pwd: %s\n", os.Getenv("PWD"))
}
func NewCopier(s *ModuleSpec, prefix string) Copier {
func NewCopier(s *ModuleSpec, prefix, pgmName string) Copier {
tmp := Copier{
spec: s,
pgmName: os.Getenv("GOPACKAGE"),
pgmName: pgmName,
pwdPackage: os.Getenv("GOPACKAGE"),
goModCache: RunGetOutputCommand("go", "env", "GOMODCACHE"),
}
goMod := RunGetOutputCommand("go", "env", "GOMOD")
@@ -79,7 +82,7 @@ func (c Copier) CopyFile(dir, name string) error {
w.write(
fmt.Sprintf(
// This particular phrasing is required.
"// Code generated by %s/generator from %s; DO NOT EDIT.",
"// Code generated by %s from %s; DO NOT EDIT.",
c.pgmName, c.spec.Name()))
w.write(
fmt.Sprintf(