netop

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 6 Imported by: 4

README

netop

common net operation helper

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound not found
	ErrNotFound = errors.New("not found")
)

Functions

func Get

func Get(url string, parameters ...RequestParam) (*http.Response, error)

Get send a GET request to server and return response or error

func GetBuffer added in v0.2.0

func GetBuffer(url string, parameters ...RequestParam) (*bytes.Buffer, error)

GetBuffer send a GET request to server and return response buffer or error

func GetBytes

func GetBytes(url string, parameters ...RequestParam) ([]byte, error)

GetBytes send a GET request to server and return response buffer or error

func GetString

func GetString(url string, parameters ...RequestParam) (string, error)

GetString send a GET request to server and return response string or error

Types

type Param

type Param struct {
	URL              string
	Refer            string
	Retry            int
	RetryInterval    time.Duration
	LogChannel       chan<- string
	ProgressChannel  chan<- *Progress
	ProgressInterval time.Duration
}

Param download parameters

func (Param) Log added in v0.1.1

func (s Param) Log(log string)

Log send log

func (Param) SendProgress added in v0.2.0

func (s Param) SendProgress(progress *Progress)

SendProgress send progress

type Progress added in v0.2.0

type Progress struct {
	Total     int64
	Completed int64
	Speed     int64
	Elapsed   time.Duration
	Remain    time.Duration
}

Progress download progress

type RequestParam

type RequestParam interface {
	// contains filtered or unexported methods
}

RequestParam defines download parameters

func Log

func Log(logChannel chan<- string) RequestParam

Log set log chan to show operation log

func OnProgress added in v0.2.0

func OnProgress(progressChannel chan<- *Progress, interval time.Duration) RequestParam

OnProgress send download progress

func Refer

func Refer(refer string) RequestParam

Refer set request refer

func Retry

func Retry(retry int, interval time.Duration) RequestParam

Retry set request retry times and interval

Jump to

Keyboard shortcuts

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