Last active
May 30, 2019 19:20
-
-
Save maniankara/005ae1459d1d982e3916eafdca518685 to your computer and use it in GitHub Desktop.
Simple Golang snippet which checks for file availability on filesystem - Used in blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
err := filepath.Walk("/home/go", func(path string, info os.FileInfo, err error) error { | |
if err != nil { | |
fmt.Printf("Error", err) | |
return err | |
} | |
if info.Name() == "abc" { | |
fmt.Println("found: " + path) | |
} | |
return nil | |
}) | |
if err != nil { | |
fmt.Printf("", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment