validation - Validate URL with standard package in GO -


is there function in standard package in go allows validate url?

i have not found on initial search, , prefer not resort regex checking.

yep, url.parserequesturi returns error if url not valid, not absolute url, etc etc. url.parse returns valid on anything...

import "net/url"  ...   u, err := url.parserequesturi("http://google.com/") if err != nil {    panic(err) } 

the above example not fail, these will:

u, err := url.parserequesturi("http//google.com")  u, err := url.parserequesturi("google.com")  u, err := url.parserequesturi("/foo/bar") 

Comments