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 }