ssl.wrap_socket实现

In python you can wrap a standard socket with ssl. Detailed doc can be found here, https://docs.python.org/2/library/ssl.html

I want something similar in go. Here is my attempt.

func GetSSLWrappedConnection() (SSLWrappedConnection net.Conn, err error){

fmt.Println("Initialiazing proxy connection")
rawConn, er_ := net.Dial("tcp", "127.0.0.1:8080")
if  er_ != nil {
    return nil, fmt.Errorf("Can't establish connection with remote server!")
} else {
    // now we need to wrap the connection (SSL Wrap)
    var TLSconfig *tls.Config
    TLSconfig = &tls.Config{
                InsecureSkipVerify: true}

    ssl_wrapped_connection := tls.Client(rawConn, TLSconfig)
    err = ssl_wrapped_connection.Handshake()

    if err != nil {
        fmt.Println(err)
        rawConn.Close()
        return nil, err
    }
    return ssl_wrapped_connection, nil
}

}

Is this the correct implementation?

Wrong question to ask.

A simple tls.Dial will do!