utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(v1, v2 string) (int, error)

CompareVersions compares two version strings Returns -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile downloads a file from the given URL to the specified filepath

func Duration

func Duration(d time.Duration) string

Duration formats time duration in human-readable form. Examples:

  • Less than 1 second: "0s"
  • Less than 1 minute: "5.2s"
  • Less than 1 hour: "3m5.2s"
  • 1 hour or more: "2h15m"

func IsModernPoE

func IsModernPoE(version string) (bool, error)

IsModernPoE checks if the version uses modern hash algorithm (≥3.21.2)

func Number

func Number(n int64) string

Number formats large numbers with commas for readability. For example: 1234567 becomes "1,234,567"

func ParseGameVersion

func ParseGameVersion(version string) (int, error)

ParseGameVersion parses a game version string and returns the major version number

func Rate

func Rate(rate float64) string

Rate formats insertion rates for readability with appropriate unit suffixes. Examples:

  • Less than 1,000: "123.45"
  • Less than 1,000,000: "12.34K"
  • 1,000,000 or more: "12.34M"

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts a string to snake_case

Types

type Progress

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

Progress represents a progress bar using mpb

func NewProgress

func NewProgress(total int, enabled bool) *Progress

NewProgress creates a new progress bar with the given total count

func (*Progress) Finish

func (p *Progress) Finish()

Finish completes the progress bar and shuts down the container

func (*Progress) SetEnabled

func (p *Progress) SetEnabled(enabled bool)

SetEnabled allows manually enabling/disabling the progress bar

func (*Progress) Update

func (p *Progress) Update(current int, description string)

Update updates the progress bar with current count and description

type VersionInfo

type VersionInfo struct {
	Major int
	Minor int
	Patch int
	Build int
}

VersionInfo represents parsed version components

func ParseVersionInfo

func ParseVersionInfo(version string) (*VersionInfo, error)

ParseVersionInfo parses a full version string (e.g., "3.21.2.1") into components

Jump to

Keyboard shortcuts

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