You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

options.go 1.4KB

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