Skip to content

Instantly share code, notes, and snippets.

@gerep
Created August 21, 2017 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerep/9f359402ba141c8c721e7f9d01a35bc6 to your computer and use it in GitHub Desktop.
Save gerep/9f359402ba141c8c721e7f9d01a35bc6 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
x := []byte(`{
"hash":"123456",
"order":123456
}`)
x2 := []byte(`{
"hass":"123456",
"order":123456
}`)
if equal(x, x2) {
fmt.Println("Equal")
} else {
fmt.Println("Different")
}
}
func equal(a []byte, b []byte) bool {
var counter int
for i, x := range b {
counter++
if x != a[i] {
fmt.Println("a", string(a[:counter]))
fmt.Println("b", string(b[:counter]))
return false
}
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment