1 Star 0 Fork 0

宁成增/base-core

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
toml.go 554 Bytes
Copy Edit Raw Blame History
宁成增 authored 2021-01-11 20:33 +08:00 . init
package toml
import (
"bytes"
"github.com/BurntSushi/toml"
"gitee.com/psdnfu/base-core/config/encoder"
)
type tomlEncoder struct{}
func (t tomlEncoder) Encode(v interface{}) ([]byte, error) {
b := bytes.NewBuffer(nil)
defer b.Reset()
err := toml.NewEncoder(b).Encode(v)
if err != nil {
return nil, err
}
return b.Bytes(), nil
}
func (t tomlEncoder) Decode(d []byte, v interface{}) error {
return toml.Unmarshal(d, v)
}
func (t tomlEncoder) String() string {
return "toml"
}
func NewEncoder() encoder.Encoder {
return tomlEncoder{}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/psdnfu/base-core.git
git@gitee.com:psdnfu/base-core.git
psdnfu
base-core
base-core
v0.0.1

Search