From ce995a5aa2369db9207084c09acd9f22adeca055 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 12 Aug 2021 09:56:50 -0400 Subject: [PATCH] Fix unchecked error. No issue # Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- exportnumpy.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/exportnumpy.go b/exportnumpy.go index c8e9f7cfc5..8815b4b26a 100644 --- a/exportnumpy.go +++ b/exportnumpy.go @@ -251,19 +251,23 @@ func (cmd *exportNumpy) RunCommand(prog string, args []string, stdin io.Reader, return } defer f.Close() - npw, err := gonpy.NewWriter(f) + // gonpy closes our writer and ignores errors. Give it a nopCloser so we can close f properly. + npw, err := gonpy.NewWriter(nopCloser{f}) if err != nil { lastErr.Store(err) return } npw.Shape = []int{len(names), len(pdis) * 2} - npw.WriteInt8(data) - // gonpy closes f and ignores errors, doh. - // err = f.Close() - // if err != nil { - // lastErr.Store(err) - // return - // } + err = npw.WriteInt8(data) + if err != nil { + lastErr.Store(err) + return + } + err = f.Close() + if err != nil { + lastErr.Store(err) + return + } }() } wg.Wait() -- 2.30.2