Add goctl version to code header (#4293)

This commit is contained in:
kesonan
2024-08-03 22:22:51 +08:00
committed by GitHub
parent dedba17219
commit 64e3aeda55
11 changed files with 28 additions and 2 deletions

View File

@@ -1,17 +1,21 @@
package util
import "github.com/zeromicro/go-zero/tools/goctl/internal/version"
const (
// DoNotEditHead added to the beginning of a file to prompt the user not to edit
DoNotEditHead = "// Code generated by goctl. DO NOT EDIT."
headTemplate = DoNotEditHead + `
// goctl {{.version}}
// Source: {{.source}}`
)
// GetHead returns a code head string with source filename
func GetHead(source string) string {
buffer, _ := With("head").Parse(headTemplate).Execute(map[string]any{
"source": source,
"source": source,
"version": version.BuildVersion,
})
return buffer.String()
}