github.com/weedge/lib@v0.0.0-20230424045628-a36dcc1d90e4/strings/string.go (about)

     1  package strings
     2  
     3  import (
     4  	"strconv"
     5  	"unsafe"
     6  )
     7  
     8  func BytesToString(b []byte) string {
     9  	return *(*string)(unsafe.Pointer(&b))
    10  }
    11  
    12  func isIntNum(str string) bool {
    13  	_, err := strconv.ParseInt(str, 10, 64)
    14  	if err != nil {
    15  		return false
    16  	}
    17  
    18  	return true
    19  }
    20  
    21  func isFloatNum(str string) bool {
    22  	_, err := strconv.ParseFloat(str, 64)
    23  	if err != nil {
    24  		return false
    25  	}
    26  
    27  	return true
    28  }