当前位置: 首页 > news >正文

html5企业网站开发设计网站免费素材

html5企业网站开发,设计网站免费素材,上海松一网站建设,wordpress安装文本编辑器carbon 是一个轻量级、语义化、对开发者友好的 golang 时间处理库,支持链式调用。 目前已被 awesome-go 收录,如果您觉得不错,请给个 star 吧 github.com/golang-module/carbon gitee.com/golang-module/carbon 安装使用 Golang 版本大于…

carbon 是一个轻量级、语义化、对开发者友好的 golang 时间处理库,支持链式调用。

目前已被 awesome-go 收录,如果您觉得不错,请给个 star 吧

github.com/golang-module/carbon

gitee.com/golang-module/carbon

安装使用
Golang 版本大于等于 1.16
// 使用 github 库
go get -u github.com/golang-module/carbon/v2import "github.com/golang-module/carbon/v2"// 使用 gitee 库
go get -u gitee.com/golang-module/carbon/v2import "gitee.com/golang-module/carbon/v2"
Golang 版本小于 1.16
// 使用 github 库
go get -u github.com/golang-module/carbonimport "github.com/golang-module/carbon"// 使用 gitee 库
go get -u gitee.com/golang-module/carbonimport  "gitee.com/golang-module/carbon"
定义模型
type Person struct {Name string `json:"name"`Age  int    `json:"age"`Birthday0 Carbon `json:"birthday0"`Birthday1 Carbon `json:"birthday1" carbon:"date"`Birthday2 Carbon `json:"birthday2" carbon:"time"`Birthday3 Carbon `json:"birthday3" carbon:"dateTime"`Birthday4 Carbon `json:"birthday4" carbon:"date" tz:"PRC"`Birthday5 Carbon `json:"birthday5" carbon:"time" tz:"PRC"`Birthday6 Carbon `json:"birthday6" carbon:"dateTime" tz:"PRC"`
}

type Person struct {Name string `json:"name"`Age  int    `json:"age"`Birthday0 Carbon `json:"birthday0"`Birthday1 Carbon `json:"birthday1" carbon:"layout:2006-01-02"`Birthday2 Carbon `json:"birthday2" carbon:"layout:15:04:05"`Birthday3 Carbon `json:"birthday3" carbon:"layout:2006-01-02 15:04:05"`Birthday4 Carbon `json:"birthday4" carbon:"layout:2006-01-02" tz:"PRC"`Birthday5 Carbon `json:"birthday5" carbon:"layout:15:04:05" tz:"PRC"`Birthday6 Carbon `json:"birthday6" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
}

type Person struct {Name string `json:"name"`Age  int    `json:"age"`Birthday0 Carbon `json:"birthday0"`Birthday1 Carbon `json:"birthday1" carbon:"format:Y-m-d"`Birthday2 Carbon `json:"birthday2" carbon:"format:H:i:s"`Birthday3 Carbon `json:"birthday3" carbon:"format:Y-m-d H:i:s"`Birthday4 Carbon `json:"birthday4" carbon:"format:Y-m-d" tz:"PRC"`Birthday5 Carbon `json:"birthday5" carbon:"format:H:i:s" tz:"PRC"`Birthday6 Carbon `json:"birthday6" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
}

如果 carbon 标签没有设置,默认是 layout:2006-01-02 15:04:05;如果 tz 标签没有设置,默认是 Local

实例化模型
now := Parse("2020-08-05 13:14:15", PRC)
person := Person {Name:      "gouguoyin",Age:       18,Birthday0: now,Birthday1: now,Birthday2: now,Birthday3: now,Birthday4: now,Birthday5: now,Birthday6: now,
}
JSON 编码
loadErr := carbon.LoadTag(&person)
if loadErr != nil {// 错误处理log.Fatal(loadErr)
}
data, marshalErr := json.Marshal(person)
if marshalErr != nil {// 错误处理log.Fatal(marshalErr)
}
fmt.Printf("%s", data)
// 输出
{"name": "gouguoyin","age": 18,"birthday0": "2020-08-05 13:14:15","birthday1": "2020-08-05","birthday2": "13:14:15","birthday3": "2020-08-05 13:14:15","birthday4": "2020-08-05","birthday5": "213:14:15","birthday6": "2020-08-05 13:14:15"
}
JSON 解码
str := `{"name": "gouguoyin","age": 18,"birthday0": "2020-08-05 13:14:15","birthday1": "2020-08-05","birthday2": "13:14:15","birthday3": "2020-08-05 13:14:15","birthday4": "2020-08-05","birthday5": "213:14:15","birthday6": "2020-08-05 13:14:15"
}`
var person Person
loadErr := carbon.LoadTag(&person)
if loadErr != nil {// 错误处理log.Fatal(loadErr)
}unmarshalErr := json.Unmarshal([]byte(str), &person)
if unmarshalErr != nil {// 错误处理log.Fatal(unmarshalErr)
}fmt.Sprintf("%s", person.Birthday0) // 2002-08-05 13:14:15
fmt.Sprintf("%s", person.Birthday1) // 2020-08-05
fmt.Sprintf("%s", person.Birthday2) // 13:14:15
fmt.Sprintf("%s", person.Birthday3) // 2002-08-05 13:14:15
fmt.Sprintf("%s", person.Birthday4) // 2002-08-05
fmt.Sprintf("%s", person.Birthday5) // 13:14:15
fmt.Sprintf("%s", person.Birthday6) // 2002-08-05 13:14:15
更新日志
  • 修复在 Now 方法中设置测试时间时 testNow 为 0,造成 IsSetTestNow 方法返回 false 的 bug
  • 添加性能测试文件 xxx_bench_test.go
  • 增加格式模板常量,如 DateTimeFormat, DateFormat, TimeFormat, AtomFormat, ANSICFormat
  • loadTag 函数中 carbon 标签增加对 datetimedatetimeiso8601 等字符串的支持
  • loadTag 函数中新增 tz 标签,用于设置时区
  • ParseByLayout 方法中添加对 UVXZ 格式化符号的支持
  • ToFormatStringFormat 方法中添加对 vux 格式符号的支持
  • ClearTestNow 方法重命名为 UnSetTestNow
  • HasTestNow 方法重命名为 IsSetTestNow
  • xxx_test.go 文件重命名为 xxx_unit_test.go
  • json.go 文件重命名为 encoding.go, json_test.go 文件重命名为 encoding_unit_test.go
  • ClosestFarthest 方法从 traveler.go 文件移动到 extremum.go,从 traveler_test.go 文件移动到 extremum_unit_test.go
  • SetTestNow 方法中接收者类型从 结构体 更改为 指针
http://www.zhongyajixie.com/news/10423.html

相关文章:

  • 济南网站建设 小程序广州seo推广优化
  • 广州公司注册地址迁址网上办理电商seo优化是什么
  • 日本做a视频网站国外引擎搜索
  • 快速建设网站工具北京网站维护公司
  • 微信小程序设计制作班级优化大师电脑版
  • 网站建设试卷怎么把自己的网站发布到网上
  • 觅知网是免费的吗苏州seo整站优化
  • 网站被黑刚恢复排名又被黑了深圳优化公司高粱seo较
  • 延吉网站建设女生做sem专员的工作难吗
  • 荣茂网站建设八零云自助建站免费建站平台
  • 海淀网站制作服务公司网上销售平台有哪些
  • 百度seo公司有哪些武汉seo公司哪家专业
  • 广元做网站威海网站制作
  • 免费网站备济南网站制作平台
  • 网站开发要学习什么googleseo优化
  • 网站申请备案国产搜什么关键词最好看
  • 如何免费建设网站网络免费推广平台
  • 在360怎么做网站搜索引擎优化的含义和目标
  • 微信小程序第三方开发seo费用
  • 做餐饮要看的网站免费正能量erp软件下载
  • 怎么做网站推广的论文seo排名工具给您好的建议下载官网
  • 苏州cms建站网站优化策划书
  • 南京网页网站制作seo是怎么优化推广的
  • labview 做网站推广营销软件
  • 网站seo推广的方法商业软文案例
  • 政府网站建设服务方案群排名优化软件官网
  • 怎样做网站xmlseo搜索引擎优化到底是什么
  • 做的较好的拍卖网站全国疫情高峰感染进度
  • 武威网站怎么做seo一站式海外推广平台
  • 电商类网站开发定制文山seo