Skip to content

Commit d874cb9

Browse files
committed
try fix table output not stable
1 parent fa802d2 commit d874cb9

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### v0.1.1
44

55
1. 添加 github actions
6+
2. 修复行情命令输出格式不稳定
67

78
### v0.1.0
89

provider/sina/sina.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,39 +335,39 @@ func parseSecQuote(quote string) *SecurityQuote {
335335
newQuote = strings.TrimSuffix(newQuote, "\"")
336336
items := strings.Split(newQuote, ",")
337337
res := new(SecurityQuote)
338-
res.Name = items[0]
338+
res.Name = strings.TrimSpace(items[0])
339339
slog.Debug("parseSecQuote", "quote string", quote, "items", items)
340340
var err error
341-
res.Current, err = strconv.ParseFloat(items[3], 64)
341+
res.Current, err = strconv.ParseFloat(strings.TrimSpace(items[3]), 64)
342342
if err != nil {
343343
slog.Error(err.Error())
344344
}
345-
res.Open, err = strconv.ParseFloat(items[1], 64)
345+
res.Open, err = strconv.ParseFloat(strings.TrimSpace(items[1]), 64)
346346
if err != nil {
347347
slog.Error(err.Error())
348348
}
349-
res.YClose, err = strconv.ParseFloat(items[2], 64)
349+
res.YClose, err = strconv.ParseFloat(strings.TrimSpace(items[2]), 64)
350350
if err != nil {
351351
slog.Error(err.Error())
352352
}
353-
res.High, err = strconv.ParseFloat(items[4], 64)
353+
res.High, err = strconv.ParseFloat(strings.TrimSpace(items[4]), 64)
354354
if err != nil {
355355
slog.Error(err.Error())
356356
}
357-
res.Low, err = strconv.ParseFloat(items[5], 64)
357+
res.Low, err = strconv.ParseFloat(strings.TrimSpace(items[5]), 64)
358358
if err != nil {
359359
slog.Error(err.Error())
360360
}
361-
res.Volume, err = strconv.ParseFloat(items[9], 64)
361+
res.Volume, err = strconv.ParseFloat(strings.TrimSpace(items[9]), 64)
362362
if err != nil {
363363
slog.Error(err.Error())
364364
}
365-
res.TurnOver, err = strconv.ParseInt(items[8], 10, 64)
365+
res.TurnOver, err = strconv.ParseInt(strings.TrimSpace(items[8]), 10, 64)
366366
if err != nil {
367367
slog.Error(err.Error())
368368
}
369-
res.TradeDate = items[30]
370-
res.Time = items[31]
369+
res.TradeDate = strings.TrimSpace(items[30])
370+
res.Time = strings.TrimSpace(items[31])
371371

372372
return res
373373
}

0 commit comments

Comments
 (0)