util

package
v0.0.0-...-43a0c9e Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package util includes common utilities.

Index

Constants

This section is empty.

Variables

View Source
var File = myfile{}

File utilities.

View Source
var Go = mygo{}

Go utilities.

View Source
var Net = mynet{}

Network utilities.

View Source
var OS = myos{}

OS utilities.

View Source
var Rand = myrand{}

Random utilities.

View Source
var Str = str{}

String utilities.

View Source
var Zip = myzip{}

Zip utilities.

Functions

func Recover

func Recover()

Recover recovers a panic.

func RetGzJSON

func RetGzJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})

RetGzJSON writes HTTP response with "Content-Type, application/json".

func RetJSON

func RetJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})

RetJSON writes HTTP response with "Content-Type, application/json".

Types

type Reader

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

Reader represents a reader.

func NewReader

func NewReader(rd io.Reader) *Reader

NewReader returns a new Reader whose buffer has the default size.

func NewReaderSize

func NewReaderSize(rd io.Reader, size int) *Reader

NewReaderSize creates a reader with the specified buffer size.

func (*Reader) Buffered

func (b *Reader) Buffered() int

Buffered returns the size of buffered.

func (*Reader) Read

func (b *Reader) Read(buf []byte) (count int, err error)

func (*Reader) ReadData

func (b *Reader) ReadData() (line string, err error)

ReadData reads a line.

type WSChannel

type WSChannel struct {
	Sid     string          // wide session id
	Conn    *websocket.Conn // websocket connection
	Request *http.Request   // HTTP request related
	Time    time.Time       // the latest use time
}

WSChannel represents a WebSocket channel.

func (*WSChannel) Close

func (c *WSChannel) Close()

Close closed the channel.

func (*WSChannel) ReadJSON

func (c *WSChannel) ReadJSON(v interface{}) (ret error)

ReadJSON reads the next JSON-encoded message from the channel and stores it in the value pointed to by v.

func (*WSChannel) Refresh

func (c *WSChannel) Refresh()

Refresh refreshes the channel by updating its use time.

func (*WSChannel) WriteJSON

func (c *WSChannel) WriteJSON(v interface{}) (ret error)

WriteJSON writes the JSON encoding of v to the channel.

type ZipFile

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

ZipFile represents a zip file.

func (*ZipFile) AddDirectory

func (z *ZipFile) AddDirectory(path, dirName string) error

AddDirectory adds a directory.

func (*ZipFile) AddDirectoryN

func (z *ZipFile) AddDirectoryN(path string, names ...string) error

AddDirectoryN adds directories.

func (*ZipFile) AddEntry

func (z *ZipFile) AddEntry(path, name string) error

AddEntry adds a entry.

func (*ZipFile) AddEntryN

func (z *ZipFile) AddEntryN(path string, names ...string) error

AddEntryN adds entries.

func (*ZipFile) Close

func (z *ZipFile) Close() error

Close closes the zip file writer.

Jump to

Keyboard shortcuts

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