Categorygithub.com/beyondstorage/go-endpoint
modulepackage
1.1.0
Repository: https://github.com/beyondstorage/go-endpoint.git
Documentation: pkg.go.dev

# README

go-endpoint

Build Status Go dev License go storage dev

Both human and machine readable endpoint format.

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")
}

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Parse will parse config string to create a endpoint Endpoint.

# Constants

ProtocolFile is the file endpoint protocol.
ProtocolHTTP is the http endpoint protocol.
ProtocolHTTPS is the https endpoint protocol.
ProtocolTCP is the tcp endpoint protocol.

# Variables

ErrInvalidValue means value is invalid.
ErrUnsupportedProtocol will return if protocol is unsupported.

# Structs

No description provided by the author
Error represents error related to endpoint.