mardi 30 mars 2021

Go 1.16.2 throwing "undeclared name" for all references in unit test files

for some reason i can run all of my Go functions across files in a directory with Go Run ... but everytime i create a unit test of the format "main_test.go" it throws the following error

go: go.mod file not found in current directory or any parent directory; see 'go help modules'

Here is my simple test:

package main

import "testing"

func TestMain(t *testing.T) {
    g := greetings()
    if g != "Hi There, Tony" {
        t.Errorf("Didnt return the right person!")
    }
}

Aucun commentaire:

Enregistrer un commentaire