Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit fae30bd

Browse files
committed
query_result: assign result of type assertion to variable
Addressing the static check linter. Signey-off-by: Radim Hrazdil <[email protected]>
1 parent 2725d0d commit fae30bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

platform/model/query_result.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ func (c *QueryResultCol) String(ctx context.Context) string {
3939
if valueExtracted == nil {
4040
return ""
4141
}
42-
switch valueExtracted.(type) {
42+
switch v := valueExtracted.(type) {
4343
case string:
44-
processed, err := json.Marshal(valueExtracted)
44+
processed, err := json.Marshal(v)
4545
if err != nil {
46-
logger.ErrorWithCtx(ctx).Err(err).Msgf("failed to marshal value %v", valueExtracted)
46+
logger.ErrorWithCtx(ctx).Err(err).Msgf("failed to marshal value %v", v)
4747
}
4848
return fmt.Sprintf(`"%s": %s`, c.ColName, string(processed))
4949
case time.Time:
5050
// Format timestamp with consistent microsecond precision
51-
formattedTime := valueExtracted.(time.Time).Format("2006-01-02 15:04:05.000000 -0700 MST")
51+
formattedTime := v.Format("2006-01-02 15:04:05.000000 -0700 MST")
5252
return fmt.Sprintf(`"%s": "%s"`, c.ColName, formattedTime)
5353
case int, int64, float64, uint64, bool:
54-
return fmt.Sprintf(`"%s": %v`, c.ColName, valueExtracted)
54+
return fmt.Sprintf(`"%s": %v`, c.ColName, v)
5555
default:
5656
// Probably good to only use marshaller when necessary, so for arrays/maps,
5757
// and try to handle simple cases without it
58-
marshalled, err := json.Marshal(valueExtracted)
58+
marshalled, err := json.Marshal(v)
5959
if err != nil {
60-
logger.ErrorWithCtx(ctx).Err(err).Msgf("failed to marshal value %v", valueExtracted)
60+
logger.ErrorWithCtx(ctx).Err(err).Msgf("failed to marshal value %v", v)
6161
}
6262
return fmt.Sprintf(`"%s": %v`, c.ColName, string(marshalled))
6363
}

0 commit comments

Comments
 (0)