-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# go-domain-tools | ||
|
||
GOlang package for checking if url contains subdomain, what that subdomain is, what is a top level domain in url etc. | ||
|
||
# Installation | ||
|
||
`go get github.com/bobesa/go-domain-util/domainutil` | ||
|
||
# Example code | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
import "github.com/bobesa/go-domain-util/domainutil" | ||
|
||
func main(){ | ||
fmt.Println(domainutil.Domain("keep.google.com")) | ||
} | ||
``` | ||
|
||
# Functions | ||
|
||
## Get the top level domain from url | ||
```go | ||
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. | ||
|
||
## Get the domain suffix from url | ||
```go | ||
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. | ||
|
||
## Check if url has subdomain | ||
```go | ||
func HasSubdomain(domain string) bool | ||
``` | ||
HasSubdomain reports whether domain contains any subdomain. | ||
|
||
## Get subdomain from url | ||
```go | ||
func Subdomain(url string) string | ||
``` | ||
Subdomain returns subdomain from provided url. If subdomain is not found in provided url, this function returns empty string. |