From 8a335225c705232fe1174755a1b1ea475456b864 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 24 Mar 2022 00:19:30 +0800 Subject: Format code, update documentation and remove exported variable `XMLHeaderByte` --- lib.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'lib.go') diff --git a/lib.go b/lib.go index 439e50a..4205e08 100644 --- a/lib.go +++ b/lib.go @@ -80,10 +80,13 @@ func (f *File) unzipToTemp(zipFile *zip.File) (string, error) { if err != nil { return tmp.Name(), err } - _, err = io.Copy(tmp, rc) - rc.Close() - tmp.Close() - return tmp.Name(), err + if _, err = io.Copy(tmp, rc); err != nil { + return tmp.Name(), err + } + if err = rc.Close(); err != nil { + return tmp.Name(), err + } + return tmp.Name(), tmp.Close() } // readXML provides a function to read XML content as bytes. @@ -109,7 +112,7 @@ func (f *File) readBytes(name string) []byte { } content, _ = ioutil.ReadAll(file) f.Pkg.Store(name, content) - file.Close() + _ = file.Close() return content } @@ -437,9 +440,10 @@ func (avb attrValBool) MarshalXML(e *xml.Encoder, start xml.StartElement) error } } start.Attr = []xml.Attr{attr} - e.EncodeToken(start) - e.EncodeToken(start.End()) - return nil + if err := e.EncodeToken(start); err != nil { + return err + } + return e.EncodeToken(start.End()) } // UnmarshalXML convert the literal values true, false, 1, 0 of the XML @@ -558,7 +562,7 @@ func genSheetPasswd(plaintext string) string { charPos++ rotatedBits := value >> 15 // rotated bits beyond bit 15 value &= 0x7fff // first 15 bits - password ^= (value | rotatedBits) + password ^= value | rotatedBits } password ^= int64(len(plaintext)) password ^= 0xCE4B @@ -793,8 +797,8 @@ type Stack struct { // NewStack create a new stack. func NewStack() *Stack { - list := list.New() - return &Stack{list} + l := list.New() + return &Stack{l} } // Push a value onto the top of the stack. -- cgit v1.2.1