Use TokenCounter and correct unsafe pointer usage

Record write errors in TokenCounter.Printf and add Println method
to propagate write failures. Route file-read warnings to stderr
instead of mixing them into token output. Use unsafe.Add with a
base pointer when computing the drop target on Windows.
This commit is contained in:
2026-01-31 03:33:36 +01:00
parent 14dfacea29
commit a32b7e4693
3 changed files with 24 additions and 15 deletions
+8 -1
View File
@@ -89,5 +89,12 @@ func (tc *TokenCounter) Printf(format string, a ...any) {
if tc.Err != nil {
return
}
fmt.Fprintf(tc, format, a...)
_, tc.Err = fmt.Fprintf(tc, format, a...)
}
func (tc *TokenCounter) Println(a ...any) {
if tc.Err != nil {
return
}
_, tc.Err = fmt.Fprintln(tc, a...)
}