Skip to content

net/url: Parse can't parse url like 10.88.237.69:4222 #21415

@himulawang

Description

@himulawang

Please answer these questions before submitting your issue. Thanks!

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

1.8.3

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\project
set GORACE=
set GOROOT=d:\SDK\go
set GOTOOLDIR=d:\SDK\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

package main

import (
    "net/url"
    "fmt"
    "os"
)

func main() {
    addr := "10.88.237.69:4222"
    u, err := url.Parse(addr)
    if err != nil {
        fmt.Println(err.Error())
	os.Exit(1)
    }

    fmt.Println(u.Hostname(), u.Port())
}

A link on play.golang.org is best.
https://play.golang.org/p/AxIZvVA7fm

What did you expect to see?

err == nil
I think 10.88.237.69:4222 is a validate URL.

What did you see instead?

parse 10.88.237.69:4222: first path segment in URL cannot contain colon

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions