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

     1  package tmp
     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  	"fmt"
    12  )
    13  
    14  // ////////////////////////////////////////////////////////////////////////////////// //
    15  
    16  func ExampleNewTemp() {
    17  	tmp, _ := NewTemp()
    18  
    19  	fmt.Println(tmp.Dir)
    20  
    21  	// Output: /tmp
    22  }
    23  
    24  func ExampleTemp_MkDir() {
    25  	tmp, _ := NewTemp()
    26  
    27  	fmt.Println(tmp.MkDir())
    28  	fmt.Println(tmp.MkDir("test123"))
    29  
    30  	tmp.Clean()
    31  }
    32  
    33  func ExampleTemp_MkFile() {
    34  	tmp, _ := NewTemp()
    35  
    36  	fmt.Println(tmp.MkFile())
    37  	fmt.Println(tmp.MkFile("test123"))
    38  
    39  	tmp.Clean()
    40  }
    41  
    42  func ExampleTemp_MkName() {
    43  	tmp, _ := NewTemp()
    44  
    45  	fmt.Println(tmp.MkDir())
    46  	fmt.Println(tmp.MkDir("test123"))
    47  }
    48  
    49  func ExampleTemp_Clean() {
    50  	tmp, _ := NewTemp()
    51  
    52  	tmp.MkDir()
    53  
    54  	// All temporary data will be removed
    55  	tmp.Clean()
    56  }