Initial commit
This commit is contained in:
26
adapters/stdoutpub/service.go
Normal file
26
adapters/stdoutpub/service.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package stdoutpub
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
const outPrefix = "Result: "
|
||||
|
||||
func NewService() Service {
|
||||
return Service{
|
||||
fd: os.Stdout,
|
||||
}
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
fd *os.File
|
||||
}
|
||||
|
||||
func (s Service) Publish(i int64) error {
|
||||
if _, err := fmt.Fprintf(s.fd, "%s%d\n", outPrefix, i); err != nil {
|
||||
return fmt.Errorf("write to file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user