Im just getting started with Golang and am trying to run unit tests. When running go test, I end up getting the following output from the terminal
go: cannot find main module, but found .git/config in /Users/dp/Documents
to create a module there, run:
cd ../.. && go mod init
My file structure is fairly simple, as is as follows
├── CARDS
│ ├── .vscode
│ ├── main.go
│ ├── test.go
│ ├── deck_test.go
│ └── my_cards.txt
the contents of deck_test.go are
package main
import "testing"
func TestNewDeck(t *testing.T) {
d := newDeck()
if len(d) != 52 {
t.Errorf("Length is not 52, got %v", len(d))
}
if d[0] != "A of D" {
t.Errorf("First card is not A of D, got %v", d[0])
}
if d[len(d)-1] != "K of C" {
t.Errorf("Last card is not K of C, got %v", d[len(d)-1])
}
}
Any insights would be of help!