Added http-get exercise

This commit is contained in:
raul 2024-03-10 09:29:55 +01:00
parent 08040ef9c9
commit 7693f81e0b
2 changed files with 30 additions and 0 deletions

3
http-get/go.mod Normal file
View File

@ -0,0 +1,3 @@
module http-get
go 1.22.1

27
http-get/main.go Normal file
View File

@ -0,0 +1,27 @@
package main
import (
"fmt"
//"net"
"net/http"
"os"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: ./http-get http://bulgariu.xyz")
os.Exit(0)
}
request, err := http.Get(os.Args[1])
fmt.Println(os.Args[1])
if err != nil {
fmt.Println(err)
os.Exit(2)
}
fmt.Println(request)
}
// func handleConn(conn net.Conn) {
//
// }