Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid memory address or nil pointer dereference #2

Closed
KasperTidemann opened this issue Sep 1, 2014 · 2 comments
Closed

Invalid memory address or nil pointer dereference #2

KasperTidemann opened this issue Sep 1, 2014 · 2 comments

Comments

@KasperTidemann
Copy link

I'm trying to get the library to connect to a Gmail server using some of the example code provided at http://godoc.org/github.com/mxk/go-imap/imap. I've stripped out all unnecessary code in order to just connect to a server. This is my example code:

package main

import "code.google.com/p/go-imap/go1/imap"
import "fmt"

func main() {
  client, _ := imap.Dial("imap.gmail.com")

  fmt.Println("Server says hello:", client.Data[0].Info)

  if client.State() == imap.Login {
    client.Login("<example e-mail>", "<example password>")
  }
}

For the sake of clarity and isolating the problem, I've removed the deferring of the logout and so on. Running the above code results in this error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x21bc]

goroutine 16 [running]:
runtime.panic(0x22adc0, 0x3a24a4)
    /usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/panic.c:279 +0xf5
main.main()
    /Users/kasper/go/src/test/imap.go:9 +0x1bc

goroutine 19 [finalizer wait]:
runtime.park(0x145d0, 0x3a5a60, 0x3a4569)
    /usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x3a5a60, 0x3a4569)
    /usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
    /usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
    /usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1445

goroutine 17 [syscall]:
runtime.goexit()
    /usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1445
exit status 2

I've seen this problem referenced elsewhere, but I've been unable to find a solution. Any suggestions as to what might be wrong?

@mxk
Copy link
Owner

mxk commented Sep 1, 2014

imap.Dial is returning an error and a nil client. The error should tell you what went wrong (probably the missing port number resulting in a failed connection).

@KasperTidemann
Copy link
Author

You're right - thanks! Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants