Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: darccio/mergo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.16
Choose a base ref
...
head repository: darccio/mergo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.0
Choose a head ref
  • 3 commits
  • 40 files changed
  • 1 contributor

Commits on Jun 19, 2023

  1. feat: v1.0.0 released

    darccio committed Jun 19, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    fanatid Kirill Fomichev
    Copy the full SHA
    a5b2cb8 View commit details

Commits on Jun 20, 2023

  1. Copy the full SHA
    e6e9dec View commit details
  2. Merge pull request #238 from imdario/dcc/v1.0.0

    feat: v1.0.0 released
    darccio authored Jun 20, 2023
    Copy the full SHA
    131de81 View commit details
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
@@ -9,4 +9,4 @@ name = "go"
enabled = true

[analyzers.meta]
import_path = "github.com/imdario/mergo"
import_path = "dario.cat/mergo"
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -46,13 +46,19 @@ Also a lovely [comune](http://en.wikipedia.org/wiki/Mergo) (municipality) in the

It is ready for production use. [It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, Microsoft, etc](https://github.com/imdario/mergo#mergo-in-the-wild).

### Important note
### Important notes

#### 1.0.0

In [1.0.0](//github.com/imdario/mergo/releases/tag/1.0.0) Mergo moves to a vanity URL `dario.cat/mergo`.

#### 0.3.9

Please keep in mind that a problematic PR broke [0.3.9](//github.com/imdario/mergo/releases/tag/0.3.9). I reverted it in [0.3.10](//github.com/imdario/mergo/releases/tag/0.3.10), and I consider it stable but not bug-free. Also, this version adds support for go modules.

Keep in mind that in [0.3.2](//github.com/imdario/mergo/releases/tag/0.3.2), Mergo changed `Merge()`and `Map()` signatures to support [transformers](#transformers). I added an optional/variadic argument so that it won't break the existing code.

If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with ```go get -u github.com/imdario/mergo```. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with ```go get -u dario.cat/mergo```. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).

### Donations

@@ -110,11 +116,11 @@ If Mergo is useful to you, consider buying me a coffee, a beer, or making a mont

## Install

go get github.com/imdario/mergo
go get dario.cat/mergo

// use in your .go code
import (
"github.com/imdario/mergo"
"dario.cat/mergo"
)

## Usage
@@ -152,7 +158,7 @@ package main

import (
"fmt"
"github.com/imdario/mergo"
"dario.cat/mergo"
)

type Foo struct {
@@ -188,9 +194,9 @@ package main

import (
"fmt"
"github.com/imdario/mergo"
"reflect"
"time"
"dario.cat/mergo"
"reflect"
"time"
)

type timeTransformer struct {
43 changes: 24 additions & 19 deletions doc.go
Original file line number Diff line number Diff line change
@@ -8,30 +8,36 @@ A helper to merge structs and maps in Golang. Useful for configuration default v
Mergo merges same-type structs and maps by setting default values in zero-value fields. Mergo won't merge unexported (private) fields. It will do recursively any exported one. It also won't merge structs inside maps (because they are not addressable using Go reflection).
Status
# Status
It is ready for production use. It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, etc.
Important note
# Important notes
1.0.0
In 1.0.0 Mergo moves to a vanity URL `dario.cat/mergo`.
0.3.9
Please keep in mind that a problematic PR broke 0.3.9. We reverted it in 0.3.10. We consider 0.3.10 as stable but not bug-free. . Also, this version adds suppot for go modules.
Keep in mind that in 0.3.2, Mergo changed Merge() and Map() signatures to support transformers. We added an optional/variadic argument so that it won't break the existing code.
If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with go get -u github.com/imdario/mergo. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with go get -u dario.cat/mergo. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
Install
# Install
Do your usual installation procedure:
go get github.com/imdario/mergo
go get dario.cat/mergo
// use in your .go code
import (
"github.com/imdario/mergo"
)
// use in your .go code
import (
"dario.cat/mergo"
)
Usage
# Usage
You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. It won't merge empty structs value as they are zero values too. Also, maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
@@ -59,7 +65,7 @@ Here is a nice example:
import (
"fmt"
"github.com/imdario/mergo"
"dario.cat/mergo"
)
type Foo struct {
@@ -81,17 +87,17 @@ Here is a nice example:
// {two 2}
}
Transformers
# Transformers
Transformers allow to merge specific types differently than in the default behavior. In other words, now you can customize how some types are merged. For example, time.Time is a struct; it doesn't have zero value but IsZero can return true because it has fields with zero value. How can we merge a non-zero time.Time?
package main
import (
"fmt"
"github.com/imdario/mergo"
"reflect"
"time"
"dario.cat/mergo"
"reflect"
"time"
)
type timeTransformer struct {
@@ -127,17 +133,16 @@ Transformers allow to merge specific types differently than in the default behav
// { 2018-01-12 01:15:00 +0000 UTC m=+0.000000001 }
}
Contact me
# Contact me
If I can help you, you have an idea or you are using Mergo in your projects, don't hesitate to drop me a line (or a pull request): https://twitter.com/im_dario
About
# About
Written by Dario Castañé: https://da.rio.hn
License
# License
BSD 3-Clause license, as Go language.
*/
package mergo
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/imdario/mergo
module dario.cat/mergo

go 1.13

2 changes: 1 addition & 1 deletion issue100_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type issue100s struct {
2 changes: 1 addition & 1 deletion issue104_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type Record struct {
2 changes: 1 addition & 1 deletion issue121_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue121WithSliceDeepCopy(t *testing.T) {
2 changes: 1 addition & 1 deletion issue123_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue123(t *testing.T) {
2 changes: 1 addition & 1 deletion issue125_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type settings struct {
2 changes: 1 addition & 1 deletion issue129_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue129Boolean(t *testing.T) {
2 changes: 1 addition & 1 deletion issue131_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type foz struct {
2 changes: 1 addition & 1 deletion issue136_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type embeddedTestA struct {
2 changes: 1 addition & 1 deletion issue138_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

const issue138configuration string = `
2 changes: 1 addition & 1 deletion issue143_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue143(t *testing.T) {
2 changes: 1 addition & 1 deletion issue149_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type user struct {
2 changes: 1 addition & 1 deletion issue174_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type structWithBlankField struct {
2 changes: 1 addition & 1 deletion issue17_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue17MergeWithOverwrite(t *testing.T) {
2 changes: 1 addition & 1 deletion issue202_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue202(t *testing.T) {
2 changes: 1 addition & 1 deletion issue209_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue209(t *testing.T) {
2 changes: 1 addition & 1 deletion issue220_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue220(t *testing.T) {
2 changes: 1 addition & 1 deletion issue230_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

var testDataM = []struct {
2 changes: 1 addition & 1 deletion issue23_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type document struct {
2 changes: 1 addition & 1 deletion issue33_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type Foo struct {
2 changes: 1 addition & 1 deletion issue38_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type structWithoutTimePointer struct {
2 changes: 1 addition & 1 deletion issue50_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type testStruct struct {
2 changes: 1 addition & 1 deletion issue52_test.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type structWithTime struct {
2 changes: 1 addition & 1 deletion issue61_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

func TestIssue61MergeNilMap(t *testing.T) {
2 changes: 1 addition & 1 deletion issue64_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type Student struct {
2 changes: 1 addition & 1 deletion issue66_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package mergo_test
import (
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

type PrivateSliceTest66 struct {
Loading