Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // ProtocolHTTP is the http endpoint protocol. ProtocolHTTP = "http" // ProtocolHTTPS is the https endpoint protocol. ProtocolHTTPS = "https" // ProtocolFile is the file endpoint protocol ProtocolFile = "file" // ProtocolTCP is the tcp endpoint protocol ProtocolTCP = "tcp" )
Variables ¶
View Source
var ( // ErrUnsupportedProtocol will return if protocol is unsupported. ErrUnsupportedProtocol = errors.New("unsupported protocol") // ErrInvalidValue means value is invalid. ErrInvalidValue = errors.New("invalid value") )
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func Parse ¶
Parse will parse config string to create a endpoint Endpoint.
Example ¶
ep, err := Parse("http:example.com") if err != nil { log.Fatal(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) case ProtocolTCP: addr, host, port := ep.TCP() log.Println("addr:", addr) log.Println("host:", host) log.Println("port", port) default: panic("unsupported protocol") }
Output:
Click to show internal directories.
Click to hide internal directories.