Tips and techniques for debugging the Nylas CLI.
# Run command with verbose flag (if supported)
nylas --debug email list
# Check logs
tail -f ~/.config/nylas/nylas.log# Test authentication
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.nylas.com/v3/grants/YOUR_GRANT_ID
# Test specific endpoint
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.nylas.com/v3/grants/YOUR_GRANT_ID/messages?limit=1# Check installation
which nylas
# Verify PATH
echo $PATH
# Reinstall if needed
go install github.com/mqasimca/nylas/cmd/nylas@latest# Check config
cat ~/.config/nylas/config.yaml
# Verify API key
nylas auth status
# Reconfigure
nylas auth config# Check file exists
ls -la /path/to/file
# Use absolute path
nylas email send --attach "/absolute/path/to/file.pdf"# Install Delve
go install github.com/go-delve/delve/cmd/dlv@latest
# Debug CLI
dlv debug github.com/mqasimca/nylas/cmd/nylas -- email list
# Set breakpoint
(dlv) break main.main
(dlv) continue
(dlv) print variableNameimport "fmt"
func myFunction() {
// Add debug prints
fmt.Printf("DEBUG: value = %+v\n", value)
fmt.Printf("DEBUG: entering function with args: %v\n", args)
}import "log"
log.Printf("Processing email: %s", emailID)
log.Printf("API response: %+v", response)# Run specific test
go test ./internal/cli/email/ -run TestSendEmail -v
# With race detector
go test -race ./internal/cli/email/ -run TestSendEmail# Debug specific test
dlv test ./internal/cli/email/ -- -test.run TestSendEmailfunc TestMyFunction(t *testing.T) {
// Use t.Log instead of fmt.Print
t.Logf("DEBUG: testing with value: %v", value)
// Force test failure to see logs
t.Errorf("Debug output: %+v", result)
}# Use mitmproxy
pip install mitmproxy
mitmproxy -p 8080
# Configure proxy
export HTTP_PROXY=http://localhost:8080
export HTTPS_PROXY=http://localhost:8080
# Run CLI
nylas email list# Verify DNS resolution
nslookup api.nylas.com
dig api.nylas.com
# Test connectivity
ping api.nylas.com
curl -I https://api.nylas.com# Remove artifacts
make clean
# Clear Go cache
go clean -cache -testcache -modcache
# Rebuild
make build# Update dependencies
go mod tidy
# Verify go.mod
go mod verify
# Download dependencies
go mod download.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug CLI",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/cmd/nylas",
"args": ["email", "list"],
"env": {
"NYLAS_API_KEY": "your-api-key",
"NYLAS_GRANT_ID": "your-grant-id"
}
}
]
}- Run → Edit Configurations
- Add New Configuration → Go Build
- Set Program arguments:
email list - Set Environment variables:
NYLAS_API_KEY=... - Run → Debug
# Run with CPU profiling
go test -cpuprofile=cpu.prof -bench=.
# Analyze profile
go tool pprof cpu.prof# Run with memory profiling
go test -memprofile=mem.prof -bench=.
# Analyze profile
go tool pprof mem.proffunc BenchmarkFunction(b *testing.B) {
for i := 0; i < b.N; i++ {
Function()
}
}# Check Go environment
go env
# List dependencies
go list -m all
# Show module info
go list -m -json github.com/mqasimca/nylas
# Find where CLI is installed
which nylas
# Check version
nylas version
go version- Delve Docs: https://github.com/go-delve/delve
- Go Debugging: https://go.dev/doc/diagnostics
- pprof: https://pkg.go.dev/runtime/pprof