buaazp / Godef

Plugin of sublime to use godef to go to definitions accurately.
BSD 3-Clause "New" or "Revised" License
82 stars 24 forks source link

Correctly handle case where gopath/goroot are None. #21

Closed alecthomas closed 6 years ago

alecthomas commented 6 years ago

This was causing the Godef plugin to crash on load, which for some reason completely broke Sublime for me. Sublime refused to accept any keyboard input in the edit window.

Anyway, this correctly deals with None.

buaazp commented 6 years ago

Maybe support ~ and $ is better:

def real_path(go_path):
    if go_path is None:
        return None
    if -1 != go_path.find("$"):
        return os.path.expandvars(go_path)
    elif -1 != go_path.find("~"):
        return os.path.expanduser(go_path)
    else:
        return go_path
jostyee commented 6 years ago

Can godef read settings from sublime config ?

alecthomas commented 6 years ago

Maybe support ~ and $ is better:

There shouldn't be a need to explicitly check; expandvars and expanduser will do the right thing automatically.

buaazp commented 6 years ago

@alecthomas Good. It's my mistake.

buaazp commented 6 years ago

@jostyee Yes, but in the future. Mabe you can open a new issue to discuss it.

alecthomas commented 6 years ago

Thanks!