generated from hiddify/hiddify-app-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.old
66 lines (56 loc) · 1.35 KB
/
main.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"embed"
_ "embed"
"fmt"
"io/fs"
"log"
ex "github.com/hiddify/hiddify-app-example-extension/hiddify_extension"
)
// // go:embed resources/en.i18n.json
// var enJsonData []byte
func getAllFilenames(efs *embed.FS) (files []string, err error) {
if err := fs.WalkDir(efs, ".", func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
return nil
}
files = append(files, path)
return nil
}); err != nil {
return nil, err
}
return files, nil
}
func main() {
var result map[string]interface{}
// // Unmarshal the embedded JSON data
// err := json.Unmarshal(enJsonData, &result)
// if err != nil {
// fmt.Println("Error loading JSON:", err)
// return
// }
content1, _ := ex.Resources.ReadFile("translations/en.i18n.json")
print(string(content1))
v, e := getAllFilenames(&ex.Resources)
fmt.Printf("%++v, %v", v, e)
err := fs.WalkDir(ex.Resources, "translations/", func(path string, d fs.DirEntry, err error) error {
fmt.Println(path)
if err != nil {
return err
}
// If it's a file, print its name and content
if !d.IsDir() {
fmt.Println("Found file:", path)
content, err := ex.Resources.ReadFile(path)
if err != nil {
return err
}
fmt.Printf("Content of %s:\n%s\n", path, string(content))
}
return nil
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Loaded JSON:", result)
}