golang 一个简单web 自动加载项目依赖

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   自动加载项目依赖

发布了173 篇原创文章 · 获赞 29 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/qq_29058883/article/details/105597899