Go语言搭建简单服务器

package main

import (
	"fmt"
	"net/http"
)

// 创建处理函数
func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "hello golang", r.URL.Path)
}
func main() {
	http.HandleFunc("/", handler)
	// 创建路由
	http.ListenAndServe(":8080", nil)
}

猜你喜欢

转载自blog.csdn.net/qq2942713658/article/details/113705378