goutils

package module
v0.0.0-...-582c98b Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2016 License: MIT Imports: 21 Imported by: 0

README

goutils

Go语言常用工具类封装

Documentation

Index

Constants

View Source
const (
	XForwardedFor = "X-Forwarded-For"
	XRealIP       = "X-Real-IP"
)
View Source
const DefaultCharset = randutil.Alphanumeric + "!%@#"

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(data string) string

func Base64Encode

func Base64Encode(data string) string

func CamelName

func CamelName(name string) string

下划线写法转为驼峰写法

func ConvertString

func ConvertString(inter interface{}, precs ...int) string

func GenSign

func GenSign(args url.Values, secretKey string) string

GenSign 根据输入参数进行签名

func Gunzip

func Gunzip(r io.Reader) ([]byte, error)

func Gzip

func Gzip(b []byte, w io.Writer) (int, error)

func Ip2long

func Ip2long(ipstr string) uint32

Ip2long 将 IPv4 字符串形式转为 uint32

func Md5

func Md5(text string) string

func Md5Buf

func Md5Buf(buf []byte) string

func Md5File

func Md5File(reader io.Reader) string

func MustBool

func MustBool(s string, defaultVal ...bool) bool

func MustFloat

func MustFloat(inter interface{}, defaultVals ...float64) float64

func MustInt

func MustInt(s string, defaultVal ...int) int

MustInt 字符串转int

func MustInt64

func MustInt64(s string, defaultVal ...int64) int64

MustInt64 字符串转int64

func RandString

func RandString(n int, defaultCharsets ...string) string

RandString 产生随机字符串,可用于密码等

func RemoteIp

func RemoteIp(req *http.Request) string

RemoteIp 返回远程客户端的 IP,如 192.168.1.1

func SearchString

func SearchString(slice []string, s string) int

func UnderscoreName

func UnderscoreName(name string) string

驼峰式写法转为下划线写法

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
}

内嵌bytes.Buffer,支持连写

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Append

func (b *Buffer) Append(i interface{}) *Buffer

Jump to

Keyboard shortcuts

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