Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 18files/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"os"
)

Expand All @@ -26,7 +25,7 @@ func main() {
}

func readFile(filname string) {
databyte, err := ioutil.ReadFile(filname)
databyte, err := os.ReadFile(filname)
checkNilErr(err)

fmt.Println("Text data inside the file is \n", string(databyte))
Expand Down
4 changes: 2 additions & 2 deletions 19webrequests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -21,7 +21,7 @@ func main() {

defer response.Body.Close() // caller's responsibility to close the connection

databytes, err := ioutil.ReadAll(response.Body)
databytes, err := io.ReadAll(response.Body)

if err != nil {
panic(err)
Expand Down
8 changes: 4 additions & 4 deletions 21webreqverbs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand All @@ -29,7 +29,7 @@ func PerformGetRequest() {
fmt.Println("Content length is: ", response.ContentLength)

var responseString strings.Builder
content, _ := ioutil.ReadAll(response.Body)
content, _ := io.ReadAll(response.Body)
byteCount, _ := responseString.Write(content)

fmt.Println("ByteCount is: ", byteCount)
Expand Down Expand Up @@ -59,7 +59,7 @@ func PerformPostJsonRequest() {
}
defer response.Body.Close()

content, _ := ioutil.ReadAll(response.Body)
content, _ := io.ReadAll(response.Body)

fmt.Println(string(content))
}
Expand All @@ -81,7 +81,7 @@ func PerformPostFormRequest() {

defer response.Body.Close()

content, _ := ioutil.ReadAll(response.Body)
content, _ := io.ReadAll(response.Body)
fmt.Println(string(content))

}