cockroachdb / errors

Go error library with error portability over the network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

format width specifiers ignored for values wrapped by Safe

jbowens opened this issue · 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`
}

Thanks for noticing.