internal

package
v0.0.0-...-a12e6e1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PieceSize   = 32 // byte
	ReadTimeOut = 985
)
View Source
const (
	MIMEJSON              = "application/json"
	MIMEHTML              = "text/html"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
	MIMEPROTOBUF          = "application/x-protobuf"
	MIMEMSGPACK           = "application/x-msgpack"
	MIMEMSGPACK2          = "application/msgpack"
	MIMEYAML              = "application/x-yaml"

	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	MethodOptions = "OPTIONS"
	MethodTrace   = "TRACE"
)
View Source
const IOCGetterErrorCode = 4

Variables

View Source
var NoRecord = &MyError{code: 1, description: "record not exists"}
View Source
var TokenInvalid = &MyError{code: 2, description: "token invalid"}

Functions

func AddPrefix

func AddPrefix(path string, prefix string) string

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation.

func CRC

func CRC(s string) int

String hashes a string to a unique hashcode.

crc32 returns a uint32, but for our use we need and non negative integer. Here we cast to an integer and invert it if the result is negative.

func CheckPath

func CheckPath(path string) string

func Copy

func Copy(dst, src interface{})

func Exists

func Exists(path string) bool

func Init

func Init()

func IsDir

func IsDir(path string) bool

func PrintStack

func PrintStack() []byte

Stack returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.

func StringToBytes

func StringToBytes(s string) (b []byte)

StringToBytes converts string to byte slice without a memory allocation.

func TrimSuffix

func TrimSuffix(path string, suffix string) string

Types

type MyError

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

func (*MyError) Code

func (e *MyError) Code() int

func (*MyError) Error

func (e *MyError) Error() string

type RequestLogger

type RequestLogger struct {
	StartTime, StopTime time.Time
	Ip, Method, Path    string
	Status              int16
}

type Semaphore

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

func NewSemaphore

func NewSemaphore(permits int) *Semaphore

func (*Semaphore) Acquire

func (s *Semaphore) Acquire()

func (*Semaphore) AvailablePermits

func (s *Semaphore) AvailablePermits() int

func (*Semaphore) Release

func (s *Semaphore) Release()

func (*Semaphore) TryAcquire

func (s *Semaphore) TryAcquire() bool

func (*Semaphore) TryAcquireOnTime

func (s *Semaphore) TryAcquireOnTime(timeout time.Duration) bool

Jump to

Keyboard shortcuts

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