diff options
| author | Jeff Carr <[email protected]> | 2025-01-09 17:15:53 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-09 17:15:53 -0600 |
| commit | 948af64ea2b6e586f4d152fcfc7ed168dae4c919 (patch) | |
| tree | 8ac36eed2d783ee57eeb8f45c84adc75e8f7c8d4 /example/main.go | |
| parent | 7c10ff958e57d02d13287c4cdbe0aca3781e1600 (diff) | |
example doesn't seem to work. why? notsure
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'example/main.go')
| -rw-r--r-- | example/main.go | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/example/main.go b/example/main.go index 6222701..90efe25 100644 --- a/example/main.go +++ b/example/main.go @@ -20,22 +20,53 @@ var uniqueKeys []string var pb *Fruits func main() { - pb = NewFruits() + // pb = NewFruits() + pb = new(Fruits) + pb.Uuid = "test" + pb.Version = "v0.0.2" fruit := &Fruit{ Brand: "mom", City: "New NewYork", } + x := new(Fruit) + x = &Fruit{ + Brand: "dad", + City: "Germany", + } + appendByUPC(x) + appendByUPC(fruit) + + testAppend(fruit) + testAppend(x) +} + +func testAppend(fruit *Fruit) { if pb.AppendUnique(fruit) { - log.Info("AppendUnique() ok") + log.Info("AppendUnique() test1 ok", fruit.Brand, fruit.City) } else { - log.Info("AppendUnique() failed") + log.Info("AppendUnique() test1 failed", fruit.Brand, fruit.City) os.Exit(-1) } if pb.AppendUnique(fruit) { - log.Info("AppendUnique() worked but should not have") + log.Info("AppendUnique() test2 worked but should not have", fruit.Brand, fruit.City) + os.Exit(-1) + } else { + log.Info("AppendUnique() test2 failed ok", fruit.Brand, fruit.City) + } +} + +func appendByUPC(fruit *Fruit) { + if pb.AppendUniqueUPC(fruit) { + log.Info("AppendUnique() test1 ok", fruit.Brand, fruit.City) + } else { + log.Info("AppendUnique() test1 failed", fruit.Brand, fruit.City) + os.Exit(-1) + } + if pb.AppendUniqueUPC(fruit) { + log.Info("AppendUnique() test2 worked but should not have", fruit.Brand, fruit.City) os.Exit(-1) } else { - log.Info("AppendUnique() failed ok") + log.Info("AppendUnique() test2 failed ok", fruit.Brand, fruit.City) } } |
