https://github.com/fmorenovr/gonv
Golang implementation to manage environment variables in system.
https://github.com/fmorenovr/gonv
enrivonment-system environmental-variable getenv setenv setenvironment system-variable varenv variable
Last synced: 14 days ago
JSON representation
Golang implementation to manage environment variables in system.
- Host: GitHub
- URL: https://github.com/fmorenovr/gonv
- Owner: fmorenovr
- License: mit
- Created: 2018-08-18T00:32:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T17:38:28.000Z (over 6 years ago)
- Last Synced: 2024-06-21T08:58:09.900Z (over 1 year ago)
- Topics: enrivonment-system, environmental-variable, getenv, setenv, setenvironment, system-variable, varenv, variable
- Language: Go
- Homepage: https://godoc.org/github.com/fmorenovr/gonv
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Golang + Environment = gonv
gonv (Golang eNVironment) is a Golang implementation to manage environment variables in operating system.
You can see an extended doc in [godocs](https://godoc.org/github.com/fmorenovr/gonv).
Install it writing in terminal:
go get github.com/fmorenovr/gonv
Example:
```go
import(
"fmt"
"github.com/jenazads/gonv"
)
func main(){
// using system environmental variables
gonv.SetEnv("BOOL", true)
isBool, _ := gonv.GetBoolEnv("BOOL")
username, _:= gonv.GetEnv("USER") // return $USER system variable
fmt.Println(username, ", ", isBool)
gonv.SetEnv("NAME", "Jenazads")
nameSystem ,_ := gonv.GetEnv("NAME")
fmt.Println("name:", nameSystem)
gonv.UpdateEnv("NAME", 4)
nameUpdatedsystem, _ := gonv.GetIntEnv("NAME")
fmt.Println("name updated:", nameUpdatedsystem)
// using object environmental variables
gonvObject := gonv.NewGonv()
gonvObject.SetEnv("BOOL", true)
isBool, _ = gonvObject.GetBoolEnv("BOOL")
usernameObj,_ := gonvObject.GetEnv("USER") // return nil
fmt.Println(usernameObj, ", ", isBool)
gonvObject.SetEnv("NAME", "Jenazads")
nameLocal, _ := gonvObject.GetEnv("NAME")
fmt.Println("name:", nameLocal)
fmt.Println(gonvObject)
gonvObject.UpdateEnv("NAME", 4)
nameLocal, _ = gonv.GetIntEnv("NAME") // we can set another type because is interface type !
fmt.Println("name updated:", nameLocal)
fmt.Println(gonvObject)
}
```