Skip to content

Instantly share code, notes, and snippets.

@mattes
Last active October 13, 2025 14:50
Show Gist options
  • Save mattes/d13e273314c3b3ade33f to your computer and use it in GitHub Desktop.
Save mattes/d13e273314c3b3ade33f to your computer and use it in GitHub Desktop.

Revisions

  1. mattes revised this gist Sep 23, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion check.go
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@ if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
    // path/to/whatever does not exist
    }

    if _, err := os.Stat("/path/to/whatever"); err == nil {
    if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
    // path/to/whatever exists
    }
  2. mattes revised this gist Aug 6, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion check.go
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
    // ...
    // path/to/whatever does not exist
    }

    if _, err := os.Stat("/path/to/whatever"); err == nil {
    // path/to/whatever exists
    }
  3. mattes revised this gist Aug 6, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions check.go
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
    // ...
    }
    if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
    // ...
    }
  4. mattes created this gist Aug 6, 2014.
    3 changes: 3 additions & 0 deletions check.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
    // ...
    }