Skip to content

boatware/domainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

domainer

Go Reference

Simple Go library to split URLs into their domain parts.

Installation

go get github.com/boatware/domainer

Usage

package main

import (
    "fmt"

    "github.com/boatware/domainer"
)

func main() {
    url := "http://www.example.com:8080/path/to/file.html?query=string#fragment"

    d, _ := domainer.FromString(url)

    fmt.Println(d.Protocol) // http
    fmt.Println(d.Subdomain) // www
    fmt.Println(d.Domain) // example
    fmt.Println(d.TLD) // com
    fmt.Println(d.Port) // 8080
    fmt.Println(d.Path) // path/to/file.html
    fmt.Println(d.Query) // []Query{ Query{ Key: "query", Value: "string" } }
    fmt.Println(d.Fragment) // fragment
}

About

Go library to split a URL into its parts

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages