Quick reference for building pgcov on different platforms.
- Go: 1.21+
- C Compiler: GCC (Linux/macOS) or MinGW-w64 (Windows)
- CGO: Must be enabled
# Install compiler
sudo apt-get install build-essential # Ubuntu/Debian
sudo dnf install gcc # Fedora/RHEL
# Build
export CGO_ENABLED=1
go build -o pgcov ./cmd/pgcov
# Test
go test ./...# Install compiler
xcode-select --install
# Build
export CGO_ENABLED=1
go build -o pgcov ./cmd/pgcov
# Test
go test ./...# Install MSYS2 from https://www.msys2.org/
# Then in MSYS2 terminal: pacman -S mingw-w64-x86_64-gcc
# Build
$env:CGO_ENABLED = "1"
$env:CC = "C:\msys64\mingw64\bin\gcc.exe"
$env:PATH = "$env:PATH;C:\msys64\mingw64\bin"
go build -o pgcov.exe .\cmd\pgcov
# Test
go test .\...REM Build
set CGO_ENABLED=1
set CC=C:\msys64\mingw64\bin\gcc.exe
set PATH=%PATH%;C:\msys64\mingw64\bin
go build -o pgcov.exe .\cmd\pgcov
REM Test
go test .\...#!/bin/bash
set -e
export CGO_ENABLED=1
go build -ldflags="-s -w" -o pgcov ./cmd/pgcov
echo "Build complete"$ErrorActionPreference = "Stop"
$env:CGO_ENABLED = "1"
$env:CC = "C:\msys64\mingw64\bin\gcc.exe"
$env:PATH = "$env:PATH;C:\msys64\mingw64\bin"
go build -ldflags="-s -w" -o pgcov.exe .\cmd\pgcov
Write-Host "Build complete"Linux: sudo apt-get install build-essential
macOS: xcode-select --install
Windows: Install MSYS2 and add to PATH
Add to PATH: C:\msys64\mingw64\bin
go mod download
go mod tidypgcov uses pg_query_go which wraps PostgreSQL's C parser (libpg_query). This provides native PostgreSQL SQL parsing but requires CGO.
go clean -cache
go clean -testcache
go build ./cmd/pgcov- README.md - Full documentation
- CONTRIBUTING.md - Development guide