1.
2.
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func sayhello(w http.ResponseWriter,r *http.Request){
b,_ := ioutil.ReadFile("./hello.txt")
_,_ = fmt.Fprintf(w,string(b))
}
func main(){
http.HandleFunc("/hello",sayhello)
err := http.ListenAndServe(":9090",nil)
if err !=nil{
fmt.Printf("http.listen%v\n",err)
return
}
}
go mod tidy 自动加载项目依赖