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