From 558477eeb16aa81bc8bd7776c819cb98f96fc5c1 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Fri, 1 Oct 2010 14:04:55 +1000 Subject: [PATCH] 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 --- src/pkg/fmt/print.go | 6 ++++++ 1 file changed, 6 insertions(+) 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. -- 2.50.0