go-hep.org/x/hep@v0.38.1/fwk/cmd/fwk-new-comp/gen.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "io" 9 "os" 10 "text/template" 11 ) 12 13 func gen_task(c Component) error { 14 return gen(os.Stdout, g_task_template, c) 15 } 16 17 func gen_svc(c Component) error { 18 return gen(os.Stdout, g_svc_template, c) 19 } 20 21 func gen(w io.Writer, text string, data any) error { 22 t := template.Must(template.New("fwk").Parse(text)) 23 return t.Execute(w, data) 24 }