-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loader): Adding loader examples (#11)
Adding loader examples
- Loading branch information
1 parent
1a94798
commit afe3fac
Showing
2 changed files
with
68 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Jacobbrewer1/patcher" | ||
) | ||
|
||
type Something struct { | ||
Number int | ||
Text string | ||
PrePopulated string | ||
NewText string | ||
} | ||
|
||
func main() { | ||
s := Something{ | ||
Number: 5, | ||
Text: "Hello", | ||
PrePopulated: "PrePopulated", | ||
} | ||
|
||
n := Something{ | ||
Number: 6, | ||
Text: "Old Text", | ||
NewText: "New Text", | ||
} | ||
|
||
// The patcher.LoadDiff function will apply the changes from n to s. | ||
if err := patcher.LoadDiff(&s, &n); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Output: | ||
// 6 | ||
// Old Text | ||
// PrePopulated | ||
// New Text | ||
fmt.Println(s.Number) | ||
fmt.Println(s.Text) | ||
fmt.Println(s.PrePopulated) | ||
fmt.Println(s.NewText) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters