enhance(crc):CRC系列校验算法增加使用大端序或者小端序输出的功能。

This commit is contained in:
徐涛
2023-07-25 23:11:48 +08:00
parent 8719a0e689
commit 190dd36490
4 changed files with 49 additions and 0 deletions

28
types/endian.go Normal file
View File

@@ -0,0 +1,28 @@
package types
import "fmt"
type Endian string
const (
BigEndian Endian = "big"
LittleEndian Endian = "little"
)
func (e *Endian) String() string {
return string(*e)
}
func (e *Endian) Set(s string) error {
switch s {
case "big", "little":
*e = Endian(s)
return nil
default:
return fmt.Errorf("不支持的字节序:%s", s)
}
}
func (e *Endian) Type() string {
return "Endian"
}