Skip to content

Instantly share code, notes, and snippets.

@l0gicgate
Last active July 10, 2019 18:16
Show Gist options
  • Save l0gicgate/85091e2ab7ebb369ed6088b632af1488 to your computer and use it in GitHub Desktop.
Save l0gicgate/85091e2ab7ebb369ed6088b632af1488 to your computer and use it in GitHub Desktop.
type IGenericType interface {
GetName() string
}
type GenericTypeRepository struct {
NativeType IGenericType
}
func (r *GenericTypeRepository) FindAll() (*[]IGenericType, error) {
var types []r.NativeType
// How can I make this var be whatever type is specified when instantiating the GenericTypeRepository
}
// Type A implements IGenericType
type A struct {
Name string
}
func (a *A) GetName() string {
return a.Name
}
// Instantiation of GenericTypeRepository
repo := &GenericTypeRepository{ NativeType: A }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment