go/path_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

37 lines
630 B
Go

package core_test
import (
. "dappco.re/go/core"
)
func ExampleJoinPath() {
Println(JoinPath("deploy", "to", "homelab"))
// Output: deploy/to/homelab
}
func ExamplePathBase() {
Println(PathBase("/srv/workspaces/alpha"))
// Output: alpha
}
func ExamplePathDir() {
Println(PathDir("/srv/workspaces/alpha"))
// Output: /srv/workspaces
}
func ExamplePathExt() {
Println(PathExt("report.pdf"))
// Output: .pdf
}
func ExampleCleanPath() {
Println(CleanPath("/tmp//file", "/"))
Println(CleanPath("a/b/../c", "/"))
Println(CleanPath("deploy/to/homelab", "/"))
// Output:
// /tmp/file
// a/c
// deploy/to/homelab
}