Skip to content

Commit cafa993

Browse files
committed
Set -> Add
1 parent 4db2431 commit cafa993

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func main() {
1515
os.Setenv("ENVS_ARE_FUN", "true")
1616
os.Setenv("WOOT", `{ "yes": "even_json" }`)
1717

18-
env.Set([]string{
18+
env.Add([]string{
1919
"ENVS_ARE_FUN",
2020
"WOOT",
2121
"PORT=8080", // default values

environment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ var (
1616
optionalKeys map[string]bool
1717
)
1818

19-
/* Set : environment variables for use later. This is global to the project
19+
/* Add : environment variables for use later. This is global to the project
2020
* requred -> NAME
2121
* with_default -> NAME=taybart
2222
* optional -> NAME? // defaults to zero value
2323
*/
24-
func Set(keys []string) {
24+
func Add(keys []string) {
2525
err := Ensure(keys)
2626
if err != nil {
2727
panic(err)
@@ -56,7 +56,7 @@ func Ensure(keys []string) error {
5656
}
5757

5858
if len(missingKeys) > 0 {
59-
return fmt.Errorf("Set all required environment variables: %v", missingKeys)
59+
return fmt.Errorf("set all required environment variables: %v", missingKeys)
6060
}
6161
return nil
6262
}

environment_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestDefault(t *testing.T) {
1414
// Define key
1515
k := "TEST_DEFAULT"
1616
v := "default_value"
17-
env.Set([]string{fmt.Sprintf("%s=%s", k, v)})
17+
env.Add([]string{fmt.Sprintf("%s=%s", k, v)})
1818
is.True(env.Is(k, v))
1919
}
2020

@@ -25,7 +25,7 @@ func TestOptionalKey(t *testing.T) {
2525
k := "TEST_OPTIONAL_KEY"
2626

2727
// Add optional to env
28-
env.Set([]string{
28+
env.Add([]string{
2929
fmt.Sprintf("%s?", k),
3030
})
3131
// make sure its empty string

scan/test_project/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func main() {
10-
env.Set([]string{
10+
env.Add([]string{
1111
"ENV",
1212
"PORT=6969",
1313
})

scan/visitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (v *visitor) Visit(n ast.Node) bool {
9696
}
9797
}
9898
case *ast.CallExpr: // line contains a function call
99-
if isPkgDot(n.Fun, v.packageName, "Set") { // check that function call is env.Set() (handles import renames)
99+
if isPkgDot(n.Fun, v.packageName, "Add") { // check that function call is env.Set() (handles import renames)
100100
switch arg := n.Args[0].(type) {
101101
case *ast.CompositeLit: // function was passed anon []string
102102
arr, _ := getStringArray(arg)

0 commit comments

Comments
 (0)