$ show slack-go/slack
This is a Go client library for the Slack API, providing comprehensive coverage of Slack's REST API, Real-Time Messaging (RTM) over WebSocket, Socket Mode for event-driven interactions, and the Block Kit for rich interactive messages. It enables developers to build Slack apps, bots, and integrations with full access to Slack's platform features including messaging, files, admin functions, workflows, and more. The library is organized into several packages: `slack` (main client with all API methods), `socketmode` (WebSocket client for Socket Mode), `slackevents` (Events API parsing), `slacktest` (mock server for testing), and `internal` (backoff, error handling). It uses a functional options pattern for API calls, context propagation for cancellation, and a pluggable retry system. The Block Kit is implemented with builder patterns and custom JSON serialization for type-safe block construction. Key entry points include `slack.New(token)` to create a client, `socketmode.NewClient` for WebSocket connections, and `slackevents.ParseEvent` for Events API payloads. The library handles authentication, rate limiting, pagination, and error responses. External dependencies are minimal, relying primarily on the Go standard library and a WebSocket library for real-time communication.
The LLM identified 5 files worth highlighting for reuse:
Implements exponential backoff with jitter for retry logic. Well-structured, configurable, and isolated. Can be extracted for use in any HTTP client or retry scenario.
Provides a pluggable retry infrastructure with handlers for connection errors, rate limiting (429), and server errors (5xx). Uses exponential backoff with jitter and supports context cancellation. A clean, reusable pattern for any API client.
Implements a multi-level event dispatcher for Socket Mode, routing events to handlers based on event type, interaction type, and callback ID. Supports middleware for preprocessing. Demonstrates a flexible event-driven architecture.
A mock Slack server for integration testing, supporting both HTTP and WebSocket endpoints. Allows simulating API responses and WebSocket events without a live Slack workspace. Reusable for any Slack integration testing.
Implements OAuth v1/v2 token exchange, PKCE code verifier/challenge generation, and OpenID Connect. Self-contained and well-structured, can be extracted for OAuth flows in other projects.