From 85380193cf93341a7fde4001c188c43fedf6bab6 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 13 Apr 2015 19:49:08 +0200 Subject: [PATCH] types: add CloseFunc and update TB's docs Change-Id: I49dcbc5c48754e5d5074dfbbb278fb969b35aee5 --- pkg/types/types.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/types/types.go b/pkg/types/types.go index 61eb40409..7b31bc6f2 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -236,7 +236,8 @@ func (c *onceCloser) Close() error { return err } -// TB is a copy of Go 1.2's testing.TB. +// TB is a copy of testing.TB so things can take a TB without linking +// in the testing package (which defines its own flags, etc). type TB interface { Error(args ...interface{}) Errorf(format string, args ...interface{}) @@ -252,3 +253,8 @@ type TB interface { Skipf(format string, args ...interface{}) Skipped() bool } + +// CloseFunc implements io.Closer with a function. +type CloseFunc func() error + +func (fn CloseFunc) Close() error { return fn() }