How to determine if the var passed to my Func is actually the Type that i want?
i have a custom Type
type Name string
and a bunch of constants of that type
const Fred Name = "fred"
and i have a func that i need to forbid any other type of input other than my custom Type ex:
func MyFunc(name1 Name, name2 Name) (*Person, error) {
//bunch of stuff
}
how i check inside my func that name1 and name2 are not strings passed to the func but exclusively the const i already defined in my type ex:
p, err := MyFunc(Fred,Albert) //What i want
p, err := MyFunc("fred","albert") //What i dont want to happen
if cannot answer my question how i can make like a Enum in Golang a type that means something and restrict other ppl to use that type i defined