common

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogFile *os.File

Functions

func BCDToByte

func BCDToByte(b byte) int

BCDToByte 将一个字节的BCD码转换为对应的整数

func BCDToFloat32

func BCDToFloat32(bcd []byte, format string, endian binary.ByteOrder) (float32, error)

BCDToFloat32 将BCD码字节数组转换为float32数值,支持不同字节序

func BCDToTime

func BCDToTime(bcd []byte) (time.Time, error)

BCDToTime 将BCD码字节数组转换为时间

func BcdToDigits

func BcdToDigits(bcd []byte) string

BcdToDigits 将 BCD 码字节数组转换为数字字符串

func BytesToFloat32

func BytesToFloat32(bytes []byte) float32

BytesToFloat32 将字节数组转换为浮点数

func BytesToInt64

func BytesToInt64(bytes []byte) int64

BytesToInt64 将字节数组转换为有符号 64 位整数

func BytesToSpacedHex

func BytesToSpacedHex(data []byte) string

BytesToSpacedHex 将字节切片转换为每两个字符用空格分隔的十六进制字符串,不足的补0

func BytesToUint32

func BytesToUint32(bytes []byte) uint32

BytesToUint32 将字节数组转换为无符号 32 位整数

func Float32ToBCD

func Float32ToBCD(value float32, format string, endian binary.ByteOrder) ([]byte, error)

Float32ToBCD 将float32数值转换为BCD码字节数组,支持不同数据格式和字节序

func GetProjectRoot

func GetProjectRoot() string

func InitLogger

func InitLogger()

func InterfaceToFloat32

func InterfaceToFloat32(i interface{}) (float32, error)

func InterfaceToUint32

func InterfaceToUint32(i interface{}) (uint32, error)

func ReverseBytes

func ReverseBytes(src []byte) []byte

func StringToBCD

func StringToBCD(digits string, endian binary.ByteOrder) ([]byte, error)

将数字字符串转换为BCD码(小端序)

func TimeToBCD

func TimeToBCD(t time.Time) []byte

TimeToBCD 将时间转换为BCD码字节数组(小端序)

func Uint8ToBCD

func Uint8ToBCD(value uint8) byte

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL