-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
VALUE="ok" | ||
NUM="1" | ||
STR="hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
module github.com/ysmood/dotenv | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require github.com/joho/godotenv v1.5.1 | ||
require ( | ||
github.com/joho/godotenv v1.5.1 | ||
github.com/ysmood/got v0.38.2 | ||
) | ||
|
||
require github.com/ysmood/gop v0.2.0 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= | ||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= | ||
github.com/ysmood/gop v0.2.0 h1:+tFrG0TWPxT6p9ZaZs+VY+opCvHU8/3Fk6BaNv6kqKg= | ||
github.com/ysmood/gop v0.2.0/go.mod h1:rr5z2z27oGEbyB787hpEcx4ab8cCiPnKxn0SUHt6xzk= | ||
github.com/ysmood/got v0.38.2 h1:h2RYvAe5nIK+oBRMLzNIrkZaX5kjmkOBqfRMIsFzLyU= | ||
github.com/ysmood/got v0.38.2/go.mod h1:W7DdpuX6skL3NszLmAsC5hT7JAhuLZhByVzHTq874Qg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package lib_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/ysmood/dotenv/lib" | ||
"github.com/ysmood/got" | ||
) | ||
|
||
func TestGet(t *testing.T) { | ||
g := got.T(t) | ||
|
||
t.Setenv("BOOL", "true") | ||
t.Setenv("NUM", "2") | ||
t.Setenv("STR", "ok") | ||
t.Setenv("FLOAT", "1.2") | ||
t.Setenv("DURATION", "1m") | ||
|
||
g.Eq(lib.Get("BOOL", false), true) | ||
g.Eq(lib.Get("BOOL_DEFAULT", true), true) | ||
g.Eq(lib.Get("NUM", 0), 2) | ||
g.Eq(lib.Get("NUM_DEFAULT", 1), 1) | ||
g.Eq(lib.Get("STR", ""), "ok") | ||
g.Eq(lib.Get("STR_DEFAULT", "yes"), "yes") | ||
g.Eq(lib.Get("FLOAT", 0.0), 1.2) | ||
g.Eq(lib.Get("FLOAT_DEFAULT", 1.1), 1.1) | ||
g.Eq(lib.Get("DURATION", time.Second), time.Minute) | ||
g.Eq(lib.Get("DURATION_DEFAULT", time.Hour), time.Hour) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters