π GoAnalysis
δΈζη |
English
π Overview
Professional Go function tracing analysis tool with advanced visualization. Built with Kratos backend and Vue3 frontend.
π Features
- π Function Tracing - Real-time goroutine execution capture
- π Visualization - Interactive Mermaid flowcharts and heatmaps
- π Performance - Bottleneck identification and analysis
- π Git Integration - GitLab MR change analysis
- π Web UI - Modern Vue3 interface
π οΈ Tech Stack
- Backend: Kratos, gRPC, SQLite
- Frontend: Vue3, Bootstrap, ECharts
- Visualization: Mermaid.js, D3.js
π Quick Start
Using Pre-built Binaries
- Download from GitHub Releases
- Extract and run:
# Linux - Start with default configuration
./goanalysis-linux-v* server
# Windows - Start with default configuration
goanalysis-windows-v*.exe server
- Open http://localhost:8001
Building from Source
git clone https://github.com/toheart/goanalysis.git
cd goanalysis
make init
make sync-frontend
make build
./bin/goanalysis server
βοΈ Configuration
π― Recommended: Command Line Arguments (No Config File Required)
GoAnalysis now supports direct configuration via command line arguments without creating config files:
# Start with default configuration
./goanalysis server
# Customize port and log level
./goanalysis server --http-addr=0.0.0.0:8080 --log-level=info
# Customize database path
./goanalysis server --db-path=./my-database.db
# Set GitLab configuration
./goanalysis server --gitlab-token="your-token" --gitlab-url="https://gitlab.com/api/v4"
π All Available Parameters
# View all available parameters
./goanalysis server --help
Server Configuration:
--http-addr - HTTP server address (default: 0.0.0.0:8001)
--grpc-addr - gRPC server address (default: 0.0.0.0:9000)
--http-timeout - HTTP timeout (default: 1s)
--grpc-timeout - gRPC timeout (default: 1s)
Logging Configuration:
--log-level - Log level (default: debug)
--log-file - Log file path (default: ./logs/app.log)
--log-console - Output to console (default: true)
GitLab Configuration:
--gitlab-token - GitLab access token
--gitlab-url - GitLab API URL
--gitlab-clone-dir - Clone directory (default: ./data)
OpenAI Configuration:
--openai-api-key - OpenAI API key
--openai-api-base - OpenAI API base URL
--openai-model - OpenAI model name
Storage Paths:
--static-store-path - Static storage path (default: ./data/static)
--runtime-store-path - Runtime storage path (default: ./data/runtime)
--file-storage-path - File storage path (default: ./data/files)
Data Configuration:
--db-path - Database path (default: ./goanalysis.db)
π Environment Variables Support
Sensitive information can also be set via environment variables:
export GITLAB_TOKEN="your-gitlab-token"
export GITLAB_API_URL="https://gitlab.com/api/v4"
export OPENAI_API_KEY="your-openai-key"
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_MODEL="gpt-3.5-turbo"
./goanalysis server
π Traditional: Configuration File
Still supports traditional configuration file approach:
# Generate default configuration file
./goanalysis config
# Start with configuration file
./goanalysis server --conf=configs/config.yaml
Configuration file example:
server:
http:
addr: 0.0.0.0:8001
grpc:
addr: 0.0.0.0:9000
logger:
level: debug
file_path: ./logs/app.log
console: true
biz:
gitlab:
token: "${GITLAB_TOKEN}"
url: "${GITLAB_API_URL}"
clone_dir: ./data
openai:
api_key: "${OPENAI_API_KEY}"
api_base: "${OPENAI_API_BASE}"
model: "${OPENAI_MODEL}"
data:
dbpath: ./goanalysis.db
π Configuration Priority
Configuration priority from high to low:
- Command Line Arguments - Highest priority
- Environment Variables - For sensitive information
- Configuration File - Traditional approach
- Default Values - Lowest priority
π§ Usage
Basic Tracing
# Start with default configuration
./goanalysis server
# Start with custom configuration
./goanalysis server --http-addr=0.0.0.0:8080 --log-level=info
# Code rewriting
./goanalysis rewrite -d /path/to/project
Git Analysis
# Set GitLab configuration
export GITLAB_TOKEN="your-token"
export GITLAB_API_URL="https://gitlab.com/api/v4"
# Start server
./goanalysis server
π Project Structure
βββ api/ # API definitions
βββ cmd/ # CLI commands
βββ internal/ # Core logic
βββ web/ # Frontend files
βββ configs/ # Configuration
ποΈ Deployment
Docker
docker run -p 8000:8000 -p 9000:9000 \
ghcr.io/toheart/goanalysis:latest
Build
make package-linux
make package-windows
π§ Troubleshooting
| Issue |
Solution |
| Port in use |
lsof -i :8000; kill -9 <PID> |
| DB locked |
rm -f goanalysis.db-* |
| Frontend missing |
make sync-frontend |
π€ Contributing
- Fork repository
- Create feature branch
- Make changes with tests
- Submit pull request
Follow Conventional Commits.
π Releases
| Version |
Date |
Changes |
| v1.1.4 |
2024-12-16 |
GitLab integration |
| v1.1.0 |
2024-12-01 |
Vue3 upgrade |
| v1.0.0 |
2024-11-15 |
First stable |
π License
MIT License - see LICENSE file.
π Support
π± Follow WeChat
ε°εηζζ―ζ₯εΏ
Scan for latest updates
GoAnalysis - Empowering Go developers
β Star us on GitHub!