Golang testing> package load

I am having a problem with inline testing for go lang.

I keep getting this error.

> go test
> can't load package: package .: found packages main (calculator.go) and calculator (calculator_test.go) in  

      

calculator.go

package main

func main() {

}

      

calculator_test.go

package calculator

import "testing"

func TestAdd(t *testing.T) {
    result := Add(1, 3)
    if result != 4 {
        t.Fail()
    }
}

      

+3


source to share


1 answer


You have

package main

func main() {}

      

in the file calculator.go

.

and



package calculator

      

in the file calculator_test.go

.

They should be

package main

      

+6


source







All Articles