gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/net/http2/go115.go (about) 1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build go1.15 6 // +build go1.15 7 8 package http2 9 10 import ( 11 "context" 12 13 tls "gitee.com/ks-custle/core-gm/gmtls" 14 ) 15 16 // dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS 17 // connection. 18 func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { 19 dialer := &tls.Dialer{ 20 Config: cfg, 21 } 22 cn, err := dialer.DialContext(ctx, network, addr) 23 if err != nil { 24 return nil, err 25 } 26 tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed 27 return tlsCn, nil 28 }