在GO中测试具有相同名称的函数

In go it is possible to write functions that are specific to structs.

type one struct{}

func (o *one) fly() {}

My questions is how can you test a function if there are two functions with the same name but point to different structs.

type one struct{}

func (o *one) fly() {}

type two struct{}

func (t *two) fly() {}

Since the formatting for GO tests is TestXxx (t *testing.T) {} I'm unsure how I would be able to test each function separately. Thanks

TestXxx is just a naming convention. Xxx may be anything you want, but Test (with Benchmark and Example) are required. So, declare 2 testing functions — TestOneFly and TestTwoFly, that's all. Or you can test both in TestFly, initializing both structs in one test.

Invoke the specific function using the dot operator on an instance of the struct.

aOne := one{}
aOne.fly() //Calls the first version

aTwo := two{}
aTwo.fly() //Calls the second version