We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent adcf760 commit 6636e14Copy full SHA for 6636e14
scripts/save-image/main.go
@@ -0,0 +1,31 @@
1
+package main
2
+
3
+import (
4
+ "io"
5
+ "log"
6
+ "net/http"
7
+ "os"
8
+)
9
10
+func main() {
11
+ resp, err := http.Get("https://picsum.photos/200/300/")
12
13
+ if err != nil {
14
+ log.Fatal("Error:", err)
15
+ }
16
17
+ defer resp.Body.Close()
18
19
+ file, err := os.Create("img/image1.jpg")
20
21
+ log.Fatal(err)
22
23
24
+ _, err = io.Copy(file, resp.Body)
25
26
27
28
29
30
+ file.Close()
31
+}
0 commit comments