does tls.Conn really implement the net.Conn interface?

788 views
Skip to first unread message

Stephen Waits

unread,
Oct 13, 2014, 6:02:21 PM10/13/14
to golan...@googlegroups.com
The docs for tls.Conn say:
// A Conn represents a secured connection.
    23	// It implements the net.Conn interface.
However, when I try to do a type assertion, it's returned as impossible:

impossible type assertion:
tls.Conn does not implement net.Conn (Close method has pointer receiver)

See example here:


Why do this? I'm trying to get at the tls.Conn.ConnectionState() stuff in the case that my net.Conn is actually a tls.Conn.

Any help appreciated!

Thanks,
Steve

william....@gmail.com

unread,
Oct 13, 2014, 6:31:44 PM10/13/14
to golan...@googlegroups.com
You're seeing that because it's *tls.Conn, not tls.Conn, that implements net.Conn. See http://play.golang.org/p/lc7dXbVqXk for a 'revised' example.

The wording of 'It implements the net.Conn interface' might be a little imprecise, but similar language is used in, at least, the UnixConn doc ("UnixConn is an implementation of the Conn interface for connections to Unix domain sockets.").

Stephen Waits

unread,
Oct 13, 2014, 6:48:52 PM10/13/14
to golan...@googlegroups.com, william....@gmail.com
Seems so obvious.. now. ;)  Thanks!
Reply all
Reply to author
Forward
0 new messages