https://github.com/ilolicon/gosh
execute shell command with golang
https://github.com/ilolicon/gosh
bash command go shell
Last synced: 6 months ago
JSON representation
execute shell command with golang
- Host: GitHub
- URL: https://github.com/ilolicon/gosh
- Owner: ilolicon
- Created: 2022-06-09T07:01:12.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T09:40:49.000Z (over 2 years ago)
- Last Synced: 2024-06-21T09:05:58.585Z (about 2 years ago)
- Topics: bash, command, go, shell
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gosh
## usage example
- single command
```go
package main
import (
"fmt"
command "github.com/ilolicon/gosh"
)
func main() {
cmd := command.NewCommand("echo 'hello, gosh'")
_ = cmd.Run()
fmt.Printf("stdout:%s stderr:%s\n", cmd.Stdout(), cmd.Stderr())
}
```
- multi commands
```go
package main
import (
"fmt"
command "github.com/ilolicon/gosh"
)
func main() {
cmds := []string{
"echo 'task test'",
"uptime",
"date",
}
task := command.NewTask(cmds, 10)
task.Run(false)
for _, v := range task.Result() {
fmt.Printf("cmd:`%s` stdout:%s stderr:%s success:%t\n", v.Cmd, v.Stdout, v.Stderr, v.Success)
}
}
```