util

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YMDParseLayout   = "2006年1月2日"
	YMD02ParseLayout = "2006年01月02日"
	ShortDateLayout  = "200601"
	Day              = 24 * time.Hour // 24h0m0s
	Week             = 7 * Day
)

Variables

View Source
var Asia_Shanghai, _ = time.LoadLocation("Asia/Shanghai")

Functions

func CheckZhCn

func CheckZhCn(s string) bool

func ConvertZhCnNumbToa

func ConvertZhCnNumbToa(cnn string) (string, error)

func FileSeparatorConv

func FileSeparatorConv(path string) string

func GetExecutePath

func GetExecutePath() (string, error)

func IsJsonFile

func IsJsonFile(fn string) bool

func IsNumber

func IsNumber(s string) bool

func IsRegexp

func IsRegexp(str string) bool

func IsSubtitleFile

func IsSubtitleFile(fn string) bool

func IsVideofile

func IsVideofile(fn string) bool

func ParseShort02Time

func ParseShort02Time(strd string) (string, error)

func ParseShortTime

func ParseShortTime(strd string) (string, error)

func ParseTime

func ParseTime(strd, layout string) (time.Time, error)

func ParseTimeStr

func ParseTimeStr(t time.Time) string

func SetSubtract added in v0.0.8

func SetSubtract[T comparable, V any](a map[T]V, b map[T]struct{}) (res map[T]V)

func SliceDelete added in v0.0.8

func SliceDelete[S ~[]E, E any](s S, i int) S

func TrimExtensionAndGetEpi

func TrimExtensionAndGetEpi(fn string) string

TrimExtensionAndGetEpi trim the rename file ext and name eg: example xxxS01E02 => S01E02

Types

type ListView added in v0.0.8

type ListView[T any] struct {
	// contains filtered or unexported fields
}

ListView is a thread-safe list view that allows only a single goroutine to append elements while permitting multiple goroutines to read concurrently. This data structure is particularly useful when sharing a list across multiple goroutines where only one goroutine is responsible for adding new elements.

func NewListView added in v0.0.8

func NewListView[T any](ls []T) *ListView[T]

func (*ListView[T]) Append added in v0.0.8

func (lv *ListView[T]) Append(val T)

Append adds a new element to the list. Note: This method should only be called by a single goroutine as it's not designed for concurrent append operations.

func (*ListView[T]) List added in v0.0.8

func (lv *ListView[T]) List() []T

List returns a copy of all elements in the list. This method is safe to be called concurrently by multiple goroutines.

type StringAppender added in v0.0.8

type StringAppender struct {
	strings.Builder
}

func (*StringAppender) Append added in v0.0.8

func (sa *StringAppender) Append(ss ...string)

type Timer

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

func (*Timer) End

func (tr *Timer) End() time.Duration

func (*Timer) Start

func (tr *Timer) Start()

type Tuple

type Tuple[F, S any] struct {
	// contains filtered or unexported fields
}

func NewTuple

func NewTuple[F, S any](a1 F, a2 S) Tuple[F, S]

func (*Tuple[F, S]) Get0

func (t *Tuple[F, S]) Get0() F

func (*Tuple[F, S]) Get1

func (t *Tuple[F, S]) Get1() S

Jump to

Keyboard shortcuts

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