That's easy, right?
import (
"errors"
"fmt"
)
err := errors.New(fmt.Sprintf("my %s error", "awesome"))
About 4000 golang projects do errors.New(fmt.Sprintf(...
Don't do it, there is a better way:
import (
"fmt"
)
err := fmt.Errorf("my %s error", "awesome")
You're welcome.
Seems like all gophers removed this code, currently GitHub returns 682 projects contain this code.
ReplyDelete