github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/base/banytostring/README.md (about)

     1  # banytostring
     2  
     3  将任何输入转化成字符串
     4  
     5  ## API
     6  
     7  - ToStringE
     8  
     9  ```go
    10  ToStringE(i interface{}) (string, error) 
    11  ```
    12  
    13  - ToString
    14  
    15  ```go
    16  ToString(v any) string 
    17  ```
    18  
    19  ## EXAMPLE
    20  
    21  ```go
    22  package main
    23  
    24  import (
    25  	"fmt"
    26  	"github.com/songzhibin97/go-baseutils/base/banytostring"
    27  )
    28  
    29  func main() {
    30  	v := "test"
    31  	nv, err := anytostring.ToStringE(v)
    32  	if err != nil {
    33  		fmt.Println(err)
    34  		return
    35  	}
    36  	fmt.Println(nv) // test
    37  	
    38  	v = "test"
    39  	fmt.Println(anytostring.ToString(v)) // test
    40  }
    41  ```