I've isolated an odd situation in my program to a minimal test case:
package main
import (
"fmt"
"net"
"crypto/tls"
)
func main() {
var c net.Conn
c, err := tls.Dial("tcp", "
www.jgc.org:80", nil)
fmt.Printf("%v %v\n", c, err)
if c == nil {
fmt.Printf("Nil\n")
} else {
fmt.Printf("Not nil\n")
}
}
This attempts to make a TLS connection to my web server on port 80
(this is done to _force_ a TLS error return from tls.Dial). The
output of this program is peculiar:
<nil> local error: record overflow
Not nil
When c is printed with %v it is reported as 'nil'. But when tested
with the if c == nil it is not nil. What's happening here?
John.