common

package
v1.3.395 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 14 Imported by: 9

Documentation

Overview

Package common 公共函数.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) uintptr

BoolPtr 将bool转换到uintptr.

b: bool.

func BoolToInt added in v1.3.395

func BoolToInt(input bool) int

BoolToInt 将 bool 类型转换为 int 类型.

  • true 返回 1, false 返回 0.

func BoolToString added in v1.3.395

func BoolToString(input bool) string

BoolToString 将 bool 类型转换为字符串 true 或 false.

func ByteSliceDataPtr

func ByteSliceDataPtr(b *[]byte) uintptr

ByteSliceDataPtr 将byte[0]的指针转换到uintptr.

b: byte[0]的指针.

func Bytes2String added in v1.3.381

func Bytes2String(b []byte) string

Bytes2String 转换[]byte到string.

b: []byte.

func ErrorToErrno added in v1.3.395

func ErrorToErrno(err error) (syscall.Errno, bool)

ErrorToErrno 将错误转换为系统调用错误号.

err: 需要转换的错误对象

返回值:

  • syscall.Errno: 转换后的系统错误号
  • bool: 是否成功转换的标志

func Float32Ptr

func Float32Ptr(f float32) uintptr

Float32Ptr 将float32转换到uintptr.

f: float32.

func GetProcessName added in v1.3.395

func GetProcessName() string

GetProcessName 取当前进程名.

func GetProcessNameWithoutExt added in v1.3.395

func GetProcessNameWithoutExt() string

GetProcessNameWithoutExt 取当前进程名(不含扩展名).

func StrPtr

func StrPtr(s string) uintptr

StrPtr 将string转换到uintptr.

s: 文本.

func String2Bytes added in v1.3.381

func String2Bytes(s string) []byte

String2Bytes 转换string到[]byte.

s: 文本.

func StringToBool added in v1.3.395

func StringToBool(input string) bool

StringToBool 将字符串转换为 bool 类型.

  • true 和 1 字符串都会转换为 true, 'true'字符串不区分大小写, 其他值都转换为 false.

func StringToUint16Ptr

func StringToUint16Ptr(s string) *uint16

StringToUint16Ptr 返回指向 UTF-8 字符串 s 的 UTF-16 编码的指针,与 syscall.UTF16PtrFromString 不同的是末尾没有添加终止 NUL.

s: 文本.

func UTF16PtrToString added in v1.3.395

func UTF16PtrToString(p *uint16) string

UTF16PtrToString 接收一个指向 UTF-16 切片的指针,并返回对应的 UTF-8 编码字符串。

  • 如果指针为空,则返回空字符串。该函数假设 UTF-16 序列以零字符结尾;
  • 如果不存在零字符,程序可能会崩溃。

func Uint16SliceDataPtr

func Uint16SliceDataPtr(p *[]uint16) uintptr

Uint16SliceDataPtr 将uint16[0]指针转换到uintptr.

p: uint16[0]的指针.

func Uint16SliceToStringSlice

func Uint16SliceToStringSlice(s []uint16) []string

Uint16SliceToStringSlice 按null字符分割, 把 []uint16 转换到 []string.

s: []uint16.

func UintPtrToFloat32

func UintPtrToFloat32(ptr uintptr) float32

UintPtrToFloat32 将uintptr转换到float32.

ptr: uintptr.

func UintPtrToSlice added in v1.3.395

func UintPtrToSlice(ptr uintptr) []interface{}

UintPtrToSlice 将uintptr转换到[]interface{}.

ptr: uintptr.

func UintPtrToString

func UintPtrToString(ptr uintptr) string

UintPtrToString 将uintptr转换到string.

ptr: uintptr.

Types

type GifFrame added in v1.3.395

type GifFrame struct {
	ImageData []byte        // PNG 格式的二进制数据
	Delay     time.Duration // 帧延时
}

GifFrame 包含 Gif 每帧的二进制数据和延时信息.

func ExtractGifFrames added in v1.3.395

func ExtractGifFrames(gifReader io.Reader) ([]GifFrame, error)

ExtractGifFrames 提取 GIF 的所有帧.

Jump to

Keyboard shortcuts

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