Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
package stderr
import "fmt"
type Code int
type CodeMsg struct {
Code int `json:"code"`
Msg string `json:"msg"`
Tip string `json:"tip,omitempty"`
}
func (c Code) Msg() string {
msg, ok := codeAndMsg[c]
if ok {
return msg
}
return ""
}
func (c Code) Tip() string {
tip, ok := codeAndTip[c]
if ok {
return tip
}
return ""
}
func (c Code) Error() string {
return fmt.Sprintf("code=%d,msg=%v,tip=%v", c, c.Msg(), c.Tip())
}
func (c Code) Struct() CodeMsg {
return CodeMsg{Code: int(c), Msg: c.Msg(), Tip: c.Tip()}
}
func New(code int, msg string) error {
return fmt.Errorf("code:%d,msg:%s", code, msg)
}
func (c Code) SetMsg(msg string) CodeMsg {
return CodeMsg{Code: int(c), Msg: msg, Tip: c.Tip()}
}
func (c Code) SetTip(tip string) CodeMsg {
return CodeMsg{Code: int(c), Msg: c.Msg(), Tip: tip}
}