util

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: BSD-3-Clause Imports: 31 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset added in v0.0.3

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir added in v0.0.3

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo added in v0.0.3

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames added in v0.0.3

func AssetNames() []string

AssetNames returns the names of the assets.

func CutKey

func CutKey(key string) string

CutKey cuts key to 11words. used in a func which is used in templates.

func Datestr2ch

func Datestr2ch(epoch int64) string

Datestr2ch converts unixtime str ecpochStr to the certain format string. e.g. 2006/01/02(日) 15:04:05.99

func EachFiles

func EachFiles(dir string, handler func(dir os.FileInfo) error) error

EachFiles iterates each dirs in dir and calls handler,not recirsively.

func EachIOLine

func EachIOLine(f io.ReadCloser, handler func(line string, num int) error) error

EachIOLine iterates each line to a ReadCloser ,calls func and close f.

func EachLine

func EachLine(path string, handler func(line string, num int) error) error

EachLine iterates each lines and calls a func.

func EmbedURL added in v0.0.3

func EmbedURL(url string) string

EmbedURL gets the url for embeding by using oEmbed API.

func Emoji added in v0.0.8

func Emoji(str string) string

Emoji converts :hoe: to a png pic link.

func Escape

func Escape(msg string) string

Escape is like a html.escapestring, except &#xxxx and \n

func EscapeSpace

func EscapeSpace(msg string) string

EscapeSpace converts spaces into html space.

func Fclose

func Fclose(f io.Closer)

Fclose closes io.Close, if err exists ,println err.

func FileDecode

func FileDecode(query string) string

FileDecode decodes filename.

>>> file_decode('foo_7E')
'~'

func FileEncode

func FileEncode(t, query string) string

FileEncode encodes filename.

>>> file_encode('foo', 'a')
'foo_61'
>>> file_encode('foo', '~')
'foo_7E'

func FindString

func FindString(s []string, val string) int

FindString search the val in ary and returns index. it returns -1 if not found.

func FromSJIS

func FromSJIS(b string) string

FromSJIS converts an array of bytes (a valid ShiftJIS string) to a UTF-8 string

func GetBoard

func GetBoard(url string) string

GetBoard returns decoded board name.

func HasExt added in v0.0.3

func HasExt(fname, suffix string) bool

HasExt returns true if fname has prefix and not secret.

func HasString

func HasString(s []string, val string) bool

HasString returns true if ary has val.

func IsDir

func IsDir(path string) bool

IsDir returns true is path is an existing dir.

func IsFile

func IsFile(path string) bool

IsFile returns true is path is an existing file.

func IsValidImage

func IsValidImage(mimetype, path string) bool

IsValidImage checks type of path is same as mimetype or not.

func MD5digest

func MD5digest(dat string) string

MD5digest returns hex string of md5sum

func MakeThumbnail

func MakeThumbnail(encoded []byte, suffix, thumbnailSize string) []byte

MakeThumbnail makes thumbnail to suffix image format with thumbnailSize.

func MustAsset added in v0.0.3

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset added in v0.0.3

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.0.3

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func StrDecode

func StrDecode(query string) string

StrDecode decode from url query

func StrEncode

func StrEncode(query string) string

StrEncode returns enscaped string for url , including "~"

func ToSJIS

func ToSJIS(b string) string

ToSJIS converts an string (a valid UTF-8 string) to a ShiftJIS string

func Verify

func Verify(mesg, testsig, publicKey string) bool

Verify verifies testsig by publicKey.

Types

type ConfList

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

ConfList represents regexp list.

One regexp per one line.

func NewConfList

func NewConfList(path string, defaultList []string) *ConfList

NewConfList makes a confList instance from path.

func (*ConfList) GetData

func (r *ConfList) GetData() []string

GetData retuns a copy of lines in the file.

type PrivateKey

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

PrivateKey reppresents private key,

func MakePrivateKey

func MakePrivateKey(keystr string) (*PrivateKey, error)

MakePrivateKey makes privatekey from keystr

func (*PrivateKey) GetKeys

func (p *PrivateKey) GetKeys() (string, string)

GetKeys returns base64 encoded private key

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(mesg string) string

Sign signs mesg by p.

type RegexpList

type RegexpList struct {
	*ConfList
	// contains filtered or unexported fields
}

RegexpList represents RegExp list.

One regexp per one line.

func NewRegexpList

func NewRegexpList(path string) *RegexpList

NewRegexpList makes a regexpList and regexp.comples each lines in the file.

func (*RegexpList) Check

func (r *RegexpList) Check(target string) bool

Check returns true if target matches one of all regexps or not.

Jump to

Keyboard shortcuts

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