forked from electricdusk/rushlink
Use a more standardized project layout
In #2, mrngm made the point that we should move to a more standardized project structure. This commit does exactly that. The new project structure is based on the repository listed at <https://github.com/golang-standards/project-layout>. Fixes #2.
This commit is contained in:
22
pkg/gobmarsh/marshal.go
Normal file
22
pkg/gobmarsh/marshal.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package gobmarsh
|
||||
|
||||
// Easier marshalling to and from gob encoding
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
)
|
||||
|
||||
func Marshal(v interface{}) ([]byte, error) {
|
||||
b := new(bytes.Buffer)
|
||||
err := gob.NewEncoder(b).Encode(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func Unmarshal(data []byte, v interface{}) error {
|
||||
b := bytes.NewBuffer(data)
|
||||
return gob.NewDecoder(b).Decode(v)
|
||||
}
|
||||
Reference in New Issue
Block a user