尝试优化代码

This commit is contained in:
wyx2685 committed 2024-01-25 23:06:37 +09:00
1 parent e292b3b0e7
commit 91e78fbc20
7 files changed
+66 -24

No files matched your search

+4 -2
View File
@@ -262,12 +262,14 @@ func (u *User) DecodePrivate(pemEncodedPriv string) (*ecdsa.PrivateKey, error) {
privateKey, err := x509.ParseECPrivateKey(x509EncodedPriv)
return privateKey, err
}
func (u *User) Load(path string) error {
f, err := os.Open(path)
data, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("open file error: %s", err)
}
err = json.NewDecoder(f).Decode(u)
err = json.Unmarshal(data, u)
if err != nil {
return fmt.Errorf("unmarshal json error: %s", err)
}