增加ini序列化能力
This commit is contained in:
parent
8a9502c122
commit
f617c9cda4
67
ini.go
Normal file
67
ini.go
Normal file
@ -0,0 +1,67 @@
|
||||
// Package serialize ...
|
||||
//
|
||||
// Description : serialize ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2025-04-28 11:32
|
||||
package serialize
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/go-ini/ini"
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
Ini = &ownIni{}
|
||||
)
|
||||
|
||||
type ownIni struct {
|
||||
}
|
||||
|
||||
func (o *ownIni) UnmarshalWithNumber(byteData []byte, receiver any) error {
|
||||
if nil == receiver {
|
||||
return errors.New("receiver is nil")
|
||||
}
|
||||
return ini.MapTo(receiver, byteData)
|
||||
}
|
||||
|
||||
func (o *ownIni) UnmarshalWithNumberIgnoreError(byteData []byte, receiver any) {
|
||||
_ = o.UnmarshalWithNumber(byteData, receiver)
|
||||
}
|
||||
|
||||
func (o *ownIni) UnmarshalWithNumberForIOReader(ioReader io.ReadCloser, receiver any) error {
|
||||
if nil == receiver {
|
||||
return errors.New("receiver is nil")
|
||||
}
|
||||
return ini.MapTo(receiver, ioReader)
|
||||
}
|
||||
|
||||
func (o *ownIni) UnmarshalWithNumberForIOReaderIgnoreError(ioReader io.ReadCloser, receiver any) {
|
||||
_ = o.UnmarshalWithNumberForIOReader(ioReader, receiver)
|
||||
}
|
||||
|
||||
func (o *ownIni) UnmarshalWithNumberForString(input string, receiver any) error {
|
||||
return o.UnmarshalWithNumber([]byte(input), receiver)
|
||||
}
|
||||
|
||||
func (o *ownIni) UnmarshalWithNumberForStringIgnoreError(input string, receiver any) {
|
||||
_ = o.UnmarshalWithNumberForString(input, receiver)
|
||||
}
|
||||
|
||||
func (o *ownIni) MarshalForByte(input any) ([]byte, error) {
|
||||
return JSON.MarshalForByte(input)
|
||||
}
|
||||
|
||||
func (o *ownIni) MarshalForByteIgnoreError(input any) []byte {
|
||||
return JSON.MarshalForByteIgnoreError(input)
|
||||
}
|
||||
|
||||
func (o *ownIni) MarshalForString(input any) (string, error) {
|
||||
return JSON.MarshalForString(input)
|
||||
}
|
||||
|
||||
func (o *ownIni) MarshalForStringIgnoreError(input any) string {
|
||||
return JSON.MarshalForStringIgnoreError(input)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user