cockroachdb/errors

format width specifiers ignored for values wrapped by Safe

jbowens opened this issue · 1 comments

If a format string contains a width specifier and the corresponding argument is wrapped with errors.Safe, the resulting error string ignores the format string's width specifier.

I'm guessing this has to do with how the fmt package is implemented. If we wanted, we could unwrap Safe args before passing them to fmt.Sprintf.

package main

import (
	"fmt"

	"github.com/cockroachdb/errors"
)

func main() {
	err := errors.Errorf("%06d %06d", errors.Safe(1), 1)
	fmt.Println(err) // prints `1 000001`
}
knz commented

Thanks for noticing.