Technology Sharing

vscode compilation environment configuration-golang

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

1. Support jump

If run test | debug test is not displayed above the single test function, you need to install Code Debugger (because the previous go Test Explorer is no longer maintained)
insert image description here

2. Unit Testing

  • Specifying a single test case
go test -v run TestXXX
  • 1
  • dlv debugging
    You need to install matching go and delve versions (such as go1.18 and delve1.20)
go install github.com/go-delve/delve/cmd/[email protected]
  • 1
dlv test
  • 1
  • Generate and query coverage
go test -v -cover ./{dir}/... -coverprofile={cov-out-file-path}
  • 1

go tool cover --html={cov-out-file-path} -o={html-path}