diff --git a/opengemini/measurement.go b/opengemini/measurement.go index 408071d..390e7bf 100644 --- a/opengemini/measurement.go +++ b/opengemini/measurement.go @@ -64,10 +64,11 @@ func (c *client) ShowSeries(database, command string) ([]string, error) { return []string{}, nil } for _, v := range seriesResult[0].Values { - if _, ok := v.(string); !ok { + strV, ok := v.(string) + if !ok { return series, nil } - series = append(series, v.(string)) + series = append(series, strV) } return series, nil } diff --git a/opengemini/query.go b/opengemini/query.go index b2093c1..f197720 100644 --- a/opengemini/query.go +++ b/opengemini/query.go @@ -110,10 +110,11 @@ func (c *client) showTagSeriesQuery(database, command string) ([]ValuesResult, e tagSeriesRes.Measurement = res.Name for _, valRes := range res.Values { for _, value := range valRes { - if _, ok := value.(string); !ok { + strVal, ok := value.(string) + if !ok { return tagSeries, nil } - tagSeriesRes.Values = append(tagSeriesRes.Values, value.(string)) + tagSeriesRes.Values = append(tagSeriesRes.Values, strVal) } } tagSeries = append(tagSeries, *tagSeriesRes) @@ -143,11 +144,11 @@ func (c *client) showTagFieldQuery(database, command string) ([]ValuesResult, er if len(valRes) < 2 { return tagValueResult, nil } - if _, ok := valRes[0].(string); ok { - tagValue.Name = valRes[0].(string) + if strVal, ok := valRes[0].(string); ok { + tagValue.Name = strVal } - if _, ok := valRes[1].(string); ok { - tagValue.Value = valRes[1].(string) + if strVal, ok := valRes[1].(string); ok { + tagValue.Value = strVal } tagValueRes.Values = append(tagValueRes.Values, *tagValue) }