Problem with using 2 file Go in Eclipse

Hi to everyone, I’m a newbie with go. I’m using go with eclipse.
Does anyone know how to build and run a project in Eclipse with two files? I’ve created a first file with a function for test and a second file with a definition of an array of struct. They are in the same src and in the same package.

First file:

import ( "math" "testing")
func TestData(t *testing.T) { 
const precision = 0.01
for _, tc := range testExamples {
actual := DataTest(tc.FirstValue, tc.SecondValue)
if ... {
    t.Fatalf("FAIL: %s\nExpected: %#v\nActual: %#v", tc.description, tc.expected, actual)
t.Logf("PASS: %s", tc.description)

Second File:

var testCases = []struct {
description string
valuex      string
valuey      string
expected    float64
description: "example1",
FirstValue:      xxxxx,
SecondValue:     yyyyy,
expected:    10,
description: "example2",
FirstValue:      xxxxx,
SecondValue:     yyyyy,
expected:    280,

Eclipse, in the first file, report: undefined: testCases

I thought the problem was related to the automatic compilation that does not take into account the 2 files. Does anyone have any suggestions?


Did you write the package declaration? They are missing in your examples here…

Yes, I’m sorry. I forgot to write It in the post but in both of them, I wrote the package declaration: package main.

Are your funcs being called inside the func main? If doesn’t, try to call them inside that func.

Does it work from the terminal using go build?

Hello, I did not put the main function inside my application, because I seemed to have understood that to perform the test function was not necessary.

I tried to build the build manually but I always get the same error, as if I did not see the test case I declared inside the other file go.

Do you have any suggestions?
is it necessary to use the main function even when using test_case?

Do you have any suggestions?

Sorry for the late response, since I was lack of time from work.
Well, maybe this should be late, but reading again, your need is about tests. Being honest I didn’t study tests in go yet. So I’m sorry for not being able to help. I’m really sorry