hyhtool

package module
v0.0.0-...-22cfb34 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: GPL-3.0 Imports: 20 Imported by: 0

README

hyhtool

介绍

{以下是 Gitee 平台说明,您可以替换此简介 hyhtool是本人在学习go语言后,开始着手对已有的C/C++代码移植过程中逐步积累的部分实用工具函数的集合。该集合包含了字符串处理、字节 数组处理、JSON字符串处理、文件访问以及部分系统调用工具。

软件架构

FileTool 该文件中封装了对本地文件访问的工具函数

JsonTool 在这个文件中封装了常用的对JSON串的处理函数,他可以对比较复杂的结构进行解析或者封装。

SliceTool 这个文件封装了对字节数组的处理函数。他主要用于解析C语言常用的字节流。

StringTool 这个文件主要封装了对字符串处理等常用功能

SystemTool 本文件封装了常用的系统功能函数

NetLogTool 本文件封装通过UDP端口远程输出调试信息功能

参与贡献
  1. huangyh于2022年4月17日第一次上传源代码

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayToJsonStr

func ArrayToJsonStr(s []HJson) (string, error)

slice转json

func Capitalize

func Capitalize(str string) string

Capitalize 字符首字母大写

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

*

  • 判断文件是否存在 存在返回 true 不存在返回false

func CloseMyFile

func CloseMyFile(f *os.File)

func CopyByteToSlice

func CopyByteToSlice(ary []byte, i byte)

func CopyFloat32ToSlice

func CopyFloat32ToSlice(ary []byte, f float32)

func CopyFloat64ToSlice

func CopyFloat64ToSlice(ary []byte, f float64)

func CopyInt16ToSlice

func CopyInt16ToSlice(ary []byte, i int16)

func CopyInt32ToSlice

func CopyInt32ToSlice(ary []byte, i int32)

func CopyInt64ToSlice

func CopyInt64ToSlice(ary []byte, i int64)

func FreeUdpLog

func FreeUdpLog(log *UdpLog)

func GbkToUtf8

func GbkToUtf8(strGbk string) string

func GetExeMem

func GetExeMem(pid int) int

func GetExecutePath

func GetExecutePath() string

func GetJsonArray

func GetJsonArray(json HJson, key string) []interface{}

func GetJsonFloat

func GetJsonFloat(json HJson, key string, default_value float64) float64

func GetJsonInt

func GetJsonInt(json HJson, key string, default_value int) int

func GetJsonStr

func GetJsonStr(json HJson, key string, default_value string) string

func GetMd5String1

func GetMd5String1(str string) string

方式一

func GetMd5String2

func GetMd5String2(b []byte) string

方式二

func GetMyMac

func GetMyMac() string

func GetTime

func GetTime() int64

func HJsonToStr

func HJsonToStr(tempMap HJson) (string, error)

map转json

func InetAddr

func InetAddr(ip string) int

func InetNtoA

func InetNtoA(ip int32) string

func Int2Byte

func Int2Byte(data int) [4]byte

func MAX

func MAX(a, b int) int

func MIN

func MIN(a, b int) int

func OpenMyFile

func OpenMyFile(filename string) *os.File

*

  • 打开文件 成功返回 不存在返回false

func ParseByteFromSlice

func ParseByteFromSlice(ary []byte, start int, default_val byte) byte

func ParseFloat32FromSlice

func ParseFloat32FromSlice(ary []byte, start int, default_val float32) float32

func ParseFloat64FromSlice

func ParseFloat64FromSlice(ary []byte, start int, default_val float64) float64

func ParseInt16FromSlice

func ParseInt16FromSlice(ary []byte, start int, default_val int16) int16

func ParseInt32FromSlice

func ParseInt32FromSlice(ary []byte, start int, default_val int32) int32

func ParseInt64FromSlice

func ParseInt64FromSlice(ary []byte, start int, default_val int64) int64

func ParseIntFromSlice

func ParseIntFromSlice(ary []byte, start int, default_val int) int

func ParseStringFromSlice

func ParseStringFromSlice(ary []byte, start int, count int) string

func ReadDataFromFile

func ReadDataFromFile(buf []byte, f *os.File) int

func Redirect

func Redirect(w http.ResponseWriter, req *http.Request, url string)

func ReplaceAllBlank

func ReplaceAllBlank(str string) string

func ReverseString

func ReverseString(s string) string

反转字符串

func SaveDataToFile

func SaveDataToFile(data []byte, f *os.File) (int, error)

func SetCommandStd

func SetCommandStd(cmd *exec.Cmd) (stdout, stderr *bytes.Buffer)

func SplitString

func SplitString(str string, sep string) []string

func ToJsonString

func ToJsonString(json HJson) string

func TrimMyStr

func TrimMyStr(str string) string

func Utf8ToGbk

func Utf8ToGbk(strUtf8 string) string

Types

type Exe_Info

type Exe_Info struct {
	Uid    string
	Pid    int
	Ppid   int
	Cpu    float32
	Mem    int
	Cmd    string
	Params []string
}

func GetExeInfo

func GetExeInfo(strExe string) []Exe_Info

func GetTopInfo

func GetTopInfo() ([]Exe_Info, []string)

type HJson

type HJson map[string]interface{}

func GetJsonObject

func GetJsonObject(json HJson, key string) HJson

func MakeHJson

func MakeHJson() HJson

func ParseStrToArray

func ParseStrToArray(str string) ([]HJson, error)

字符串转换为json数组

func ParseStrToHJson

func ParseStrToHJson(str string) (HJson, error)

type UdpLog

type UdpLog struct {
	// contains filtered or unexported fields
}

func NewUdpLog

func NewUdpLog(port int, logPath string) *UdpLog

func (*UdpLog) WriteLog

func (log *UdpLog) WriteLog(data []byte)

func (*UdpLog) WriteLogStr

func (log *UdpLog) WriteLogStr(str string)

Jump to

Keyboard shortcuts

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