From b5e2a444c632871d22336472db5f23924fdfb534 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Sat, 2 Jul 2022 13:04:09 +0530 Subject: [PATCH 1/2] Fix skipped file closing Signed-off-by: Ashish Tiwari --- adapter/oam.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adapter/oam.go b/adapter/oam.go index 434d1c1..14f1d8e 100644 --- a/adapter/oam.go +++ b/adapter/oam.go @@ -104,14 +104,13 @@ func (or *OAMRegistrant) Register() error { if err != nil { return ErrOpenOAMDefintionFile(err) } - defer func() { - _ = definition.Close() - }() definitionMap := map[string]interface{}{} if err := json.NewDecoder(definition).Decode(&definitionMap); err != nil { + _ = definition.Close() return ErrJSONMarshal(err) } + _ = definition.Close() ord.OAMDefinition = definitionMap schema, err := ioutil.ReadFile(dpath.OAMRefSchemaPath) From 57d984cbeaf582dc5caa970ab925fee7ebd73eff Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Wed, 13 Jul 2022 15:58:09 +0530 Subject: [PATCH 2/2] lint Signed-off-by: Ashish Tiwari --- adapter/adapter.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index 3ef5a4f..ae785c0 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -49,8 +49,8 @@ type Adapter struct { mx sync.Mutex } -func (a *Adapter) SetChannel(hchan *chan interface{}) { - a.mx.Lock() - defer a.mx.Unlock() - a.Channel = hchan +func (h *Adapter) SetChannel(hchan *chan interface{}) { + h.mx.Lock() + defer h.mx.Unlock() + h.Channel = hchan }