cliutils

package
v0.0.0-...-b1774e8 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DNSName string = `^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$`
)

Variables

View Source
var (
	ErrOssFileTooLarge = errors.New(`oss file too large`)

	DefaultPartSize = int64(32 * 1024 * 1024) // 32MB
	DefaultTimeout  = uint(30)                // seconds
	DefaultWorkers  = 8
)

Functions

func ArrayUnique

func ArrayUnique(arr []int) []int

数组去重

func FilterPort

func FilterPort(str string) (int, error)

func HttpCli

func HttpCli(method, path, body string, headers map[string]string) (int, interface{})

func IsCIDR

func IsCIDR(str string) bool

IsCIDR check if the string is an valid CIDR notiation (IPV4 & IPV6)

func IsDNS

func IsDNS(str string) bool

IsDNSName will validate the given string as a DNS name

func IsIP

func IsIP(str string) bool

IsIP checks if a string is either IP version 4 or 6. Alias for `net.ParseIP`

func ParseCIDR

func ParseCIDR(cidr string) ([]string, error)

cidr解析

func ParseDNS

func ParseDNS(domain string) (string, error)

func SizeFmt

func SizeFmt(n int64) string

Types

type OssCli

type OssCli struct {
	Host, AccessKey, SecretKey, BucketName, WorkDir string
	Timeout                                         uint
	PartSize                                        int64
	Workers                                         int

	ReconnectCnt  int
	FailedCnt     int
	UploadedFiles int
	UploadedBytes int64
	// contains filtered or unexported fields
}

func (*OssCli) Download

func (oc *OssCli) Download(obj, to string) error

func (*OssCli) GetMeta

func (oc *OssCli) GetMeta(obj string) (map[string][]string, error)

func (*OssCli) Init

func (oc *OssCli) Init() error

func (*OssCli) ListObjects

func (oc *OssCli) ListObjects(prefix, marker string, maxKeys int) (oss.ListObjectsResult, error)

func (*OssCli) Move

func (oc *OssCli) Move(from, to string) error

func (*OssCli) Reconnect

func (oc *OssCli) Reconnect() error

func (*OssCli) SetMeta

func (oc *OssCli) SetMeta(obj string, meta map[string]string) error

func (*OssCli) Stat

func (oc *OssCli) Stat() string

func (*OssCli) Upload

func (oc *OssCli) Upload(from, to string) error

Jump to

Keyboard shortcuts

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