util

package module
v0.0.0-...-6908ac9 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-utils

golang util pkg

cryptox 包

封装了运行时加密包以及数据的填充方式。

加密类型包含:

  • AES
  • DES
  • TripleDES
  • HMac
  • SHA

填充方式包含:

  • ZeroPadding
  • PKCS5Padding

dbx 包

封装的数据库连接类,包含:

  • PostgreSQL
  • MySQL
  • Redis
  • SQLite

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteAddr

func RemoteAddr(req *http.Request) string

Types

type Byte

type Byte struct{}

func NewHex

func NewHex() *Byte

func (*Byte) Bin2Byte

func (this *Byte) Bin2Byte(bin []byte) (buf []byte)

func (*Byte) Byte2Bin

func (this *Byte) Byte2Bin(buf []byte) (bin []byte)

func (*Byte) Byte2Hex

func (this *Byte) Byte2Hex(buf []byte) (hex []byte)

func (*Byte) Hex2Byte

func (this *Byte) Hex2Byte(hex []byte) (buf []byte)

type Date

type Date struct{}

func NewDate

func NewDate() *Date

func (*Date) DefaultFormat

func (this *Date) DefaultFormat(t time.Time) string

func (*Date) Format

func (this *Date) Format(t time.Time, format string) string

*

  • 使用易于理解的字符串格式化时间,Y-m-d H:M:S.ms

type Http

type Http struct {
	Method  string
	Addr    string
	Data    string // http POST data
	Timeout int    // http timeout second
	Header  struct {
		UserAgent   string
		ContentType string // "text/json; charset=utf-8"
	}
}

func NewHttp

func NewHttp() *Http

func NewHttpWithUserAgent

func NewHttpWithUserAgent(userAgent string) *Http

func (*Http) Do

func (this *Http) Do() (data []byte, err error)

func (*Http) GET

func (this *Http) GET(addr string) ([]byte, error)

func (*Http) POST

func (this *Http) POST(addr, data string) ([]byte, error)

func (*Http) PostForm

func (this *Http) PostForm(addr string, data url.Values) ([]byte, error)

type Path

type Path struct{}

func NewPath

func NewPath() *Path

func (*Path) Abs

func (this *Path) Abs(filePath string) (string, error)

func (*Path) Create

func (this *Path) Create(dir string, perm os.FileMode) error

func (*Path) Dir

func (this *Path) Dir(filePath string) (string, error)

func (*Path) ExecPath

func (this *Path) ExecPath() string

func (*Path) FileName

func (this *Path) FileName(filePath string) (string, error)

func (*Path) IsExist

func (this *Path) IsExist(path string) (bool, error)

判断文件夹是否存在

func (*Path) Split

func (this *Path) Split(filePath string) []string

func (*Path) WorkDir

func (this *Path) WorkDir() string

WorkDir returns absolute path of work directory.

func (*Path) WorkName

func (this *Path) WorkName() string

type Rand

type Rand struct{}

func NewRand

func NewRand() *Rand

func (*Rand) Bytes

func (this *Rand) Bytes(length int) []byte

生成随机字符串

func (*Rand) Num

func (this *Rand) Num(length int) int64

func (*Rand) String

func (this *Rand) String(length int) string

生成随机字符串

type Strings

type Strings struct{}

func NewStrings

func NewStrings() *Strings

func (*Strings) Empty

func (this *Strings) Empty() string

func (*Strings) IsEmpty

func (this *Strings) IsEmpty(str string) bool

Directories

Path Synopsis
* This file copy from https://github.com/qyxing/ostar/blob/master/codec/rsa_ext.go * It's license same with upstream.
* This file copy from https://github.com/qyxing/ostar/blob/master/codec/rsa_ext.go * It's license same with upstream.

Jump to

Keyboard shortcuts

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