merge

package
v0.0.0-...-3fc3a86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2015 License: MIT, MIT Imports: 2 Imported by: 0

README

merge

Go library for merging structs and maps

Build Status

Usage:


type StructToMerge struct {
	One   string
	Two   int    `merge:"false"`
	Three string `merge:"true"`
}

func main() {
	from := &StructToMerge{"from", 1, "b"}
	to := &StructToMerge{"to", 0, "c"}

	// whitelist fields
	merge.Wl(from, to, "Three")
	// to = {to,0,b}

	from = &StructToMerge{"from", 1, "b"}
	to = &StructToMerge{"to", 0, "c"}

	// blacklist fields
	merge.Bl(from, to, "Two")
	// to = {from,0,b}

	from = &StructToMerge{"from", 1, "b"}
	to = &StructToMerge{"to", 0, "c"}

	// whitelist using struct tags
	merge.TagWl(from, to)
	// to = {to,0,b}

	from = &StructToMerge{"from", 1, "b"}
	to = &StructToMerge{"to", 0, "c"}

	// blacklist using struct tags
	merge.TagBl(from, to)
	// to = {from,0,b}
}


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bl

func Bl(from interface{}, to interface{}, keys ...string)

func TagBl

func TagBl(from interface{}, to interface{})

func TagWl

func TagWl(from interface{}, to interface{})

func Wl

func Wl(from interface{}, to interface{}, keys ...string)

Types

type ListType

type ListType int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL