From 843bd24e56450791ad122a2f3875956a0a70ec6e Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 6 Aug 2020 05:58:40 +0000 Subject: This closes #677 and closes #679, fix panic when enabling compiler inline flags --- lib.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'lib.go') diff --git a/lib.go b/lib.go index 2d2c1fa..acb4590 100644 --- a/lib.go +++ b/lib.go @@ -20,7 +20,6 @@ import ( "io" "strconv" "strings" - "unsafe" ) // ReadZipReader can be used to read the spreadsheet in memory without touching the @@ -251,17 +250,11 @@ func namespaceStrictToTransitional(content []byte) []byte { StrictNameSpaceSpreadSheet: NameSpaceSpreadSheet.Value, } for s, n := range namespaceTranslationDic { - content = bytesReplace(content, stringToBytes(s), stringToBytes(n), -1) + content = bytesReplace(content, []byte(s), []byte(n), -1) } return content } -// stringToBytes cast a string to bytes pointer and assign the value of this -// pointer. -func stringToBytes(s string) []byte { - return *(*[]byte)(unsafe.Pointer(&s)) -} - // bytesReplace replace old bytes with given new. func bytesReplace(s, old, new []byte, n int) []byte { if n == 0 { @@ -366,7 +359,7 @@ func getXMLNamespace(space string, attr []xml.Attr) string { // replaceNameSpaceBytes provides a function to replace the XML root element // attribute by the given component part path and XML content. func (f *File) replaceNameSpaceBytes(path string, contentMarshal []byte) []byte { - var oldXmlns = stringToBytes(`xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`) + var oldXmlns = []byte(`xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`) var newXmlns = []byte(templateNamespaceIDMap) if attr, ok := f.xmlAttr[path]; ok { newXmlns = []byte(genXMLNamespace(attr)) -- cgit v1.2.1