MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / getConfigFile

Function getConfigFile

plugin/qqci/qqci.go:338–367  ·  view source on GitHub ↗
(path, executePath, templatePath string, app application)

Source from the content-addressed store, hash-verified

336}
337
338func getConfigFile(path, executePath, templatePath string, app application) error {
339 _ = os.MkdirAll(filepath.Dir(path), 0755)
340 f, err := os.Create(executePath)
341 if err != nil {
342 return err
343 }
344 if file.IsNotExist(path) {
345 nf, err := os.Create(path)
346 if err != nil {
347 return err
348 }
349 tmpl, err := template.ParseFiles(templatePath)
350 if err != nil {
351 return err
352 }
353 err = tmpl.Execute(nf, app)
354 if err != nil {
355 return err
356 }
357 _ = nf.Close()
358 }
359 pf, err := os.Open(path)
360 if err != nil {
361 return err
362 }
363 _, _ = io.Copy(f, pf)
364 _ = f.Close()
365 _ = pf.Close()
366 return nil
367}
368
369func deCompress(tarFile, dest string) error {
370 srcFile, err := os.Open(tarFile)

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected