diff options
author | Kurt <kurt.w.jung@gmail.com> | 2018-11-10 12:06:51 -0500 |
---|---|---|
committer | Kurt <kurt.w.jung@gmail.com> | 2018-11-10 12:06:51 -0500 |
commit | 193187d077554b92944a4757e202d1300e1ed1fb (patch) | |
tree | 0ce3865cbd2051a4a6d74e4273ccc3eb2dd7cd24 /template_impl.go | |
parent | 8d469f984ef048ff3547911bede39b7b651e8c8c (diff) |
Added some comments to new encoding/decoding methods
Diffstat (limited to 'template_impl.go')
-rw-r--r-- | template_impl.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/template_impl.go b/template_impl.go index 1a91112..c34e688 100644 --- a/template_impl.go +++ b/template_impl.go @@ -82,7 +82,7 @@ func (t *FpdfTpl) Templates() []Template { return t.templates } -// Turn a template into a byte string for later deserialization +// Serialize turns a template into a byte string for later deserialization func (t *FpdfTpl) Serialize() ([]byte, error) { b := new(bytes.Buffer) enc := gob.NewEncoder(b) @@ -91,7 +91,8 @@ func (t *FpdfTpl) Serialize() ([]byte, error) { return b.Bytes(), err } -// Create a template from a previously serialized template +// DeserializeTemplate creaties a template from a previously serialized +// template func DeserializeTemplate(b []byte) (Template, error) { tpl := new(FpdfTpl) dec := gob.NewDecoder(bytes.NewBuffer(b)) @@ -116,6 +117,8 @@ func (t *FpdfTpl) childrenImages() map[string]*ImageInfoType { return childrenImgs } +// GobEncode encodes the receiving template into a byte buffer. Use GobDecode +// to decode the byte buffer back to a template. func (t *FpdfTpl) GobEncode() ([]byte, error) { w := new(bytes.Buffer) encoder := gob.NewEncoder(w) @@ -161,6 +164,7 @@ func (t *FpdfTpl) GobEncode() ([]byte, error) { return w.Bytes(), err } +// GobDecode decodes the specified byte buffer into the receiving template. func (t *FpdfTpl) GobDecode(buf []byte) error { r := bytes.NewBuffer(buf) decoder := gob.NewDecoder(r) |