package types import ( "fmt" "archgrid.xyz/ag/toolsbox/hash/crc32" ) type CRC32Algorithm string const ( CRC32_IEEE CRC32Algorithm = "ieee" CRC32_CASTAGNOLI CRC32Algorithm = "castagnoli" CRC32_KOOPMAN CRC32Algorithm = "koopman" ) func (a *CRC32Algorithm) String() string { return string(*a) } func (a *CRC32Algorithm) Set(s string) error { switch s { case "ieee", "castagnoli", "koopman": *a = CRC32Algorithm(s) return nil default: return fmt.Errorf("不支持的CRC32算法:%s", s) } } func (a *CRC32Algorithm) Type() string { return "CRC32Algorithm" } func (a CRC32Algorithm) IntoCRC32Mode() crc32.CRC32Mode { switch a { case CRC32_IEEE: return crc32.IEEE case CRC32_CASTAGNOLI: return crc32.Castagnoli case CRC32_KOOPMAN: return crc32.Koopman default: return crc32.IEEE } }