August 2019
Beginner to intermediate
798 pages
17h 2m
English
This subsection will present yet another way to timeout an HTTP connection from the client side. As you will see, this is the simplest form of timeout, because you just need to use an http.Client object and set its Timeout field to the desired timeout value.
The name of the utility that showcases this last type of timeout is anotherTimeOut.go, and it is going to be presented in four parts.
The first part of anotherTimeOut.go is as follows:
package main
import (
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
var timeout = time.Duration(time.Second)
The second part of anotherTimeOut.go contains the following Go code:
func main() { if len(os.Args) == 1 { fmt.Println("Please provide a URL") return } if len(os.Args) ...Read now
Unlock full access