ap

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

ap a package for go utils

Index

Constants

View Source
const (
	MacFull = 281474976710655
)

Variables

View Source
var (
	ErrorIPParse         = errors.New("IPParse error")
	ErrorAccountIdFormat = errors.New("account id format error")
	ErrorMacIsZero       = errors.New("MacIsZero error")
	ErrorMacIsFull       = errors.New("MacIsFull error")
	ErrorMacParse        = errors.New("mac address parse error")
)

Functions

func B2S

func B2S(b []byte) string

B2S converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note it may break if string and/or slice header will change in the future go versions. nolint

func GetCurrentExecDir

func GetCurrentExecDir() (string, error)

GetCurrentExecDir get exec dir

func GetCurrentPath

func GetCurrentPath() (string, error)

GetCurrentPath get current path of commend running

func GetLocalIP

func GetLocalIP() ([]string, error)

GetLocalIP get all your local ipv4 address (except 127.0.0.1)

func GetNetMeta

func GetNetMeta() (string, int64, error)

GetNetMeta get ip address

func GetOutboundIP

func GetOutboundIP() (string, error)

GetOutboundIP get the out bound ip, especially useful when you have multi local ipv4 ip and you want figure out which one is been used

func GetPublicIP

func GetPublicIP() (string, error)

GetPublicIP get your publilc ip

func IP4String

func IP4String(ipInt int64) string

IP4String converts a ip address to a string

func IP4toInt

func IP4toInt(IPv4Addr net.IP) int64

IP4toInt converts a string to a ip address

func IPStringToInt

func IPStringToInt(s string) (int64, error)

IPStringToInt converts a string to a ip address

func Int64ToMac

func Int64ToMac(ipInt int64) (string, error)

Int64ToMac converts a ip address to a string

func Mac2Int64

func Mac2Int64(s string) (int64, error)

Mac2Int64 converts a string to a mac address

func MeasureTime

func MeasureTime(process string) func()

MeasureTime measure time

func PerformanceMonitor

func PerformanceMonitor(log *logger.Logger, name, url string) error

PerformanceMonitor 监控

func S2B

func S2B(s string) (b []byte)

S2B converts string to a byte slice without memory allocation.

Note it may break if string and/or slice header will change in the future go versions. nolint

func SaveTOML

func SaveTOML(v interface{}, filename string) error

SaveTOML save interface to TOML file

func Sleep

func Sleep(min, m int)

func SliceByteToString

func SliceByteToString(b []byte) string

SliceByteToString transfer byte to string

func StrBuilder

func StrBuilder(args ...string) string

StrBuilder strings builder

func StringToSliceByte

func StringToSliceByte(s string) []byte

StringToSliceByte transfer string to byte

func SubString

func SubString(str string, begin, length int) (substr string)

SubString sub string

func SyncLogger

func SyncLogger(log *logger.Logger, quit <-chan os.Signal)

SyncLogger sync logger to disk storage

func WriteToFile

func WriteToFile(c []byte, filename string) error

WriteToFile write []byte to file

Types

This section is empty.

Jump to

Keyboard shortcuts

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