util

package
v0.0.0-...-ccdf126 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2016 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ApiPrefix = ""
View Source
const ConsoleApiPrefix = "/api/c"
View Source
const InternalApiPrefix = "/api/i"

Variables

View Source
var Location *time.Location = time.Local

Functions

func A

func A()

func AddDate

func AddDate(ts int64, years, months, days int) int64

func ApiPath

func ApiPath(subpath string) string

func ConsoleApiPath

func ConsoleApiPath(subpath string) string

func ForceToInt64

func ForceToInt64(s string) int64

去掉非数字字符后,再转换成字符串

func GetCurrYearMonth

func GetCurrYearMonth() (int, time.Time)

func GetDatePart

func GetDatePart(t *time.Time) time.Time

func GetMs

func GetMs(t *time.Time) int64

func GetPartOfInt64Slice

func GetPartOfInt64Slice(theSlice []int64, fromKey int, size int) []int64

func GetPartOfStringSlice

func GetPartOfStringSlice(theSlice []string, fromKey int, size int) []string

func GetPrevYearMonth

func GetPrevYearMonth() (int, time.Time)

201401, 201402 以此类推

func GetRandomByMinMax

func GetRandomByMinMax(min, max int) int

获取区间内的随机数

func GetUserAgent

func GetUserAgent(req *http.Request) string

func GetYearMonth

func GetYearMonth(t time.Time) int

func Getwd

func Getwd() string

func HasFormValue

func HasFormValue(req *http.Request, key string) bool

func Int64SliceToString

func Int64SliceToString(s []int64) []string

func IntSliceToString

func IntSliceToString(s []int) []string

func InternalApiPath

func InternalApiPath(subpath string) string

func IsApiPath

func IsApiPath(path string) bool

func IsDate

func IsDate(s string) bool

func IsDirExists

func IsDirExists(dir string) bool

func IsDuplicateError

func IsDuplicateError(err error) bool

func IsDuplicateError2

func IsDuplicateError2(err error) bool

func IsEmail

func IsEmail(s string) bool

func IsEmpty

func IsEmpty(s string) bool

func IsExists

func IsExists(array []int, key int) bool

func IsExistsString

func IsExistsString(array []string, key string) bool

func IsFileExisted

func IsFileExisted(thepath string) bool

func IsMobile

func IsMobile(s string) bool

func IsNotEmpty

func IsNotEmpty(s string) bool

func IsPublicIP

func IsPublicIP(ip string) bool

func IsRegularOrNotExists

func IsRegularOrNotExists(thepath string) bool

func Md5

func Md5(src string) string

func MergeValues

func MergeValues(src, dst url.Values)

func MonthToRange

func MonthToRange(month int) (begin, end time.Time, err error)

func NewUUID

func NewUUID() *uuid.UUID

func NowDate

func NowDate() time.Time

func NowDateString

func NowDateString() string

func NowDateTimeString

func NowDateTimeString() string

func NowMs

func NowMs() int64

当前毫秒数

func ParseAddress

func ParseAddress(remoteAddr string) string

func ParseInt

func ParseInt(s string, defaultValue int64) int64

func ParseScreen

func ParseScreen(screen string) (long int, short int)

func RandHex

func RandHex(n int) string

随机字节,并转换成十六进制小写

func RandNumberString

func RandNumberString(length int) string

func RandString

func RandString(bits int) string

生成一个随机位数的字符串

func ReadJson

func ReadJson(reader io.ReadCloser, data interface{}) error

func RenderHtml

func RenderHtml(r render.Render, view string, data interface{})

func RepeatString

func RepeatString(times int, s, split string) string

func SplitToIntSlice

func SplitToIntSlice(s string) []int64

func String2Date

func String2Date(s string, loc *time.Location) *time.Time

func String2DateTime

func String2DateTime(s string, loc *time.Location) *time.Time

func StringS2Interface

func StringS2Interface(slice []string) []interface{}

func StringSliceToInt

func StringSliceToInt(s []string) []int

func StringSliceToInt64

func StringSliceToInt64(s []string) []int64

func TimestampToTime

func TimestampToTime(ts int64) time.Time

func ToTimestamp

func ToTimestamp(t *time.Time) int64

func Today

func Today() time.Time

func UniqueId

func UniqueId() string

func UniqueInt64Slice

func UniqueInt64Slice(values []int64) []int64

func UniqueIntSlice

func UniqueIntSlice(values []int) []int

func WriteUploadFile

func WriteUploadFile(fileheaer *multipart.FileHeader, dst string) error

func Yesterday

func Yesterday() time.Time

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
}

func NewBuffer

func NewBuffer(buf []byte) *Buffer

func (*Buffer) Close

func (me *Buffer) Close() error

type PagingParams

type PagingParams struct {
	LowerId   int64 `form:"lowerId"`
	UpperId   int64 `form:"upperId"`
	StartId   int64 `form:"startId"`
	PageSize  int64 `form:"pageSize"`
	PageIndex int64 `form:"pageIndex"`
	Reverse   bool  `form:"reverse"`
}

func (*PagingParams) Adjust

func (pp *PagingParams) Adjust(count int64, defaultPageSize int64)

func (*PagingParams) Process

func (pp *PagingParams) Process(minStartId int64, defaultPageSize int64, maxPageSize int64)

Jump to

Keyboard shortcuts

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