Last Updated: February 25, 2016
·
1.02K
· buger

Access unexported struct value in Go

As you may know you can't access struct variable from another package if its name starts from lowercase letter. But there is trick using reflect package:

import "reflect"
...
// Get current file offset from bufio.Scanner object.
reflect.ValueOf(scanner).Elem().FieldByName("start").Int()