68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
// 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)
|
|
}
|