go_echo_wol/res/res.go

24 lines
435 B
Go
Raw Normal View History

2023-09-02 11:47:53 +08:00
package res
import "encoding/json"
type response struct {
Code int
Message string
2023-09-05 17:53:38 +08:00
Uuid string
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)
}