mirror of
https://github.com/skidoodle/ctx.git
synced 2026-04-28 03:07:41 +02:00
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:
@@ -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...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user