环境go1.17.8
mac m1
按pdf学习需要github.com/julienschmidt/httprouter这个包,
```go
package main
import (
"fmt"
"net/http"
"github.com/julienschmidt/httprouter"
)
func hello(w http.ResponseWriter,r *http.Request,p httprouter.Params){
fmt.Fprintf(w,"Hello world")
}
func main() {
mux := httprouter.New()
mux.GET("/hello/:name",hello)
server := http.Server{
Addr: "localhost:8080",
Handler: mux,
}
err := server.ListenAndServe()
if err!=nil{
fmt.Println(err.Error())
}
}
```
但是go mod tidy报错,
我的gopath设置是Users/xx/gopath这样的目录

go mod download好像没有任何错误

go run main.go的时候也能跑起来,不知道我goland包总是标红是什么情况


有疑问加站长微信联系(非本文作者)
