I have a parent struct :
type BigPoly struct{
Value []*ring.Poly
}
And two child structs :
type Plaintext BigPoly
type Ciphertext BigPoly
I would like to have functions accepting both Plaintext and Ciphertext. My solution is to use a function of the form :
func Add(a *Ciphertext, b interface{}) (*Ciphertext)
and use a switch-case to decide what to do, but I find it troublesome and it can lead to very complicated cases if the number of inputs grows.
However since Plaintext and Ciphertext have exactly the same structure and internal variables and only differ in their name, is it possible to create a function accepting both Plaintext and Ciphertext in a cleaner way ? I.e. it doesn't care if it is a type Plaintext or Ciphertext, as long as it is a type BigPoly.