zdpgo_shell

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 11 Imported by: 1

README

zdpgo_shell

使用 Golang 操作 shell

版本历史

  • v0.1.1 2022/05/01 新增:跨平台的 kill 命令
  • v0.1.2 2022/05/16 升级:升级 kill 命令
  • v0.1.3 2022/07/12 新增:执行后台任务和杀死后台任务命令
  • v0.1.4 2022/07/13 优化:优化后台任务
  • v0.1.5 2022/09/22 BUG修复:runInLinux方法报空指针问题

使用示例

请查看 examples 目录

Documentation

Index

Constants

View Source
const (
	UTF8    = Charset("UTF-8")
	GB18030 = Charset("GB18030")
)

Variables

This section is empty.

Functions

func ConvertByte2String

func ConvertByte2String(byte []byte, charset Charset) string

Types

type Charset

type Charset string

type Config

type Config struct {
}

type Result added in v0.1.3

type Result struct {
	Result string `json:"result"`
	Pid    int    `json:"pid"`
	Error  string `json:"error"`
}

Result 命令执行结果

func Run added in v0.1.3

func Run(cmd string) Result

Run 执行CMD命令

func RunRealTime added in v0.1.3

func RunRealTime(command string) Result

RunRealTime 获取命令实时结果

type Shell

type Shell struct {
	Config *Config // 配置对象
}

func New

func New() *Shell

func NewWithConfig

func NewWithConfig(config Config) *Shell

func (*Shell) Kill added in v0.1.1

func (s *Shell) Kill(pid int) Result

Kill 终止指定进程

func (*Shell) KillEnv added in v0.1.3

func (s *Shell) KillEnv() Result

删除.env中的进程ID

func (*Shell) Run

func (s *Shell) Run(command string) Result

Run 阻塞式的执行外部shell命令的函数,等待执行完毕并返回标准输出

func (*Shell) RunBackground added in v0.1.3

func (s *Shell) RunBackground(executeFile string) Result

RunBackground 开启新的进程执行

func (*Shell) RunRealTime added in v0.1.3

func (s *Shell) RunRealTime(command string) Result

RunRealTime 执行命令并等待结果返回,适合ping之类的需要等待一段时间的命令

Directories

Path Synopsis
Package encoding defines an interface for character encodings, such as Shift JIS and Windows 1252, that can convert to and from UTF-8.
Package encoding defines an interface for character encodings, such as Shift JIS and Windows 1252, that can convert to and from UTF-8.
charmap
Package charmap provides simple character encodings such as IBM Code Page 437 and Windows 1252.
Package charmap provides simple character encodings such as IBM Code Page 437 and Windows 1252.
htmlindex
Package htmlindex maps character set encoding names to Encodings as recommended by the W3C for use in HTML 5.
Package htmlindex maps character set encoding names to Encodings as recommended by the W3C for use in HTML 5.
ianaindex
Package ianaindex maps names to Encodings as specified by the IANA registry.
Package ianaindex maps names to Encodings as specified by the IANA registry.
internal
Package internal contains code that is shared among encoding implementations.
Package internal contains code that is shared among encoding implementations.
internal/identifier
Package identifier defines the contract between implementations of Encoding and Index by defining identifiers that uniquely identify standardized coded character sets (CCS) and character encoding schemes (CES), which we will together refer to as encodings, for which Encoding implementations provide converters to and from UTF-8.
Package identifier defines the contract between implementations of Encoding and Index by defining identifiers that uniquely identify standardized coded character sets (CCS) and character encoding schemes (CES), which we will together refer to as encodings, for which Encoding implementations provide converters to and from UTF-8.
simplifiedchinese
Package simplifiedchinese provides Simplified Chinese encodings such as GBK.
Package simplifiedchinese provides Simplified Chinese encodings such as GBK.
traditionalchinese
Package traditionalchinese provides Traditional Chinese encodings such as Big5.
Package traditionalchinese provides Traditional Chinese encodings such as Big5.
examples

Jump to

Keyboard shortcuts

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