Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit f7661cb

Browse files
committed
Merging slices with override. Using go.mod
1 parent e793091 commit f7661cb

File tree

5 files changed

+24
-84
lines changed

5 files changed

+24
-84
lines changed

Gopkg.lock

-53
This file was deleted.

Gopkg.toml

-29
This file was deleted.

go.mod

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/microparts/configuration-golang
2+
3+
go 1.12
4+
5+
require (
6+
github.com/imdario/mergo v0.3.7
7+
github.com/stretchr/testify v1.3.0
8+
gopkg.in/yaml.v2 v2.2.2
9+
)

go.sum

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
4+
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
9+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
11+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
12+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
13+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

reader.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
9191
}
9292

9393
cc := configs[folder]
94-
if err := mergo.Merge(&cc, configFromFile[folder], mergo.WithOverride, mergo.WithAppendSlice); err != nil {
94+
if err := mergo.Merge(&cc, configFromFile[folder], mergo.WithOverride); err != nil {
9595
log.Fatalf("[config] merging files in folder error: %s", err)
9696
}
9797
configs[folder] = cc
@@ -105,7 +105,7 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
105105
config := configs["defaults"]
106106
c, ok := configs[stage]
107107
if ok {
108-
if err := mergo.Merge(&config, c, mergo.WithOverride, mergo.WithAppendSlice); err != nil {
108+
if err := mergo.Merge(&config, c, mergo.WithOverride); err != nil {
109109
log.Fatalf("[config] merging error: %s", err)
110110
}
111111

0 commit comments

Comments
 (0)