misc

package module
v0.0.0-...-b649bb8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(fns ...func() error) error

func CallWith

func CallWith[T any](val T, fns ...func(T) error) error

func CharsetByType

func CharsetByType(typ string) string

func Decode62

func Decode62(str string) int64

Decode62 将62进制转换成10进制 Decode62("HCSFOD") // 15758306521

func Encode62

func Encode62(num int64) string

Encode62 将10进制转换成62进制

Encode62(15758306521) // HCSFOD

func ExtensionByType

func ExtensionByType(mimeType string) string

func Interpolate

func Interpolate(template, startTag, endTag string, w io.Writer, f TagFunc) (int64, error)

Interpolate calls f on each template tag (placeholder) occurrence.

Returns the number of bytes written to w.

func MD5

func MD5(str string) string

func MustCall

func MustCall(fns ...func() error)

func MustCallWith

func MustCallWith[T any](val T, fns ...func(T) error)

func PasswordHash

func PasswordHash(password string) (string, error)

func PasswordVerify

func PasswordVerify(password, hash string) bool

func Sha1

func Sha1(str string) string

func Sha256

func Sha256(str string) string

func SliceByteToString

func SliceByteToString(b []byte) string

func StringToSliceByte

func StringToSliceByte(s string) []byte

func Strtr

func Strtr(template string, data map[string]any) (string, error)

Strtr translate characters or replace substrings

func Strtr2

func Strtr2(template, startTag, endTag string, data map[string]any) (string, error)

func TypeByExtension

func TypeByExtension(ext string) string

func Wrap

func Wrap(fns ...func() error) func() error

func WrapWith

func WrapWith[T any](fns ...func(T) error) func(val T) error

Types

type TagFunc

type TagFunc func(w io.Writer, tag string) (int, error)

TagFunc can be used as a substitution value in the map passed to Interpolate. Interpolate functions pass tag (placeholder) name in 'tag' argument.

TagFunc must be safe to call from concurrently running goroutines.

TagFunc must write contents to w and return the number of bytes written.

Jump to

Keyboard shortcuts

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