Are you asking a question? This is what I would expect from your program.
I note that if err2 != nil, you call fmt.Errorf, which just returns an
error value. Perhaps you mean fmt.Printf. I also note that you call
client.Close even if err2 != nil, which is why you get the SIGSEGV.
Ian