1 Star 0 Fork 66

chewel/carbon

forked from dromara/carbon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
database_test.go 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
package carbon
import (
"encoding/json"
"fmt"
"testing"
)
var user = struct {
ID int64 `json:"id"`
Name string `json:"name"`
Age int `json:"age"`
Birthday ToDateTimeString `json:"birthday"`
GraduatedAt ToDateString `json:"graduated_at"`
CreatedAt ToTimeString `json:"created_at"`
UpdatedAt ToTimestamp `json:"updated_at"`
DateTime1 ToTimestampWithSecond `json:"date_time1"`
DateTime2 ToTimestampWithMillisecond `json:"date_time2"`
DateTime3 ToTimestampWithMicrosecond `json:"date_time3"`
DateTime4 ToTimestampWithNanosecond `json:"date_time4"`
}{
Name: "勾国印",
Age: 18,
Birthday: ToDateTimeString{Now().SubYears(18)},
GraduatedAt: ToDateString{Parse("2012-09-09")},
CreatedAt: ToTimeString{Now()},
UpdatedAt: ToTimestamp{Now()},
DateTime1: ToTimestampWithSecond{Now()},
DateTime2: ToTimestampWithMillisecond{Now()},
DateTime3: ToTimestampWithMicrosecond{Now()},
DateTime4: ToTimestampWithNanosecond{Now()},
}
func TestCarbon_MarshalJSON(*testing.T) {
data, _ := json.Marshal(&user)
fmt.Print("Model output by json:\n", string(data)+"\n")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/chewel/carbon.git
git@gitee.com:chewel/carbon.git
chewel
carbon
carbon
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385