utils

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WsMsgInput  = "input"
	WsMsgResize = "resize"
	Heartbeat   = "heartbeat"
)

Variables

This section is empty.

Functions

func EnsureDirExist

func EnsureDirExist(name string) error

func File2lines

func File2lines(filePath string) ([]string, error)

func FileOrPathExist

func FileOrPathExist(filename string) bool

func GzipCompressFile

func GzipCompressFile(srcPath, dstPath string) error

func InSliceString

func InSliceString(v string, sl []string) bool

func InsertStringToFile

func InsertStringToFile(path, str string, index int) error

InsertStringToFile inserts a string to a file *

  • Insert sting to n-th line of file.
  • If you want to insert a line, append newline '\n' to the end of the string.

func LinesFromReader

func LinesFromReader(r io.Reader) ([]string, error)

func TarKFTools

func TarKFTools(name string, writer io.Writer) error

func ToLinuxPath

func ToLinuxPath(path string) string

ToLinuxPath windows 路径转Linux格式路径

func WsHandleError

func WsHandleError(ws *WsConnection, err error) bool

WsHandleError 错误检查

Types

type ConsoleFormatter

type ConsoleFormatter struct {
	logrus.TextFormatter
}

func (*ConsoleFormatter) Format

func (c *ConsoleFormatter) Format(entry *logrus.Entry) ([]byte, error)

type File

type File struct {
	Name    string      `json:"Name"`
	Path    string      `json:"Path"`
	Size    int64       `json:"Size"`
	Mode    string      `json:"Mode"`
	ModTime time.Time   `json:"ModTime"`
	IsDir   bool        `json:"IsDir"`
	Sys     interface{} `json:"SysInfo"`
}

type WsConnection

type WsConnection struct {
	CloseChan chan byte // 关闭通知
	// contains filtered or unexported fields
}

WsConnection 封装websocket连接

func InitWebsocket

func InitWebsocket(resp http.ResponseWriter, req *http.Request) (wsConn *WsConnection, err error)

InitWebsocket 初始化websocket ************* 并发安全 API *************

func (*WsConnection) WritePing

func (wsConn *WsConnection) WritePing(body []byte) error

func (*WsConnection) WritePong

func (wsConn *WsConnection) WritePong(body []byte) error

func (*WsConnection) WsClose

func (wsConn *WsConnection) WsClose()

WsClose 关闭连接

func (*WsConnection) WsRead

func (wsConn *WsConnection) WsRead() (msg *WsMessage, err error)

WsRead 读取消息

func (*WsConnection) WsWrite

func (wsConn *WsConnection) WsWrite(messageType int, data []byte) (err error)

WsWrite 发送消息

type WsMessage

type WsMessage struct {
	MessageType int
	Data        []byte
}

WsMessage websocket消息

type XtermMessage

type XtermMessage struct {
	Type  string `json:"type"`  // 类型:resize客户端调整终端, input客户端输入
	Input string `json:"input"` // msgtype=input情况下使用
	Rows  uint16 `json:"rows"`  // msgtype=resize情况下使用
	Cols  uint16 `json:"cols"`  // msgtype=resize情况下使用
}

XtermMessage web终端发来的包

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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