package rabbit import ( "errors" "fmt" "net/url" ) type Address struct { Username string Password string Host string Port uint16 Vhost string } func (a *Address) makeAddr() (string, error) { if a.Host == "" { return "", errors.New("no host provided") } if a.Vhost == "" { return "", errors.New("no vhost provided") } //"amqp://username:password@host:port/vhost" return fmt.Sprintf("amqp://%v:%v@%v:%v/%v", url.QueryEscape(a.Username), url.QueryEscape(a.Password), a.Host, a.Port, url.PathEscape(a.Vhost), ), nil }