Documentation
¶
Overview ¶
提供一些实用函数
Index ¶
- Variables
- func Bool(v bool) *bool
- func Bool2Int(b bool) int
- func DecodeXMLToMap(r io.Reader) (m map[string]string, err error)
- func EncodeXMLFromMap(w io.Writer, m map[string]string, rootname string) (err error)
- func Float32(v float32) *float32
- func Float64(v float64) *float64
- func HttpResponseWriter(w io.Writer) http.ResponseWriter
- func Int(v int) *int
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func NonceStr() string
- func Paginator0(pageNum, currentPageIndex int) ([]int, error)
- func Paginator0Ex(totalItemNum, pageSize, currentPageIndex int) (arr []int, pageNum int, err error)
- func Paginator1(pageNum, currentPageIndex int) (arr []int, err error)
- func Paginator1Ex(totalItemNum, pageSize, currentPageIndex int) (arr []int, pageNum int, err error)
- func String(v string) *string
- func TrimSpace(src []byte) []byte
- func TrimSpaceString(src string) string
- func Uint32(v uint32) *uint32
- func Uint64(v uint64) *uint64
- func WXVersion(userAgent string) (x, y, z, w int, err error)
- type RoundRobinIndex
Constants ¶
This section is empty.
Variables ¶
var BeijingLocation = time.FixedZone("Asia/Shanghai", 8*60*60)
var DefaultHttpClient *http.Client
var DefaultMediaHttpClient *http.Client
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func DecodeXMLToMap ¶
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 ¶
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 Float32 ¶
Float32 is a helper routine that allocates a new float32 value to store v and returns a pointer to it.
func Float64 ¶
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
func HttpResponseWriter ¶
func HttpResponseWriter(w io.Writer) http.ResponseWriter
将 io.Writer 从语义上实现 http.ResponseWriter.
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func Int32 ¶
Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.
func Int64 ¶
Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.
func Paginator0 ¶
获取分页编号序列, 页码从 0 开始, 序列中非负整数表示页码, -1 表示省略, 如 [0,1,-1,8,9,10,11,12,-1,15,16] 表示 0,1,...,8,9,10,11,12,...,15,16
pageNum: 页面数量, 大于 0 的整数 currentPageIndex: 当前页码, 从 0 开始编码
func Paginator0Ex ¶
获取分页编号序列, 页码从 0 开始, 序列中非负整数表示页码, -1 表示省略, 如 [0,1,-1,8,9,10,11,12,-1,15,16] 表示 0,1,...,8,9,10,11,12,...,15,16
totalItemNum: 总的记录数量, 不是页面数量, 非负整数 pageSize: 每页显示的数量, 大于 0 的整数 currentPageIndex: 当前页码, 从 0 开始编码
func Paginator1 ¶
获取分页编号序列, 页码从 1 开始, 序列中正整数表示页码, -1 表示省略, 如 [1,2,-1,8,9,10,11,12,-1,15,16] 表示 1,2,...,8,9,10,11,12,...,15,16
pageNum: 页面数量, 大于 0 的整数 currentPageIndex: 当前页码, 从 1 开始编码
func Paginator1Ex ¶
获取分页编号序列, 页码从 1 开始, 序列中正整数表示页码, -1 表示省略, 如 [1,2,-1,8,9,10,11,12,-1,15,16] 表示 1,2,...,8,9,10,11,12,...,15,16
totalItemNum: 总的记录数量, 不是页面数量, 非负整数 pageSize: 每页显示的数量, 大于 0 的整数 currentPageIndex: 当前页码, 从 1 开始编码
func String ¶
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
func TrimSpace ¶
去掉 src 开头和结尾的空白, 如果 src 包括换行, 去掉换行和这个换行符两边的空白
NOTE: 根据 '\n' 来分行的, 某些系统或软件用 '\r' 来分行, 则不能正常工作.
func TrimSpaceString ¶
去掉 src 开头和结尾的空白, 如果 src 包括换行, 去掉换行和这个换行符两边的空白
NOTE: 根据 '\n' 来分行的, 某些系统或软件用 '\r' 来分行, 则不能正常工作.
func Uint32 ¶
Uint32 is a helper routine that allocates a new uint32 value to store v and returns a pointer to it.
Types ¶
type RoundRobinIndex ¶
type RoundRobinIndex struct {
// contains filtered or unexported fields
}
func NewRoundRobinIndex ¶
func NewRoundRobinIndex(bound int) *RoundRobinIndex
func (*RoundRobinIndex) Next ¶
func (rr *RoundRobinIndex) Next() int