mirror of
https://github.com/github/codeql.git
synced 2026-04-18 21:44:02 +02:00
caarlos0/env
This commit is contained in:
15
go/ql/lib/ext/github.com.caarlos0.env.model.yml
Normal file
15
go/ql/lib/ext/github.com.caarlos0.env.model.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/go-all
|
||||
extensible: sourceModel
|
||||
data:
|
||||
- ["github.com/caarlos0/env", "", False, "Parse", "", "", "Argument[0]", "environment", "manual"]
|
||||
- ["github.com/caarlos0/env", "", False, "ParseAs", "", "", "ReturnValue[0]", "environment", "manual"]
|
||||
- ["github.com/caarlos0/env", "", False, "ParseAsWithOptions", "", "", "ReturnValue[0]", "environment", "manual"]
|
||||
- ["github.com/caarlos0/env", "", False, "ParseWithOptions", "", "", "Argument[0]", "environment", "manual"]
|
||||
- addsTo:
|
||||
pack: codeql/go-all
|
||||
extensible: summaryModel
|
||||
data:
|
||||
- ["github.com/caarlos0/env", "", False, "Must", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
|
||||
- ["github.com/caarlos0/env", "", False, "ToMap", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
|
||||
@@ -2,6 +2,7 @@ package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/caarlos0/env"
|
||||
"github.com/hashicorp/go-envparse"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
@@ -69,3 +70,19 @@ func envparseEnvironmentVariables() {
|
||||
|
||||
fmt.Printf("HOME: %s\n", envVars["HOME"])
|
||||
}
|
||||
|
||||
func caarlos0EnvironmentVariables() {
|
||||
type config struct {
|
||||
Home string `env:"HOME"`
|
||||
Port int `env:"PORT"`
|
||||
}
|
||||
|
||||
cfg := config{}
|
||||
env.Parse(&cfg) // $ source
|
||||
|
||||
fmt.Printf("HOME: %s\n", cfg.Home)
|
||||
|
||||
cfg = env.ParseAs[config]() // $ source
|
||||
|
||||
fmt.Printf("HOME: %s\n", cfg.Home)
|
||||
}
|
||||
28
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/environment/vendor/github.com/caarlos0/env/stub.go
generated
vendored
Normal file
28
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/environment/vendor/github.com/caarlos0/env/stub.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
type Options struct {}
|
||||
|
||||
func Must[T any](t T, err error) T {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func Parse(v interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ParseAs[T any]() (T, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func ParseAsWithOptions[T any](opts Options) (T, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func ParseWithOptions(v interface{}, opts Options) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ToMap(env []string) map[string]string {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user