go_echo_wol/res/res.go

24 lines
498 B
Go
Raw Normal View History

2023-09-02 11:47:53 +08:00
package res
import "encoding/json"
type response struct {
2023-09-05 17:57:32 +08:00
Code int `json:"code"`
Message string `json:"message"`
Uuid string `json:"uuid"`
2023-09-05 17:53:38 +08:00
Data interface{} `json:"data,omitempty"`
2023-09-02 11:47:53 +08:00
}
2023-09-05 17:53:38 +08:00
func Get_res_string(Code int, Message string, Uuid string, Data ...interface{}) string {
2023-09-02 11:47:53 +08:00
var res = new(response)
res.Code = Code
res.Message = Message
2023-09-05 17:53:38 +08:00
res.Uuid = Uuid
2023-09-02 11:47:53 +08:00
res.Data = Data
res_str, err := json.Marshal(res)
if err != nil {
panic(err)
}
return string(res_str)
}