1. 使用CGO对代码进行重构

This commit is contained in:
kunmeng
2025-02-27 11:17:22 +08:00
parent 6c8cbae1fe
commit a4caf70ae8
26 changed files with 54861 additions and 477 deletions

30
core/error.go Normal file
View File

@@ -0,0 +1,30 @@
package core
import "C"
import (
"strconv"
)
// 构造HcnetError
func NewHcnetError(Code int, Msg string, FuncName string) *HcnetError {
return &HcnetError{Code: Code, Msg: Msg, FuncName: FuncName}
}
// 海康网络sdk自定义错误
type HcnetError struct {
Code int `json:"Code"` // 错误码
Msg string `json:"Msg"` // 错误码描述
FuncName string `json:"FuncName"`
}
func (p *HcnetError) Error() string {
return strconv.FormatInt(int64(p.Code), 10) + "," + p.Msg
}
func (p *HcnetError) IsPasswordError() bool {
return p.Code == 1
}
func (p *HcnetError) IsDeviceOfflineError() bool {
return p.Code == 7
}