Skip to content

Commit 5e177ec

Browse files
author
Doug Hatcher
committed
embeds tasks into binary
1 parent 667cdbb commit 5e177ec

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

main.go

+33-12
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,54 @@ workflow around this tool.
1010
package main
1111

1212
import (
13+
"embed"
1314
"fmt"
14-
"io/ioutil"
15-
"log"
15+
"io/fs"
1616
"os"
1717
"path/filepath"
1818

1919
"github.com/mumoshu/variant/cmd"
2020
)
2121

22+
// content holds our static web server content.
23+
//go:embed tasks/*.yaml
24+
var tasks embed.FS
25+
2226
func main() {
2327

2428
data := ""
2529

26-
files, err := ioutil.ReadDir("../tasks")
27-
if err != nil {
28-
log.Fatal(err)
29-
}
30+
fs.WalkDir(tasks, ".", func(path string, d fs.DirEntry, err error) error {
31+
if err != nil {
32+
return err
33+
}
34+
// fmt.Printf("path=%q, isDir=%v\n", path, d.IsDir())
3035

31-
for _, f := range files {
36+
content, err := fs.ReadFile(tasks, path)
37+
if err != nil {
38+
// return err // or panic or ignore
39+
}
3240

33-
if filepath.Ext(f.Name()) == ".yaml" {
34-
content, _ := ioutil.ReadFile("../tasks/" + f.Name())
41+
data = data + string(content) + "\n"
3542

36-
data = data + string(content) + "\n"
37-
}
43+
return nil
3844

39-
}
45+
})
46+
47+
// files, err := ioutil.ReadDir("../tasks")
48+
// if err != nil {
49+
// log.Fatal(err)
50+
// }
51+
52+
// for _, f := range files {
53+
54+
// if filepath.Ext(f.Name()) == ".yaml" {
55+
// content, _ := ioutil.ReadFile("../tasks/" + f.Name())
56+
57+
// data = data + string(content) + "\n"
58+
// }
59+
60+
// }
4061

4162
ex, err := os.Executable()
4263
if err != nil {

0 commit comments

Comments
 (0)