def _join_host_port(host, port):
    """Adapted golang's net.JoinHostPort"""
    template = '{}:{}'
    host_requires_bracketing = ':' in host or '%' in host
    if host_requires_bracketing:
        template = '[{}]:{}'
    return template.format(host, port)
