github.com/mantzas/incata@v0.3.0/mocks/memory_writer.go (about) 1 package mocks 2 3 import ( 4 "github.com/mantzas/incata/model" 5 "sync" 6 ) 7 8 // MemoryWriter Writer for memory 9 type MemoryWriter struct { 10 Data []model.Event 11 mx sync.Mutex 12 } 13 14 // NewMemoryWriter creates a new memory writer 15 func NewMemoryWriter(data []model.Event) *MemoryWriter { 16 17 return &MemoryWriter{ 18 Data: data, 19 } 20 } 21 22 // Write writes a value to a string slice 23 func (w *MemoryWriter) Write(event model.Event) (err error) { 24 25 w.mx.Lock() 26 defer w.mx.Unlock() 27 w.Data = append(w.Data, event) 28 err = nil 29 return 30 }