{"id":44971798,"url":"https://github.com/wingnut128/outlier-go","last_synced_at":"2026-02-18T16:02:51.958Z","repository":{"id":336323478,"uuid":"1149213390","full_name":"wingnut128/outlier-go","owner":"wingnut128","description":"Calculates outliers from numerical value input (P99, P95, etc.). This is a learning exercise. Use at your own risk","archived":false,"fork":false,"pushed_at":"2026-02-17T22:45:33.000Z","size":12477,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-18T02:58:10.737Z","etag":null,"topics":["cli-tool","go","http-api","percentile-calculator"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wingnut128.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-03T21:17:13.000Z","updated_at":"2026-02-17T22:45:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wingnut128/outlier-go","commit_stats":null,"previous_names":["wingnut128/outlier-go"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/wingnut128/outlier-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingnut128%2Foutlier-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingnut128%2Foutlier-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingnut128%2Foutlier-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingnut128%2Foutlier-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wingnut128","download_url":"https://codeload.github.com/wingnut128/outlier-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingnut128%2Foutlier-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29585441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T13:56:48.962Z","status":"ssl_error","status_checked_at":"2026-02-18T13:54:34.145Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-tool","go","http-api","percentile-calculator"],"created_at":"2026-02-18T16:02:49.632Z","updated_at":"2026-02-18T16:02:51.947Z","avatar_url":"https://github.com/wingnut128.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Outlier - Percentile Calculator\n\n[![CI](https://github.com/wingnut128/outlier-go/actions/workflows/ci.yml/badge.svg)](https://github.com/wingnut128/outlier-go/actions/workflows/ci.yml)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/wingnut128/outlier-go)](https://go.dev/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Go Report Card](https://goreportcard.com/badge/github.com/wingnut128/outlier-go)](https://goreportcard.com/report/github.com/wingnut128/outlier-go)\n[![codecov](https://codecov.io/gh/wingnut128/outlier-go/branch/main/graph/badge.svg)](https://codecov.io/gh/wingnut128/outlier-go)\n\nA percentile calculator written in Go, supporting both CLI and HTTP API modes. Converted from the original Rust implementation.\n\n## Features\n\n- **Core percentile calculation** with linear interpolation\n- **CLI mode** with support for:\n  - Direct value input (comma-separated)\n  - JSON file input\n  - CSV file input\n- **HTTP API server** with:\n  - RESTful endpoints for percentile calculation\n  - File upload support (JSON/CSV)\n  - Health check endpoint\n  - CORS enabled\n- **Configuration management** via TOML files\n- **OpenTelemetry integration** for Honeycomb observability\n- **Docker support** with multi-stage builds\n\n## Installation\n\n### From Source\n\n```bash\ngo install github.com/wingnut128/outlier-go/cmd/outlier@latest\n```\n\n### Build Locally\n\n```bash\ngit clone https://github.com/wingnut128/outlier-go\ncd outlier-go\nmake build\n```\n\nThe binary will be available at `bin/outlier`.\n\n### Docker\n\n```bash\ndocker build -t outlier:latest .\n```\n\n## Usage\n\n### CLI Mode\n\n#### Calculate from direct values\n\n```bash\noutlier --values 1,2,3,4,5 --percentile 50\n```\n\nOutput:\n```\nNumber of values: 5\nPercentile (P50): 3.00\n```\n\n#### Calculate from JSON file\n\n```bash\noutlier --file examples/sample.json --percentile 95\n```\n\n#### Calculate from CSV file\n\n```bash\noutlier --file examples/sample.csv --percentile 99\n```\n\nThe CSV file must have a `value` column:\n```csv\nvalue\n1.0\n2.0\n3.0\n```\n\n### Server Mode\n\nStart the HTTP API server:\n\n```bash\noutlier --serve\n```\n\nOr with custom configuration:\n\n```bash\noutlier --serve --config configs/config.development.toml\n```\n\nOr override the port:\n\n```bash\noutlier --serve --port 8080\n```\n\n### API Endpoints\n\n#### POST /calculate\n\nCalculate percentile from an array of values.\n\n**Request:**\n```bash\ncurl -X POST http://localhost:3000/calculate \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"values\": [1, 2, 3, 4, 5],\n    \"percentile\": 50\n  }'\n```\n\n**Response:**\n```json\n{\n  \"count\": 5,\n  \"percentile\": 50,\n  \"result\": 3\n}\n```\n\n#### POST /calculate/file\n\nUpload a file (JSON or CSV) and calculate percentile.\n\n**Request:**\n```bash\ncurl -X POST http://localhost:3000/calculate/file \\\n  -F \"file=@examples/sample.json\" \\\n  -F \"percentile=95\"\n```\n\n**Response:**\n```json\n{\n  \"count\": 100,\n  \"percentile\": 95,\n  \"result\": 95.05\n}\n```\n\n#### GET /health\n\nHealth check endpoint.\n\n**Request:**\n```bash\ncurl http://localhost:3000/health\n```\n\n**Response:**\n```json\n{\n  \"status\": \"healthy\",\n  \"service\": \"outlier\",\n  \"version\": \"1.0.5\"\n}\n```\n\n\u003e The `version` field reflects the build-time version injected via ldflags (e.g. `make build`). Binaries built without ldflags return `\"dev\"`.\n\n## Configuration\n\nConfiguration is managed via TOML files. Priority order:\n\n1. `--config` flag\n2. `CONFIG_FILE` environment variable\n3. Default configuration\n\n### Example Configuration\n\n```toml\n[logging]\nlevel = \"info\"      # trace, debug, info, warn, error\noutput = \"stdout\"   # stdout, stderr, file\nformat = \"compact\"  # compact, pretty, json\n\n[server]\nport = 3000\nbind_ip = \"0.0.0.0\"\n```\n\nSee the `configs/` directory for example configurations:\n- `config.example.toml` - Full template\n- `config.development.toml` - Development settings\n- `config.production.toml` - Production settings\n- `config.minimal.toml` - Minimal settings\n\n## OpenTelemetry / Honeycomb Integration\n\nEnable telemetry by setting environment variables:\n\n```bash\nexport HONEYCOMB_API_KEY=your_api_key_here\nexport OTEL_SERVICE_NAME=outlier\noutlier --serve\n```\n\nTraces will be sent to Honeycomb for observability.\n\n## Docker Usage\n\n### Build the image\n\n```bash\nmake docker-build\n```\n\n### Run CLI mode\n\n```bash\ndocker run --rm outlier:latest --values 1,2,3,4,5 --percentile 50\n```\n\n### Run server mode\n\n```bash\ndocker run --rm -p 3000:3000 outlier:latest --serve\n```\n\n### With environment variables\n\n```bash\ndocker run --rm -p 3000:3000 \\\n  -e HONEYCOMB_API_KEY=your_key \\\n  -e OTEL_SERVICE_NAME=outlier-docker \\\n  outlier:latest --serve\n```\n\n## Development\n\n### Run tests\n\n```bash\nmake test\n```\n\n### Generate coverage report\n\n```bash\nmake coverage\n```\n\nThis generates `coverage.html` for viewing test coverage.\n\n### Run linter\n\n```bash\nmake lint\n```\n\nRequires `golangci-lint` to be installed.\n\n### Project Structure\n\n```\noutlier-go/\n├── cmd/outlier/           # CLI entrypoint\n├── internal/              # Private application code\n│   ├── calculator/        # Percentile calculation logic\n│   ├── parser/            # File parsing (JSON/CSV)\n│   ├── server/            # HTTP server and handlers\n│   ├── config/            # Configuration management\n│   └── telemetry/         # OpenTelemetry setup\n├── pkg/api/               # Public API types\n├── examples/              # Example data files\n├── configs/               # Configuration templates\n└── docs/                  # Documentation\n```\n\n## Algorithm\n\nThe percentile calculation uses **linear interpolation**:\n\n1. Sort the input values\n2. Calculate index position: `index = (percentile / 100) * (length - 1)`\n3. If index is exact, return that value\n4. Otherwise, interpolate between the lower and upper indices\n\nThis matches the behavior of many statistical packages and provides smooth, accurate results.\n\n## Performance\n\nThe implementation is optimized for:\n- Large datasets (tested with 1M+ values)\n- Low memory footprint (sorts in-place copy)\n- Fast HTTP response times\n- Concurrent request handling\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality\n4. Ensure all tests pass (`make test`)\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Original Implementation\n\nThis is a Go port of the original Rust implementation. The core algorithm and API remain identical for compatibility.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwingnut128%2Foutlier-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwingnut128%2Foutlier-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwingnut128%2Foutlier-go/lists"}