go返回json数据

package main

import (
    "encoding/json"
)

type Repay struct {
    Code  uint64 `json:"code"`
    Message string `json:"message"`
}

var msg []byte

func main() []byte {
    Repays := &Repay{
      Code:  0,
      Message: "成功",
    }

    msg, _ = json.Marshal(Repays)
    return msg       
}

 

posted @ 2020-11-05 10:25  钧一  阅读(2602)  评论(0编辑  收藏  举报