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>
33 lines
629 B
Go
33 lines
629 B
Go
package core_test
|
|
|
|
import (
|
|
|
|
. "dappco.re/go/core"
|
|
)
|
|
|
|
func ExampleE() {
|
|
err := E("cache.Get", "key not found", nil)
|
|
Println(Operation(err))
|
|
Println(ErrorMessage(err))
|
|
// Output:
|
|
// cache.Get
|
|
// key not found
|
|
}
|
|
|
|
func ExampleWrap() {
|
|
cause := NewError("connection refused")
|
|
err := Wrap(cause, "database.Connect", "failed to reach host")
|
|
Println(Operation(err))
|
|
Println(Is(err, cause))
|
|
// Output:
|
|
// database.Connect
|
|
// true
|
|
}
|
|
|
|
func ExampleRoot() {
|
|
cause := NewError("original")
|
|
wrapped := Wrap(cause, "op1", "first wrap")
|
|
double := Wrap(wrapped, "op2", "second wrap")
|
|
Println(Root(double))
|
|
// Output: original
|
|
}
|