Skip to content

Commit

Permalink
adds GetEnvWithDefault (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jritsema authored Oct 16, 2020
1 parent 333e26a commit a90bf6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ A kitchen sink of Go tools that I've found useful. Uses only the standard librar

- [super lightweight http server framework](web)
- [exponential backoff retry](retry.go)
- [working with json](json.go)
- [working with JSON](json.go)
- [working with the file system](fs.go)
- [working with slices](slice.go)
- [working with CLIs](cli.go)

### example usage

Expand Down
Binary file modified app
Binary file not shown.
11 changes: 11 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ package gotoolbox

import (
"bytes"
"os"
"os/exec"
)

//GetEnvWithDefault returns the value of an enviornment variable
//or a default value if the environment variables is not set
func GetEnvWithDefault(key, defaultValue string) string {
result := os.Getenv(key)
if result == "" {
return defaultValue
}
return result
}

//ExecCmd executes a command and waits
func ExecCmd(cmd *exec.Cmd) error {

Expand Down

0 comments on commit a90bf6b

Please sign in to comment.