options.go

 1package vfsgen
 2
 3import (
 4	"fmt"
 5	"strings"
 6)
 7
 8// Options for vfsgen code generation.
 9type Options struct {
10	// Filename of the generated Go code output (including extension).
11	// If left empty, it defaults to "{{toLower .VariableName}}_vfsdata.go".
12	Filename string
13
14	// PackageName is the name of the package in the generated code.
15	// If left empty, it defaults to "main".
16	PackageName string
17
18	// BuildTags are the optional build tags in the generated code.
19	// The build tags syntax is specified by the go tool.
20	BuildTags string
21
22	// VariableName is the name of the http.FileSystem variable in the generated code.
23	// If left empty, it defaults to "assets".
24	VariableName string
25
26	// VariableComment is the comment of the http.FileSystem variable in the generated code.
27	// If left empty, it defaults to "{{.VariableName}} statically implements the virtual filesystem provided to vfsgen.".
28	VariableComment string
29}
30
31// fillMissing sets default values for mandatory options that are left empty.
32func (opt *Options) fillMissing() {
33	if opt.PackageName == "" {
34		opt.PackageName = "main"
35	}
36	if opt.VariableName == "" {
37		opt.VariableName = "assets"
38	}
39	if opt.Filename == "" {
40		opt.Filename = fmt.Sprintf("%s_vfsdata.go", strings.ToLower(opt.VariableName))
41	}
42	if opt.VariableComment == "" {
43		opt.VariableComment = fmt.Sprintf("%s statically implements the virtual filesystem provided to vfsgen.", opt.VariableName)
44	}
45}