util

package
v0.0.0-...-42d190a Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeXMLToMap

func DecodeXMLToMap(r io.Reader) (m map[string]string, err error)

DecodeXMLToMap decodes xml reading from io.Reader and returns the first-level sub-node key-value set, if the first-level sub-node contains child nodes, skip it.

func EncodeXMLFromMap

func EncodeXMLFromMap(w io.Writer, m map[string]string, rootname string) (err error)

EncodeXMLFromMap encodes map[string]string to io.Writer with xml format.

NOTE: This function requires the rootname argument and the keys of m (type map[string]string) argument
are legitimate xml name string that does not contain the required escape character!

func FormatTime

func FormatTime(t time.Time) string

FormatTime 将参数 t 格式化成北京时间 yyyyMMddHHmmss.

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

GbkToUtf8 Gbk转码到utf8

func Now

func Now() int

Now 获取1970到现在的秒数

func ParseTime

func ParseTime(value string) (time.Time, error)

ParseTime 将北京时间 yyyyMMddHHmmss 字符串解析到 time.Time.

func RandString

func RandString(length int) string

RandString 在数字、大写字母、小写字母范围内生成num位的随机字符串

func Sha1

func Sha1(key string) string

Sha1 获取散列

func TrimBytesSpace

func TrimBytesSpace(src []byte) []byte

* TrimBytesSpace * 去掉 src 开头和结尾的空白, 如果 src 包括换行, 去掉换行和这个换行符两边的空白 * TrimSpace NOTE: 根据 '\n' 来分行的, 某些系统或软件用 '\r' 来分行, 则不能正常工作.

func TrimStringSpace

func TrimStringSpace(src string) string

* TrimStringSpace src string * 去掉 src 开头和结尾的空白, 如果 src 包括换行, 去掉换行和这个换行符两边的空白 * NOTE: 根据 '\n' 来分行的, 某些系统或软件用 '\r' 来分行, 则不能正常工作.

func URLValuesToStruct

func URLValuesToStruct(value url.Values, out interface{}) error

URLValuesToStruct 把url.Values转成struct

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Utf8ToGbk Utf8转码到Bbk

Types

type List

type List []string

List 参数列表

func (List) Len

func (list List) Len() int

func (List) Less

func (list List) Less(i, j int) bool

func (List) String

func (list List) String() string

func (List) Swap

func (list List) Swap(i, j int)

Jump to

Keyboard shortcuts

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