Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

24 lines
336 B
Go

package conf
import (
"encoding/json"
"io"
"os"
)
func LoadJSON(path string, cfg interface{}) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer func() { _ = f.Close() }()
bs, err := io.ReadAll(f)
if err != nil {
return err
}
if err = json.Unmarshal(bs, cfg); err != nil {
return err
}
return nil
}