I have
type DocId int
func foo(documents []String) {
for i := range documents {
id := DocId(i)
...
}
}
How do I get rid of the explicit conversion line? DocIds are meant to be the type that indexes individual documents.
What I want is more like:
func foo(documents []String) {
for id := range documents {
... // id gets used as the DocId that it damn well *IS*
}
}
Which gives me 'invalid operation: ... (mismatched types int and DocId)' when I attempt to use the id from range as a DocId, even though DocId is an int.