import re


def go_match_beginning(buf, string):
    """Check if a string matches the beginning of buffer name/short name."""
    if not string:
        return False
    esc_str = re.escape(string)
    if re.search(r'^#?' + esc_str, buf['name']) \
            or re.search(r'^#?' + esc_str, buf['short_name']):
        return True
    return False