mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-23 13:52:26 +08:00
feat: add DecodeByte
This commit is contained in:
@@ -282,3 +282,10 @@ func EncodeByte(data any) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
return buffer.Bytes(), nil
|
return buffer.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DecodeByte decode byte data to target object
|
||||||
|
func DecodeByte(data []byte, target any) error {
|
||||||
|
buffer := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(buffer)
|
||||||
|
return decoder.Decode(target)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user