This question already has an answer here:
I've grown fond of the Printf
of fmt
and log
Is there a way I can use it with errors.New
?
I tried the following:
return errors.New(fmt.Printf("User %v already exists", dbcfg.Username))
</div>
You can use fmt.Sprintf
to format things into a string and fmt.Errorf
to format into error
.