blob: 1ef2357b42ce72f3bc64fdcf2031ca9079fc34ba (
plain)
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
|
package vm
type Output interface {
Write(message string) error
}
type EmptyOutput struct{}
func NewEmptyOutput() *EmptyOutput {
return &EmptyOutput{}
}
func (o *EmptyOutput) Write(message string) error {
return nil
}
type GatheringOutput struct {
messages []string
}
func NewGatheringOutput() *GatheringOutput {
return &GatheringOutput{
messages: make([]string, 0, 8),
}
}
func (o *GatheringOutput) Messages() []string {
return o.messages
}
func (o *GatheringOutput) Write(message string) error {
o.messages = append(o.messages, message)
return nil
}
type ConsoleOutput struct{}
func NewConsoleOutput() *ConsoleOutput {
return &ConsoleOutput{}
}
func (o *ConsoleOutput) Write(message string) error {
println(message)
return nil
}
|