-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathundo_test.go
52 lines (43 loc) · 1.08 KB
/
undo_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
/*
Copyright (c) 2014-2019, Undo Ltd.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
*/
// Package undodb provides examples for using other UndoDB packages
package undodb
import (
"go.undo.io/bindings/undoex"
"go.undo.io/bindings/undolr"
"time"
)
func Example_Annotation() {
// Start a recording
err := undolr.Start()
if err != nil {
panic(err)
}
// Add an annotation in the recording
err = undoex.AnnotationAddInt("Example", "example annotation", 42)
if err != nil {
panic(err)
}
// Stop the recording process, defering Discard to clean up
recContext, err := undolr.Stop()
if err != nil {
panic(err)
}
defer recContext.Discard()
// We now have a recording context and we can save it as we please.
// We save it via a goroutine here, so we could do other things while
// the save continues in the background if we wanted.
ch := make(chan error, 1)
go recContext.SaveBackground("recording.undolr", ch)
select {
case err = <-ch:
if err != nil {
panic(err)
}
case <-time.After(time.Second * 30):
panic("Save hadn't completed after 30 seconds")
}
}