Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chirino/hawtgo
A Hawt Go Library
https://github.com/chirino/hawtgo
Last synced: about 1 month ago
JSON representation
A Hawt Go Library
- Host: GitHub
- URL: https://github.com/chirino/hawtgo
- Owner: chirino
- License: apache-2.0
- Created: 2019-06-13T19:03:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-28T21:55:51.000Z (over 3 years ago)
- Last Synced: 2024-10-15T12:24:28.165Z (3 months ago)
- Language: Go
- Size: 22.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# My Hawt set of Go Packages
Install with:
go get github.com/chirino/hawtgo
## Pacakge: sh [![GoDoc](https://godoc.org/github.com/chirino/hawtgo/sh?status.svg)](https://godoc.org/github.com/chirino/hawtgo/sh)
The sh package makes executing processes from go almost as easy as using a shell.
See the following example that takes care of splitting up the command arguments
and doing variable replacement:sh.New().Line(`cp "${HOME}/my file.txt" /tmp/target.txt`).MustExec()
sh will can run command string like the ones you would enter into your shell.
The `sh.New()` function give you back a new immutable builder object. You can safely
reuse it for multiple command invocations.var mysh = sh.New().
CommandLog(os.Stdout).
CommandLogPrefix("> ").
Env(map[string]string{
"CGO_ENABLED": "0",
"GOOS": "linux",
"GOARCH": "amd64",
}).
Dir("./target")
func BuildExecutable() {
mysh.Line(`go build -o "my app" github.com/chirino/cmd/myapp`).MustExec()
mysh.Line(`go build -o otherapp github.com/chirino/cmd/otherapp`).MustExec()
}