Compare commits

..
9 changed files with 18 additions and 67 deletions

No files matched your search

-2
View File
@@ -15,8 +15,6 @@ import "io"
//
// Date : 16:55 2024/10/23
type Serializable interface {
// Unmarshal 反序列化
Unmarshal(byteData []byte, receiver any) error
// UnmarshalWithNumber 反序列化,同时解析数字
UnmarshalWithNumber(byteData []byte, receiver any) error
// UnmarshalWithNumberIgnoreError 反序列化,同时解析数字, 忽略结果的成功与失败
+2 -3
View File
@@ -10,6 +10,7 @@ package serialize
import (
"encoding/xml"
"errors"
"git.zhangdeman.cn/zhangdeman/consts"
"io"
"net/http"
"net/url"
@@ -18,13 +19,11 @@ import (
"path/filepath"
"strings"
"git.zhangdeman.cn/zhangdeman/consts"
"github.com/BurntSushi/toml"
"git.zhangdeman.cn/zhangdeman/util/define"
"gopkg.in/ini.v1"
"github.com/go-ini/ini"
)
var (
+6 -8
View File
@@ -5,12 +5,10 @@ go 1.23.0
toolchain go1.24.2
require (
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a
github.com/BurntSushi/toml v1.6.0
github.com/sbabiv/xml2map v1.2.1
gopkg.in/ini.v1 v1.67.1
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e
github.com/BurntSushi/toml v1.5.0
github.com/go-ini/ini v1.67.0
gopkg.in/yaml.v3 v3.0.1
)
require github.com/stretchr/testify v1.11.1 // indirect
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250425024726-cc17224cb995
github.com/stretchr/testify v1.9.0 // indirect
)
+8 -24
View File
@@ -1,42 +1,26 @@
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71 h1:ivFHFIHbviWLvyQyCKw0C0Nd8hfobp9lPpKbbxdTtDY=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20260110085649-492e9bae2f71/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a h1:IGUsWz204BTQlD2l4kenlwJQS4Av2RS2kfUHZ5QVrmw=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20260105024213-3d76b1bcde5a/go.mod h1:OKI+RVVfRTUf/ox9uDMydtos2YDFr+/UuU4FFZKgPYY=
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250425024726-cc17224cb995 h1:LmPRAf0AsxRVFPibdpZR89ajlsz8hof2IvMMyTqiEq4=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250425024726-cc17224cb995/go.mod h1:5p8CEKGBxi7qPtTXDI3HDmqKAfIm5i/aBWdrbkbdNjc=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e h1:Q973S6CcWr1ICZhFI1STFOJ+KUImCl2BaIXm6YppBqI=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI=
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sbabiv/xml2map v1.2.1 h1:1lT7t0hhUvXZCkdxqtq4n8/ZCnwLWGq4rDuDv5XOoFE=
github.com/sbabiv/xml2map v1.2.1/go.mod h1:2TPoAfcaM7+Sd4iriPvzyntb2mx7GY+kkQpB/GQa/eo=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.67.1 h1:tVBILHy0R6e4wkYOn3XmiITt/hEVH4TFMYvAX2Ytz6k=
gopkg.in/ini.v1 v1.67.1/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+1 -5
View File
@@ -9,7 +9,7 @@ package serialize
import (
"errors"
"gopkg.in/ini.v1"
"github.com/go-ini/ini"
"io"
)
@@ -20,10 +20,6 @@ var (
type ownIni struct {
}
func (o *ownIni) Unmarshal(byteData []byte, receiver any) error {
return o.UnmarshalWithNumber(byteData, receiver)
}
func (o *ownIni) UnmarshalWithNumber(byteData []byte, receiver any) error {
if nil == receiver {
return errors.New("receiver is nil")
-9
View File
@@ -33,10 +33,6 @@ func init() {
type ownJSON struct {
}
func (oj *ownJSON) Unmarshal(byteData []byte, receiver any) error {
return oj.UnmarshalWithNumber(byteData, receiver)
}
// UnmarshalWithNumber 解析json
//
// Author : go_developer@163.com<白茶清欢>
@@ -78,11 +74,6 @@ func (oj *ownJSON) UnmarshalWithNumberForIOReaderIgnoreError(ioReader io.ReadClo
return
}
// UnmarshalForString ...
func (oj *ownJSON) UnmarshalForString(input string, receiver any) error {
return oj.Unmarshal([]byte(input), receiver)
}
// UnmarshalWithNumberForString 字符串转结构体
//
// Author : go_developer@163.com<白茶清欢>
-4
View File
@@ -21,10 +21,6 @@ var (
type ownToml struct {
}
func (o *ownToml) Unmarshal(byteData []byte, receiver any) error {
return o.UnmarshalWithNumber(byteData, receiver)
}
func (o *ownToml) Parse(byteData []byte, receiver any) (*toml.MetaData, error) {
if nil == receiver {
return nil, errors.New("receiver is nil")
+1 -9
View File
@@ -10,7 +10,6 @@ package serialize
import (
"bytes"
"encoding/xml"
"github.com/sbabiv/xml2map"
"io"
)
@@ -20,15 +19,8 @@ var (
type ownXml struct{}
func (o *ownXml) Unmarshal(byteData []byte, receiver any) error {
return o.UnmarshalWithNumber(byteData, receiver)
}
func (o *ownXml) UnmarshalWithNumber(byteData []byte, receiver any) error {
res, err := xml2map.NewDecoder(bytes.NewReader(byteData)).Decode()
if nil != err {
return err
}
return JSON.Transition(res, receiver)
return xml.NewDecoder(bytes.NewReader(byteData)).Decode(receiver)
}
func (o *ownXml) UnmarshalWithNumberIgnoreError(byteData []byte, receiver any) {
-3
View File
@@ -40,9 +40,6 @@ func (o *ownYml) MarshalForStringIgnoreError(input any) string {
return string(o.MarshalForByteIgnoreError(input))
}
func (o *ownYml) Unmarshal(byteData []byte, receiver any) error {
return o.UnmarshalWithNumber(byteData, receiver)
}
func (o *ownYml) UnmarshalWithNumber(byteData []byte, receiver any) error {
return yaml.NewDecoder(bytes.NewReader(byteData)).Decode(receiver)
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.