Skip to content
CAI
Software that uses CAICheck a score

ikaiguang/go-srv-kit

50.2

Adequate · 21 September 2026

15.3k

lines of production code

Go

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a Go-based microservice framework built on the Kratos architecture, providing a comprehensive toolkit for building distributed applications. It offers standardized implementations for service discovery (Consul, Etcd), data persistence (MySQL, PostgreSQL, MongoDB, Redis), and messaging (RabbitMQ), alongside robust utilities for configuration management, authentication, logging, and error handling. The codebase also includes a reference 'ping-service' example that demonstrates the integration of these components, including automated API generation and Docker-based deployment pipelines.

How it got here

2021–2022 — comprehensive kit and infrastructure expansion

43 changes.

This period focused on significantly expanding the project's utility and infrastructure capabilities. The codebase introduced a wide array of new 'kit' packages for encryption, HTTP clients, file handling, and ID generation, while also adding robust data layer integrations for databases, caching, and message queues. Additionally, the framework's core was modernized by removing legacy configuration and logging mechanisms in favor of more standardized, extensible implementations.

2023–2024 — Comprehensive kit and testdata expansion

28 changes.

This period focused on expanding the framework's utility kits, adding robust implementations for logging, error handling, and data access across MongoDB, etcd, and Consul. Simultaneously, the project introduced a complete 'ping-service' testdata module, providing a full-stack reference implementation including service wiring, Docker build scripts, and configuration management tools.

2025–2026 — utility kit and debugging enhancements

5 changes.

This period focused on expanding the project's utility libraries, introducing new packages for pointer management, streaming downloads, UUID generation, and safe goroutine execution. It also added debugging and profiling helpers, including context-aware logging and pprof integration, to improve observability and developer experience.

Features

Add AES, RSA, and utility kits to the toolkit

The toolkit now includes new encryption utilities: an AES cipher supporting both CBC mode with random IVs and a deterministic CBC mode, an RSA cipher for encryption/decryption and PKCS1v15 signing/verification, and a generic ternary operator. Tests and benchmarks are included for all new components.

kit/aes · high confidence

Add Consul client initialization with connection verification

A new Consul client factory is introduced in the data/consul package, providing a Config struct and a NewConsulClient function that builds an api.Client from configuration options. The client is immediately tested with a ping-pong KV pair to verify connectivity upon creation.

data/consul · high confidence

Add Consul registry implementation

Users can now register services with Consul via a new \NewConsulRegistry\ helper in \kratos/registry\. This adds a convenience wrapper that configures health checks, heartbeats, and a default timeout, simplifying the setup of Consul-based service discovery.

kratos/registry · medium confidence

Add IP address utility functions

A new IP utility package has been introduced, providing functions to retrieve the local machine's IPv4 address (LocalIP, NewLocalIP) and validate IP strings (IsValidIP). The implementation includes logic to detect the local IP by querying a DNS server or scanning network interfaces, with caching via sync.Once to avoid repeated network calls.

kit/ip · high confidence

Add JSON marshaling functions that disable HTML escaping

The kit now provides \MarshalWithoutEscapeHTML\ and \MarshalIndentWithoutEscapeHTML\ functions that serialize data to JSON without escaping HTML characters (e.g., \\<\, \\>\, \&\). These functions use a thread-safe buffer pool to ensure concurrent safety, and the package includes concurrency safety tests to verify that the implementation is free of data races.

kit/json · high confidence

Add JWT authentication and token management utilities

The kratos/auth package now includes a comprehensive JWT authentication kit. This adds support for generating, signing, and validating access and refresh tokens, with configurable expiration times and support for different token types (USER, ADMIN, EMPLOYEE). The change introduces a token manager for storing and managing tokens in Redis, including features for token blacklisting, login limits, and token validation. Error handling is standardized with specific error codes for missing tokens, expired tokens, and invalid claims.

kratos/auth · high confidence

Add Jaeger exporter with HTTP and gRPC support

Users can now configure and initialize a Jaeger trace exporter via the new \NewJaegerExporter\ function, which supports both HTTP and gRPC protocols. The implementation validates the connection endpoint and allows configuration of timeout and insecure mode, with corresponding tests verifying the creation of the OpenTelemetry OTLP trace exporter.

data/jaeger · high confidence

Add MD5 utility functions for hashing strings and files

A new md5 package has been added to the kit, providing utility functions to compute MD5 hashes. It includes a Md5 function for hashing byte slices and a new FileMd5 function for calculating the MD5 hash of a file's contents. Tests have been added to verify the string hashing functionality.

kit/md5 · high confidence

Add OS detection utility for Windows

A new \IsWindows()\ function is introduced in the \kit/os\ package, allowing users to programmatically detect if the application is running on a Windows operating system. This includes a corresponding test to verify the detection logic.

kit/os · high confidence

Add RabbitMQ integration kit with publisher, subscriber, and logging support

A new RabbitMQ integration kit is introduced in the data/rabbitmq directory, providing factory functions to create AMQP publishers and subscribers via the watermill-amqp library. The kit supports durable and non-durable queue configurations, TLS connections, and custom logging through a Watermill logger adapter that bridges to the Kratos logger. A test file is also added to verify subscriber and publisher functionality.

data/rabbitmq · high confidence

Add Snowflake ID generation kit

Introduced a new \kit/snowflake\ package that provides distributed, monotonically increasing 64-bit IDs using the \sonyflake\ library. The kit exposes functions to generate unique IDs (\ID\, \NextID\) and allows for custom node configuration (\NewNode\, \SetNode\). A corresponding test file (\snowflake.kit\_test.go\) was added to verify ID uniqueness, monotonicity, and basic generation.

kit/snowflake · high confidence

Add buffer pool utility in kit/buffer

A new buffer pool utility has been added to kit/buffer, providing a thread-safe way to reuse bytes.Buffer instances via GetBuffer and PutBuffer functions. The implementation uses a sync.Pool to manage the buffers, ensuring that returned buffers are reset before being returned to the pool. Tests confirm that buffers are correctly reset upon return and that concurrent access is safe.

kit/buffer · high confidence

Add command execution utilities with context support

The kit/cmd package now provides new functions for executing system commands. RunCommandContext and RunCommandWithWorkDirContext allow running commands with a context for cancellation and logging, while the older RunCommand and RunCommandWithWorkDir functions are marked as deprecated. The implementation uses a buffer pool from kit/buffer for stdout/stderr handling. Additionally, a new file provides cross-platform shell execution helpers (Linux/macOS and Windows).

kit/cmd · high confidence

Add configuration templates and upload utility for Consul integration

Added a new \testdata/configuration\ directory containing YAML configuration templates for various services (MySQL, Redis, Jaeger, etc.) and a Go utility (\main.go\) to read local config files and upload them to a Consul key-value store. The setup includes a README explaining the path prefixing logic and usage examples for both general and service-specific configurations.

testdata/configuration · high confidence

Add context utilities for client IP extraction and transport matching

New helper functions have been added to the \contextpkg\ package to simplify extracting the client's IP address from HTTP and gRPC requests. The \ClientIP\ function automatically detects the transport type and extracts the IP from headers (e.g., \X-Forwarded-For\, \X-Real-IP\) or gRPC metadata. Additionally, the package provides utilities to match HTTP and gRPC server contexts, as well as methods to set and retrieve the client IP from the Go context.

kratos/context · high confidence

Add download and UUID utility kits

Introduced new utility kits for the application: a download kit that provides a streaming download function with progress reporting and a UUID kit that wraps the xid and uuid libraries to generate and manage unique identifiers. Both kits include comprehensive test coverage to ensure reliability.

kit/download · high confidence

Add email kit with template-based code verification emails

The kit/email package introduces a new email utility for sending verification code emails. It provides a Sender struct and Message struct for basic email sending, along with a CodeMessage type that renders an HTML template (email\_code.html) containing the verification code and issuer. The package exposes a Client interface with Send and SendCode methods, plus a DefaultClient implementation that wraps the functional Send/SendCode functions. A test file (email.kit\_test.go) is also added to verify the SendCode flow.

kit/email · high confidence

Add error handling kit with enum-based error codes and stack traces

The \kratos/error\ package now includes a comprehensive error handling kit. This introduces a generated \ERROR\ enum containing standard HTTP status codes (e.g., \BAD\_REQUEST\, \NOT\_FOUND\, \INTERNAL\_ERROR\) and specific application errors (e.g., \DB\, \CACHE\, \MQ\). The kit provides utility functions to create, wrap, and inspect errors, including \FormatError\, \WithStack\, \Wrap\, and \Kvs\ for adding metadata. It also adds stack trace capabilities via \Caller\ and \Println\ functions, with a configurable \DefaultStackTracerDepth\ (default 9). Additionally, helper functions like \IsCustomError\, \IsCode\, and \IsReason\ allow for easy error type checking. The change also includes a README and test files for the new functionality.

kratos/error · high confidence

Add filepath utility functions for directory traversal and management

A new \filepath\ package is introduced, providing utilities for directory operations. This includes \WalkDir\ for traversing directories using \filepath.WalkDir\ and \fs.DirEntry\, alongside a deprecated \WaldDir\ for backward compatibility. The package also offers \ReadDirEntries\ (using \os.ReadDir\) and a deprecated \ReadDir\ for reading directory contents, as well as \CreateDir\ and \RenewDir\ for directory creation and recreation.

kit/filepath · high confidence

Add generic slice utility functions with tests

The kit/slice package now provides generic helper functions for slice manipulation. Specifically, it introduces \ReverseSlice\ for in-place reversal and \Contains\ for element existence checks, both leveraging Go's standard \slices\ package. The implementation also includes a deprecated \Reverse\ function that uses reflection, alongside \InStringSlice\ as a legacy alias for \Contains\. Comprehensive tests have been added to verify the behavior of these new utilities, including edge cases like empty and nil slices.

kit/slice · high confidence

Add header parsing utilities and local/distributed locking primitives

The kit now provides HTTP header constants and helper functions for request ID, trace ID, and WebSocket detection, alongside a new locking subsystem. The locking subsystem introduces a \Locker\ interface with \Mutex\ (blocking) and \Once\ (auto-expiring) modes, supported by a \LocalLocker\ implementation for single-process use and a \DistributedLocker\ wrapper for external providers like Redis. Tests are included for both local and cache-based lockers.

kit/locker · medium confidence

Add new etcd client with TLS and connection verification

A new etcd client implementation is introduced in data/etcd/etcd.kit.go, providing a Config struct for endpoints, credentials, and TLS settings. The client initialization now supports mutual TLS via CA certificates and includes a ping/pong verification step to ensure connectivity upon creation.

data/etcd · high confidence

Add pagination kit with request/response models and helper utilities

Introduces a new \kit/page\ module providing pagination support. This includes \PageRequest\ and \PageResponse\ Protobuf messages for handling pagination parameters and results, along with Go utilities to parse and validate page numbers and sizes (capping the maximum page size at 1000). The kit also provides helper functions to calculate total pages, check for next pages, and determine display ranges, accompanied by comprehensive unit tests.

kit/page · high confidence

Add password hashing and verification utilities

Added a new password utility kit that provides functions to hash and verify passwords using the bcrypt algorithm. The implementation includes Encrypt and Compare functions for direct usage, as well as a PasswordHash struct with Encrypt and Verify methods for structured access. Tests are included to verify the encryption and comparison logic.

kit/password · high confidence

Add path utility to retrieve current source directory

A new \path\ package is introduced in the \kit\ directory, providing a \Path()\ function that returns the directory of the current source file using \runtime.Caller\. A corresponding test ensures the returned path is non-empty, not just '.', and ends with 'path'.

kit/path · high confidence

Add ptr package with generic pointer utilities

The kit/ptr package introduces a new set of utility functions for working with pointers. It provides generic \Ptr\ and \Value\ functions that handle pointer creation and safe dereferencing (returning zero values for nil pointers). Additionally, it offers \Slice\ and \ValueSlice\ to convert between value slices and pointer slices. To maintain backward compatibility, the package also includes deprecated, type-specific functions (e.g., \String\, \Int\, \Bool\) that wrap the new generic implementations.

kit/ptr · high confidence

Add random utility functions for generating strings, numbers, and tokens

The kit/random package introduces a new set of random generation utilities, including functions for creating random strings (alphanumeric, hex, lowercase), random integers within ranges, and specialized generators for passwords, verification codes, tokens, order numbers, and trace IDs. The package also provides generic helpers for selecting or shuffling elements in slices. Comprehensive tests are included to verify the behavior of each function.

kit/random · high confidence

Add reflect utility functions for value inspection and manipulation

Added kit/reflect package providing reflection-based utilities: IsDefaultValue to check if a value is the Go zero value, IsEmpty to determine if an object is empty or nil, SwapObject to copy values between pointers, and NewObject to create new instances of a given type. Includes comprehensive tests for all functions.

kit/reflect · high confidence

Add regex validation utilities for phone, email, ID card, and post code

A new \kit/regex\ package was introduced, providing four validation functions: \IsPhone\, \IsEmail\, \IsIDCard\, and \IsPostCode\. These functions use compiled regular expressions to validate Chinese mobile phone numbers, email addresses, ID card numbers (both 15 and 18 digit formats), and 6-digit postal codes. The implementation includes comprehensive unit tests covering valid and invalid inputs for each validator.

kit/regex · high confidence

Add snowflake-based ID generation utility

The kit now includes a new ID generation utility that provides a global \NextID()\ function for generating unique identifiers using the Bwmarrin Snowflake algorithm, with a fallback to Sony's Sonyflake implementation. The implementation derives a node ID from the local machine's IPv4 address to help ensure uniqueness across distributed systems, and includes a README referencing similar implementations like Meituan Leaf and Baidu uid-generator.

kit/id · high confidence

Add testdata/configs with comprehensive configuration templates

Added a new testdata/configs directory containing a Go helper for resolving configuration paths and a complete YAML configuration file (config\_all.yaml) that defines settings for the application, server, logging, MySQL, PostgreSQL, MongoDB, and Redis. This provides a full-featured reference configuration for testing and development environments.

testdata/configs · high confidence

Add testdata/ping-service internal service and business logic

The ping-service testdata module now includes the full internal implementation for handling ping requests, including the business logic (biz), data access layer (data), and service layer (service). This adds the ability to process HTTP and gRPC ping requests, handle WebSocket connections, and return mock responses for testing purposes.

testdata/ping-service/internal · high confidence

Add time utility functions and constants

A new time utility package (kit/time) has been added, providing a collection of helper functions for date and time operations. This includes constants for common date formats, functions to truncate or round times to the start of the day/hour/minute/month/year, check if a date is today/yesterday/this week/month/year, calculate the difference in days between two dates, and add days or months to a time. The package also includes comprehensive tests for all these utilities.

kit/time · high confidence

Add zip and unzip utilities to the kit

A new \kit/zip\ package has been introduced, providing functions to compress and decompress files and directories into \.zip\ archives. The \zip.kit.go\ file implements \Zip\ and \ZipFile\ for creating archives and \Unzip\ for extracting them, while \zip.kit\_test.go\ adds corresponding test coverage for these operations.

kit/zip · medium confidence

Added Chinese character encoding utilities

A new file, gbk.kit.go, was added to the kit/chinese package, providing functions to convert between GBK and UTF-8 encodings and to detect whether a string is valid UTF-8 or GBK.

kit/chinese · high confidence

Added Docker build scripts and Dockerfiles for the ping-service

Introduced a new Docker build pipeline for the ping-service, including three multi-stage Dockerfiles (base, release, and service images) and corresponding shell scripts to automate the image building process. The configuration sets the Go base image to golang:1.24.10 and configures the Go module proxy to use goproxy.cn, while also setting the system timezone to Asia/Shanghai.

testdata/ping-service/devops/docker-build/service-image · high confidence

Added Google API and Protobuf third-party definitions

The project has added a collection of third-party Protocol Buffer definitions to the \third\_party\ directory. This includes Google API annotations (such as \annotations.proto\, \client.proto\, \field\_behavior.proto\, \http.proto\, and \httpbody.proto\) which enable gRPC-REST transcoding and field behavior annotations, as well as standard Protobuf well-known types (including \any.proto\, \api.proto\, \descriptor.proto\, \duration.proto\, \empty.proto\, and \field\_mask.proto\). These files provide the necessary schema definitions for API configuration and data types used by the application's service layer.

_third\party · high confidence

Added Makefile for building and deploying the ping-service test environment

A new Makefile (makefile\_cicd.mk) has been added to the ping-service devops directory, introducing build and deployment targets for the test environment. Users can now run 'make build' to construct the service image using specified base images (golang:1.24.10, debian:stable-20250520) and deploy configurations or database migrations via dedicated targets. The file also provides commands to start, stop, and restart the Docker-based test environment using docker-compose.

testdata/ping-service/devops · medium confidence

Added Makefile targets for generating API protobufs

A new Makefile, api/makefile\_protoc.mk, was added to automate the generation of API protobufs. It introduces the 'protoc-api-protobuf' target to generate all services and a 'protoc-specified-api' target that accepts a 'service' variable to generate protobufs for a specific service.

api · high confidence

Added Redis client and distributed locking kit

The data/redis package now includes a new Redis client implementation (NewDB) that configures and connects to a Redis instance using go-redis/v9, along with a distributed locker implementation (NewLocker) that wraps redsync to provide exclusive locking (Once) and mutex-based locking (Mutex) with automatic extension. Tests have been added to verify connection, set/get operations, and lock/unlock behavior.

data/redis · high confidence

Added URL utility functions for encoding and URL construction

The kit/url package now provides new utility functions for URL manipulation. Users can use Encode and EncodeValues to replace plus signs with %20 in query string values, GenRequestURL to concatenate endpoint and API path, and SplicingQueryParam to append encoded query parameters to a base URL. A corresponding test suite validates these behaviors.

kit/url · high confidence

Added all-in-one server entry point for testing

A new Go entry point at testdata/ping-service/cmd/all-in-one/main.go has been added. This file configures and launches a combined server using the go-srv-kit framework, integrating the ping-service's configuration, middleware whitelists, and service exporters. This change provides a unified way to run the service for testing purposes.

testdata/ping-service/cmd/all-in-one · medium confidence

Added client utility functions for HTTP and gRPC connections

A new file, client.kit.go, was added to the kratos/client package, introducing helper functions for creating HTTP and gRPC clients. This includes a generic NewHTTPClient and NewGRPCClient, as well as a specialized NewSampleHTTPClient that configures recovery middleware and a custom response decoder for handling JSON and protobuf data.

kratos/client · medium confidence

Added connection validation and WebSocket detection utilities

Added new utility functions for connection management. The \connection.kit.go\ file introduces \IsWebSocketConn\ to detect WebSocket upgrade headers and \CheckEndpointValidity\/\IsValidConnection\ to verify TCP connectivity to a given endpoint. Additionally, \connection\_error.kit.go\ provides \IsConnCloseErr\ to identify closed network connection errors.

kit/connection · high confidence

Added curl HTTP client kit and sort utilities

Introduced a new HTTP client utility in kit/curl that provides helper functions for creating and executing HTTP requests (GET, POST, and generic methods) with configurable timeouts and optional TLS certificate verification skipping. Additionally, added sorting utilities in kit/sort that include generic Sort and SortFunc functions for ordered types, alongside deprecated wrappers for int32, int64, and their slice types.

kit/curl · high confidence

Added database initialization utilities for MySQL and PostgreSQL

New utility files were added to the data directory to initialize database connections for both MySQL and PostgreSQL using GORM. Each database type now has a dedicated module (mysql.kit.go, postgres.kit.go) that provides configuration structs and factory functions (NewMysqlDB, NewPostgresDB) to establish database connections with configurable logging, connection pooling, and slow query thresholds. The implementation also includes helper functions (IsErrDuplicatedKey) to detect duplicate key errors specific to each database driver. Corresponding test files (mysql.kit\_test.go, postgres.kit\_test.go) were added to verify the database connection and ping functionality.

data/mysql · high confidence

Added database migration tooling for the ping-service

A new command-line tool has been added to handle database migrations for the ping-service. This includes a main entry point that initializes the database connection and executes migration routines, alongside a migration package that manages schema initialization and future upgrade paths. The tooling is located in the testdata directory, indicating it is intended for testing or demonstration purposes.

testdata/ping-service/cmd/database-migration · high confidence

Added debug logging utilities with context support

New files in the debug package provide a suite of logging functions (Print, Debug, Info, Warn, Error, Fatal) and their formatted variants, all delegating to a central handler. The addition includes both standard logging calls and context-aware versions (e.g., DebugWithContext) that propagate the Go context to the underlying logger, enabling better traceability in distributed systems.

kratos/debug · medium confidence

Added file-rotating writer implementation

The kit now includes a new \writerpkg\ package providing a \NewRotateFile\ function that creates an \io.Writer\ backed by \github.com/lestrrat-go/file-rotatelogs\. This allows users to write logs to files that automatically rotate based on configurable time, size, or age parameters, with support for custom filename suffixes. A corresponding test suite validates the rotation behavior.

kit/writer · high confidence

Added generated API code and build scripts for the ping-service

Added new files in the \testdata/ping-service/api\ directory to support the ping-service API. This includes Makefiles (\makefile\_protoc.mk\) to automate the generation of Protocol Buffers and gRPC/HTTP handlers. It also includes the generated Go code for the \ping-service\ v1 API, comprising the \PingReq\ and \PingResp\ resource messages, the \SrvPing\ service definition with a \Ping\ RPC, and associated error enums. Additionally, an \auth\_white\_list.api.go\ file was added to define the authentication whitelist for the service, and README files were added to document the code generation process.

testdata/ping-service/api · high confidence

Added pprof and etcd registry helper functions

Users can now easily register standard Go pprof HTTP handlers on a Kratos HTTP server via a new \RegisterPprof\ function, and create an etcd registry instance with default retry settings via a new \NewEtcdRegistry\ helper.

_kratos/pprof, kratos/registry\etcd · high confidence

Added safe goroutine execution with panic recovery

A new 'thread' package was introduced, providing utility functions (Go, GoSafe, GoSafeWithContext) that launch goroutines and automatically recover from panics, logging the error and stack trace via slog. A corresponding test file was added to verify the panic-recovery behavior.

kit/thread · high confidence

Added service API utility functions for ping-service

A new utility file (service\_api.util.go) was added to the testdata/service-api directory. It defines service name constants (including ping-service, nodeid-service, feishu-openapi, and dingtalk-openapi variants) and provides helper functions to create gRPC and HTTP clients for the ping-service, allowing callers to easily obtain typed clients via a service API manager.

testdata/service-api · high confidence

Added store-configuration utility for pushing configs to Consul

A new command-line utility has been added at testdata/ping-service/cmd/store-configuration. It reads local configuration files and stores them into a Consul key-value store, supporting flags for the config path, source directory, and store directory. This tool can be run via 'go run' or built into a binary to migrate local configuration files into Consul.

testdata/ping-service/cmd/store-configuration · high confidence

Added string utility functions for case conversion and type conversion

The kit/string package now includes new string manipulation utilities. It provides ToSnake and ToCamel functions for converting between snake\_case and CamelCase string formats, alongside a generic ToString function that safely converts various data types (including int, float, and byte slices) into strings.

kit/string · high confidence

Added testdata package and remote host configuration guide

A new \testdata\ package has been introduced, containing a Go file for the package and a README. Additionally, a new file \README-REMOTE-HOST.md\ was added, which provides instructions for configuring the local hosts file to map service hostnames like \testing-service-hostname\ to \127.0.0.1\ for development environments.

testdata · high confidence

Added transport kind helper in kratos/transport

A new file transport.kit.go was added to the kratos/transport package, introducing a TransportKind helper function. This function extracts the transport kind from the server context by wrapping the underlying go-kratos/kratos/v2/transport.FromServerContext call, providing a convenient way to determine the service type (e.g., HTTP, gRPC) within the application.

kratos/transport · high confidence

Introduce export-based service wiring for the ping-service testdata

The ping-service testdata now uses an export package to centralize service wiring. A new \export\ directory contains \wire.go\ (with a \wireinject\ build tag) and a generated \wire\_gen.go\ that assemble the HTTP/GRPC servers, business logic, and data layers. \main.go\ is added to bootstrap the application using \serverutil.AllInOneServer\, and a \README.md\ documents the \wire\ code-generation step. This change shifts how the service is constructed, making the wiring explicit and generated rather than inline.

testdata/ping-service/cmd/ping-service · high confidence

Introduce new MongoDB client initialization and monitoring

Added new files in the data/mongo package to provide a standardized way to instantiate a MongoDB client with configurable connection parameters (hosts, timeouts, pool sizes) and a command monitor that logs all commands, warns on slow queries, and logs failures. A test file was also added to verify the client initialization.

data/mongo · high confidence

Introduce protobuf-based configuration schema for the application

The system now defines a comprehensive, code-generated configuration schema for managing application settings, service endpoints, and infrastructure connections. This new \config\ API introduces a \Bootstrap\ message that centralizes configuration for HTTP/GRPC servers, logging (including JSON format support), database connections (MySQL, PostgreSQL, Redis, MongoDB), and service registries (Consul, Etcd). The addition of these \.proto\ definitions and their Go implementations enables structured, validated configuration loading at startup, supporting multi-instance setups and standardized validation rules for all configuration fields.

api/config · high confidence

Introduce structured database migration framework

Added a new database migration system in the \data/migration\ package, providing a standardized way to manage schema changes. The implementation includes a \MigrationInterface\ for defining up/down operations, concrete migrators for creating and dropping tables, and a \MigrateRepo\ to track and execute migrations against both MySQL and PostgreSQL databases. This allows the application to safely apply and roll back database schema changes.

data/migration · high confidence

Introduces GORM utility kit for database operations

The \data/gorm\ directory now contains a comprehensive GORM helper library (\gormpkg\) that provides reusable database utilities. This includes a transaction manager with automatic rollback on error, a batch insert mechanism supporting MySQL's \ON DU...\ (conflict resolution) and Postgres \ON CONFLICT\ syntax, and helper functions for soft deletes, query conditions, sorting, and pagination. The package also adds error detection helpers for common GORM errors like \ErrRecordNotFound\ and \ErrDuplicatedKey\, along with connection and logging configuration tools.

data/gorm · high confidence

Introduces new app-level utilities for environment management, HTTP response encoding, and logging

The kratos/app package now includes a comprehensive set of utilities for application configuration and HTTP handling. A new environment management system has been added, allowing the application to track and switch between runtime states such as LOCAL, DEVELOP, TESTING, UAT, PREVIEW, and PRODUCTION. Additionally, the package provides custom HTTP response encoders and decoders for both success and error cases, ensuring consistent JSON formatting and header handling. A dedicated 404 handler is also included. The package further introduces structured logging middleware that captures request details like client IP, latency, and operation info, along with helper functions for JSON marshalling and unmarshalling.

kratos/app · high confidence

Introduces new middleware implementations for CORS, rate limiting, tracing, and validation

The kratos/middleware package now includes new middleware implementations: a CORS handler allowing specific headers, methods, and origins; a rate limiter using a BBR algorithm with a 429 error on limit exceeded; a header middleware that injects trace and request IDs into request and response headers; a validator middleware that checks for a Validate() method on requests; and a tracer configuration utility for setting up OpenTelemetry tracing providers. These changes add new capabilities for cross-origin requests, traffic control, distributed tracing, and request validation.

kratos/middleware · high confidence

New base64 encoding and decoding utilities

Added a new base64 utility package that provides Encode, Decode, EncryptToString, and DecryptToString functions. The package includes an Encryptor interface and a B64 struct implementation for encoding and decoding base64 strings, along with example functions for standard encoding and decoding operations.

kit/base64 · high confidence

New command-line tool for generating and executing Protocol Buffer scripts

A new Go-based CLI tool has been added to the 'cmd' directory, designed to locate .proto files within a specified directory, generate shell scripts containing Kratos client commands for each file, and execute those scripts. The tool supports cross-platform execution by detecting the operating system to select the appropriate shell (/bin/sh for Linux/macOS, cmd.exe for Windows). The README has been updated to reflect the tool's purpose as a set of quick utility tools.

cmd · high confidence

New file utility functions for copying, moving, and hashing files

Added new file utility functions to the kit. Users can now copy files (CopyFile), move files to a directory (MoveFileToDir), and compute file hashes (Md5, Sha256) along with generating unique identifiers based on hash and size. Tests have been added to verify these new capabilities.

kit/file · high confidence

New logging kit with multi-logger, file rotation, and context-aware helpers

The \kratos/log\ package introduces a comprehensive logging kit (\logpkg\) providing multiple output targets: console (stdout) logging with configurable JSON or console encoding, file logging with automatic rotation by size or time, and a dummy/nop logger for testing. It includes a \MultiLogger\ to write to multiple destinations simultaneously, an \AsyncWriter\ for non-blocking log writes, and a global helper (\Setup\) that allows easy integration with existing code. Additionally, context-aware logging functions (e.g., \InfoWithContext\) are provided to propagate request context through logs. The changes also include extensive unit tests for all new components.

kratos/log · high confidence

New service utility packages for configuration, client management, and authentication

The service area introduces several new utility packages to support service initialization and client management. The \service/app\ package provides helpers for application configuration, environment parsing, and HTTP decoder/encoder setup. The \service/cluster\_service\_api\ package introduces a client utility for managing connections to other services, supporting both HTTP and gRPC transports with optional Consul or Etcd registry discovery, and includes a \WithSkipRegistryCheck\ option to bypass health checks during startup. The \service/auth\ package adds an authentication manager for handling token and auth repository access. Additionally, the \service/config\ package adds utilities for loading and merging configuration from local files or Consul, and the \service/consul\ package provides a manager for Consul client initialization.

service · high confidence

Removals

Removed custom logutil logging implementation

The custom log utility package (logutil) has been removed from the codebase. This includes the deletion of files responsible for standard output logging (log\_std.kit.go), file-based logging with rotation (log\_file.kit.go), log level conversion (log\_level.kit.go), and configuration structures (log\_config.kit.go). This change eliminates the internal logging abstraction layer, likely to simplify the codebase or migrate to a different logging strategy.

log · high confidence

Removed generated configuration code and proto definitions

The \conf.proto\ file, which defined the structure for application, tracing, server, logging, and data (including Redis and database configurations), has been removed, along with its corresponding \conf.pb.go\ Go source file and the \README.md\. This eliminates the auto-generated Protobuf code for the internal configuration package, meaning the application no longer uses this specific Protobuf-based configuration loading mechanism.

example/internal/conf · high confidence

Behavioural changes

Added Makefile targets for running and testing the ping-service

A new Makefile (makefile\_run.mk) has been added to the testdata/ping-service/cmd directory. This file introduces build and test automation for the ping-service, including targets to run the service (run-ping-service, run-service, run-all-in-one) and to execute integration tests against local endpoints (testing-ping-service, testing-all-in-one).

testdata/ping-service/cmd · medium confidence

Removal of legacy configuration loading mechanism

The legacy configuration loading mechanism has been removed. Specifically, the \config/README.md\ documentation and the \config/config.kit.go\ file, which previously handled command-line flag parsing for the config file path, have been deleted. This eliminates the previous method of specifying the configuration directory via the \-conf\ flag.

config · high confidence

Removed obsolete example/cmd/main/mian.go entry point

The file example/cmd/main/mian.go, which previously defined the application's main entry point and the newApp function for initializing the Kratos application, has been removed. This change eliminates the legacy startup logic and associated flags for name and version, streamlining the example's structure.

example/cmd · medium confidence

Test coverage

Added test fixtures for page pagination

Added test data and unit tests for the page package. This includes a new Go test file (page\_gorm.kit\_test.go) that validates page request parsing for various page numbers, along with supporting test data files (testdata.page.go and testdata.page.sql) that define the User model and a sample users table for testing pagination logic.

kit/page/testdata · high confidence

Dependencies

Updated Go dependencies and runtime version

The project has been upgraded to Go 1.25.9 and significantly updated its dependencies. The core framework, go-kratos/v2, was upgraded from v2.0.5 to v2.9.2. Additional libraries were added or updated to support new features, including watermill for message queues, go-redis for caching, gorm for database access, and various OpenTelemetry and tracing libraries.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 45 → 50 (+5.4)
  • Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 94 → 96 (+1.9)
  • Architecture 99 → 90 (-9.5)
  • Maturity 60 → 60 (-0.3)
  • Readiness 25 → 34 (+8.7)
  • Security 61 → 60 (-0.2)
  • Domain Modelling 54 → 61 (+7.2)

Resolved (34)

  • Change coupling: app.kit.go ↔ app_json_handler.kit.go (kratos/app/app.kit.go)
  • Coverage not included — suite not readable by the collector
  • Critical CVE: [GHSA redacted] (go.mod)
  • Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
  • Duplicated block (10 lines × 2) (service/logger/logger_writer.util.go)
  • Duplicated block (11 lines × 2) (service/mysql/mysql.util.go)
  • Duplicated block (12 lines × 2) (service/cluster_service_api/client_grpc_conn.util.go)
  • Duplicated block (12 lines × 2) (service/config/config_from_consul.util.go)
  • Duplicated block (13 lines × 2) (data/mysql/mysql.kit.go)
  • Duplicated block (13 lines × 2) (service/logger/logger_instance.util.go)
  • Duplicated block (15 lines × 2) (kratos/auth/auth_token.kit.go)
  • Duplicated block (7 lines × 4) (service/logger/logger_instance.util.go)
  • Duplicated block (9 lines × 2) (kratos/auth/auth_token_manger.kit.go)
  • Duplicated block (9 lines × 2) (kratos/log/log_console.kit.go)
  • Duplicated block (9 lines × 2) (kratos/log/log_console.kit.go)
  • Duplicated block (9 lines × 3) (service/logger/logger_writer.util.go)
  • High vulnerability: [GHSA redacted] (go.mod)
  • LLM evaluation failed
  • Medium CVE: [GHSA redacted] (go.mod)
  • Medium CVE: [GHSA redacted] (go.mod)
  • …and 14 more

New (106)

  • Critical CVE: [GHSA redacted] (go.mod)
  • Critical CVE: [GHSA redacted] (go.mod)
  • Dependency pinned to a stale untagged commit: gopkg.in/gomail.v2
  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • Duplicated block (10 lines × 2) (kratos/auth/auth_token_manger.kit.go)
  • Duplicated block (10 lines × 2) (kratos/log/log_console.kit.go)
  • Duplicated block (10 lines × 4) (service/consul/consul_provider.util.go)
  • Duplicated block (10 lines × 5) (service/consul/consul.util.go)
  • Duplicated block (10 lines × 5) (service/logger/logger_provider.util.go)
  • Duplicated block (12 lines × 2) (service/cluster_service_api/client_grpc_conn.util.go)
  • Duplicated block (12 lines × 2) (service/server/server_grpc.util.go)
  • Duplicated block (13 lines × 2) (data/consul/consul_option.kit.go)
  • Duplicated block (14 lines × 2) (kratos/log/log_console.kit.go)
  • Duplicated block (15 lines × 2) (service/config/config_from_consul.util.go)
  • Duplicated block (15 lines × 2) (service/logger/logger_instance.util.go)
  • Duplicated block (15 lines × 3) (service/logger/logger_writer.util.go)
  • Duplicated block (16 lines × 2) (data/mysql/mysql.kit.go)
  • Duplicated block (17 lines × 2) (data/mysql/mysql.kit.go)
  • Duplicated block (18 lines × 2) (service/mysql/mysql.util.go)
  • …and 86 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

ikaiguang/go-srv-kit was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit c1374946d8c6883aac5b246f15674932a7aa36c3 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-fa71c66cabd8.