https://github.com/tkdeng/gobash
Run linux bash commands in Go.
https://github.com/tkdeng/gobash
bash go golang linux
Last synced: 2 months ago
JSON representation
Run linux bash commands in Go.
- Host: GitHub
- URL: https://github.com/tkdeng/gobash
- Owner: tkdeng
- License: mit
- Created: 2024-08-17T02:40:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-29T20:56:51.000Z (almost 2 years ago)
- Last Synced: 2025-01-03T22:51:42.931Z (over 1 year ago)
- Topics: bash, go, golang, linux
- Language: Go
- Homepage:
- Size: 107 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Bash
[
](./assets/icon.png)
Run linux bash commands in Go.
## Installation
```shell script
go get github.com/tkdeng/gobash
```
## Usage
```go
import (
"github.com/tkdeng/gobash"
)
func main(){
// run bash command
out, err := bash.Run([]string{`echo`, `test`}, "/pwd", []string{"ENV=var"})
// run from default directory and no environment vars
out, err := bash.Run([]string{`echo`, `test`}, "", nil)
// run raw `bash -c` command
bash.RunRaw(`echo "test"`, "", nil)
// run command as specified user
bash.RunUser(`echo "root test"`, "sudo", "", nil)
bash.RunUser(`echo "user test"`, "user", "", nil)
// pipe multiple commands `echo "test" | tee -a "./test.txt"`
bash.Pipe(".", []string{"echo", "test"}, []string{"tee", "-a", "./test.txt"})
}
```