utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Content types
	ContentTypeJSON   = "application/json"
	ContentTypeXML    = "application/xml"
	ContentTypeJS     = "application/javascript"
	ContentTypeNDJSON = "application/x-ndjson"
	ContentTypeText   = "text/"

	// Time conversion constants
	SecondsPerMinute      = 60
	SecondsPerHour        = 3600
	MillisecondsPerSecond = 1000

	// Default timestamp format
	DefaultSRTTime = "00:00:00,000"
)

Variables

This section is empty.

Functions

func BodyToString

func BodyToString(header http.Header, body []byte) string

func BuildGetRequestURL

func BuildGetRequestURL(baseURL string, body []byte) (string, error)

func CheckServiceIsExistInEnv

func CheckServiceIsExistInEnv(serviceName string) bool

CheckServiceIsExistInEnv checks if service exists in environment variables

func Contains

func Contains(slice []string, target string) bool

func DecodeBase64

func DecodeBase64(data string) ([]byte, error)

DecodeBase64 解码Base64字符串为字节数组

func DetectGpuModel

func DetectGpuModel() string

func DownloadFile

func DownloadFile(downloadURL string, saveDir string) (string, error)

func DownloadImageUrlToPath

func DownloadImageUrlToPath(url string) (string, error)

func FormatSecondsToSRT

func FormatSecondsToSRT(secondsStr string) string

FormatSecondsToSRT 将秒数转换为SRT时间格式 (HH:MM:SS,mmm)

func GenerateNonceString

func GenerateNonceString(n int) string

func GenerateUUID

func GenerateUUID() string

GenerateUUID generates a unique UUID string

func GetAOGDataDir

func GetAOGDataDir() (string, error)

func GetAbsolutePath

func GetAbsolutePath(p string, base string) string

GetAbsolutePath Convert relative path to absolute path from the passed in base directory No change if the passed in path is already an absolute path

func GetDownloadDir

func GetDownloadDir() (string, error)

func GetGpuInfo

func GetGpuInfo() (int, error)

func GetSystemVersion

func GetSystemVersion() int

func GetUserDataDir

func GetUserDataDir() (string, error)

func HmacSha1String

func HmacSha1String(s, key string) string

func HmacSha256

func HmacSha256(s, key string) string

func HmacSha256String

func HmacSha256String(s, key string) string

func IpexOllamaSupportGPUStatus

func IpexOllamaSupportGPUStatus() bool

func IsHTTPText

func IsHTTPText(header http.Header) bool

func IsServerRunning

func IsServerRunning() bool

func Min

func Min(a, b int) int

Min 辅助函数,返回两个整数中的较小值

func NowUnixMilli

func NowUnixMilli() int64

NowUnixMilli 获取当前Unix时间戳(毫秒)

func ParseImageData

func ParseImageData(data []byte) ([][]byte, error)

func ParseRequestBody

func ParseRequestBody(reqBody []byte) (map[string]interface{}, error)

func ParseSRTTimestamps

func ParseSRTTimestamps(srtContent string) (*int, *int)

func ParseSizeToGB

func ParseSizeToGB(sizeStr string) float64

func ParseTableOutput

func ParseTableOutput(output string) map[string]string

+-----------------------------+--------------------------------------------------------------------+ | Device ID | 0 | +-----------------------------+--------------------------------------------------------------------+ | GPU Utilization (%) | 0 | | EU Array Active (%) | | Analyze the output table content of the above terminal command

func ParseTimestamp

func ParseTimestamp(timestamp string) int

ParseTimestamp 将 SRT 格式的时间戳 (00:00:00,000) 转换为毫秒

func ReadImageFileToBase64

func ReadImageFileToBase64(filePath string) (string, error)

func Sha256hex

func Sha256hex(s string) string

func StartAOGServer

func StartAOGServer(logPath string, pidFilePath string) error

func StopAOGServer

func StopAOGServer(pidFilePath string) error

func SystemDiskSize

func SystemDiskSize(path string) (*types.PathDiskSizeInfo, error)

func UnzipFile

func UnzipFile(zipFile, destDir string) error

Unzip file, distinguish system win/linux/macos

Types

type MemoryInfo

type MemoryInfo struct {
	Size       int
	MemoryType string
}

func GetMemoryInfo

func GetMemoryInfo() (*MemoryInfo, error)

type SafeList

type SafeList struct {
	// contains filtered or unexported fields
}

func NewSafeList

func NewSafeList() *SafeList

func (*SafeList) Back

func (sl *SafeList) Back() *list.Element

func (*SafeList) Front

func (sl *SafeList) Front() *list.Element

func (*SafeList) InsertAfter

func (sl *SafeList) InsertAfter(v any, mark *list.Element) *list.Element

func (*SafeList) InsertBefore

func (sl *SafeList) InsertBefore(v any, mark *list.Element) *list.Element

func (*SafeList) Len

func (l *SafeList) Len() int

func (*SafeList) MoveAfter

func (sl *SafeList) MoveAfter(e, mark *list.Element)

func (*SafeList) MoveBefore

func (sl *SafeList) MoveBefore(e, mark *list.Element)

func (*SafeList) MoveToBack

func (sl *SafeList) MoveToBack(e *list.Element)

func (*SafeList) MoveToFront

func (sl *SafeList) MoveToFront(e *list.Element)

func (*SafeList) PushBack

func (sl *SafeList) PushBack(v any) *list.Element

func (*SafeList) PushFront

func (sl *SafeList) PushFront(v any) *list.Element

func (*SafeList) Remove

func (sl *SafeList) Remove(e *list.Element) any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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