Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v1.0.0 released #238

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -152,7 +158,7 @@ package main

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

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

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

type timeTransformer struct {
Expand Down
43 changes: 24 additions & 19 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -59,7 +65,7 @@ Here is a nice example:

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

type Foo struct {
Expand All @@ -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 {
Expand Down Expand Up @@ -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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

type PrivateSliceTest66 struct {
Expand Down
Loading