Golang - Enter/Input a URL Using Get Function in HTTP Code Example

The code for Enter/Input a URL Using Get Function in HTTP

package main
 
import (
    "fmt"
    "net/http"
)
func main() {
    var url string
    fmt.Print("Enter the website's URL: ")
    fmt.Scan(&url)
    resp,err := http.Get(url)
    fmt.Print(resp)
    fmt.Print(err)
}

/*
Output:
Enter the website's URL: https://www.includehelp.com
<nil>Get https://www.includehelp.com: dial tcp: 
lookup www.includehelp.com on 169.254.169.254:53: 
dial udp 169.254.169.254:53: connect: network is unreachable
*/
Code by IncludeHelp, on February 28, 2023 15:43

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.