From e21a6e2c6bf504673cc06e4317d3209ceed78b5b Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Fri, 15 Mar 2024 10:10:17 +0100 Subject: [PATCH] refactor: rename and modify CloserFunc --- interfaces/closer.go | 14 -------------- interfaces/closerfunc.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 interfaces/closerfunc.go diff --git a/interfaces/closer.go b/interfaces/closer.go index 9107be2..abbc719 100644 --- a/interfaces/closer.go +++ b/interfaces/closer.go @@ -4,14 +4,6 @@ import ( "context" ) -type CloseHandler struct { - Value func(ctx context.Context) error -} - -func (r CloseHandler) Close(ctx context.Context) error { - return r.Value(ctx) -} - // Closer interface type Closer interface { Close() @@ -31,9 +23,3 @@ type CloserWithContext interface { type ErrorCloserWithContext interface { Close(ctx context.Context) error } - -func CloseFunc(v func(ctx context.Context) error) CloseHandler { - return CloseHandler{ - Value: v, - } -} diff --git a/interfaces/closerfunc.go b/interfaces/closerfunc.go new file mode 100644 index 0000000..cb7120f --- /dev/null +++ b/interfaces/closerfunc.go @@ -0,0 +1,11 @@ +package interfaces + +import ( + "context" +) + +type CloserFunc func(ctx context.Context) error + +func (f CloserFunc) Close(ctx context.Context) error { + return f(ctx) +}