github.com/coreservice-io/utils@v0.3.0/README.md (about)

     1  # utils
     2  
     3  ### common tools for golang 
     4  
     5  example
     6  ```go
     7  
     8  package main
     9  
    10  import (
    11  	"log"
    12  
    13  	"github.com/coreservice-io/utils/bytes_util"
    14  	"github.com/coreservice-io/utils/hash_util"
    15  	"github.com/coreservice-io/utils/rand_util"
    16  	"github.com/coreservice-io/utils/time_util"
    17  )
    18  
    19  func main() {
    20  	//time_util
    21  	log.Println(time_util.GetUTCDate())
    22  	log.Println(time_util.GetUTCDateTime())
    23  
    24  	//bytes_util
    25  	log.Println(bytes_util.Format(12312341344))
    26  	bytes_num, err := bytes_util.Parse("11.47TB") //case insensitive
    27  	if err != nil {
    28  		log.Println(err.Error())
    29  	} else {
    30  		log.Println(bytes_num)
    31  	}
    32  
    33  	//rand_util
    34  	log.Println("randstr:" + rand_util.GenRandStr(80))
    35  
    36  	//hash_util
    37  	log.Println(hash_util.MD5Hash([]byte("123123")))
    38  	log.Println(hash_util.MD5HashString("123123"))
    39  
    40  	log.Println(hash_util.SHA256([]byte("123123")))
    41  	log.Println(hash_util.SHA256String("123123"))
    42  
    43  	log.Println(hash_util.CRC32HashString("123123"))
    44  	log.Println(hash_util.CRC32HashString("123123"))
    45  	log.Println(hash_util.CRC32HashArrayString([]string{"1", "2", "3", "1", "2", "3"}))
    46  	log.Println(hash_util.CRC32HashArrayString([]string{"1", "2", "3", "1", "2", "3"}))
    47  
    48  }
    49  
    50  
    51  ```