Documentation
¶
Index ¶
- func BytesToString(b []byte) string
- func Combination[T any](nums []T) [][]T
- func CombinationValue(n int) int
- func EachDo[T any](slice []T, do func(T))
- func EachForGet[T any, R any](slice []T, get func(i int) R) []R
- func Filter[T any](slice []T, filter func(i int) bool) []T
- func Foreach[T any](slice []T, fn func(i int) bool)
- func ForeachReverse[T any](slice []T, fn func(i int) bool)
- func MaxFn[T any](aIsLarger func(current, max T) bool, args ...T) T
- func Permute[T any](nums []T) [][]T
- func Range(count int, action func(i int) (stop bool))
- func StringToBytes(s string) []byte
- func Ternary[T any](condition bool, trueValue, falseValue T) T
- type Flight
- type FlightGroup
- type MySQLVersion
- type VersionSemantic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString converts byte slice to string without a memory allocation.
func Combination ¶
func Combination[T any](nums []T) [][]T
Combination function: given an array, returns all combinations, e.g. (a,b,c) -> (a,b,c), (a,b), (a,c), (b,c), (a), (b), (c)
func CombinationValue ¶
func EachForGet ¶
func ForeachReverse ¶
func StringToBytes ¶
StringToBytes converts string to byte slice without a memory allocation.
Types ¶
type Flight ¶
type Flight[V any] struct { // contains filtered or unexported fields }
Flight represents one call registered with a FlightGroup.
type FlightGroup ¶
type FlightGroup[K comparable, V any] struct { // contains filtered or unexported fields }
FlightGroup tracks in-progress calls by key. Its zero value is ready to use. The caller serializes registration and completion with the same lock, so it can coordinate both with external state such as a cache. Wait outside that lock.
func (*FlightGroup[K, V]) FinishLocked ¶
func (g *FlightGroup[K, V]) FinishLocked(key K, call *Flight[V], value V, err error)
FinishLocked removes the leader's call for key and publishes its result to waiters. Pass the call returned by JoinOrStartLocked for that key. The value may be shared with multiple waiters and must be safe to share.
func (*FlightGroup[K, V]) JoinOrStartLocked ¶
func (g *FlightGroup[K, V]) JoinOrStartLocked(key K) (call *Flight[V], leader bool)
JoinOrStartLocked joins a pending call or registers a new one. The caller that receives leader=true performs the work and must finish the call once.
type MySQLVersion ¶
type MySQLVersion struct {
MySQLDBType int // 1 is MySQL, 2 is MariaDB
Major int
Minor int
Patch int
}
func ParseVersion ¶
func ParseVersion(versionString string) MySQLVersion
func (*MySQLVersion) BeforeMySQL57 ¶
func (mv *MySQLVersion) BeforeMySQL57() bool
BeforeMySQL57 reports whether mv is a known MySQL release older than 5.7. MariaDB and unknown or invalid versions return false so callers keep the MySQL 5.7/8.0 behavior.
func (*MySQLVersion) IsMariaDB ¶
func (mv *MySQLVersion) IsMariaDB() bool
func (*MySQLVersion) IsMySQL ¶
func (mv *MySQLVersion) IsMySQL() bool
func (*MySQLVersion) IsValid ¶
func (mv *MySQLVersion) IsValid() bool
type VersionSemantic ¶
type VersionSemantic int
const ( VersionMajor VersionSemantic = 0 VersionMinor VersionSemantic = 1 VersionPatch VersionSemantic = 2 )