Skip to content

Instantly share code, notes, and snippets.

@daehee
Created December 30, 2020 20:02
Show Gist options
  • Select an option

  • Save daehee/45fbeb9df39552b6f561b48dd8cd0eab to your computer and use it in GitHub Desktop.

Select an option

Save daehee/45fbeb9df39552b6f561b48dd8cd0eab to your computer and use it in GitHub Desktop.

Revisions

  1. daehee created this gist Dec 30, 2020.
    8 changes: 8 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    if path == "~" {
    // In case of "~", which won't be caught by the "else if"
    path = dir
    } else if strings.HasPrefix(path, "~/") {
    // Use strings.HasPrefix so we don't match paths like
    // "/something/~/something/"
    path = filepath.Join(dir, path[2:])
    }