Answers for "http golang"

Go
0

http go

package main

import (
	"fmt"
	"net/http"
	"time"
)

func greet(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello World! %s", time.Now())
}

func main() {
	http.HandleFunc("/", greet)
	http.ListenAndServe(":8080", nil)
}
Posted by: Guest on January-23-2021
0

golang http writer redirect

func redirect(w http.ResponseWriter, r *http.Request) {
    http.Redirect(w, r, "http://www.google.com", 301)
}
Posted by: Guest on January-04-2021

Browse Popular Code Answers by Language