Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Same trash as mergo #22

Closed
loeffel-io opened this issue Jun 9, 2020 · 2 comments
Closed

Same trash as mergo #22

loeffel-io opened this issue Jun 9, 2020 · 2 comments

Comments

@loeffel-io
Copy link

This will set the User field not to nil

opts := conjungo.NewOptions()
opts.Overwrite = true
if err = conjungo.Merge(token, &go_saas_model.Token{
	User:    nil,
	TeamId:  &teamId,
	Team:    nil,
	RWMutex: new(sync.RWMutex),
}, opts); err != nil {
	c.AbortWithStatusJSON(h.StatusInternalServerError, http.Response(err, nil))
	return
}

ref: darccio/mergo#149

@dionysius
Copy link

dionysius commented Oct 21, 2020

You can always use opts.SetTypeMergeFunc() for your type. There is no OverwriteNil/OverwriteZero/OverwriteEmpty option so far. The code explicitly checks source for empty to decide to directly use the target https://github.com/InVisionApp/conjungo/blob/master/merge.go#L134

@maxclaus
Copy link
Member

This project is no longer actively supported and will be archived. Therefore all issues and pull requests are being closed. Please, feel free to fork it and apply the proposed change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants