mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-25 03:58:37 +08:00
23 lines
395 B
Go
23 lines
395 B
Go
package tcp
|
|
|
|
type Response interface {
|
|
PkgResponse()
|
|
GetError() (err error)
|
|
}
|
|
|
|
// PkgResponse 打包响应消息
|
|
func PkgResponse(data interface{}) {
|
|
if c, ok := data.(Response); ok {
|
|
c.PkgResponse()
|
|
return
|
|
}
|
|
}
|
|
|
|
// GetResponseError 解析响应消息中的错误
|
|
func GetResponseError(data interface{}) (err error) {
|
|
if c, ok := data.(Response); ok {
|
|
return c.GetError()
|
|
}
|
|
return
|
|
}
|