commons

package
v0.0.0-...-5a29284 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BUY const
	BUY int = 0
	// SELL const
	SELL int = 1

	// DEV Phase DEV. No real API calls. Only mocking.
	DEV int = 2
	// RC Phase RC. Only testing if trading works.
	RC int = 3
	// REAL Phase REAL. Real mode.
	REAL int = 4
)

Variables

View Source
var AsiaSeoul *time.Location

AsiaSeoul is the timezone of Asia/Seoul

View Source
var PHASE = DEV

PHASE Phase of the server.

Functions

func Decrypt

func Decrypt(msg string) string

Decrypt Decrypts message. Length of message must be longer than aes.BlockSize

func Encrypt

func Encrypt(msg string) string

Encrypt Encrypts message.

func GetDouble

func GetDouble(s string) float64

GetDouble parses string into float64 s: string, comma allowed if parsing fails: panics

func GetInt

func GetInt(s string) int

GetInt parses string into int s: string, comma allowed if parsing fails: panics

func GetInt64

func GetInt64(s string) int64

GetInt64 parses string into int64 s: string, comma allowed if parsing fails: panics

func GetTimestamp

func GetTimestamp(layout, value string) int64

GetTimestamp returns timestamp from string value given layout.

func InvokeGoroutine

func InvokeGoroutine(tag string, f func())

InvokeGoroutine Invoke goroutine with handling panicking Sends log to GCE with stack trace https://jacking75.github.io/go_spew/

func MaxInt

func MaxInt(a, b int) int

MaxInt Maximum of two numbers

func MaxInt64

func MaxInt64(a, b int64) int64

MaxInt64 Maximum of two numbers

func MinInt

func MinInt(a, b int) int

MinInt Minimum of two numbers

func MinInt64

func MinInt64(a, b int64) int64

MinInt64 Minimum of two numbers

func Now

func Now() time.Time

Now returns time.Now() of Asia/Seoul

func ResetEncryptionKey

func ResetEncryptionKey(newKey string)

ResetEncryptionKey Use this to change the encryption key

func Today

func Today() time.Time

Today returns today's time.Time of Asia/Seoul

func Unix

func Unix(timestamp int64) time.Time

Unix converts timestamp to time in Seoul

Types

type ConcurrentMap

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

func NewConcurrentMap

func NewConcurrentMap() *ConcurrentMap

func (*ConcurrentMap) Count

func (cm *ConcurrentMap) Count() int

func (*ConcurrentMap) DeleteValue

func (cm *ConcurrentMap) DeleteValue(key interface{})

func (*ConcurrentMap) GetValue

func (cm *ConcurrentMap) GetValue(key interface{}) (interface{}, bool)

func (*ConcurrentMap) Iterate

func (cm *ConcurrentMap) Iterate(f func(key, value interface{}, stop *bool))

func (*ConcurrentMap) SetValue

func (cm *ConcurrentMap) SetValue(key, value interface{})

type MetaError

type MetaError func(msg string) error

MetaError generates an error with a cached tag

func NewTaggedError

func NewTaggedError(tag string) MetaError

NewTaggedError generates an error generator given a tag

type Ref

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

Ref is a simple struct for reference counting. Will panic if overreleased.

func (*Ref) Count

func (r *Ref) Count() int

Count returns the reference count of the struct.

func (*Ref) Release

func (r *Ref) Release()

Release decreases reference count of the struct. It is the holder's responsibility to make use of the reference count. It panics if the struct is overreleased.

func (*Ref) Retain

func (r *Ref) Retain()

Retain increases reference count of the struct.

type ReferenceCounting

type ReferenceCounting interface {
	Retain()
	Release()
	Count() int
}

ReferenceCounting is an interface for reference counting structs

Jump to

Keyboard shortcuts

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