Skip to main content

Golang CheatSheet

Zero Values

  • integer: 0
  • float: 0.0
  • boolean: false
  • strings: ""
  • channel, map, slice, pointer, function, interface: nil
// MD5 hashing example:

import (
    "crypto/md5"
    "encoding/hex"
)

func GetMD5Hash(text string) string {
    hasher := md5.New()
    hasher.Write([]byte(text))
    return hex.EncodeToString(hasher.Sum(nil))
}