go启动项目失败
2024年11月12日大约 1 分钟
go启动报错问题
在运行 go run main.go 命令时报错:
go run main.go
main.go:8:2: missing go.sum entry for module providing package github.com/gin-gonic/gin; to add:
go mod download github.com/gin-gonic/gin
conf\conf.go:9:2: missing go.sum entry for module providing package github.com/joho/godotenv (imported by singo/conf); to add:
go get singo/conf
conf\i18n.go:7:2: missing go.sum entry for module providing package gopkg.in/yaml.v2 (imported by singo/conf); to add:
go get singo/conf
cache\cache.go:9:2: missing go.sum entry for module providing package github.com/redis/go-redis/v9 (imported by singo/cache); to add:
go get singo/cache
model\user.go:4:2: missing go.sum entry for module providing package golang.org/x/crypto/bcrypt (imported by singo/model); to add:
go get singo/model
model\init.go:9:2: missing go.sum entry for module providing package gorm.io/driver/mysql (imported by singo/model); to add:
go get singo/model
model\case.go:7:2: missing go.sum entry for module providing package gorm.io/gorm (imported by singo/model); to add:
go get singo/model
model\init.go:11:2: missing go.sum entry for module providing package gorm.io/gorm/logger (imported by singo/model); to add:
go get singo/model
api\user.go:7:2: missing go.sum entry for module providing package github.com/gin-contrib/sessions (imported by singo/api); to add:
go get singo/api
api\main.go:12:2: missing go.sum entry for module providing package github.com/go-playground/validator/v10 (imported by singo/api); to add:
go get singo/api
middleware\cors.go:6:2: missing go.sum entry for module providing package github.com/gin-contrib/cors (imported by singo/middleware); to add:
go get singo/middleware
middleware\session.go:5:2: missing go.sum entry for module providing package github.com/gin-contrib/sessions/cookie (imported by singo/middleware); to add:
go get singo/middleware原因: 没有安装go相关的依赖
先在项目目录下使用 go mod tidy 命令安装依赖