-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
36 lines (31 loc) · 933 Bytes
/
types.go
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
// Package intro used for examples. The
// package implements some exampe types and
// registry with these types
package intro
import (
"github.com/skycoin/cxo/skyobject/registry"
)
// A User's information
type User struct {
Name string // user's name
Age uint32 // user's age
}
// A Feed of the User
type Feed struct {
Head string // head of the feed
Info string // brief information about the feed
Posts registry.Refs `skyobject:"schema=intro.Post"` // posts
}
// A Post represnts post in the Feed
type Post struct {
Head string // head of the Post
Body string // content of the Post
}
// Registry that contains User, Feed and Post types
var Registry = registry.NewRegistry(func(r *registry.Reg) {
// the name can be any, e.g. the "intro.User" can be
// "usr" or any other; feel free to choose
r.Register("intro.User", User{})
r.Register("intro.Feed", Feed{})
r.Register("intro.Post", Post{})
})