Boilerplate for how I like to write a backend web service.
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.
 
 
 

39 lines
724 B

package main
import (
"strconv"
"text/template"
)
type data struct {
ImportPath string
PackageName string
BuildTags string
VariableName string
VariableComment string
}
var generateTemplate = template.Must(template.New("").Funcs(template.FuncMap{
"quote": strconv.Quote,
}).Parse(`package main
import (
"log"
"github.com/shurcooL/vfsgen"
sourcepkg {{.ImportPath | quote}}
)
func main() {
err := vfsgen.Generate(sourcepkg.{{.VariableName}}, vfsgen.Options{
PackageName: {{.PackageName | quote}},
BuildTags: {{.BuildTags | quote}},
VariableName: {{.VariableName | quote}},
VariableComment: {{.VariableComment | quote}},
})
if err != nil {
log.Fatalln(err)
}
}
`))