-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
document_test.go
52 lines (40 loc) · 838 Bytes
/
document_test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package gofindit
import "fmt"
func ExampleNewDoc() {
type Test struct {
Name string `find:"Name"`
Age int `find:"Age"`
}
// Create a new document
doc := Test{
Name: "Test",
Age: 10,
}
// Create a new document
document, err := NewDoc(doc)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(document.Fields)
// Output: map[Age:{int 10 []} Name:{string Test [test]}]
}
func ExampleDocument_GetFieldValue() {
type Test struct {
Name string `find:"name"`
Age int `find:"age"`
}
// Create a new document
doc := Test{
Name: "Test",
Age: 10,
}
// Create a new document
document, _ := NewDoc(doc)
nameField, _ := document.GetField("name")
fmt.Println(nameField.Value())
valueField, _ := document.GetField("age")
fmt.Println(valueField.Value())
// Output: test true
// 10 true
}