plain.go 388 B

1234567891011121314151617181920212223242526272829
  1. package progress
  2. import (
  3. "context"
  4. "fmt"
  5. "io"
  6. )
  7. type plainWriter struct {
  8. out io.Writer
  9. done chan bool
  10. }
  11. func (p *plainWriter) Start(ctx context.Context) error {
  12. select {
  13. case <-ctx.Done():
  14. return ctx.Err()
  15. case <-p.done:
  16. return nil
  17. }
  18. }
  19. func (p *plainWriter) Event(e Event) {
  20. fmt.Println(e.ID, e.Text, e.StatusText)
  21. }
  22. func (p *plainWriter) Stop() {
  23. p.done <- true
  24. }