util

package
v0.0.0-...-9931aa1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION = "0.76"
)

Variables

View Source
var (
	Transport *http.Transport
)

Functions

func BytesToUint16

func BytesToUint16(b []byte) (v uint16)

func BytesToUint32

func BytesToUint32(b []byte) (v uint32)

func BytesToUint64

func BytesToUint64(b []byte) (v uint64)

func Delete

func Delete(url string, jwt security.EncodedJwt) error

func Do

func Do(req *http.Request) (resp *http.Response, err error)

func DownloadUrl

func DownloadUrl(fileUrl string) (filename string, rc io.ReadCloser, e error)

func Get

func Get(url string) ([]byte, error)

func GetBufferStream

func GetBufferStream(url string, values url.Values, allocatedBytes []byte, eachBuffer func([]byte)) error

func GetFileSize

func GetFileSize(file *os.File) (size int64, err error)

func GetUrlStream

func GetUrlStream(url string, values url.Values, readFn func(io.Reader) error) error
func Head(url string) (http.Header, error)

func NewListener

func NewListener(addr string, timeout time.Duration) (net.Listener, error)

func NormalizeUrl

func NormalizeUrl(url string) string

func OnInterrupt

func OnInterrupt(fn func())

func ParseInt

func ParseInt(text string, defaultValue int) int

func ParseUint64

func ParseUint64(text string, defaultValue uint64) uint64

func Post

func Post(url string, values url.Values) ([]byte, error)

func PostBytes

func PostBytes(url string, body []byte) ([]byte, error)

func Readln

func Readln(r *bufio.Reader) ([]byte, error)

func SetupProfiling

func SetupProfiling(cpuProfile, memProfile string)

func TestFolderWritable

func TestFolderWritable(folder string) (err error)

func Uint16toBytes

func Uint16toBytes(b []byte, v uint16)

func Uint32toBytes

func Uint32toBytes(b []byte, v uint32)

func Uint64toBytes

func Uint64toBytes(b []byte, v uint64)

func Uint8toBytes

func Uint8toBytes(b []byte, v uint8)

Types

type ConcurrentReadMap

type ConcurrentReadMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A mostly for read map, which can thread-safely initialize the map entries.

func NewConcurrentReadMap

func NewConcurrentReadMap() *ConcurrentReadMap

func (*ConcurrentReadMap) Delete

func (m *ConcurrentReadMap) Delete(key string)

func (*ConcurrentReadMap) Find

func (m *ConcurrentReadMap) Find(key string) (interface{}, bool)

func (*ConcurrentReadMap) Get

func (m *ConcurrentReadMap) Get(key string, newEntry func() interface{}) interface{}

func (*ConcurrentReadMap) Items

func (m *ConcurrentReadMap) Items() (itemsCopy []interface{})

type Config

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

func LoadConfig

func LoadConfig(filename string) *Config

Loads config information from a JSON file

func LoadConfigString

func LoadConfigString(s string) *Config

Loads config information from a JSON string

func (*Config) GetArray

func (c *Config) GetArray(key string) []interface{}

Returns an array for the config variable key

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

Returns a bool for the config variable key

func (*Config) GetFloat

func (c *Config) GetFloat(key string) float64

Returns a float for the config variable key

func (*Config) GetInt

func (c *Config) GetInt(key string) int

Returns an int for the config variable key

func (*Config) GetString

func (c *Config) GetString(key string) string

Returns a string for the config variable key

func (*Config) LoadMerge

func (c *Config) LoadMerge(filename string)

func (*Config) StringMerge

func (c *Config) StringMerge(s string)

type Conn

type Conn struct {
	net.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Conn wraps a net.Conn, and sets a deadline for every read and write operation.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (count int, e error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (count int, e error)

type Listener

type Listener struct {
	net.Listener
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Listener wraps a net.Listener, and gives a place to store the timeout parameters. On Accept, it will wrap the net.Conn with our own Conn for us.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Jump to

Keyboard shortcuts

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