summaryrefslogtreecommitdiff
path: root/lib.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-08-19 13:37:15 +0800
committerRi Xu <xuri.me@gmail.com>2017-08-19 13:37:15 +0800
commit1ec2661dda1ef16f58b2a3d614b11a2bcd0a2f2f (patch)
treeb06360066f67463f4eb57461b98226c26821b8b6 /lib.go
parent77af25295ece8863326c99652d615f82385286b2 (diff)
Bugfix: deep copy issue with function `CopySheet()`, relate PR #108.
Diffstat (limited to 'lib.go')
-rw-r--r--lib.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib.go b/lib.go
index 5649f65..1bcb8fc 100644
--- a/lib.go
+++ b/lib.go
@@ -3,6 +3,7 @@ package excelize
import (
"archive/zip"
"bytes"
+ "encoding/gob"
"io"
"log"
"math"
@@ -104,3 +105,14 @@ func intOnlyMapF(rune rune) rune {
}
return -1
}
+
+// deepCopy provides method to creates a deep copy of whatever is passed to it
+// and returns the copy in an interface. The returned value will need to be
+// asserted to the correct type.
+func deepCopy(dst, src interface{}) error {
+ var buf bytes.Buffer
+ if err := gob.NewEncoder(&buf).Encode(src); err != nil {
+ return err
+ }
+ return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst)
+}