I'm new to Golang.
My go version: 1.17.8
Trying write tests to compare strcuts. Found this lib can show you which fields exactly equivalent. So thought of using it over reflect.DeepEqual
Here's my test go file,
package main
import (
"os"
"testing"
"github.com/go-test/deep"
)
func TestDeepEqual(t *testing.T) {
os.Remove("_decktesting.txt")
d := newDeck()
d.saveToFile("_decktesting.txt")
l := newDeckFromFile("_decktesting.txt")
if diff := deep.Equal(d, l); diff != nil {
t.Error(diff)
}
}
Here's what it says when try to test,
➜ go get
go-training/cards on develop [!] via v1.17.8
➜ go test
# go-training/cards
deck_test.go:7:2: cannot find package "github.com/go-test/deep" in any of:
/usr/local/go/src/github.com/go-test/deep (from $GOROOT)
/Users/ssamarasin/go/src/github.com/go-test/deep (from $GOPATH)
FAIL go-training/cards [setup failed]
go-training/cards on develop [!] via v1.17.8
➜ go install github.com/go-test/deep@latest
package github.com/go-test/deep is not a main package
Can someone please explain how I can use this lib to compare my structs?
Thank you