MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / ToFile

Function ToFile

pkg/strcut_json/struct_json.go:11–30  ·  view source on GitHub ↗

ToFile 注意传入的不是指针

(srcJsonFileFPath string, input interface{})

Source from the content-addressed store, hash-verified

9
10// ToFile 注意传入的不是指针
11func ToFile(srcJsonFileFPath string, input interface{}) error {
12 jsonBytes, err := json.Marshal(input)
13 if err != nil {
14 return err
15 }
16
17 file, err := os.Create(filepath.FromSlash(srcJsonFileFPath))
18 if err != nil {
19 return err
20 }
21 defer func() {
22 _ = file.Close()
23 }()
24
25 _, err = file.Write(jsonBytes)
26 if err != nil {
27 return err
28 }
29 return nil
30}
31
32// ToStruct 传入的必须是指针
33func ToStruct(desJsonFileFPath string, output interface{}) error {

Callers 4

saveVideoListCacheMethod · 0.92
TestNewSettingsFunction · 0.92
SaveMethod · 0.92

Calls 1

CloseMethod · 0.45

Tested by 1

TestNewSettingsFunction · 0.74