-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
package activitypub
import (
"bytes"
"encoding/gob"
)
func GobEncode(it Item) ([]byte, error) {
b := new(bytes.Buffer)
err := gob.NewEncoder(b).Encode(it)
return b.Bytes(), err
}
type hasType struct {
Type ActivityVocabularyType
}
func GobUnmarshalToItem(data []byte) Item {
if len(data) == 0 {
return nil
}
if ItemTyperFunc == nil {
return nil
}
typer := new(hasType)
err := gob.NewDecoder(bytes.NewReader(data)).Decode(typer)
if err != nil {
return nil
}
var it Item
switch typer.Type {
}
return it
}
// UnmarshalGob
func UnmarshalGob(data []byte) (Item, error) {
if ItemTyperFunc == nil {
ItemTyperFunc = GetItemByType
}
return GobUnmarshalToItem(data), nil
}