尝试vscode debug ,但是遇到下面错误
DAP server listening at: 127.0.0.1:62253
Build Error: go build -o C:\GoProject\kb-api-gateway\src\__debug_bin.exe -gcflags all=-N -l .\server.go
go: gopkg.in/guregu/null.v4@v4.0.0: missing go.sum entry; to add it:
go mod download gopkg.in/guregu/null.v4 (exit status 1)
Solution:
run 下面命令, download 依赖
go mod tidy
或者
go mod download
output:
go: downloading github.com/lib/pq v1.10.4
go: downloading go.opentelemetry.io/contrib v1.1.1
go: downloading go.opentelemetry.io/otel v1.1.0
go: downloading go.opentelemetry.io/contrib/detectors/aws/ecs v1.1.1
go: downloading go.opentelemetry.io/contrib/propagators/aws v1.1.1
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.1.0
go: downloading go.opentelemetry.io/otel/sdk v1.1.0
go: downloading go.opentelemetry.io/otel/trace v1.1.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0
go: downloading gorm.io/driver/postgres v1.2.2
go: downloading go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.26.1
go: downloading github.com/uptrace/opentelemetry-go-extra/otelgorm v0.1.4
go: downloading gorm.io/gorm v1.22.2
go: downloading go.opentelemetry.io/contrib/propagators/b3 v0.24.0
go: downloading gopkg.in/go-playground/assert.v1 v1.2.1
go: downloading github.com/uptrace/opentelemetry-go-extra/otelsql v0.1.4
go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
go: downloading github.com/kr/pretty v0.3.0
go: downloading golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
go: downloading github.com/kr/text v0.2.0
go: downloading github.com/rogpeppe/go-internal v1.8.0
go: downloading go.opentelemetry.io/otel/metric v0.24.0
go: downloading cloud.google.com/go v0.64.0
go: downloading google.golang.org/appengine v1.6.6
go: downloading go.opentelemetry.io/otel/internal/metric v0.24.0
各人情况不一样
把launch.json 中 mod改为 auto
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
//改为auto
"mode": "auto",
"program": "${workspaceFolder}\\src\\server.go",
"cwd": "${workspaceFolder}",
//"envFile": "${workspaceFolder}\\****\\***\\application.env",
"env": {
"DB_HOST":"*************",
"DB_PORT":"*****",
"DB_SCHEMA":"****",
"DB_USERNAME":"****",
"DB_PASSWORD":"****",
},
"args": [
"-env","dev",
]
}
]
}
然后基本就解决了
版权声明:本文为Jason_hj11原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。