storj/private/cui/example.go
Egon Elbre 0d2d59f884 all: fix linting issues
Change-Id: Idfc93948e59a181321d79b365e638d63e256a16f
2022-03-21 15:26:42 +00:00

53 lines
844 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build ignore
// +build ignore
package main
import (
"context"
"fmt"
"strings"
"time"
"golang.org/x/sync/errgroup"
"storj.io/storj/private/cui"
)
func main() {
screen, err := cui.NewScreen()
if err != nil {
fmt.Println(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var group errgroup.Group
group.Go(func() error {
defer cancel()
return screen.Run()
})
counter := 0
for ctx.Err() == nil {
width, _ := screen.Size()
fmt.Fprintf(screen, "%2d\n", counter)
fmt.Fprintf(screen, "%s\n", strings.Repeat("=", width))
screen.Flush()
counter++
time.Sleep(time.Second)
}
if err := screen.Close(); err != nil {
fmt.Println(err)
}
if err := group.Wait(); err != nil {
fmt.Println(err)
}
}