Skip to content

Commit 6061c47

Browse files
committedOct 27, 2023
release: v10
1 parent 3f90e4a commit 6061c47

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed
 

‎README.md

+24-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://img.shields.io/github/actions/workflow/status/caarlos0/env/build.yml?branch=main&style=for-the-badge)](https://github.com/caarlos0/env/actions?workflow=build)
44
[![Coverage Status](https://img.shields.io/codecov/c/gh/caarlos0/env.svg?logo=codecov&style=for-the-badge)](https://codecov.io/gh/caarlos0/env)
5-
[![](http://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge)](https://pkg.go.dev/github.com/caarlos0/env/v9)
5+
[![](http://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge)](https://pkg.go.dev/github.com/caarlos0/env/v10)
66

77
A simple and zero-dependencies library to parse environment variables into
88
`struct`s.
@@ -12,7 +12,7 @@ A simple and zero-dependencies library to parse environment variables into
1212
Get the module with:
1313

1414
```sh
15-
go get github.com/caarlos0/env/v9
15+
go get github.com/caarlos0/env/v10
1616
```
1717

1818
The usage looks like this:
@@ -24,16 +24,16 @@ import (
2424
"fmt"
2525
"time"
2626

27-
"github.com/caarlos0/env/v9"
27+
"github.com/caarlos0/env/v10"
2828
)
2929

3030
type config struct {
3131
Home string `env:"HOME"`
3232
Port int `env:"PORT" envDefault:"3000"`
3333
Password string `env:"PASSWORD,unset"`
3434
IsProduction bool `env:"PRODUCTION"`
35-
Hosts []string `env:"HOSTS" envSeparator:":"`
3635
Duration time.Duration `env:"DURATION"`
36+
Hosts []string `env:"HOSTS" envSeparator:":"`
3737
TempFolder string `env:"TEMP_FOLDER,expand" envDefault:"${HOME}/tmp"`
3838
StringInts map[string]int `env:"MAP_STRING_INT"`
3939
}
@@ -103,7 +103,7 @@ case of absence of it in the environment.
103103
By default, slice types will split the environment value on `,`; you can change
104104
this behavior by setting the `envSeparator` tag. For map types, the default
105105
separator between key and value is `:` and `,` for key-value pairs.
106-
The behavior can be changed by setting the `envKeyValSeparator` and
106+
The behavior can be changed by setting the `envKeyValSeparator` and
107107
`envSeparator` tags accordingly.
108108

109109
## Custom Parser Funcs
@@ -119,7 +119,7 @@ field.
119119
If you add a custom parser for, say `Foo`, it will also be used to parse
120120
`*Foo` and `[]Foo` types.
121121

122-
Check the examples in the [go doc](http://pkg.go.dev/github.com/caarlos0/env/v9)
122+
Check the examples in the [go doc](http://pkg.go.dev/github.com/caarlos0/env/v10)
123123
for more info.
124124

125125
### A note about `TextUnmarshaler` and `time.Time`
@@ -181,10 +181,11 @@ type config struct {
181181
```
182182

183183
This also works with `envDefault`:
184+
184185
```go
185186
import (
186187
"fmt"
187-
"github.com/caarlos0/env/v9"
188+
"github.com/caarlos0/env/v10"
188189
)
189190

190191
type config struct {
@@ -249,13 +250,14 @@ package main
249250
import (
250251
"fmt"
251252
"time"
252-
"github.com/caarlos0/env/v9"
253+
254+
"github.com/caarlos0/env/v10"
253255
)
254256

255257
type config struct {
256-
Secret string `env:"SECRET,file"`
257-
Password string `env:"PASSWORD,file" envDefault:"/tmp/password"`
258-
Certificate string `env:"CERTIFICATE,file,expand" envDefault:"${CERTIFICATE_FILE}"`
258+
Secret string `env:"SECRET,file"`
259+
Password string `env:"PASSWORD,file" envDefault:"/tmp/password"`
260+
Certificate string `env:"CERTIFICATE,file,expand" envDefault:"${CERTIFICATE_FILE}"`
259261
}
260262

261263
func main() {
@@ -297,7 +299,7 @@ import (
297299
"fmt"
298300
"log"
299301

300-
"github.com/caarlos0/env/v9"
302+
"github.com/caarlos0/env/v10"
301303
)
302304

303305
type Config struct {
@@ -337,7 +339,7 @@ import (
337339
"fmt"
338340
"log"
339341

340-
"github.com/caarlos0/env/v9"
342+
"github.com/caarlos0/env/v10"
341343
)
342344

343345
type Config struct {
@@ -374,7 +376,7 @@ import (
374376
"fmt"
375377
"log"
376378

377-
"github.com/caarlos0/env/v9"
379+
"github.com/caarlos0/env/v10"
378380
)
379381

380382
type Config struct {
@@ -408,7 +410,7 @@ import (
408410
"fmt"
409411
"log"
410412

411-
"github.com/caarlos0/env/v9"
413+
"github.com/caarlos0/env/v10"
412414
)
413415

414416
type Config struct {
@@ -457,7 +459,7 @@ import (
457459
"fmt"
458460
"log"
459461

460-
"github.com/caarlos0/env/v9"
462+
"github.com/caarlos0/env/v10"
461463
)
462464

463465
type Config struct {
@@ -497,7 +499,7 @@ import (
497499
"fmt"
498500
"log"
499501

500-
"github.com/caarlos0/env/v9"
502+
"github.com/caarlos0/env/v10"
501503
)
502504

503505
type Config struct {
@@ -533,7 +535,7 @@ import (
533535
"fmt"
534536
"log"
535537

536-
"github.com/caarlos0/env/v9"
538+
"github.com/caarlos0/env/v10"
537539
)
538540

539541
type Config struct {
@@ -542,7 +544,7 @@ type Config struct {
542544
}
543545

544546
func main() {
545-
var cfg = Config{
547+
cfg := Config{
546548
Username: "test",
547549
Password: "123456",
548550
}
@@ -551,7 +553,7 @@ func main() {
551553
fmt.Println("failed:", err)
552554
}
553555

554-
fmt.Printf("%+v", cfg) // {Username:admin Password:123456}
556+
fmt.Printf("%+v", cfg) // {Username:admin Password:123456}
555557
}
556558
```
557559

@@ -566,7 +568,7 @@ import (
566568
"fmt"
567569
"log"
568570

569-
"github.com/caarlos0/env/v9"
571+
"github.com/caarlos0/env/v10"
570572
)
571573

572574
type Config struct {
@@ -594,7 +596,7 @@ func main() {
594596
}
595597
}
596598

597-
fmt.Printf("%+v", cfg) // {Username:admin Password:123456}
599+
fmt.Printf("%+v", cfg) // {Username:admin Password:123456}
598600
}
599601
```
600602

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/caarlos0/env/v9
1+
module github.com/caarlos0/env/v10
22

33
go 1.17

0 commit comments

Comments
 (0)
Please sign in to comment.