【转】GO Check if file exists

finfo, err := os.Stat("filename.txt")
if err != nil {
    // no such file or dir
    return
}
if finfo.IsDir() {
    // it's a file
} else {
    // it's a directory
}

你可能感兴趣的:(File,Go,golang,check)