From 956a4627d1f2b78172eaaf6078209d4cf8e64ce2 Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Mon, 5 Sep 2016 10:44:32 +0800 Subject: Fix issue #4 use builtin `map` instead of home-built. --- lib.go | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'lib.go') diff --git a/lib.go b/lib.go index 9323411..7147424 100644 --- a/lib.go +++ b/lib.go @@ -14,51 +14,32 @@ import ( // ReadZip takes a pointer to a zip.ReadCloser and returns a // xlsx.File struct populated with its contents. In most cases // ReadZip is not used directly, but is called internally by OpenFile. -func ReadZip(f *zip.ReadCloser) ([]FileList, error) { +func ReadZip(f *zip.ReadCloser) (map[string]string, error) { defer f.Close() return ReadZipReader(&f.Reader) } // ReadZipReader can be used to read an XLSX in memory without // touching the filesystem. -func ReadZipReader(r *zip.Reader) ([]FileList, error) { - var fileList []FileList +func ReadZipReader(r *zip.Reader) (map[string]string, error) { + fileList := make(map[string]string) for _, v := range r.File { - singleFile := FileList{ - Key: v.Name, - Value: readFile(v), - } - fileList = append(fileList, singleFile) + fileList[v.Name] = readFile(v) } return fileList, nil } // Read XML content as string and replace drawing property in XML namespace of sheet -func readXML(files []FileList, name string) string { - for _, file := range files { - if file.Key == name { - return strings.Replace(file.Value, "