If you need to SHA256 a String in Go, then you can use the crypto/sha256 package.

SHA256 a String in Go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
package main

import (
	"crypto/sha256"
	"fmt"
)

func main() {
	s := "A sample string to SHA256!"

	h := sha256.New()

	h.Write([]byte(s))

	bs := h.Sum(nil)

	fmt.Println(s)
	fmt.Printf("%x\n", bs)
}

The output will look like this:

1
2
A sample string to SHA256!
9abf637c7e39cc4ef84d6d92cf7ffe168dc922b8ae666260d907e0353865ce89