util

package
v0.0.0-...-f171042 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(target string) string

AbsPath 转换相对路径为绝对路径

func Dirname

func Dirname(target string) string

Dirname 返回指定路径的文件夹名

func FileExt

func FileExt(path string) string

FileExt 返回文件扩展名

func FileGetContents

func FileGetContents(filename string) (data []byte, e error)

FileGetContents Get bytes to file. if non-exist, create this file.

func FilePutContents

func FilePutContents(filename string, content []byte, append bool) error

FilePutContents Put bytes to file. if non-exist, create this file.

func GetAppPath

func GetAppPath() string

GetAppPath 返回应用程序当前路径

func GetDirFiles

func GetDirFiles(dirPath string, stripExt bool) []string

GetDirFiles 获取指定文件夹文件列表

func IsDir

func IsDir(filePath string) bool

IsDir returns true if given path is a directory,

func IsExist

func IsExist(path string) bool

IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.

func IsFile

func IsFile(filePath string) bool

IsFile returns true if given path is a file, or returns false when it's a directory or does not exist.

func RelPath

func RelPath(target string) string

RelPath 转相对路径

func SafeFileName

func SafeFileName(fileName string) string

SafeFileName replace all illegal chars to a underline char

func WalkRelDirs

func WalkRelDirs(target string, suffixes ...string) (dirs []string)

WalkRelDirs 遍历目录,可指定后缀,返回相对路径

func WalkRelFiles

func WalkRelFiles(target string, suffixes ...string) (files []string)

WalkRelFiles 遍历文件,可指定后缀,返回相对路径

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client http client

func NewClient

func NewClient() *Client

NewClient new http client

func (*Client) Download

func (c *Client) Download(url string, filename string, auto bool) error

Download 下载文件

func (*Client) EnableIncrement

func (c *Client) EnableIncrement(file string)

EnableIncrement 设置支持增量下载的状态存储文件

func (*Client) GetByte

func (c *Client) GetByte(url string, payload *ClientPayload) ([]byte, *http.Response, error)

GetByte 从 URL 读取字节内容及状态码

func (*Client) GetCodec

func (c *Client) GetCodec(url string, payload *ClientPayload, codec string, out interface{}) error

GetCodec 从 URL 创建反序列化对象

func (*Client) GetDoc

func (c *Client) GetDoc(url string, payload *ClientPayload) (*goquery.Document, error)

GetDoc 从 URL 创建 goquery DOM 对象

func (*Client) GetURLExt

func (c *Client) GetURLExt(url string) string

GetURLExt 获取 URL 中文件名扩展名

func (*Client) GetURLFilename

func (c *Client) GetURLFilename(url string) string

GetURLFilename 获取 URL 中文件名名

func (*Client) Read

func (c *Client) Read(url string, payload *ClientPayload) (*http.Response, error)

Read 从 URL 读取数据

func (*Client) SaveIncrement

func (c *Client) SaveIncrement()

SaveIncrement 保存增量下载进度

type ClientPayload

type ClientPayload struct {
	KeepAlive bool
	Method    string
	Data      interface{}
	Userinfo  *url.Userinfo
	Header    *http.Header
}

ClientPayload 请求内容

Jump to

Keyboard shortcuts

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