mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
chore: upgrade golangci-lint configuration and optimize codebase (#4236)
This PR includes the following changes: - **Upgrade `.golangci.yml`**: Updated the configuration file to align with the latest golangci-lint version, ensuring compatibility and leveraging new features. - **Refactor GitHub Action workflow**: Modified `golangci-lint.yml` in the GitHub Actions workflow to reflect the updated configuration and improve CI performance. - **Codebase optimization**: Refactored code to address issues and warnings raised by the updated golangci-lint rules, including: - Improved function length and complexity. - Enhanced error handling and variable naming conventions. - Fixed minor issues such as unused imports and formatting inconsistencies. These changes aim to maintain code quality, ensure compatibility with the latest tools, and improve overall maintainability.
This commit is contained in:
@ -94,7 +94,7 @@ func doPrint(ctx context.Context, content string, stack bool) {
|
||||
buffer.WriteString(" [INTE] ")
|
||||
buffer.WriteString(file())
|
||||
buffer.WriteString(" ")
|
||||
if s := traceIdStr(ctx); s != "" {
|
||||
if s := traceIDStr(ctx); s != "" {
|
||||
buffer.WriteString(s + " ")
|
||||
}
|
||||
buffer.WriteString(content)
|
||||
@ -106,14 +106,14 @@ func doPrint(ctx context.Context, content string, stack bool) {
|
||||
fmt.Print(buffer.String())
|
||||
}
|
||||
|
||||
// traceIdStr retrieves and returns the trace id string for logging output.
|
||||
func traceIdStr(ctx context.Context) string {
|
||||
// traceIDStr retrieves and returns the trace id string for logging output.
|
||||
func traceIDStr(ctx context.Context) string {
|
||||
if ctx == nil {
|
||||
return ""
|
||||
}
|
||||
spanCtx := trace.SpanContextFromContext(ctx)
|
||||
if traceId := spanCtx.TraceID(); traceId.IsValid() {
|
||||
return "{" + traceId.String() + "}"
|
||||
if traceID := spanCtx.TraceID(); traceID.IsValid() {
|
||||
return "{" + traceID.String() + "}"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user