util

package
v0.0.0-...-43f4138 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2017 by GoSpider author. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 by GoSpider author. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64D

func Base64D(urlxxstring string) string

字符串base64解密

func Base64E

func Base64E(urlstring string) string

字符串base64加密

func ComputeHmac256

func ComputeHmac256(message string, secret string) string

HMAC with the SHA256 http://blog.csdn.net/js_sky/article/details/49024959

func CopyFF

func CopyFF(src io.Reader, dst io.Writer) error

File-File复制文件

func CopyFS

func CopyFS(src io.Reader, dst string) error

File-String复制文件

func CurDir

func CurDir() string

获取调用者的当前文件DIR Get the caller now directory

func DevideStringList

func DevideStringList(files []string, num int) (map[int][]string, error)

change by python

func FileExist

func FileExist(filename string) bool

func FileStatus

func FileStatus(filepath string)

文件状态

func GetBinaryCurrentPath

func GetBinaryCurrentPath() (string, error)

获取当前执行二进制所在的位置

func GetCurrentPath

func GetCurrentPath() (string, error)

获取当前执行命令所在的位置

func GetDateTimes2Secord

func GetDateTimes2Secord(datestring string) int64

func GetFileSuffix

func GetFileSuffix(f string) string

获取文件后缀

func GetFilenameInfo

func GetFilenameInfo(filepath string) (os.FileInfo, error)

Get file info

func GetSecord2DateTimes

func GetSecord2DateTimes(secord int64) string

201611112113

func GetSecordTimes

func GetSecordTimes() int64

get secord times 172606056

func HasFile

func HasFile(s string) bool

判断文件或文件夹是否存在

func IS

func IS(i int) string

int to string

func InArray

func InArray(sa []string, a string) bool

字符串是否在字符串数组中

func Input

func Input(say, defaults string) string

func IsDir

func IsDir(filepath string) bool

判断是否是文件夹

func IsFile

func IsFile(filepath string) bool

判断是否是文件

func JsonBack

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

最好的方法

func JsonEncode

func JsonEncode(raw string) string

将JSON中的/u unicode乱码转回来,笨方法,弃用

func ListDir

func ListDir(dirPth string, suffix string) (files []string, err error)

func MakeDir

func MakeDir(filedir string) error

根据传入文件夹名字递归新建文件夹 Create dir by recursion

func MakeDirByFile

func MakeDirByFile(filepath string) error

根据传入文件名,递归创建文件夹 ./dir/filename /home/dir/filename Create dir by the filename

func Md5

func Md5(str string) string

func ReadfromFile

func ReadfromFile(filepath string) ([]byte, error)

read bytes from file

func Rename

func Rename(oldfilename string, newfilename string) error

rename

func SI

func SI(s string) (i int, e error)

string to int

func SaveToFile

func SaveToFile(filepath string, content []byte) error

将字节数组保存到文件中去 Save bytes into file

func Second

func Second(times int) time.Duration

time

func SizeofDir

func SizeofDir(dirPth string) int

文件夹下数量

func Sleep

func Sleep(waittime int)

sleep

func StringsToJson

func StringsToJson(str string) string

将字符串转成适合JSON格式的,比如中文转为\\u

func Strtomd5

func Strtomd5(s string) string

create md5 string

func Substr

func Substr(str string, start, length int) string

func ToLower

func ToLower(s string) string

func TodayString

func TodayString(level int) string

func UrlD

func UrlD(s string) string

url解义

func UrlE

func UrlE(s string) string

url转义

func ValidBackFileName

func ValidBackFileName(filename string) string

func ValidFileName

func ValidFileName(filename string) string

# 去除标题中的非法字符 (Windows) def validateTitle(title): rstr = r"[\/\\\:\*\?\"\<\>\|]" # '/\:*?"<>|' new_title = re.sub(rstr, "", title) return new_title

func WalkDir

func WalkDir(dirPth, suffix string) (files []string, err error)

Types

This section is empty.

Directories

Path Synopsis
Open a file, directory, or URI using the OS's default application for that object type.
Open a file, directory, or URI using the OS's default application for that object type.

Jump to

Keyboard shortcuts

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