Skip to content

Commit

Permalink
Fix mutex copy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbbastien committed Sep 22, 2020
1 parent 5a4cc81 commit 475102f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func setTimeout() {
}
}

func newTransport(insecure bool, iface string) (tr http.Transport, ip net.IP) {
func newTransport(insecure bool, iface string) (tr *http.Transport, ip net.IP) {
var _tr http.Transport
tlsConf := &tls.Config{InsecureSkipVerify: insecure}

if iface != "" {
Expand All @@ -40,14 +41,14 @@ func newTransport(insecure bool, iface string) (tr http.Transport, ip net.IP) {

tcpAddr := &net.TCPAddr{IP: addrs[0].(*net.IPNet).IP}
d := net.Dialer{LocalAddr: tcpAddr}
tr = http.Transport{Dial: d.Dial, TLSClientConfig: tlsConf}
_tr = http.Transport{Dial: d.Dial, TLSClientConfig: tlsConf}

ip = tcpAddr.IP
} else {
tr = http.Transport{TLSClientConfig: tlsConf}
_tr = http.Transport{TLSClientConfig: tlsConf}
}

return tr, ip
return &_tr, ip
}

func setSourceAddr(iface string) (ip net.IP) {
Expand Down Expand Up @@ -87,7 +88,7 @@ func main() {

setTimeout()
tr, ip := newTransport(*insecure, *iface)
client = http.Client{Transport: &tr}
client = http.Client{Transport: tr}

user := fetchUserInfo()
user.Show(ip.String())
Expand Down

0 comments on commit 475102f

Please sign in to comment.