pkg.re/essentialkaos/ek.10@v12.41.0+incompatible/spinner/examples_test.go (about)

     1  package spinner
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2022 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  import (
    11  	"time"
    12  )
    13  
    14  // ////////////////////////////////////////////////////////////////////////////////// //
    15  
    16  func ExampleShow() {
    17  	file := "file.txt"
    18  	Show("Removing file %s", file)
    19  	time.Sleep(time.Second)
    20  	Done(true)
    21  }
    22  
    23  func ExampleUpdate() {
    24  	Show("My long running task")
    25  	time.Sleep(time.Second)
    26  	Show("My long running task still working")
    27  	time.Sleep(time.Second)
    28  	Done(true)
    29  }
    30  
    31  func ExampleDone() {
    32  	Show("My long running task with good result")
    33  	time.Sleep(time.Second)
    34  	Done(true)
    35  
    36  	Show("My long running task with bad result")
    37  	time.Sleep(time.Second)
    38  	Done(false)
    39  }