Documentation
¶
Index ¶
- Constants
- Variables
- func AESDecrypt(key, text []byte) ([]byte, error)
- func AESEncrypt(key, text []byte) ([]byte, error)
- func BytesReader(data interface{}) io.Reader
- func CheckErr(err error) string
- func Download(urlStr, filename string) (size int64, err error)
- func ExecCmd(cmdName string, args ...string) (string, string, error)
- func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error)
- func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error)
- func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error)
- func FileAppendBytes(filename string, data []byte) error
- func FileAppendString(filename string, data string) error
- func FileBufferedReader(filenameOrURL string) (io.Reader, error)
- func FileCopy(source string, dest string) (err error)
- func FileCopyDir(source string, dest string) (err error)
- func FileExists(filename string) bool
- func FileFind(searchDirs []string, filenames ...string) (filePath string, found bool)
- func FileGetBytes(filenameOrURL string, timeout ...time.Duration) ([]byte, error)
- func FileGetExt(filename string) string
- func FileGetPrefix(filename string) string
- func FileGetString(filenameOrURL string, timeout ...time.Duration) (string, error)
- func FileIsDir(dirname string) bool
- func FileSetBytes(filename string, data []byte) error
- func FileSetString(filename string, data string) error
- func FileSize(filename string) int64
- func FileTimeModified(filename string) time.Time
- func GetImageInfo(inputFilePath string) (int, int, error)
- func HttpCall(client *http.Client, method, url string, header http.Header, body io.Reader) (io.ReadCloser, error)
- func HttpGet(client *http.Client, url string, header http.Header) (io.ReadCloser, error)
- func HttpGetBytes(client *http.Client, url string, header http.Header) ([]byte, error)
- func HttpGetToFile(client *http.Client, url string, header http.Header, fileName string) error
- func HttpPost(client *http.Client, url string, header http.Header, body []byte) (io.ReadCloser, error)
- func ImageBase64ToFile(datasource, filename string) error
- func ImageBase64ToImg(datasource string) (image.Image, error)
- func ImageFileToBase64(filename string) string
- func ImageImgToBase64(image image.Image) string
- func ImageImgToFile(image image.Image, filename string) error
- func ListDir(dir string) ([]string, error)
- func ListDirDirectories(dir string) ([]string, error)
- func ListDirFiles(dir string) ([]string, error)
- func LoadImage(path string) (img image.Image, err error)
- func NewUpload(rootpath string) *upload
- func ProcessImage(inputFilePath string, processConfig ImageProcessor) error
- func RandInt64Between(min, max int64) int64
- func RandIntBetween(min, max int) int
- func RandNum(length int) string
- func RandNumber(start int, end int, count int) []int
- func RandString(length int) string
- func RegexpIsEmailAddress(email string) bool
- func RegexpIsPhoneNumber(mobileNum string) bool
- func RegexpIsStrongPassword(pwd string) bool
- func RegexpIsUrl(url string) bool
- func ResizeImage(inputImagePath string, width, height uint, outputFileName string) error
- func RotateImage(inputImagePath, outputImagePath string, angle float64) error
- func SaveImage(path string, img image.Image) error
- func SetConfig(filepath string) *config
- func SliceAppendStr(strs []string, str string) []string
- func SliceCompareInt(s1, s2 []int) bool
- func SliceCompareIntIgnoreOrder(s1, s2 []int) bool
- func SliceCompareStr(s1, s2 []string) bool
- func SliceCompareStrIgnoreOrder(s1, s2 []string) bool
- func StringAddURLParam(url, name, value string) string
- func StringBase64Decode(data string) (string, error)
- func StringBase64Encode(data string) string
- func StringFilter(f func(string) bool, data []string) []string
- func StringFromFloat64(f float64) string
- func StringFromInt(i int) string
- func StringFromInt64(i int64) string
- func StringListContains(list []string, str string) bool
- func StringListContainsCaseInsensitive(list []string, str string) bool
- func StringMD5Hex(data string) string
- func StringMapFunc(f func(string) string, data []string) []string
- func StringMarshalJSON(data interface{}) string
- func StringReplaceHTMLTags(text, replacement string) (plainText string)
- func StringSHA1Hex(data string) string
- func StringSHA256Hex(data string) string
- func StringStripHTMLTags(text string) (plainText string)
- func StringSubStr(s string, start, length int) string
- func StringToBool(s string) bool
- func StringToFloat64(s string) float64
- func StringToInt(str string) int
- func StringToInt64(s string) int64
- func StringToIntArray(str string) ([]int, error)
- func ThumbImage(inputFileName string, maxWidth, maxHeight uint, outputFileName string) error
- func TimeDay() string
- func TimeDayToUnix(daytime string) string
- func TimeFromUnix(unix string) string
- func TimeFromUnixNano(unix string) string
- func TimeMonth() string
- func TimeNowDate() string
- func TimeNowDateDay() string
- func TimeNowUnix() string
- func TimeNowUnixMs() string
- func TimeNowUnixNano() string
- func TimeSecondToUnix(stime string) string
- func TimeWeekDay() string
- func TimeYear() string
- func URLDecode(str string) (string, error)
- func URLEncode(str string) string
- type FileCopyError
- type ImageProcessor
- type RequestWrapper
- func (r *RequestWrapper) Exec() *RequestWrapper
- func (r *RequestWrapper) Json(data string) *RequestWrapper
- func (r *RequestWrapper) Param(key, value string) *RequestWrapper
- func (r *RequestWrapper) Pipe(w io.Writer) (written int64, err error)
- func (r *RequestWrapper) Query(query string) *RequestWrapper
- func (r *RequestWrapper) Set(key, value string) *RequestWrapper
- func (r *RequestWrapper) ToBytes() ([]byte, error)
- func (r *RequestWrapper) ToFile(filename string) (size int64, err error)
- func (r *RequestWrapper) ToString() (string, error)
- func (r *RequestWrapper) Use(client *http.Client) *RequestWrapper
- type Sizer
- type Stat
- type UploadReturnInfo
Constants ¶
const LowerAlphaSeed = "abcdefghijklmnopqrstuvwxyz"
const NumSeed = "0123456789"
const Seed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
const UpperAlphaSeed = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Variables ¶
var UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1541.0 Safari/537.36"
Functions ¶
func AESDecrypt ¶
AESDecrypt decrypts text and given key with AES.
func AESEncrypt ¶
AESEncrypt encrypts text and given key with AES.
func BytesReader ¶
BytesReader convert interface{} to io.Reader
func ExecCmd ¶
ExecCmd executes system command and return stdout, stderr in string type, along with possible error.
func ExecCmdBytes ¶
ExecCmdBytes executes system command and return stdout, stderr in bytes type, along with possible error.
func ExecCmdDir ¶
ExecCmdDir executes system command in given directory and return stdout, stderr in string type, along with possible error.
func ExecCmdDirBytes ¶
ExecCmdDirBytes executes system command in given directory and return stdout, stderr in bytes type, along with possible error.
func FileAppendBytes ¶
FileAppendBytes append bytes to the given file.
func FileAppendString ¶
FileAppendString append string to the given file.
func FileBufferedReader ¶
FileBufferedReader return io.Reader or error by the given file url.
func FileCopyDir ¶
FileCopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.
func FileExists ¶
FileExists return true if the given file exist.
func FileGetBytes ¶
FileGetBytes return []byte or error by the given url and timeout.
func FileGetPrefix ¶
FileGetPrefix return the prefix of filename.
func FileGetString ¶
FileGetString get file string content by given filename or url and timeout.
func FileSetBytes ¶
FileSetBytes set bytes to the given file.
func FileSetString ¶
FileSetString set string to the given file.
func FileTimeModified ¶
FileTimeModified returns the modified time of a file, or the zero time value in case of an error.
func GetImageInfo ¶
GetImageInfo 获取图片的宽高信息 @params inputFilePath @return (int,int,error)
func HttpCall ¶
func HttpCall(client *http.Client, method, url string, header http.Header, body io.Reader) (io.ReadCloser, error)
HttpCall makes HTTP method call.
func HttpGet ¶
HttpGet gets the specified resource. ErrNotFound is returned if the server responds with status 404. eg: rc, err := HttpGet(&http.Client{}, "http://example.com", nil) p, err := ioutil.ReadAll(rc) s := string(p)
func HttpGetBytes ¶
HttpGetBytes gets the specified resource. ErrNotFound is returned if the server responds with status 404.
func HttpGetToFile ¶
HttpGetToFile gets the specified resource and writes to file. ErrNotFound is returned if the server responds with status 404.
func HttpPost ¶
func HttpPost(client *http.Client, url string, header http.Header, body []byte) (io.ReadCloser, error)
HttpPost posts the specified resource. ErrNotFound is returned if the server responds with status 404. var params = url.Values{} param.Add("userName", user) param.Add("pwd", pwd) data := param.Encode() rc, err := HttpGet(&http.Client{}, "http://example.com", nil,[]byte(data)) p, err := ioutil.ReadAll(rc) s := string(p)
func ImageBase64ToFile ¶
ImageBase64ToFile convert base64 string to a image file.
func ImageBase64ToImg ¶
ImageBase64ToImg convert base64 string to image.Image.
func ImageFileToBase64 ¶
ImageFileToBase64 图片文件转base64
func ImageImgToBase64 ¶
ImageImgToBase64 convert image.Image to base64 string.
func ImageImgToFile ¶
ImageImgToFile convert image to file.
func ListDirDirectories ¶
//ListDirDirectories return all the directory names from the directory.
func ListDirFiles ¶
ListDirFiles return all the file names from the directory.
func ProcessImage ¶
func ProcessImage(inputFilePath string, processConfig ImageProcessor) error
ProcessImage 剪裁图片 传入图片的存储路径 name 以及剪裁参数 返回图片的name
func RandInt64Between ¶
RandIntBetween return random int64 between two given int.
func RandIntBetween ¶
RandIntBetween return random int between two given int.
func RandNumber ¶
RandNumber return no-repeat number by given start end and count[min,max).
func RandString ¶
RandString return the rand string by given length.
func RegexpIsEmailAddress ¶
RegexpIsEmailAddress return true if the given string is a email address.
func RegexpIsPhoneNumber ¶
RegexpIsPhoneNumber return true if given string is a phone number.
func RegexpIsStrongPassword ¶
RegexpIsStrongPassword return true if the given string is a strong pwd(6位以上数字和字母的组合).
func RegexpIsUrl ¶
RegexpIsUrl return true if the given string is a true url.
func ResizeImage ¶
ResizeImage 图片缩放 @params inputImagePath width height outputFileName @return error
func RotateImage ¶
RotateImage 旋转图片 参数为角度(顺时针) @params inputImagePath outputImagePath angle @return error
func SliceAppendStr ¶
SliceAppendStr appends string to slice with no duplicates.
func SliceCompareInt ¶
SliceCompareStr compares two 'int' type slices. It returns true if elements and order are both the same.
func SliceCompareIntIgnoreOrder ¶
SliceCompareStrIgnoreOrder compares two 'int' type slices. It returns true if elements are the same, and ignores the order.
func SliceCompareStr ¶
SliceCompareStr compares two 'string' type slices. It returns true if elements and order are both the same.
func SliceCompareStrIgnoreOrder ¶
SliceCompareStrIgnoreOrder compares two 'string' type slices. It returns true if elements are the same, and ignores the order.
func StringAddURLParam ¶
StringAddURLParam add url param for given url.
func StringBase64Decode ¶
StringBase64Decode returns the string represented by the base64 string data. TODO test func
func StringBase64Encode ¶
StringBase64Encode returns the base64 encoding of data. TODO test func
func StringFilter ¶
StringFilter filter out all strings where the function does not return true.
func StringFromFloat64 ¶
StringFromFloat64 convert float64 to string.
func StringFromInt64 ¶
StringFromInt64 convert int64 to string.
func StringListContains ¶
StringListContains judge if the slice of string contains the given string element.
func StringListContainsCaseInsensitive ¶
StringListContainsCaseInsensitive judge if the slice of string contains the given string element case-insensitive.
func StringMD5Hex ¶
StringMD5Hex returns the hex encoded MD5 hash of data.
func StringMapFunc ¶
StringMapFunc execute a function on each element of the slice of string.
func StringMarshalJSON ¶
func StringMarshalJSON(data interface{}) string
StringMarshalJSON marshals data to an json string.
func StringReplaceHTMLTags ¶
StringReplaceHTMLTags replaces HTML/XML tags from text with replacement.
func StringSHA1Hex ¶
StringMD5Hex returns the hex encoded SHA1 hash of data.
func StringSHA256Hex ¶
StringMD5Hex returns the hex encoded SHA256 hash of data.
func StringStripHTMLTags ¶
StringStripHTMLTags strips HTML/XML tags from text.
func StringSubStr ¶
StringSubStr returns the substr from start to length.
func StringToBool ¶
StringToInt convert string to bool. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
func StringToFloat64 ¶
StringToInt convert string to float64.
func StringToIntArray ¶
StringToIntArray convert string to a int array eg: "1,2,3" => [1,2,3]
func ThumbImage ¶
ImageThumbnail 生成缩略图 最大宽高,不会改变图片的比例 @params inputFile maxWidth maxHeight outputFile @return error
func TimeDayToUnix ¶
TimeDayToUnix return unix time string by given format-time.
func TimeFromUnix ¶
TimeFromUnix return normal format time from unix time string.
func TimeFromUnixNano ¶
TimeFromUnixNano return normal format time from unix nano time string.
func TimeNowUnixNano ¶
func TimeNowUnixNano() string
TimeNowUnixNano return now unix nano time string.
func TimeSecondToUnix ¶
TimeSecondToUnix return unix time string by given format-time.
Types ¶
type FileCopyError ¶
type FileCopyError struct {
What string
}
A struct for returning file copy error messages
func (*FileCopyError) Error ¶
func (e *FileCopyError) Error() string
type ImageProcessor ¶
type ImageProcessor struct {
//距离左边距离
LeftPoint int
//距离上边距离
TopPoint int
//裁剪后的宽
Width int
//剪裁后的高
Height int
}
ImageProcessor 图片剪裁参数
type RequestWrapper ¶
type RequestWrapper struct {
// contains filtered or unexported fields
}
封装的http请求 请求客户端 Request Response error(如果有错误发生)
func Delete ¶
func Delete(urlStr string) *RequestWrapper
func Get ¶
func Get(urlStr string) *RequestWrapper
func NewRequest ¶
func NewRequest(method, urlStr string) *RequestWrapper
func Post ¶
func Post(urlStr string) *RequestWrapper
func Put ¶
func Put(urlStr string) *RequestWrapper
func (*RequestWrapper) Json ¶
func (r *RequestWrapper) Json(data string) *RequestWrapper
设置post请求的参数 body主体 `{"greeting":"hello world"}`
func (*RequestWrapper) Param ¶
func (r *RequestWrapper) Param(key, value string) *RequestWrapper
添加url参数
func (*RequestWrapper) Pipe ¶
func (r *RequestWrapper) Pipe(w io.Writer) (written int64, err error)
结果输出为io.Writer 返回length 以及error
func (*RequestWrapper) Query ¶
func (r *RequestWrapper) Query(query string) *RequestWrapper
func (*RequestWrapper) Set ¶
func (r *RequestWrapper) Set(key, value string) *RequestWrapper
设置header
func (*RequestWrapper) ToFile ¶
func (r *RequestWrapper) ToFile(filename string) (size int64, err error)
结果输出到文件
func (*RequestWrapper) Use ¶
func (r *RequestWrapper) Use(client *http.Client) *RequestWrapper
设置client
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
仿照:https://github.com/orcaman/concurrent-map的思路
|
仿照:https://github.com/orcaman/concurrent-map的思路 |