Giter VIP home page Giter VIP logo

go-domain-util's Introduction

go-domain-tools

Build Status

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

Rebuild the TLD database from publicsuffix.org

# (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

Example code

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

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

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

func HasSubdomain(domain string) bool

HasSubdomain reports whether domain contains any subdomain.

Get subdomain from url

func Subdomain(url string) string

Subdomain returns subdomain from provided url. If subdomain is not found in provided url, this function returns empty string.

Get protocol from url

func Protocol(url string) string

Protocol returns protocol from provided url. If protocol is not found in provided url, this function returns empty string.

Get username from credentials of url

func Username(url string) string

Username returns username from provided url. If username is not found in provided url, this function returns empty string.

Get password from credentials of url

func Password(url string) string

Password returns password from provided url. If password is not found in provided url, this function returns empty string.

go-domain-util's People

Contributors

bobesa avatar gotoxu avatar baltazorbest avatar trustrevoked avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.