Archivos en Golang

package main import ( "fmt" "os" "log" ) type Directorio struct{ nombre string longitud int existe bool } func main() { archivos() } func archivos(){ var directorio string = "C:\\Directorio" fileStat, err := os.Stat(directorio) if err != nil { log.Fatal(err) } fmt.Println("Nombre:", fileStat.Name()) fmt.Println("Tamaño:", fileStat.Size()) fmt.Println("Permisos:", fileStat.Mode()) fmt.Println("Ultima modificacion:", fileStat.ModTime()) fmt.Println("Es directorio?: ", fileStat.IsDir()) var existe bool = fileStat!=nil myDirectorio := Directorio{fileStat.Name(), int(fileStat.Size()),existe} fmt.Println("Nombre archivo: ",myDirectorio.nombre) fmt.Println("Longitud: ",myDirectorio.longitud) fmt.Println("Existe?: ",myDirectorio.existe) }
Archivos en Golang

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.