Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 8, 2020 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/52cca40e9222e39fc55a0a46f206ada1 to your computer and use it in GitHub Desktop.
Save parzibyte/52cca40e9222e39fc55a0a46f206ada1 to your computer and use it in GitHub Desktop.
package main
// https://parzibyte.me/blog
import (
"fmt"
"os"
)
func main() {
archivo := "ejemplo.txt"
if archivoExiste(archivo) {
fmt.Println("Existe")
} else {
fmt.Println("NO existe")
}
}
func archivoExiste(ruta string) bool {
if _, err := os.Stat(ruta); os.IsNotExist(err) {
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment