Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Domain ¶
Domain returns top level domain from url string. If no domain is found in provided url, this function returns empty string. If no TLD is found in provided url, this function returns empty string.
Example ¶
fmt.Println(Domain("google.co.uk")) fmt.Println(Domain("keep.google.com"))
Output: google.co.uk google.com
func DomainPrefix ¶
DomainPrefix returns second-level domain from provided url. If no SLD is found in provided url, this function returns empty string.
func DomainSuffix ¶
DomainSuffix returns domain suffix from provided url. If no TLD is found in provided url, this function returns empty string.
Example ¶
fmt.Println(DomainSuffix("google.co.uk")) fmt.Println(DomainSuffix("keep.google.com"))
Output: co.uk com
func HasSubdomain ¶
HasSubdomain reports whether domain contains any subdomain.
Example ¶
fmt.Println(HasSubdomain("google.com")) fmt.Println(HasSubdomain("keep.google.com"))
Output: false true
func Password ¶
Password returns password from given url
If password is not present - return empty string
Example ¶
fmt.Printf("%q\n", Password("user:pass@google.com")) fmt.Printf("%q\n", Password("https://user:pass@google.com")) fmt.Printf("%q\n", Password("https://user@google.com")) fmt.Printf("%q\n", Password("https://google.com")) fmt.Printf("%q\n", Password("google.com"))
Output: "pass" "pass" "" "" ""
func Protocol ¶
Protocol returns protocol from given url
If protocol is not present - return empty string
Example ¶
fmt.Printf("%q\n", Protocol("google.com")) fmt.Printf("%q\n", Protocol("ftp://google.com")) fmt.Printf("%q\n", Protocol("http://google.com")) fmt.Printf("%q\n", Protocol("https://google.com")) fmt.Printf("%q\n", Protocol("https://user@google.com")) fmt.Printf("%q\n", Protocol("https://user:pass@google.com"))
Output: "" "ftp" "http" "https" "https" "https"
func Subdomain ¶
Subdomain returns subdomain from provided url. If subdomain is not found in provided url, this function returns empty string.
Example ¶
fmt.Printf("%q %q", Subdomain("google.com"), Subdomain("keep.google.com"))
Output: "" "keep"
func Username ¶
Username returns username from given url
If username is not present - return empty string
Example ¶
fmt.Printf("%q\n", Username("user:pass@google.com")) fmt.Printf("%q\n", Username("https://user:pass@google.com")) fmt.Printf("%q\n", Username("https://user@google.com")) fmt.Printf("%q\n", Username("https://google.com")) fmt.Printf("%q\n", Username("google.com"))
Output: "user" "user" "user" "" ""
Types ¶
This section is empty.