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()
Written by Leonid Bugaev
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Go
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#