go/array_example_test.go
Snider 5be20af4b0 feat: eliminate fmt, string concat — add core.Println, use Concat/Path everywhere
New primitive: core.Println() wraps fmt.Println.

Replaced across all test + example files:
- fmt.Println → Println (17 example files)
- fmt.Sprintf → Concat + Sprint
- dir + "/file" → Path(dir, "file") (path security)
- "str" + var → Concat("str", var) (AX consistency)

"fmt" import is now zero across all test files.
String concat with + is zero across all test files.

Remaining 9 stdlib imports (all Go infrastructure):
testing, context, time, sync, embed, io/fs, bytes, gzip, base64

558 tests, 84.5% coverage.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 19:42:39 +00:00

41 lines
588 B
Go

package core_test
import (
. "dappco.re/go/core"
)
func ExampleNewArray() {
a := NewArray[string]()
a.Add("alpha")
a.Add("bravo")
a.Add("charlie")
Println(a.Len())
Println(a.Contains("bravo"))
// Output:
// 3
// true
}
func ExampleArray_AddUnique() {
a := NewArray[string]()
a.AddUnique("alpha")
a.AddUnique("alpha") // no duplicate
a.AddUnique("bravo")
Println(a.Len())
// Output: 2
}
func ExampleArray_Filter() {
a := NewArray[int]()
a.Add(1)
a.Add(2)
a.Add(3)
a.Add(4)
r := a.Filter(func(n int) bool { return n%2 == 0 })
Println(r.OK)
// Output: true
}