| sidebar_position |
|---|
1 |
This guide will help you set up a development environment for NetTraceX.
- Go 1.21 or later: Download from golang.org
- Git: For version control
- Make (Unix/Linux/macOS) or PowerShell (Windows): For build automation
- Terminal Emulator: For testing the TUI
- VS Code with Go extension
- GoLand/IntelliJ IDEA with Go plugin
- Delve: Go debugger
- golangci-lint: Go linter
- Air: Live reload for development
# Clone the main repository
git clone https://github.com/nettracex/nettracex-tui.git
cd nettracex
# Or clone your fork
git clone https://github.com/your-username/nettracex-tui.git
cd nettracex# Download Go modules
go mod download
go mod tidy
# Install development tools
go install github.com/go-delve/delve/cmd/dlv@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/cosmtrek/air@latest# Check Go version
go version
# Check if tools are installed
dlv version
golangci-lint version
air -v-
Install the Go extension
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "Go" and install the official Go extension
-
Configure Go tools
- Press Ctrl+Shift+P
- Type "Go: Install/Update Tools"
- Select all tools and install
-
Configure settings (
.vscode/settings.json):{ "go.toolsManagement.checkForUpdates": "local", "go.useLanguageServer": true, "go.formatTool": "goimports", "go.lintTool": "golangci-lint", "go.testFlags": ["-v"], "go.coverOnSave": true, "go.buildOnSave": "package", "go.vetOnSave": "package", "go.lintOnSave": "package" }
-
Install the Go plugin
- Go to Settings → Plugins
- Search for "Go" and install
-
Configure Go SDK
- Go to Settings → Languages & Frameworks → Go
- Set the Go SDK path
- Enable Go modules support
-
Configure code style
- Go to Settings → Editor → Code Style → Go
- Import the project's code style settings
nettracex/
├── cmd/
│ └── nettracex/
│ └── main.go # Application entry point
├── internal/
│ ├── domain/ # Core business logic
│ │ ├── interfaces.go
│ │ ├── types.go
│ │ ├── parameters.go
│ │ ├── result.go
│ │ └── *_test.go
│ ├── application/ # Use cases
│ │ ├── services/
│ │ └── handlers/
│ ├── infrastructure/ # External dependencies
│ │ ├── network/
│ │ └── storage/
│ └── presentation/ # UI components
│ ├── tui/
│ └── cli/
├── pkg/ # Public packages
├── testdata/ # Test data files
├── scripts/ # Build and deployment scripts
├── docs/ # Documentation
├── examples/ # Example configurations
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── Makefile # Build automation
├── .gitignore # Git ignore rules
├── .golangci.yml # Linter configuration
├── .air.toml # Air configuration
└── README.md # Project documentation
# Using Air for live reload
air
# Or manually
go run ./cmd/nettracex# Run all tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Run specific tests
go test ./internal/domain -v
go test ./internal/tools/ping -v# Format code
go fmt ./...
# Check for issues
go vet ./...
# Lint code
golangci-lint run
# Check for security issues
go list -json -deps ./... | nancy sleuth# Unix/Linux/macOS
make build
# Windows
go build -o bin/nettracex.exe ./cmd/nettracex
# Cross-platform builds
make build-allCreate a development configuration file:
# config/dev.yaml
network:
timeout: 10s
dns_servers:
- "8.8.8.8"
- "1.1.1.1"
ui:
theme: "dark"
animations:
enabled: true
logging:
level: "debug"
format: "text"
output: "stdout"
plugins:
enabled:
- "ping"
- "traceroute"
- "dns"
- "whois"
- "ssl"# Development environment
export NETTRACEX_ENV=development
export NETTRACEX_LOGGING_LEVEL=debug
export NETTRACEX_LOGGING_FORMAT=text
export NETTRACEX_UI_ANIMATIONS_ENABLED=true# Debug the main application
dlv debug ./cmd/nettracex
# Debug with arguments
dlv debug ./cmd/nettracex -- --config config/dev.yaml
# Debug tests
dlv test ./internal/domainCreate .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch NetTraceX",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/nettracex",
"args": ["--config", "config/dev.yaml"],
"env": {
"NETTRACEX_ENV": "development"
}
},
{
"name": "Debug Tests",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/internal/domain"
}
]
}# Run all unit tests
go test ./...
# Run with verbose output
go test -v ./...
# Run with race detection
go test -race ./...
# Run with coverage
go test -cover ./...
# Run specific test
go test -run TestPingTool ./internal/tools/ping# Run integration tests
go test -tags=integration ./...
# Run with network tests
go test -tags=network ./...# Run benchmarks
go test -bench=. ./...
# Run specific benchmark
go test -bench=BenchmarkPingTool ./internal/tools/pingThe project uses GitHub Actions for CI/CD. The workflow includes:
- Go version matrix (1.21, 1.22, 1.23)
- Linting with golangci-lint
- Testing with coverage
- Security scanning
- Cross-platform builds
# Run the same checks as CI
make ci
# Or manually
go test ./...
go vet ./...
golangci-lint run
go build ./...# Run with CPU profiling
go run -cpuprofile=cpu.prof ./cmd/nettracex
# Analyze profile
go tool pprof cpu.prof# Run with memory profiling
go run -memprofile=mem.prof ./cmd/nettracex
# Analyze profile
go tool pprof mem.prof# Run benchmarks
go test -bench=. -benchmem ./...
# Run with profiling
go test -bench=. -cpuprofile=cpu.prof ./...# Clean module cache
go clean -modcache
# Download modules
go mod download
# Tidy modules
go mod tidy# Clean build cache
go clean -cache
# Rebuild
go build ./...# Clean test cache
go clean -testcache
# Run tests with verbose output
go test -v ./...- Check the GitHub Issues
- Join our Discord Community
- Read the Documentation
- Ask questions in GitHub Discussions
- Testing Guide - Learn about testing strategies
- Architecture Guide - Understand the project architecture
- Contributing Guide - Learn how to contribute
- API Reference - Explore the complete API