utils

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	//ResponseStatusOK coresponse status
	ResponseStatusOK = "OK"
	//ResponseStatusError response status
	ResponseStatusError = "Error"
)

Variables

View Source
var MbTable = []uint16{}/* 256 elements not displayed */

MbTable ...

Functions

func CheckSum

func CheckSum(data []byte) uint16

CheckSum ...

func CopyFile

func CopyFile(dstName, srcName string) (int64, error)

CopyFile copy file

func FindNearestIP

func FindNearestIP(source []net.IP, target net.IP) net.IP

FindNearestIP find the nearest ip

func GetAllIPv4Address

func GetAllIPv4Address() ([]net.IP, error)

GetAllIPv4Address get all IP v4 address

func GetJSONResponse

func GetJSONResponse(c echo.Context, err error, data interface{}) error

GetJSONResponse get json response

func GetStoreDir

func GetStoreDir(rootDir string) (string, error)

GetStoreDir get store dir

func Hexdump

func Hexdump(title string, data []byte)

Hexdump -

func Int16ToUint16

func Int16ToUint16(i int16) uint16

Int16ToUint16 ...

func IsKigaOverlayIP

func IsKigaOverlayIP(ip net.IP) bool

IsKigaOverlayIP check if ip is in the kiga overlay network

func MoveFile

func MoveFile(fileName string, rootDir string) (string, error)

MoveFile move file

func ParseDateTimeString

func ParseDateTimeString(str string, include bool) (int64, error)

ParseDateTimeString "Parse date and time string 2020-05-05 => unix nano

func StoreFile

func StoreFile(srcFile multipart.File, rootDir string, fileName string) (string, error)

StoreFile store file

func Str2byte

func Str2byte(s string) []byte

Str2byte -

func Uint16ToBytes

func Uint16ToBytes(n uint16) []byte

Uint16ToBytes ...

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

Uint32ToBytes 使用BigEndian方式将uint32转为Bytes

func Unzip

func Unzip(fileBuffer []byte, destDir string) error

Unzip Decompress

func UnzipBuffer

func UnzipBuffer(fileBuffer []byte, fileMap map[string][]byte) error

UnzipBuffer Decompress

func Zip

func Zip(srcFile string, destZip string) error

Zip compress

Types

type Response

type Response struct {
	Status ResponseStatus `json:"status" swagger:"required"`
	ErrStr string         `json:"err,omitempty"`
	Data   interface{}    `json:"data,omitempty"`
}

Response -

type ResponseStatus

type ResponseStatus string

ResponseStatus response status

type ResponseV2

type ResponseV2 struct {
	Code int         `json:"code" swagger:"required"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

ResponseV2 HTTP response , v2 version

type ResponseWithoutData

type ResponseWithoutData struct {
	Status ResponseStatus `json:"status" swagger:"required"`
	ErrStr string         `json:"err,omitempty"`
}

ResponseWithoutData response without data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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