main.go
package main
import (
"fmt"
"log"
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Selamat Datang di belajaitjamannow.blogspot.com")
}
func about(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Ini halaman About")
}
func main() {
http.HandleFunc("/", index)
http.HandleFunc("/about", about)
log.Println("application started at port :8000")
log.Fatal(http.ListenAndServe(":8000", nil))
}
Menjalankan program:
# go run main.go
Buka Browser : http://localhost:8000
No comments:
Post a Comment