encapsutils

package module
v0.0.0-...-de83dec Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 13 Imported by: 2

README

Encapsutils

Build Status codecov

Encapsulate utility functions that are often used in different projects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(binary []byte, path string) error

AppendToFile if path file not exist, first create it and append write binary to file.

func ByteToIpv6String

func ByteToIpv6String(x [6]byte) string

ByteToIpv6String convert ipv6 format byte byte to string.

func CreateDir

func CreateDir(path string, perm os.FileMode) error

CreateDir create path is not exist,

func CreateFile

func CreateFile(path string) (*os.File, error)

CreateFile create a file if it not exist.

func Ipv4ToUint32

func Ipv4ToUint32(ipv4 string) uint32

Ipv4ToUint32 convert ipv4 format string to uint32.

func IsDir

func IsDir(path string) bool

IsDir probe path is dir.

func IsFile

func IsFile(path string) bool

IsFile probe path is file.

func PanicGuard

func PanicGuard(f func())

func PathExists

func PathExists(path string) bool

PathExists probe path is exist.

func PingAddress

func PingAddress(address string, waitTime time.Duration) bool

PingAddress probe ip or address can be connected. NOTE: github.com/go-ping/ping must with root permitted, so use command.

func ProGress

func ProGress(percent *float32)

ProGress block to show process run status, exit when percent == 1.

func RandomLineFromFile

func RandomLineFromFile(filePath string) (string, error)

RandomLineFromFile returns a random line from a file.

func SaveToFile

func SaveToFile(binary []byte, path string) error

SaveToFile if path file not exist, first create it and write binary to file.

func Uint32ToIpv4

func Uint32ToIpv4(ipv4 uint32) string

Uint32ToIpv4 convert ipv4 format uint32 to string.

Types

type Queue

type Queue interface {
	Push(v interface{}) bool
	Pop() interface{}
	Back() interface{}
	Front() interface{}
	Size() int
	Empty() bool
}

Queue queue interface.

func NewQueue

func NewQueue() Queue

NewQueue create a new queue.

type Stack

type Stack interface {
	Push(v interface{}) bool
	Top() interface{}
	Pop() interface{}
	Size() int
	Empty() bool
}

Stack stack interface.

func NewStack

func NewStack() Stack

NewStack create new stack.

type StringSlice

type StringSlice []string

StringSlice flag包扩展数组格式

func (*StringSlice) Set

func (f *StringSlice) Set(value string) error

Set flag set.

func (*StringSlice) String

func (f *StringSlice) String() string

String flag string.

Jump to

Keyboard shortcuts

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