Documentation
¶
Overview ¶
Package tldextract provides the ability to extract gTLD or ccTLD(generic or country code top-level domain), the registered domain and subdomain from a url according to the Public Suffix List.
A simple usage:
package main
import (
"fmt"
"github.com/joeguo/tldextract"
)
func main() {
urls := []string{"git+ssh://www.github.com:8443/", "http://media.forums.theregister.co.uk", "http://218.15.32.76", "http://google.com?q=cats"}
cache := "/tmp/tld.cache"
extract := tldextract.New(cache,false)
for _, u := range (urls) {
result:=extract.Extract(u)
fmt.Printf("%+v;%s\n",result,u)
}
}
Index ¶
Constants ¶
View Source
const ( Malformed = iota Domain Ip4 Ip6 )
used for Result.Flag
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TLDExtract ¶
type TLDExtract struct {
CacheFile string
// contains filtered or unexported fields
}
func New ¶
func New(cacheFile string, debug bool) (*TLDExtract, error)
New creates a new *TLDExtract, it may be shared between goroutines, we usually need a single instance in an application.
func (*TLDExtract) Extract ¶
func (extract *TLDExtract) Extract(u string) *Result
func (*TLDExtract) SetNoStrip ¶
func (extract *TLDExtract) SetNoStrip()
SetNoStrip disables URL stripping in order to increase performance.
func (*TLDExtract) SetNoValidate ¶
func (extract *TLDExtract) SetNoValidate()
SetNoValidate disables schema check in order to increase performance.
Click to show internal directories.
Click to hide internal directories.