Is this a homework assignement?
If so, please refer to the coursematerials and lessons right before the assignement was made. It should cover all things necessary to solve the assignment.
Until the homework thing is clear, I do only see two possibilities: Either read in a loop or do it recursively. The latter is strongly discouraged in go, since no TCO is made and stack depth is limited to about 10k function calls AFAIR.