How to handle HTTP Get response?

Fprintln allows you to direct output to any writer. Feel free to choose the available port of your choice - higher ports will make it easier to bypass the built-in security functionality in any system. net/http directs requests using a URI or URL endpoint to helper functions, which must implement the http.ResponseWriter and http.Request methods.
<!DOCTYPE html>
  <meta charset="UTF-8" />
  <form method="POST" action="/">     
      <label>Name</label><input name="name" type="text" value="">
      <label>Name</label><input name="" type="text" value="">
      <input type="submit" value="submit" />


package main

import (
func ServeHTTP(w http.ResponseWriter, r *http.Request) {
	url := ""
    response, err := http.Get(url)
    if err != nil {
    defer response.Body.Close()

    responseData, err := ioutil.ReadAll(response.Body)
    if err != nil {

    responseString := string(responseData)
    fmt.Fprint(w, responseString)
func main() {
    http.HandleFunc("/", ServeHTTP)
    if err := http.ListenAndServe(":8080", nil); err != nil {
Now run url :http://localhost:8080/ in your browser and see the below content

Most Helpful This Week