-
-
Save parzibyte/8ee512e631f4e0d456e43fef2318ea8f to your computer and use it in GitHub Desktop.
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
func descargarArchivoDeInternet(url string) (string, error) { | |
/* | |
En este caso voy a descargar una imagen PNG | |
*/ | |
nombreArchivoSalida := "imagen.png" | |
respuesta, err := http.Get(url) | |
if err != nil { | |
return "", err | |
} | |
defer respuesta.Body.Close() | |
archivoSalida, err := os.Create(nombreArchivoSalida) | |
if err != nil { | |
return "", err | |
} | |
defer archivoSalida.Close() | |
_, err = io.Copy(archivoSalida, respuesta.Body) | |
return nombreArchivoSalida, err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment