go-superstruct

[library] uses reflection to merge structs
git clone https://hhvn.uk/go-superstruct
git clone git://hhvn.uk/go-superstruct
Log | Files | Refs | LICENSE

commit 3c2e23cec62015135d117132ca2dd31b066181aa
parent ccf1f90ce50f719925365caca31c9932a7869eaf
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 17 Feb 2024 15:36:04 +0000

Add license and tidy up example

Diffstat:
ALICENSE | 13+++++++++++++
Msuperstruct_example.go | 10+++++-----
2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2024 hhvn <dev@hhvn.uk> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/superstruct_example.go b/superstruct_example.go @@ -4,20 +4,20 @@ import ( "fmt" ) -type First struct { +type first struct { A string C string } -type Second struct { +type second struct { B string C string } -func Example() { - a := First{"a", "c"} - b := Second{"b", "d"} +func ExampleCreateAndCopy() { + a := first{"a", "c"} + b := second{"b", "d"} c, err := CreateAndCopy(a, b) if err != nil { return