Hashing same data in Godot GDScript and Golang Module

So the data in Godot is organized in an array of dictionaries, while data in Go module is organized in slice of structs, I want to hash the values from the client and the server and compare them. I’ve tried multiple setups but the hashes were different values. What’s a good way of approaching the hashing?

So here’s how I achieved this. Using GDScript in godot and Golang Module with SHA256.
The setup is to have the data in array of Dictionaries in Godot and to have a slice of Structs in Go.
IMPORTANT THING TO NOTE is that godots JSON.print takes 3 arguments has 3 arguments (2 are optional) the third one is the sorting of keys, if you want to have your keys sorted alphabetically it’s useful to set that to true (like I did). BUT in Go when you UNMARSHAL your data, its sorted by the order of properties in struct, not by the name of the struct but by the name of the JSON.

type Test struct {
  Ananas int `json:"bambus"`
  Banana int `json:"apple"`     

So the json output of this will be apple first then bambus, so it looks for alphabetical order of the json keys. Good thing to note

In Godot:

#data is your dictionary or your array of dictionaries
var json = JSON.print(data, "", true)
#this will give you the hash you need as a string
var data_hash = json.sha256_buffer().hex_encode()

In Nakama:

// type of data should be like []YourStruct
data, err := json.Marshal(&THETYPEOFDATAYOUWANT)
// hex.encode takes a []byte while sha256 returns [32]byte, so we
// have to get []byte out of it, we use this line together with a[:] to
// get the desired behaviour
a := [32]byte((sha256.Sum256([]byte(data))))
// we encode it to string and it works!! it will match your hash in Godot
return hex.EncodeToString(a[:]), nil