This directory contains VS Code workspace settings optimized for developing pgcov.
- settings.json - Workspace settings with CGO configuration
- launch.json - Debug configurations for running and testing
- tasks.json - Build and test tasks with CGO support
- README.md - This file
pgcov requires CGO because it uses pg_query_go, which wraps PostgreSQL's C parser library.
Configures gopls (Go language server) and other Go tools to use CGO:
CGO_ENABLED=1- Enables CGO compilationCC=C:\msys64\mingw64\bin\gcc.exe(Windows) - Sets C compiler path
This ensures:
- ✅ gopls can analyze CGO code correctly
- ✅
Go: Build Packagecommand works - ✅
Go: Test Packagecommand works - ✅ IntelliSense and code navigation work properly
Configures the VS Code integrated terminal with CGO variables:
Windows (terminal.integrated.env.windows):
{
"CGO_ENABLED": "1",
"CC": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"PATH": "${env:PATH};C:\\msys64\\mingw64\\bin"
}Linux/macOS (terminal.integrated.env.linux/osx):
{
"CGO_ENABLED": "1"
}This ensures:
- ✅
go buildworks in the integrated terminal - ✅
go testworks in the integrated terminal - ✅ No need to manually set environment variables
Additional gopls configuration for CGO:
{
"gopls": {
"build.env": {
"CGO_ENABLED": "1"
}
}
}-
Launch pgcov - Run pgcov with test data
- Runs
pgcov run ./testdata/simple --verbose - Good for quick testing during development
- Runs
-
Launch pgcov with custom args - Run with custom arguments
- Specify arguments in the debug console
- Useful for testing different scenarios
-
Test Current Package - Test the package of the open file
- Press
F5while in any Go file - Runs all tests in that package
- Press
-
Test Current File - Test specific function
- Select test function name
- Runs only that test
-
Integration Test - Run full integration test suite
- Runs
TestEndToEndWithTestcontainers - Includes 5-minute timeout
- Runs
- Open Run and Debug sidebar (
Ctrl+Shift+D) - Select a configuration from the dropdown
- Press
F5or click "Start Debugging" - Set breakpoints by clicking line numbers
Run tasks via Ctrl+Shift+P → "Tasks: Run Task" or Ctrl+Shift+B for default build.
- Build pgcov (default) - Standard debug build
- Build pgcov (Release) - Optimized build with
-ldflags=-s -w
- Test All (default) - Run all tests with
-v - Test with Coverage - Generate coverage report
- Integration Test - Run end-to-end tests
- Run pgcov - Build and run pgcov on test data
- Clean Build Cache - Clear Go build and test cache
- Go Mod Tidy - Clean up go.mod and go.sum
- Format Code - Run
go fmt ./... - Go Vet - Run
go vet ./...
Via Command Palette:
- Press
Ctrl+Shift+P - Type "Tasks: Run Task"
- Select task from list
Via Keyboard Shortcut:
Ctrl+Shift+B- Run default build task
Via Terminal Menu:
- Terminal → Run Task
- Select task
Prerequisites:
-
Install MSYS2
-
Install MinGW-w64 GCC:
pacman -S mingw-w64-x86_64-gcc
-
Verify
C:\msys64\mingw64\bin\gcc.exeexists
If GCC is installed elsewhere, update the CC path in settings.json:
"go.toolsEnvVars": {
"CC": "C:\\path\\to\\your\\gcc.exe"
},
"terminal.integrated.env.windows": {
"CC": "C:\\path\\to\\your\\gcc.exe",
"PATH": "${env:PATH};C:\\path\\to\\your\\mingw64\\bin"
}Prerequisites:
# Ubuntu/Debian
sudo apt-get install build-essential
# Fedora/RHEL
sudo dnf install gcc
# Arch Linux
sudo pacman -S base-develCGO will automatically find GCC via PATH.
Prerequisites:
# Install Xcode Command Line Tools
xcode-select --installCGO will automatically find the compiler via Xcode.
-
Open integrated terminal (
Ctrl+`` orCmd+``) -
Run:
go build ./cmd/pgcov
CGO environment is automatically applied ✓
-
Open integrated terminal
-
Run:
go test ./...Or use VS Code's test UI (Testing sidebar)
- Set breakpoints in your code
- Press
F5or use "Run and Debug" sidebar - CGO debugging works with proper C toolchain
- Code completion works for CGO code
- Go to definition works across Go/C boundaries
- Hover documentation includes C type information
- Error highlighting respects CGO build constraints
Solution: Install GCC (see Platform-Specific Setup above)
Solution: Reload VS Code window (Ctrl+Shift+P → "Reload Window")
Solution:
- Close and reopen the integrated terminal
- Or restart VS Code
Solution: Edit .vscode/settings.json and update:
go.toolsEnvVars.CCterminal.integrated.env.windows.CCterminal.integrated.env.windows.PATH
Solution: Run in terminal:
go mod download
go mod tidyInstall these VS Code extensions for the best experience:
- Go (
golang.go) - Essential for Go development - C/C++ (
ms-vscode.cpptools) - Helps with CGO C code - Test Explorer UI - Better test visualization