In go I have a named type
type identifier string
I am using a standard library method that returns []string
and I want to convert that into []identifier
. Is there a smoother way to do that other than:
...
stdLibStrings := re.FindAllString(myRe, -1)
identifiers := make([]identifier, len(stdLibStrings))
for i, s := range stdLibStrings {
identifiers[i] = identifier(s)
}
My end goal is to have this named identifier
type have some methods which, if I'm not mistaken, require a named type versus using a unnamed type as a receiver which isn't allowed.
Thanks.