Loading...
Loading...
Exclusive skill set for the GoFrame development framework. Provides comprehensive framework usage guidelines for Go language developers, covering best practices for core components such as command-line management, configuration management, logging components, error handling, data validation, type conversion, cache management, template engines, database ORM, and I18n internationalization. Includes project engineering structure specifications, development mode guidelines, common problem solutions, and rich practical code examples. Suitable for building various Go projects such as RESTful APIs, gRPC microservices, web applications, and CLI tools, helping developers quickly master GoFrame framework features, improve development efficiency and code quality.
npx skill4agent add gogf/skills goframe| Sample Code | Sample Introduction |
|---|---|
| balancer/http | Demonstrates how to implement HTTP service load balancing using the GoFrame framework combined with etcd. This example shows client-side load balancing implementation using a round-robin strategy for request distribution, supporting automatic service discovery and dynamic routing. Key features include: service registration and discovery using etcd, client-side round-robin load balancing strategy, multi-service instance request distribution, seamless integration with GoFrame's HTTP server and client components, suitable for building highly available and scalable microservice architecture systems. Through this example, you can learn how to implement service load balancing and service discovery mechanisms in a distributed environment. |
| balancer/polaris | Demonstrates how to integrate the Polaris service mesh platform with the GoFrame framework to implement HTTP service load balancing. This example shows Polaris-based service registration and discovery mechanisms, client-side round-robin load balancing strategy, local cache configuration optimization, and centralized log management. Key features include: using Polaris as the service registration center, configurable TTL (time-to-live) heartbeat mechanism, automatic service discovery, dynamic request routing, seamless integration with GoFrame's HTTP server and client components, suitable for building cloud-native microservice architectures and providing advanced traffic management capabilities. Through this example, you can learn how to implement service governance, load balancing, and failover and other enterprise-level features in a distributed environment using Polaris. |
| config/apollo | Demonstrates how to seamlessly integrate the Apollo configuration center into GoFrame applications to implement centralized configuration management. This example shows Apollo client initialization and configuration, configuration adapter implementation methods, dynamic configuration loading and parsing, real-time configuration update mechanisms, complete error handling and logging, and configuration value acquisition methods. Key features include: centralized configuration management via Apollo, support for multiple environments and namespaces, automatic configuration refresh capability, type-safe configuration access using the GoFrame configuration component, production-grade error handling mechanism. Suitable for building microservice applications that require centralized configuration management, dynamic configuration updates without restarting, and support for configuration version management and rollback. Through this example, you can learn best practices for configuration centers in distributed systems. |
| config/consul | Demonstrates how to fully integrate the HashiCorp Consul configuration center into GoFrame applications to implement distributed configuration management. This example shows Consul client setup and initialization, GoFrame configuration component adapter implementation, dynamic configuration loading and parsing, real-time configuration monitoring and update, complete error handling and logging, and secure configuration value acquisition. Key features include: distributed configuration management via Consul KV storage, support for multiple data centers and namespaces, automatic configuration synchronization, health check and service discovery integration, type-safe configuration access, production-grade error handling mechanism. Ideal for building cloud-native microservice applications that require distributed configuration management, service mesh integration, and configuration consistency among multiple instances. Through this example, you can learn how to use Consul to implement enterprise-level distributed configuration management and service governance. |
| config/kubecm | Demonstrates how to fully integrate Kubernetes ConfigMap into GoFrame applications to implement cloud-native configuration management. This example shows two configuration scenarios: inside and outside Pods, Kubernetes client initialization and authentication, ConfigMap access and dynamic loading, real-time configuration monitoring and update, namespace and resource management, complete error handling and logging, and secure configuration value acquisition. Key features include: native Kubernetes ConfigMap integration, support for multiple deployment scenarios (inside and outside clusters), automatic configuration refresh when ConfigMap changes, seamless integration with the GoFrame configuration component, RBAC-compliant access mode, production-grade error handling mechanism. Ideal for building cloud-native applications deployed on Kubernetes, especially scenarios that require native configuration management, GitOps workflows, and configuration-as-code practices. Through this example, you can learn how to implement declarative configuration management and cloud-native best practices in a Kubernetes environment. |
| config/nacos | Demonstrates how to seamlessly integrate Alibaba's Nacos configuration center into GoFrame applications to implement dynamic configuration management. This example shows Nacos client initialization and configuration, GoFrame configuration component adapter implementation, dynamic configuration loading and hot update, real-time configuration monitoring and change notification, namespace and group management, complete error handling and logging, and secure configuration value acquisition. Key features include: centralized configuration management via Nacos, support for multi-environment and namespace isolation, automatic configuration refresh without restarting services, configuration version management and rollback capabilities, type-safe configuration access, production-grade monitoring capabilities. Ideal for building cloud-native microservice applications deployed on Alibaba Cloud or locally, especially scenarios that require dynamic configuration, service discovery, and configuration sharing among distributed systems. Through this example, you can deeply learn enterprise-level application practices of Nacos in configuration management and service governance. |
| config/polaris | Demonstrates how to seamlessly integrate Tencent Cloud's Polaris configuration center into GoFrame applications to implement service mesh configuration management. This example shows Polaris client setup and initialization, GoFrame configuration component adapter implementation, dynamic configuration loading and hot update, real-time configuration monitoring and synchronization, namespace and file group management, complete error handling and logging, and secure configuration value acquisition. Key features include: centralized configuration management via Polaris, support for multiple namespaces and configuration groups, automatic configuration refresh capability, integration with Polaris service mesh to achieve unified service governance, type-safe configuration access, production-grade monitoring capabilities. Ideal for building cloud-native microservice applications based on Tencent Cloud or using Polaris mesh, especially scenarios that require dynamic configuration, service discovery, traffic management, and unified configuration governance. Through this example, you can deeply learn enterprise-level application practices of Polaris in configuration management and service mesh. |
| database/encoded-pass | Demonstrates how to implement a custom database driver in GoFrame to handle encrypted database passwords, improving application security. This example shows how to create a custom MySQL driver with AES encryption and Base64 encoding, automatic password decryption mechanism during connection establishment, secure credential storage in configuration files, transparent database connection handling, and seamless integration with the GoFrame database component. Key features include: encrypted password storage, custom driver registration, automatic decryption middleware, production-grade security mode, zero impact on existing database operations. Ideal for applications that need to enhance database security, comply with security policy requirements, protect sensitive credentials in version control, and implement secure configuration management without code changes. Through this example, you can learn how to improve database connection security without affecting development efficiency, and how to implement custom database drivers to extend GoFrame's capabilities. |
| grpc/balancer | Demonstrates implementing comprehensive gRPC load balancing in GoFrame to build an elastic distributed system. This example shows how to configure gRPC load balancers using multiple strategies, implement client-side load balancing for optimal performance, integrate with service discovery mechanisms such as etcd, handle automatic failover and service health checks, distribute requests among multiple server instances, and manage connection pools. Key features include: multiple load balancing algorithms (round-robin, weighted, least connection), automatic service instance discovery, health-based routing, connection state management, retry strategies, production-grade error handling. Ideal for building highly available microservices, implementing fault-tolerant distributed systems, horizontally scaling gRPC services, and ensuring optimal resource utilization across service instances. Through this example, you can learn how to implement gRPC load balancing in a distributed environment, how service discovery and load balancing work together, and best practices for building highly available and high-performance microservice architectures. |
| grpc/basic | Demonstrates the basic implementation of gRPC in GoFrame applications, covering protocol buffer definition, service creation, and client-server communication. This example shows how to create gRPC servers and clients using GoFrame, define and compile protocol buffers for service contracts, implement service handlers with business logic, perform synchronous and asynchronous RPC calls, handle errors and status codes, and integrate with GoFrame's configuration and logging systems. Key features include: complete server and client setup, protocol buffer integration, service interface implementation, request-response mode, error handling best practices, production-grade code structure. Ideal for gRPC novice developers, building microservices using GoFrame, learning protocol buffer usage, and implementing inter-service communication patterns. Through this example, you can learn the basic usage of gRPC in GoFrame, best practices for microservice communication, and how to build efficient RPC services. |
| grpc/ctx | Demonstrates advanced context and metadata management in GoFrame's gRPC services for request tracking and data propagation. This example shows how to pass metadata through gRPC context to handle cross-cutting concerns, handle context values and deadlines to implement request cancellation, manage request context across service boundaries, handle and extract context metadata, implement distributed tracing integration, and propagate authentication tokens and correlation IDs. Key features include: metadata injection and extraction, context timeout and cancellation handling, custom metadata keys and values, interceptor-based metadata processing, distributed tracing support, request correlation patterns. Ideal for implementing observability in microservices, tracking requests across distributed systems, implementing authentication and authorization, managing request timeouts and cancellations, and building production-grade gRPC services with proper context management. Through this example, you can learn advanced usage of gRPC context, how to propagate request information in distributed systems, and best practices and observability patterns for inter-microservice communication. |
| grpc/rawgrpc | Demonstrates implementing native gRPC directly in GoFrame without using the framework abstraction layer, providing maximum control and flexibility. This example shows how to create gRPC servers and clients directly using the native gRPC library, use protocol buffers directly without additional encapsulation, implement service handlers through direct gRPC API access, perform low-level RPC calls with full control, handle streaming RPC and advanced patterns, and selectively integrate GoFrame components. Key features include: direct creation of gRPC servers and clients, protocol buffer usage without abstraction, manual connection management, custom interceptors and middleware, streaming support (unary, client streaming, server streaming, bidirectional streaming), production-grade error handling. Ideal for advanced users who need fine-grained control, implementing custom gRPC patterns, optimizing performance-critical applications, and integrating third-party gRPC libraries. Through this example, you can learn how to use native gRPC in GoFrame, deeply understand gRPC working principles, and implement highly customized RPC communication solutions. |
| grpc/resolver | Demonstrates implementing a gRPC service resolver in GoFrame and integrating with etcd to achieve dynamic service discovery and resolution. This example shows how to configure a service resolver using etcd as the service registration center, automatically register gRPC services with etcd via automatic heartbeats, dynamically discover and resolve services using the resolver API, automatically handle service instance updates and removals, implement client-side service discovery, and manage service health monitoring. Key features include: etcd-based service registration center, automatic service registration and deregistration, dynamic service resolution, health check integration, automatic failover when services change, production-grade connection management. Ideal for building cloud-native microservices with dynamic service discovery, implementing service mesh patterns, scaling services without client reconfiguration, and ensuring high availability through automatic service resolution. Through this example, you can learn how to implement service discovery and resolution in gRPC, the application of etcd in microservice architectures, and best practices for building dynamically scalable distributed systems. |
| httpserver/basic-auth | Demonstrates implementing HTTP basic authentication in GoFrame for simple credential-based access control. This example shows the setup and configuration of basic authentication middleware, username and password validation against configured credentials, Base64 credential encoding and decoding, WWW-Authenticate header handling for browser prompts, protected route implementation, custom authentication failure responses, and integration with the GoFrame middleware system. Key features include: simple authentication without external dependencies, browser-compatible authentication dialogs, credential validation mode, secure credential storage recommendations, custom realm configuration, production-grade error handling. Ideal for internal tools and admin panels, simple API protection, development and testing environments, legacy system integration, and applications that require lightweight authentication without complex infrastructure. Through this example, you can learn how to implement HTTP basic authentication, how to implement simple authentication protection in GoFrame, and the applicable scenarios and considerations of basic authentication. |
| httpserver/jwt | Demonstrates implementing comprehensive JWT (JSON Web Token) authentication in the GoFrame HTTP server for secure API access control. This example shows JWT token generation with custom claims and expiration time, token validation and verification middleware, secure token signing using HS256/RS256 algorithms, refresh token mechanism for session extension, protected route implementation with authentication middleware, error handling for invalid or expired tokens, and integration with the GoFrame middleware system. Key features include: user login and token issuance, stateless authentication, token refresh mode, role-based access control (RBAC) integration, secure token storage recommendations, production-grade security practices. Ideal for building REST APIs with authentication, implementing microservice security, mobile application backends that require stateless authentication, and applications that require scalable authentication without server-side sessions. Through this example, you can learn best practices for JWT authentication, how to implement secure stateless authentication, and how to build secure and scalable web services. |
| httpserver/mcp-http | Demonstrates implementing a Model Context Protocol (MCP) server using GoFrame and HTTP streaming for AI model integration. This example shows MCP server setup using HTTP transport, streaming response handling for real-time model output, protocol message encoding and decoding, context management and propagation, integration with AI models and services, and error handling for MCP operations. Key features include: HTTP-based MCP transport, streaming API support, efficient message serialization, cross-request context sharing, scalable protocol processors, production-grade patterns. Ideal for building AI agent backends, integrating language models with applications, implementing streaming AI responses, and creating model context sharing services that comply with the MCP protocol. Through this example, you can learn the implementation of the MCP protocol, best practices for AI model integration, and how to build intelligent AI applications. |
| httpserver/mcp-sse | Demonstrates implementing a Model Context Protocol (MCP) server using GoFrame and Server-Sent Events (SSE) for real-time AI model communication. This example shows MCP server setup using SSE transport to achieve server-to-client streaming, real-time event streaming of model output, persistent connections for continuous communication, event formatting and client reconnection handling, integration with AI models and agents, and efficient resource management. Key features include: SSE-based MCP transport, one-way streaming from server to client, automatic reconnection support, event-driven architecture, lighter weight than WebSocket, production-grade patterns. Ideal for building real-time AI agent interfaces, implementing streaming model responses without WebSocket complexity, creating chat and assistant applications, and implementing server push notifications for model updates. Through this example, you can learn the use of SSE in AI applications, MCP protocol implementation, and how to build real-time intelligent applications. |
| httpserver/proxy | Demonstrates implementing a reverse proxy server using GoFrame for request forwarding and load distribution. This example shows reverse proxy setup and configuration with target backend servers, HTTP request and response forwarding with header preservation, custom header operations and transformations, connection pool and keepalive management, error handling and failover logic, and integration with the GoFrame middleware system. Key features include: flexible proxy configuration, transparent request forwarding, response streaming support, custom routing rules, load balancing integration, production-grade patterns. Suitable for building API gateways and service proxies, implementing microservice routing, adding authentication and rate limiting layers, implementing A/B testing and canary deployments, and creating development proxy servers. |
| httpserver/rate-limit | Demonstrates implementing rate limiting in the GoFrame HTTP server for API protection and traffic control. This example shows rate limiting middleware configuration with configurable limits, token bucket and sliding window algorithms, IP-based and user-based rate limiting strategies, custom rate limiting responses and headers (X-RateLimit-*), Redis-based distributed rate limiting for scalability, and integration with the GoFrame middleware chain. Key features include: flexible rate limiting strategies, distributed rate limiting support, custom limit rules per endpoint, graceful rate limiting responses, monitoring and metrics integration, production-grade patterns. Ideal for protecting APIs from abuse and DDoS attacks, implementing fair usage policies, ensuring service stability under load, managing API quotas and billing, and enabling multi-tier service levels. Through this example, you can learn rate limiting algorithms, how to implement efficient traffic control, and how to build secure and reliable API services. |
| httpserver/response-json-array | Demonstrates handling JSON array responses in the GoFrame HTTP server for RESTful API development. This example shows returning JSON arrays as HTTP responses, appropriate content-type header configuration, array serialization with custom formatting, pagination support for large datasets, efficient memory management for large arrays, and integration with the GoFrame response writing system. Key features include: automatic JSON serialization, appropriate HTTP status codes, empty array handling, streaming support for large datasets, error response formatting, RESTful API patterns. Ideal for building REST APIs that return collections, implementing list and search endpoints, handling batch data responses, ensuring consistent API response formats, and optimizing JSON serialization performance. Through this example, you can learn best practices for JSON array responses, RESTful API design, and efficient data serialization. |
| httpserver/sse | Demonstrates implementing Server-Sent Events (SSE) using GoFrame for real-time server-to-client streaming. This example shows SSE server setup with persistent connections, event stream formatting with data, event types, and IDs, automatic client reconnection handling with Last-Event-ID, sending real-time updates and notifications, appropriate content-type and header configuration, and connection lifecycle management. Key features include: one-way streaming from server to client, automatic reconnection support, event-driven architecture, lighter weight than WebSocket, heartbeat and keepalive support, production-grade patterns. Ideal for building real-time notifications and updates, implementing real-time dashboards and monitoring, creating chat and messaging functions, implementing server push without WebSocket, and building event-driven applications. Through this example, you can learn the implementation principles of SSE, the difference from WebSocket, and how to build real-time communication applications. |
| httpserver/swagger-auth | Demonstrates implementing Swagger API documentation with basic authentication integration using GoFrame for secure API document access. This example shows Swagger UI integration with the GoFrame HTTP server, basic authentication protection for Swagger endpoints, automatic OpenAPI specification generation and serving, authentication middleware for document access, custom Swagger UI configuration, and integration with the GoFrame routing system. Key features include: protected API documentation, automatic OpenAPI specification generation, authenticated interactive API testing, customizable Swagger UI themes, credential-based access control, developer-friendly patterns. Ideal for protecting API documentation in production environments, providing authenticated access to internal APIs, implementing authenticated interactive API testing, documenting and protecting REST APIs, and maintaining API specifications with access control. Through this example, you can learn how to protect Swagger documents, integrate OpenAPI specifications, and build secure API document systems. |
| httpserver/upload-file | Demonstrates handling file uploads in the GoFrame HTTP server for multipart form data processing. This example shows single and multiple file upload support, multipart form data parsing and processing, file size validation and limits, file type validation with MIME type checking, secure file storage with unique naming, and integration with the GoFrame request handling system. Key features include: automatic file parsing, configurable upload limits, file metadata extraction, progress tracking support, error handling for invalid uploads, production-grade patterns. Ideal for building file upload APIs and forms, implementing image and document upload functions, handling batch file uploads, ensuring secure file processing, and creating content management systems. Through this example, you can learn best practices for file uploads, secure file handling, and how to build secure and reliable file upload functions. |
| nosql/mongodb | Demonstrates comprehensive integration of MongoDB in GoFrame for document-based data storage and retrieval. This example shows MongoDB connection setup and configuration using the official Go driver, CRUD operations (create, read, update, delete) for documents, advanced queries with filters and projections, use of aggregation pipelines for data analysis, index creation and management for performance optimization, transaction support for data consistency, and connection pool configuration. Key features include: automatic connection management, error handling patterns, integration with GoFrame's ORM concepts where applicable, document serialization/deserialization, pagination support, production-grade database operations. Ideal for building applications that require flexible schema design, document-oriented data models, complex aggregations, horizontal scalability, and integrating NoSQL databases in microservice architectures. Through this example, you can learn how to use MongoDB in GoFrame, best practices for NoSQL databases, and how to build flexible and high-performance document storage systems. |
| nosql/redis | Demonstrates comprehensive integration of Redis in GoFrame for caching, session storage, and data persistence. This example shows Redis connection setup and configuration using GoFrame's redis component, basic operations including GET/SET/DEL, data structure operations (strings, hashes, lists, sets, sorted sets), TTL and expiration management, pipeline and transaction support, publish/subscribe messaging patterns, and connection pool configuration. Key features include: support for standalone and cluster modes, automatic connection management, error handling and retry logic, integration with GoFrame's cache component, serialization and deserialization helpers, production-grade patterns. Ideal for implementing application caching, session management, rate limiting, distributed locks, real-time messaging, and implementing high-performance data storage in microservice architectures. Through this example, you can learn how to use Redis in GoFrame, best practices for Redis data structures, and how to build high-performance caching systems. |
| observability/metric/basic | Demonstrates comprehensive basic metric types and their usage in GoFrame using OpenTelemetry and Prometheus integration. This example shows counter metrics for tracking event occurrences, histogram metrics for measuring distributions, gauge metrics for current values, and UpDownCounter for bidirectional counting. Key features include: metric creation and registration, attribute configuration and labeling, metric value recording and observation, integration with Prometheus exporter, OpenTelemetry metrics pipeline setup, production-grade instrumentation patterns. Ideal for learning basic metric types, implementing application observability, monitoring service performance, building custom metric dashboards, and establishing baseline monitoring for GoFrame applications. Through this example, you can learn basic concepts of metrics, OpenTelemetry metrics API, and how to build a complete monitoring system. |
| observability/metric/callback | Demonstrates implementing callback-based metric collection in GoFrame using OpenTelemetry and Prometheus for asynchronous metric updates. This example shows metric callback function registration, automatic metric value updates via callbacks, asynchronous metric observation, observable counter and gauge patterns, system resource metric collection, and scheduled metric updates. Key features include: non-blocking metric collection, periodic callback execution, system metrics integration (CPU, memory, goroutines), delayed metric evaluation, automatic value refresh, production-grade patterns. Ideal for collecting system metrics, monitoring resource usage, implementing asynchronous metric updates, reducing metric collection overhead, observing computationally expensive values, and building efficient monitoring systems with minimal performance impact. Through this example, you can learn asynchronous metric collection, callback patterns, and efficient system monitoring implementation. |
| observability/metric/dynamic_attributes | Demonstrates managing dynamic metric attributes in GoFrame using OpenTelemetry and Prometheus to implement runtime attribute updates. This example shows runtime attribute modification, context-based attribute injection, request-scoped metric labels, dynamic attribute value resolution, per-request metric customization, and flexible labeling patterns. Key features include: updating attributes during metric recording, extracting attributes from request context, injecting user/tenant/session IDs, dynamic label value calculation, attribute value caching, production-grade patterns. Ideal for implementing per-request metric labels, tracking user-specific metrics, supporting multi-tenancy, enriching metrics with runtime context, analyzing behavior by dynamic dimensions, and building flexible monitoring systems that adapt to application states. Through this example, you can learn dynamic attribute management, context injection, and flexible metric labeling practices. |
| observability/metric/global_attributes | Demonstrates managing global metric attributes in GoFrame using OpenTelemetry and Prometheus to achieve consistent metric labeling. This example shows global attribute configuration and management, automatic application of attributes across all metrics, service-level metadata (service.name, service.version), environment identification attributes, consistent metric labeling, and attribute inheritance patterns. Key features include: centralized attribute management, automatic attribute propagation, semantic convention support, multi-tenant labeling, deployment environment labeling, production-grade patterns. Ideal for achieving consistent metric labeling, managing service metadata, implementing cross-service metric aggregation, supporting multi-environment deployments, facilitating metric filtering and grouping, and establishing enterprise monitoring standards. Through this example, you can learn global attribute management, consistent labeling practices, and enterprise-level monitoring specifications. |
| observability/metric/http_client | Demonstrates collecting comprehensive HTTP client metrics in GoFrame using OpenTelemetry and Prometheus to monitor outbound HTTP requests. This example shows automatic HTTP client instrumentation, request duration histograms, request count metrics categorized by status code and method, error rate tracking, connection pool metrics, and retry attempt monitoring. Key features include: automatic metric collection without code changes, detailed request/response attributes, integration with GoFrame's HTTP client, customizable metric labels, Prometheus exporter configuration, production-grade observability patterns. Ideal for monitoring external API calls, tracking HTTP client performance, debugging connection issues, analyzing request patterns, and ensuring the reliability of outbound HTTP communication in microservice architectures. Through this example, you can learn how to monitor HTTP clients, analyze external dependencies, and optimize API call performance. |
| observability/metric/http_server | Demonstrates collecting comprehensive HTTP server metrics in GoFrame using OpenTelemetry and Prometheus to monitor inbound HTTP requests. This example shows automatic HTTP server instrumentation, request latency histograms, throughput metrics categorized by endpoint and method, HTTP status code distribution, concurrent request tracking, and error rate monitoring. Key features include: automatic metric collection via middleware, detailed request attributes (path, method, status), integration with GoFrame's HTTP server, customizable metric buckets, Prometheus endpoint exposure, production-grade monitoring patterns. Ideal for monitoring API performance, tracking service health, analyzing traffic patterns, identifying performance bottlenecks, implementing SLA monitoring, and ensuring high availability of HTTP services in production environments. Through this example, you can learn how to monitor HTTP servers, analyze request performance, and build a complete service monitoring system. |
| observability/metric/meter_attributes | Demonstrates managing meter-level attributes in GoFrame using OpenTelemetry and Prometheus to implement scoped metric labeling. This example shows meter-specific attribute configuration, attribute scoping within meters, isolated metric labeling, meter-level metadata management, attribute inheritance from meters to metrics, and fine-grained attribute control. Key features include: creating meters with custom attributes, restricting attribute scope to specific metric groups, isolated attribute namespaces, automatic application of attributes to meter metrics, meter-based multi-tenancy, production-grade patterns. Ideal for organizing metrics by module or component, implementing scoped metric labeling, managing multiple metric namespaces, isolating attributes between metric groups, building modular monitoring systems, and establishing hierarchical metric organization for complex applications. Through this example, you can learn meter-level attribute management, scoped labeling, and hierarchical metric organization. |
| observability/metric/prometheus | Demonstrates integrating Prometheus metrics directly in GoFrame without using OpenTelemetry to implement a lightweight monitoring solution. This example shows using the native Prometheus client library, registering metrics directly with the Prometheus registry, counter, gauge, histogram, and summary metric types, custom metric collectors, HTTP handlers for exposing the /metrics endpoint, and label management. Key features include: zero OpenTelemetry dependencies, simple metric creation and registration, native Prometheus metric types, flexible metric labels, built-in HTTP metrics endpoint, production-grade patterns. Ideal for lightweight monitoring needs, traditional Prometheus setups, simplified metric collection, applications that only require Prometheus integration, minimal dependency footprint, and environments where OpenTelemetry is not needed or desired. Through this example, you can learn the Prometheus native API, simplified monitoring solutions, and lightweight metric collection. |
| observability/trace/grpc-with-db | Demonstrates implementing comprehensive distributed tracing for gRPC services and database operations in GoFrame using OpenTelemetry. This example shows end-to-end trace instrumentation from gRPC calls to database queries, automatic gRPC method and database operation tracking, trace context propagation in RPC communication, span relationships between service calls and database operations, service discovery integrated with tracing, and performance monitoring of distributed systems. Key features include: full-stack gRPC trace visibility, automatic database query instrumentation, service mesh observability, distributed transaction tracing, cross-service trace correlation, production-grade patterns. Ideal for monitoring microservice architecture performance, debugging distributed gRPC systems, optimizing database query performance, ensuring observability in service mesh environments, and building enterprise-level monitoring solutions. Through this example, you can learn how to implement full-link tracing for gRPC, distributed system performance optimization, and how to build highly observable microservice architectures. |
| observability/trace/http-with-db | Demonstrates implementing comprehensive distributed tracing for HTTP services and database operations in GoFrame using OpenTelemetry. This example shows end-to-end trace instrumentation from HTTP requests to database queries, automatic database operation tracking including MySQL and Redis operations, trace context propagation throughout the request lifecycle, span relationships between HTTP handlers and database calls, performance monitoring of database queries, and integration with GoFrame's ORM and cache components. Key features include: full-stack trace visibility, automatic database query instrumentation, slow query detection, connection pool monitoring, cache operation tracking, production-grade observability. Ideal for monitoring full-stack application performance, debugging database-related issues, optimizing query performance, ensuring end-to-end observability of data-driven applications, and building comprehensive monitoring solutions. Through this example, you can learn how to implement full-link tracing, database performance optimization, and how to build high-performance and observable data applications. |
| observability/trace/http | Demonstrates implementing comprehensive distributed tracing for HTTP services in GoFrame using OpenTelemetry integration. This example shows automatic instrumentation for HTTP requests and responses, trace context propagation across service boundaries, span creation and attribute management, exporting trace data to the OpenTelemetry collector, integration with the GoFrame HTTP server middleware, and visualization of distributed traces. Key features include: automatic HTTP trace instrumentation, context propagation headers, custom span attributes, parent-child span relationships, trace sampling configuration, production-grade observability patterns. Ideal for implementing distributed tracing in microservices, monitoring HTTP service performance, debugging request flows, ensuring observability of cloud-native applications, and building production monitoring systems. Through this example, you can learn how to implement distributed tracing in HTTP services, best practices for OpenTelemetry, and how to build observable microservice architectures. |
| observability/trace/inprocess-grpc | Demonstrates implementing distributed tracing in a single-process application using GoFrame and a high-performance gRPC-based OpenTelemetry exporter. This example shows in-process function call tracing configured with the gRPC OTLP exporter, span creation and management for internal operations, trace context propagation within a single process, efficient gRPC-based trace data export to the OpenTelemetry collector, parent-child span relationships for nested function calls, and high-throughput trace data transmission. Key features include: high-performance gRPC exporter setup, automatic span instrumentation, streaming trace export, efficient binary serialization, production-grade performance, enterprise-level patterns. Ideal for applications generating large amounts of trace data, performance-critical applications, production monitoring systems, applications requiring efficient trace export, and building scalable observability solutions. Through this example, you can learn how to implement high-performance link tracing, best practices for gRPC exporters, and how to build enterprise-level monitoring systems. |
| observability/trace/inprocess | Demonstrates implementing distributed tracing in a single-process application using GoFrame and an HTTP-based OpenTelemetry exporter to simplify observability. This example shows in-process function call tracing configured with the HTTP OTLP exporter, span creation and management for internal operations, trace context propagation within a single process, HTTP-based trace data export to the OpenTelemetry collector, parent-child span relationships for nested function calls, and simplified deployment without gRPC dependencies. Key features include: lightweight HTTP exporter setup, automatic span instrumentation, in-memory trace context, firewall-friendly HTTP export, developer-friendly configuration, production-grade patterns. Ideal for monolithic application observability, development and testing environments, simplified trace data export, applications that only support HTTP infrastructure, and learning distributed tracing concepts. Through this example, you can learn how to implement in-process tracing, simplified observability solutions, and lightweight monitoring deployment. |
| observability/trace/otlp | Demonstrates implementing comprehensive OpenTelemetry link tracing data export methods in GoFrame using the OTLP protocol via gRPC and HTTP exporters. This example shows OTLP (OpenTelemetry Protocol) configuration for trace export, setup and comparison of gRPC and HTTP exporters, trace data serialization and transmission, connection management and retry logic, batching and performance optimization, and integration with the OpenTelemetry collector. Key features include: flexible exporter configuration, efficient trace data transmission, automatic batching and compression, error handling and retry mechanisms, production-grade export patterns, protocol selection guidance. Ideal for implementing production trace export, selecting the appropriate export protocol, optimizing trace data transmission, ensuring reliable trace delivery, and building enterprise-level observability infrastructure compliant with OpenTelemetry standards. Through this example, you can learn the use of the OTLP protocol, exporter selection, and how to build an efficient trace data export system. |
| observability/trace/processes | Demonstrates implementing comprehensive distributed tracing across multiple processes using GoFrame's process management methods (including gcmd and gproc). This example shows trace context propagation between processes, process generation and lifecycle management with tracing, distributed span relationships across process boundaries, trace correlation in multi-process architectures, different process communication patterns with tracing support, and integration with GoFrame's command and process components. Key features include: multi-process trace visibility, automatic inter-process context propagation, parent-child process span relationships, trace continuity under process isolation, production-grade multi-process patterns, enterprise architecture support. Ideal for building multi-process applications with observability, implementing distributed task processing, monitoring daemon and worker processes, ensuring trace continuity in complex process topologies, and creating scalable multi-process systems with comprehensive tracing. Through this example, you can learn multi-process link tracing, inter-process communication and trace propagation, and how to build complex distributed system monitoring. |
| observability/trace/provider | Demonstrates configuring comprehensive OpenTelemetry link tracing providers including gRPC and HTTP exporters in GoFrame and different setting modes. This example shows trace provider initialization and configuration, resource attribute management for service identification, sampling strategy configuration and selection, setup and comparison of gRPC and HTTP-based exporters, span processor configuration for batching and simple processing, and provider lifecycle management. Key features include: flexible provider configuration modes, resource semantic convention support, multiple sampling strategies (always, never, parent-based, ratio-based), exporter protocol selection guidance, production-grade provider setup, enterprise deployment patterns. Ideal for understanding the OpenTelemetry provider architecture, configuring production trace pipelines, selecting appropriate exporters and samplers, optimizing trace collection performance, and building scalable observability infrastructure with appropriate provider configuration. Through this example, you can learn best practices for OpenTelemetry providers, exporter and sampler selection, and how to build enterprise-level link tracing systems. |
| practices/injection | Demonstrates a comprehensive example of implementing the dependency injection pattern using the do package in the GoFrame framework. Shows how to achieve a loosely coupled architecture through interface abstraction, manage dependencies using the do package, register and resolve service instances, singleton mode management, interface injection and implementation replacement, and unit test Mock implementation. Includes practical application scenarios such as User service, Gateway gateway, demonstrating complete processes such as service layering, interface definition, implementation registration, and dependency resolution. Ideal for microservice architecture development, testable code writing, modular system design, interface-driven development, and enterprise-level applications that require flexible dependency management. Through this example, you can learn how to build highly maintainable and testable Go applications. |
| registry/consul | Demonstrates comprehensive integration of HashiCorp Consul service registration center in GoFrame to implement enterprise-level service discovery and health monitoring. This example shows registering services with the Consul agent including health check configuration, service discovery using filters and tag-based queries, built-in health monitoring and automatic removal of unhealthy services, service metadata and version management support, multi-data center service discovery, and integration with GoFrame server and client components. Key features include: enterprise service registration center, automatic health check execution, DNS and HTTP service discovery interfaces, load balancer integration, service mesh compatibility, production-grade patterns. Suitable for building microservices that require powerful service discovery, implementing enterprise service meshes, ensuring service health monitoring, and implementing dynamic service registration across multiple data centers. |
| registry/etcd | Demonstrates comprehensive integration of Etcd service registration center in GoFrame to implement distributed service discovery and registration. This example shows registering services with Etcd using an automatic heartbeat mechanism, service discovery and listening for real-time updates, TTL-based service health management, service metadata and endpoint configuration, automatic service deregistration on shutdown, and integration with GoFrame server and client components. Key features include: distributed service registration center, real-time service updates via watch mechanism, health check integration, load balancer integration, automatic failover support, production-grade patterns. Suitable for building cloud-native microservices that require dynamic service discovery, implementing service mesh architectures, ensuring high availability through automatic service registration, and implementing zero-downtime deployments. |
| registry/file | Demonstrates implementing a file system-based service registration and discovery mechanism in the GoFrame framework. This example shows how to use the local file system as a lightweight registration center, supporting automatic service registration, service list query, service instance management, configuration file storage, and simple deployment without external dependencies. Key features include: local file system storage of service information, JSON/YAML format service descriptions, automatic file monitoring and refresh, multi-instance registration management, simple configuration management, zero external dependency deployment. Suitable for rapid testing in development environments, single-machine or small application deployments, learning and demonstrating registration center concepts, service management in offline environments, and simple application scenarios that do not require complex registration centers. |
| registry/nacos | Demonstrates comprehensive integration of Alibaba's Nacos service registration center in GoFrame to implement dynamic service management and configuration. This example shows registering services with Nacos using namespace and group isolation, service discovery using instance filtering and selection strategies, built-in health monitoring and heartbeat mechanisms, service metadata and weight-based load balancing, integration with Nacos configuration center, and seamless GoFrame component integration. Key features include: centralized service registration center, real-time service status updates, automated health checks, weighted load balancing support, namespace-based service isolation, production-grade patterns. Suitable for building cloud-native microservices on Alibaba Cloud, implementing dynamic service discovery with configuration management, ensuring service health and availability, and implementing enterprise-level service governance. |
| registry/polaris | Demonstrates comprehensive integration of Tencent Cloud's Polaris service registration center in GoFrame to implement service mesh and traffic management. This example shows registering services with Polaris using advanced configuration options, service discovery integrated with circuit breakers and rate limiting, health check configuration and automatic instance isolation, service routing and traffic management, integration with Polaris mesh to achieve unified governance, and seamless GoFrame component integration. Key features include: service mesh registration center, traffic control strategies, circuit breaker patterns, health-based routing, canary deployment support, production-grade patterns. Suitable for building cloud-native microservices on Tencent Cloud, implementing service mesh architectures, ensuring high availability through traffic management, and implementing advanced service governance with a unified control panel. |