mirror of
https://github.com/lwch/natpass.git
synced 2026-10-19 16:15:48 +00:00
修正logsize的解析问题
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import "github.com/dustin/go-humanize"
|
||||
|
||||
type Bytes uint64
|
||||
|
||||
func (bt *Bytes) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var str string
|
||||
err := unmarshal(&str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := humanize.ParseBytes(str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*bt = Bytes(n)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *Bytes) Bytes() uint64 {
|
||||
return uint64(*bt)
|
||||
}
|
||||
Reference in New Issue
Block a user