GOlang package for checking if url contains subdomain, what that subdomain is, what is a top level domain in url etc.
go get github.com/bobesa/go-domain-util/domainutil# (Re)build Parser
go build -o $GOPATH/bin/domainparser github.com/bobesa/go-domain-util/cmd/domainparser
# Go to domainutil pkg & generate tlds
go generate github.com/bobesa/go-domain-util/domainutil
package main
import (
"fmt"
)
import "github.com/bobesa/go-domain-util/domainutil"
func main(){
fmt.Println(domainutil.Domain("keep.google.com"))
}func Domain(url string) stringDomain 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.
func DomainSuffix(url string) stringDomainSuffix returns domain suffix from provided url. If no TLD is found in provided url, this function returns empty string.
func HasSubdomain(domain string) boolHasSubdomain reports whether domain contains any subdomain.
func Subdomain(url string) stringSubdomain returns subdomain from provided url. If subdomain is not found in provided url, this function returns empty string.
func Protocol(url string) stringProtocol returns protocol from provided url. If protocol is not found in provided url, this function returns empty string.
func Username(url string) stringUsername returns username from provided url. If username is not found in provided url, this function returns empty string.
func Password(url string) stringPassword returns password from provided url. If password is not found in provided url, this function returns empty string.