Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.

beyondstorage/go-endpoint

Repository files navigation

go-endpoint

Both human and machine readable endpoint format.

Notes

This package has been moved to go-storage.

go get go.beyondstorage.io/endpoint

Format

<protocol>:<value>+

For example:

  • File: file:/var/cache/data
  • HTTP: http:example.com:80
  • HTTPS: https:example.com:443

Quick Start

ep, err := endpoint.Parse("https:example.com")
if err != nil {
	log.Fatal("parse: ", err)
}

switch ep.Protocol() {
case ProtocolHTTP:
    url, host, port := ep.HTTP()
    log.Println("url: ", url)
    log.Println("host: ", host)
    log.Println("port: ", port)
case ProtocolHTTPS:
    url, host, port := ep.HTTPS()
    log.Println("url: ", url)
    log.Println("host: ", host)
    log.Println("port: ", port)
case ProtocolFile:
    path := ep.File()
    log.Println("path: ", path)
default:
    panic("unsupported protocol")
}

About

Both human and machine readable endpoint format.

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 5