我正在学习 Go 广告,我正在尝试构建 go 文件:
package main
import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"net/http"
)
func main() {
r := chi.NewRouter()
r.Use(middleware.Logger)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("welcome"))
})
http.ListenAndServe(":3000", r)
}
但是当我使用 command 构建程序时go build main.go
,它会输出:
go: github.com/go-chi/chi/@v1.5.4: missing go.sum entry; to add it:
go mod download github.com/go-chi/chi/
go.mod
:
module exprog
go 1.16
require github.com/go-chi/chi/ v1.5.4
当我执行时go mod download github.com/go-chi/chi/
,我收到此错误:
go: github.com/go-chi/chi/@v1.5.4: malformed module path "github.com/go-chi/chi/": trailing slash
我该做什么?