27 lines
356 B
Go
27 lines
356 B
Go
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
|
|
}
|