Created
December 18, 2018 02:22
-
-
Save parzibyte/731fcabb6a02b0a82700371317b997a3 to your computer and use it in GitHub Desktop.
Leer contenido de archivo en string usando Go created by parzibyte - https://repl.it/@parzibyte/Leer-contenido-de-archivo-en-string-usando-Go
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
Hola, soy un archivo de texto para demostrar algunos tutoriales de parzibyte.me. Puedo contener cualquier tipo de contenido, por ejemplo, saltos, | |
tabulaciones | |
y cualquier | |
otra | |
cosa. |
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
/* | |
Leer un archivo de texto en Go, colocando | |
todo el contenido en una string (no recomendado | |
si es un archivo grande) | |
@author parzibyte | |
*/ | |
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
) | |
func main() { | |
nombreArchivo := "archivo.txt" | |
bytesLeidos, err := ioutil.ReadFile(nombreArchivo) | |
if err != nil { | |
fmt.Printf("Error leyendo archivo: %v", err) | |
} | |
contenido := string(bytesLeidos) | |
fmt.Printf("El contenido del archivo es: %s", contenido) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment