fix u.Error (use gojs.Err)
This commit is contained in:
parent
ce923e2bbe
commit
9955bc0eb5
16
go.mod
16
go.mod
@ -2,30 +2,26 @@ module apigo.cc/gojs/util
|
||||
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.24.3
|
||||
|
||||
require (
|
||||
apigo.cc/gojs v0.0.14
|
||||
apigo.cc/gojs v0.0.21
|
||||
apigo.cc/gojs/console v0.0.2
|
||||
github.com/ZZMarquis/gm v1.3.2
|
||||
github.com/emmansun/gmsm v0.30.1
|
||||
github.com/obscuren/ecies v0.0.0-20150213224233-7c0f4a9b18d9
|
||||
github.com/ssgo/u v1.7.19
|
||||
github.com/ssgo/u v1.7.21
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/chzyer/readline v1.5.1 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.5 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
||||
github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a // indirect
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b // indirect
|
||||
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 // indirect
|
||||
github.com/ssgo/config v1.7.9 // indirect
|
||||
github.com/ssgo/log v1.7.7 // indirect
|
||||
github.com/ssgo/standard v1.7.7 // indirect
|
||||
github.com/ssgo/tool v0.4.29 // indirect
|
||||
golang.org/x/crypto v0.39.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
golang.org/x/crypto v0.40.0 // indirect
|
||||
golang.org/x/sys v0.34.0 // indirect
|
||||
golang.org/x/text v0.27.0 // indirect
|
||||
)
|
||||
|
18
util.go
18
util.go
@ -210,14 +210,14 @@ func init() {
|
||||
if strings.Contains(keyText, "-----BEGIN PRIVATE KEY-----") {
|
||||
keyType = "private"
|
||||
if block, _ := pem.Decode([]byte(keyText)); block == nil {
|
||||
panic(vm.NewGoError(u.Error("bad private pem key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad private pem key")))
|
||||
} else {
|
||||
keyBytes = block.Bytes
|
||||
}
|
||||
} else if strings.Contains(keyText, "-----BEGIN PUBLIC KEY-----") {
|
||||
keyType = "public"
|
||||
if block, _ := pem.Decode([]byte(keyText)); block == nil {
|
||||
panic(vm.NewGoError(u.Error("bad public pem key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad public pem key")))
|
||||
} else {
|
||||
keyBytes = block.Bytes
|
||||
}
|
||||
@ -233,7 +233,7 @@ func init() {
|
||||
panic(vm.NewGoError(err))
|
||||
} else {
|
||||
if ecdsaPriKey, ok := priKey.(*ecdsa.PrivateKey); !ok {
|
||||
panic(vm.NewGoError(u.Error("bad private key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad private key")))
|
||||
} else {
|
||||
return vm.ToValue(ecdsaPriKey.D.Bytes())
|
||||
}
|
||||
@ -243,7 +243,7 @@ func init() {
|
||||
panic(vm.NewGoError(err))
|
||||
} else {
|
||||
if ecdsaPubKey, ok := pubKey.(*ecdsa.PublicKey); !ok {
|
||||
panic(vm.NewGoError(u.Error("bad public key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad public key")))
|
||||
} else {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteByte(byte(len(ecdsaPubKey.X.Bytes())))
|
||||
@ -347,14 +347,14 @@ func init() {
|
||||
if strings.Contains(keyText, "-----BEGIN PRIVATE KEY-----") {
|
||||
keyType = "private"
|
||||
if block, _ := pem.Decode([]byte(keyText)); block == nil {
|
||||
panic(vm.NewGoError(u.Error("bad private pem key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad private pem key")))
|
||||
} else {
|
||||
keyBytes = block.Bytes
|
||||
}
|
||||
} else if strings.Contains(keyText, "-----BEGIN PUBLIC KEY-----") {
|
||||
keyType = "public"
|
||||
if block, _ := pem.Decode([]byte(keyText)); block == nil {
|
||||
panic(vm.NewGoError(u.Error("bad public pem key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad public pem key")))
|
||||
} else {
|
||||
keyBytes = block.Bytes
|
||||
}
|
||||
@ -376,7 +376,7 @@ func init() {
|
||||
panic(vm.NewGoError(err))
|
||||
} else {
|
||||
if sm2PubKey, ok := pubKey.(*ecdsa.PublicKey); !ok {
|
||||
panic(vm.NewGoError(u.Error("bad public key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad public key")))
|
||||
} else {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteByte(byte(len(sm2PubKey.X.Bytes())))
|
||||
@ -476,14 +476,14 @@ func init() {
|
||||
if strings.Contains(keyText, "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
keyType = "private"
|
||||
if block, _ := pem.Decode([]byte(keyText)); block == nil {
|
||||
panic(vm.NewGoError(u.Error("bad private pem key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad private pem key")))
|
||||
} else {
|
||||
keyBytes = block.Bytes
|
||||
}
|
||||
} else if strings.Contains(keyText, "-----BEGIN RSA PUBLIC KEY-----") {
|
||||
keyType = "public"
|
||||
if block, _ := pem.Decode([]byte(keyText)); block == nil {
|
||||
panic(vm.NewGoError(u.Error("bad public pem key")))
|
||||
panic(vm.NewGoError(gojs.Err("bad public pem key")))
|
||||
} else {
|
||||
keyBytes = block.Bytes
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user