From: Andrew Gerrand Date: Fri, 1 Oct 2010 04:04:55 +0000 (+1000) Subject: fmt: add Errorf helper function X-Git-Tag: weekly.2010-10-13~78 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=558477eeb16aa81bc8bd7776c819cb98f96fc5c1;p=gostls13.git fmt: add Errorf helper function This crops up in a lot of places. It's just a one-liner, but doesn't add any dependancies. Seems worth it. R=r, r2 CC=golang-dev https://golang.org/cl/2344041 --- diff --git a/src/pkg/fmt/print.go b/src/pkg/fmt/print.go index 8fcde73fe2..0f3dd44bf0 100644 --- a/src/pkg/fmt/print.go +++ b/src/pkg/fmt/print.go @@ -159,6 +159,12 @@ func Sprintf(format string, a ...interface{}) string { return s } +// Errorf formats according to a format specifier and returns the string +// converted to an os.ErrorString, which satisfies the os.Error interface. +func Errorf(format string, a ...interface{}) os.Error { + return os.ErrorString(Sprintf(format, a...)) +} + // These routines do not take a format string // Fprint formats using the default formats for its operands and writes to w.