utils

package
v1.72.17 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 31 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallerFile

func CallerFile(deep int) (path string, line int)

CallerFile returns caller file path and line

func CallerFileName

func CallerFileName(deep int) string

CallerFileName returns name of caller file

func CallerFilePath added in v1.70.0

func CallerFilePath(deep int) string

CallerFilePath returns path to caller file

func ChangeFileExtension added in v1.70.0

func ChangeFileExtension(filename, targetExt string) string

ChangeFileExtension to

func ConstantTimeCompareStrings added in v1.70.0

func ConstantTimeCompareStrings(a, b string) bool

ConstantTimeCompareStrings uses zero alloc converting to bytes

func GeneratePEMCert added in v1.70.0

func GeneratePEMCert(bits int, organization string, maxAge time.Duration) (cert, key []byte, err error)

GeneratePEMCert self-signed

func GenerateTLSCert added in v1.70.0

func GenerateTLSCert(bits int, organization string, maxAge time.Duration) (*tls.Certificate, error)

GenerateTLSCert self-signed

func ImageJPGThumbnail added in v1.70.0

func ImageJPGThumbnail(src io.Reader, filename string, maxWidth, maxHeight uint) ([]byte, error)

ImageJPGThumbnail converter

func ImageJPGThumbnailTo added in v1.70.0

func ImageJPGThumbnailTo(src io.Reader, dst io.Writer, filename string, maxWidth, maxHeight uint) error

ImageJPGThumbnailTo converter

func ImagePNGThumbnail added in v1.70.0

func ImagePNGThumbnail(src io.Reader, filename string, maxWidth, maxHeight uint) ([]byte, error)

ImagePNGThumbnail converter

func ImagePNGThumbnailTo added in v1.70.0

func ImagePNGThumbnailTo(src io.Reader, dst io.Writer, filename string, maxWidth, maxHeight uint) error

ImagePNGThumbnailTo converter

func ImageRead added in v1.70.0

func ImageRead(filename string, src io.Reader) (image.Image, error)

ImageRead to GO image.Image interface

func NewCloser added in v1.70.0

func NewCloser(f func() error) io.Closer

NewCloser for func

func NewDiscardLogger added in v1.70.0

func NewDiscardLogger() *log.Logger

NewDiscardLogger std

func RandBytes added in v1.70.0

func RandBytes(n int) []byte

RandBytes - fast token generator

func RandBytesTo added in v1.70.0

func RandBytesTo(buf []byte)

RandBytesTo - fast token generator

func RandInit

func RandInit()

RandInit for init rand seed from time

func RandString

func RandString(n int) string

RandString - fast token generator

func RuntimePkgFileLineByPC added in v1.70.0

func RuntimePkgFileLineByPC(pc uintptr) (file string, line int)

RuntimePkgFileLineByPC caller

func RuntimePkgFileLineStrByPC added in v1.70.0

func RuntimePkgFileLineStrByPC(pc uintptr) string

RuntimePkgFileLineStrByPC caller

func RuntimePkgIndex added in v1.70.0

func RuntimePkgIndex(file, funcName string) int

RuntimePkgIndex by caller

func RuntimePkgPath added in v1.70.0

func RuntimePkgPath() string

RuntimePkgPath ...

func ToSnakeCase added in v1.70.0

func ToSnakeCase(s string) string

ToSnakeCase convertion

func WaitForExit added in v1.70.0

func WaitForExit()

WaitForExit signal

func Workdir

func Workdir() string

Workdir returns executable working dir

func WorkdirDSN added in v1.70.0

func WorkdirDSN() string

WorkdirDSN returns executable working dir as DSN path

Example on windows: c/users/user/Desktop

func ZAtob added in v1.70.0

func ZAtob(s string) []byte

ZAtob - zero alloc convert string to bytes

func ZBtoa added in v1.70.0

func ZBtoa(b []byte) string

ZBtoa - zero alloc convert bytes to string

Types

type AES added in v1.70.0

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

AES cryptor

func NewAES added in v1.70.0

func NewAES(key16or32 string) (*AES, error)

NewAES cryptor

func (*AES) Decrypt added in v1.70.0

func (c *AES) Decrypt(crypted []byte) ([]byte, error)

Decrypt data

func (*AES) DecryptFromBase64 added in v1.70.0

func (c *AES) DecryptFromBase64(crypted64 string) (string, error)

DecryptFromBase64 data

func (*AES) Encrypt added in v1.70.0

func (c *AES) Encrypt(data []byte) []byte

Encrypt data

func (*AES) EncryptToBase64 added in v1.70.0

func (c *AES) EncryptToBase64(text string) string

EncryptToBase64 data

Jump to

Keyboard shortcuts

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