Debian Codegraph @

spinner/examples/context-and-action-and-error/main.go

raw symbols SCIP
1 package main
2
3 import (
4 "context"
5 "fmt"
6 "log"
7 "time"
8
9 "github.com/charmbracelet/huh/spinner"
10 )
11
12 func main() {
13 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
14 defer cancel()
15
16 err := spinner.New().
17 Context(ctx).
18 ActionWithErr(func(context.Context) error {
19 time.Sleep(5 * time.Second)
20 return nil
21 }).
22 Accessible(false).
23 Run()
24 if err != nil {
25 log.Fatalln(err)
26 }
27 fmt.Println("Done!")
28 }