@@ -107,6 +107,9 @@ func (r *Reader) startNode() (uint, error) {
107107// Lookup takes an IP address as a net.IP structure and a pointer to the 
108108// result value to Decode into. 
109109func  (r  * Reader ) Lookup (ipAddress  net.IP , result  interface {}) error  {
110+ if  r  ==  nil  {
111+ return  errors .New ("not initialized" )
112+ }
110113pointer , err  :=  r .lookupPointer (ipAddress )
111114if  pointer  ==  0  ||  err  !=  nil  {
112115return  err 
@@ -120,6 +123,9 @@ func (r *Reader) Lookup(ipAddress net.IP, result interface{}) error {
120123// is an advanced API, which exists to provide clients with a means to cache 
121124// previously-decoded records. 
122125func  (r  * Reader ) LookupOffset (ipAddress  net.IP ) (uintptr , error ) {
126+ if  r  ==  nil  {
127+ return  0 , errors .New ("not initialized" )
128+ }
123129pointer , err  :=  r .lookupPointer (ipAddress )
124130if  pointer  ==  0  ||  err  !=  nil  {
125131return  NotFound , err 
@@ -144,6 +150,9 @@ func (r *Reader) LookupOffset(ipAddress net.IP) (uintptr, error) {
144150// single representative record for that country. This uintptr behavior allows 
145151// clients to leverage this normalization in their own sub-record caching. 
146152func  (r  * Reader ) Decode (offset  uintptr , result  interface {}) error  {
153+ if  r  ==  nil  {
154+ return  errors .New ("not initialized" )
155+ }
147156rv  :=  reflect .ValueOf (result )
148157if  rv .Kind () !=  reflect .Ptr  ||  rv .IsNil () {
149158return  errors .New ("result param must be a pointer" )
0 commit comments