package main import ( "fmt" "io" "net/http" ) func helloHandler(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Content-Type", "application/json") w.Write([]byte("Hello, World!")) } func requestServer() { resp, err := http.Get("http://localhost:8080") fmt.Println(err) defer resp.Body.Close() body, err := io.ReadAll(resp.Body) fmt.Printf("\nWebserver said: `%s`", string(body)) } func main() { http.HandleFunc("/", helloHandler) http.ListenAndServe(":8080", nil) }