Use env lib, add PROXY_PORT ENV variable
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
parsers
|
||||
=======
|
||||
This directory contains pre-built, custom parsers that can be used with `env.ParseWithFuncs`
|
||||
to facilitate the parsing of envs that are not basic types.
|
||||
|
||||
Example Usage:
|
||||
|
||||
```golang
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
|
||||
"github.com/caarlos0/env"
|
||||
"github.com/caarlos0/env/parsers"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
ExampleURL url.URL `env:"EXAMPLE_URL" envDefault:"https://google.com"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
cfg := config{}
|
||||
|
||||
if err := env.ParseWithFuncs(&cfg, env.CustomParsers{
|
||||
parsers.URLType: parsers.URLFunc,
|
||||
}); err != nil {
|
||||
log.Fatal("Unable to parse envs: ", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Scheme: %v Host: %v\n", cfg.ExampleURL.Scheme, cfg.ExampleURL.Host)
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user