Skip to content

net: inconsistent dial tcp error message, some have colon, some don't #45020

@digininja

Description

@digininja

What version of Go are you using (go version)?

$ go version

$ go version
go version go1.16.2 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/robin/.cache/go-build"
GOENV="/home/robin/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/robin/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/robin/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go_current"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go_current/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/xxxx/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2613921442=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Making HTTP requests and trying to handle errors

    client := &http.Client{
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },  
    }   

    log.Debugf("Requesting URL: %s\n", url)
    req, err := http.NewRequest("GET", url, nil)

    resp, err := client.Do(req)

  if err != nil {
        log.Debugf("Generic error: %s", err)
}

What did you expect to see?

Consistent use of the phrase dial tcp in error messages.

What did you see instead?

Some errors from dial tcp have a colon after the tcp, some don't:

DEBU[0003] Generic error: Get "http://host1.int": dial tcp 192.168.0.1:80: connect: no route to host
DEBU[0000] Generic error: Get "http://raasdfst.krynn.int": dial tcp: lookup host2.int on 192.168.0.2:53: no such host

Spotted this because I'm trying to tidy the errors up a bit to give a user a bit more information, my regexp was looking for dial tcp: then I found the one without the colon.

I've not dug in to see how may have or don't have the colon.

Thought I'd report it as it would be nice to have consistency over whether the colon is there or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions