Add env
This commit is contained in:
parent
8143c2d08a
commit
47c2d3b2ec
21
env/env.go
vendored
Normal file
21
env/env.go
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package env
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Env() {
|
||||||
|
os.Setenv("GOBYEXAMPLE", "WORKS")
|
||||||
|
fmt.Println("$GOBYEXAMPLE=", os.Getenv("GOBYEXAMPLE"))
|
||||||
|
envGoRoot := os.Getenv("GOROOT")
|
||||||
|
fmt.Println("$GOROOT=", envGoRoot)
|
||||||
|
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println("All env vars:")
|
||||||
|
for _, envLine := range os.Environ() {
|
||||||
|
pair := strings.SplitN(envLine, "=", 2)
|
||||||
|
fmt.Printf("%s=%s\n", pair[0], pair[1])
|
||||||
|
}
|
||||||
|
}
|
6
main.go
6
main.go
@ -43,7 +43,8 @@ import (
|
|||||||
// "git.sangeeth.dev/gobyexample/tmp"
|
// "git.sangeeth.dev/gobyexample/tmp"
|
||||||
// "git.sangeeth.dev/gobyexample/embed"
|
// "git.sangeeth.dev/gobyexample/embed"
|
||||||
// "git.sangeeth.dev/gobyexample/cli"
|
// "git.sangeeth.dev/gobyexample/cli"
|
||||||
"git.sangeeth.dev/gobyexample/subcmd"
|
// "git.sangeeth.dev/gobyexample/subcmd"
|
||||||
|
"git.sangeeth.dev/gobyexample/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -89,5 +90,6 @@ func main() {
|
|||||||
// tmp.Tmp()
|
// tmp.Tmp()
|
||||||
// embed.Embed()
|
// embed.Embed()
|
||||||
// cli.Cli()
|
// cli.Cli()
|
||||||
subcmd.SubCmd()
|
// subcmd.SubCmd()
|
||||||
|
env.Env()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user