https://github.com/fern4lvarez/go-export
Read a file and exports all key-value bash format lines to the env
https://github.com/fern4lvarez/go-export
Last synced: 2 months ago
JSON representation
Read a file and exports all key-value bash format lines to the env
- Host: GitHub
- URL: https://github.com/fern4lvarez/go-export
- Owner: fern4lvarez
- License: mit
- Created: 2015-02-19T14:35:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-08T12:04:15.000Z (over 9 years ago)
- Last Synced: 2025-01-12T10:45:38.069Z (4 months ago)
- Language: Go
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-export [](http://godoc.org/github.com/fern4lvarez/go-export)
**go-export** reads a given file path and exports all key-value bash format lines to the env
## Install
* Step 1: Get the `go-export` package
```
go get github.com/fern4lvarez/go-export
```* Step 2 (Optional): Run tests
```
$ go test -v -cover ./...
```##Usage
```go
package mainimport (
"fmt"
"os"
"path/filepath""github.com/fern4lvarez/go-export"
)func ExampleDo() {
exampleFile := filepath.Join(os.Getenv("PWD"), "example", "example.sh")
err := Do(exampleFile)
if err != nil {
fmt.Println(err)
}fmt.Println("K", os.Getenv("K"))
fmt.Println("FOO", os.Getenv("FOO"))
fmt.Println("user", os.Getenv("user"))
fmt.Println("pwd", os.Getenv("pwd"))
}func main() {
ExampleDo()
// Output:
// K V
// FOO BAR
// user fa@csdada*%^&*%&
// pwd vshugvshcfvhscf
}
```## License
go-export is MIT licensed.