fix length bug
parent
ddbe297947
commit
70596ed8d5
|
@ -114,6 +114,12 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
var futureProducts []structs.FutureProduct
|
||||
|
||||
for _, row := range resp.Values[1:] { // skip first google worksheet row
|
||||
// maybe some error in google sheets table
|
||||
if len(row) < 2 {
|
||||
logger.AddSystemLog(rslogger.LogTypeError, "Skipped row, because row length less than 2")
|
||||
continue
|
||||
}
|
||||
|
||||
// skip to next if id, status or name is empty
|
||||
if row[0] == "" || row[1] == "" || row[2] == "" {
|
||||
continue
|
||||
|
@ -125,13 +131,13 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
|
||||
var productVariant string
|
||||
|
||||
if row[3] != "" {
|
||||
if len(row) >= 3 && row[3] != "" {
|
||||
productVariant = fmt.Sprintf("%v", row[3])
|
||||
}
|
||||
|
||||
var productCharacteristics string
|
||||
|
||||
if row[4] != "" {
|
||||
if len(row) >= 4 && row[4] != "" {
|
||||
productCharacteristics = fmt.Sprintf("%v", row[4])
|
||||
}
|
||||
|
||||
|
@ -166,7 +172,7 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
} else if state == 3 {
|
||||
var url string
|
||||
|
||||
if row[8] != "" {
|
||||
if len(row) >= 8 && row[8] != "" {
|
||||
url = fmt.Sprintf("%v", row[8])
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue