Maybe you need the two Any* interfaces for some reason that is not apparent from the code snippet, but I have removed them to simplify the code. Within the context of the given code, the following function signature is semantically identical to your definition using the Any* interfaces:
func FuncName[T *E | []*E, E any](data T) (err error)
The error message seems unjustified, as the type of &a is clearly “pointer to ModelAA” and not “slice of pointers to ModelAA”. But you can help the compiler and specify the types to use for T and E when calling the function:
package main
import "testing"
func FuncName[T *E | []*E, E any](data T) (err error) {
return nil
}
type ModelAA struct {
A int
B int
}
func TestAddV2(t *testing.T) {
var a = ModelAA{
A: 1, B: 2,
}
_ = FuncName[*ModelAA, ModelAA](&a)
}