summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-02-28 21:51:21 +0700
committerShulhan <ms@kilabit.info>2022-02-28 21:51:21 +0700
commitde8a9f01a9859fbfc2145dabaf3fe97c13d01188 (patch)
treefc8b19e2184aa0a859d8ad81f80932b622ae32d5
parent1c0f0a63b6030f06708687ea4db6a07e36c6a767 (diff)
downloadpakakeh.go-de8a9f01a9859fbfc2145dabaf3fe97c13d01188.tar.xz
lib/memfs: embed the field CommentHeader on generated Go file
Since the comment header may contain multiple lines and the value will be rendered into template, we must remind user that the value must be set using raw string literal syntax ``, not "".
-rw-r--r--lib/memfs/embed_options.go3
-rw-r--r--lib/memfs/template.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/memfs/embed_options.go b/lib/memfs/embed_options.go
index 4462b82c..841c58f8 100644
--- a/lib/memfs/embed_options.go
+++ b/lib/memfs/embed_options.go
@@ -10,6 +10,9 @@ type EmbedOptions struct {
// generated file, for example copyright holder and/or license.
// The string value is not checked, whether it's a comment or not, it
// will rendered as is.
+ //
+ // Due to templating, the value MUST be set using raw
+ // string literal syntax ``, NOT "".
CommentHeader string
// The generated package name for GoEmbed().
diff --git a/lib/memfs/template.go b/lib/memfs/template.go
index ba9c7e78..3ed45ac2 100644
--- a/lib/memfs/template.go
+++ b/lib/memfs/template.go
@@ -104,6 +104,7 @@ func init() {
{{- end}}
},
Embed: memfs.EmbedOptions{
+ CommentHeader: ` + "`" + `{{.Opts.Embed.CommentHeader}}` + "`" + `,
PackageName: "{{.Opts.Embed.PackageName}}",
VarName: "{{.Opts.Embed.VarName}}",
GoFileName: "{{.Opts.Embed.GoFileName}}",