We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d52fa9 commit 7374335Copy full SHA for 7374335
xenv/xcollection_test.go
@@ -0,0 +1,13 @@
1
+package xenv
2
+
3
+import (
4
+ "github.com/stretchr/testify/assert"
5
+ "testing"
6
+)
7
8
+func TestFetchingCurrentUser(t *testing.T) {
9
10
+ user := Env("USER", "")
11
12
+ assert.NotEmpty(t, user)
13
+}
xenv/xenv.go
@@ -0,0 +1,12 @@
+import "os"
+// Env - get environment variable value or default value if missing.
+func Env(name string, def string) string {
+ v := os.Getenv(name)
+ if v == "" {
+ return def
+ }
+ return v
0 commit comments