Skip to content

Commit 8a7e378

Browse files
committed
caarlos0/env
1 parent f0f535b commit 8a7e378

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: sourceModel
5+
data:
6+
- ["github.com/caarlos0/env", "", False, "Parse", "", "", "Argument[0]", "environment", "manual"]
7+
- ["github.com/caarlos0/env", "", False, "ParseAs", "", "", "ReturnValue[0]", "environment", "manual"]
8+
- ["github.com/caarlos0/env", "", False, "ParseAsWithOptions", "", "", "ReturnValue[0]", "environment", "manual"]
9+
- ["github.com/caarlos0/env", "", False, "ParseWithOptions", "", "", "Argument[0]", "environment", "manual"]
10+
- addsTo:
11+
pack: codeql/go-all
12+
extensible: summaryModel
13+
data:
14+
- ["github.com/caarlos0/env", "", False, "Must", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
15+
- ["github.com/caarlos0/env", "", False, "ToMap", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]

go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/environment/test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package test
22

33
import (
44
"fmt"
5+
"github.com/caarlos0/env"
56
"github.com/hashicorp/go-envparse"
67
"github.com/joho/godotenv"
78
"github.com/kelseyhightower/envconfig"
@@ -69,3 +70,19 @@ func envparseEnvironmentVariables() {
6970

7071
fmt.Printf("HOME: %s\n", envVars["HOME"])
7172
}
73+
74+
func caarlos0EnvironmentVariables() {
75+
type config struct {
76+
Home string `env:"HOME"`
77+
Port int `env:"PORT"`
78+
}
79+
80+
cfg := config{}
81+
env.Parse(&cfg) // $ source
82+
83+
fmt.Printf("HOME: %s\n", cfg.Home)
84+
85+
cfg = env.ParseAs[config]() // $ source
86+
87+
fmt.Printf("HOME: %s\n", cfg.Home)
88+
}

go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/environment/vendor/github.com/caarlos0/env/stub.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)