domainutil

package
v0.0.0-...-52a3e12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Domain

func Domain(url string) string

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 DomainSuffix

func DomainSuffix(url string) string

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

func HasSubdomain(domain string) bool

HasSubdomain reports whether domain contains any subdomain.

Example
fmt.Println(HasSubdomain("google.com"))
fmt.Println(HasSubdomain("keep.google.com"))
Output:

false
true

func Subdomain

func Subdomain(url string) string

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"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL