terjadi error:
echo: http: panic serving [::1]:59064: runtime error: index out of range [1] with length 1

code yang dipakai:
perbaiki kode tersebut:
func MetricReadStatusMapper(compareData map[string]interface{}, sReference interface{}, dataOld string, userReadStatus string, dataNew string) []map[string]interface{} {

	var sReferences []map[string]interface{}
	json.Unmarshal([]byte(sReference.(string)), &sReferences)

	split := strings.Split(userReadStatus, ",")
	for _, value := range sReferences{
		key := ShrimpEstateMetricKey[value["key"].(string)]

		statusDataOld := "good"
		statusDataNew := "wary"

		keyIndex := key.(int)
		splitDataOld := strings.Split(dataOld, ",")[keyIndex]
		for _, sReference := range sReferences {
			if splitDataOld == sReference["key"].(string) {
				var reference []map[string]interface{}
				byteReference, _ := json.Marshal(sReference["reference"])
				json.Unmarshal(byteReference, &reference)

				checker := false
				for _, refValue := range reference {
					var parameter []map[string]interface{}
					byteParameter, _ := json.Marshal(refValue["parameter"])
					json.Unmarshal(byteParameter, &parameter)

					for _, parValue := range parameter {
						convRaw, _ := strconv.ParseFloat(splitDataOld, 64)
						if !checker {
							statusDataOld = refValue["status"].(string)
							switch parValue["type"] {
							case "greater-than":
								conv, _ := strconv.ParseFloat(parValue["value"].(string), 64)
								if conv < convRaw {
									checker = true
									break
								}
							case "lower-than":
								conv, _ := strconv.ParseFloat(parValue["value"].(string), 64)
								if conv > convRaw {
									checker = true
									break
								}
							case "between":
								splitVal := strings.Split(parValue["value"].(string), "-")
								fConv, _ := strconv.ParseFloat(splitVal[0], 64)
								sConv, _ := strconv.ParseFloat(splitVal[1], 64)
								if fConv <= convRaw && sConv >= convRaw {
									checker = true
									break
								}
							}
						}
					}
				}
			}
		}

		splitDataNew := strings.Split(dataNew, ",")[keyIndex]
		for _, sReference := range sReferences {
			if splitDataNew == sReference["key"].(string) {
				var reference []map[string]interface{}
				byteReference, _ := json.Marshal(sReference["reference"])
				json.Unmarshal(byteReference, &reference)

				checker := false
				for _, refValue := range reference {
					var parameter []map[string]interface{}
					byteParameter, _ := json.Marshal(refValue["parameter"])
					json.Unmarshal(byteParameter, &parameter)

					for _, parValue := range parameter {
						convRaw, _ := strconv.ParseFloat(splitDataNew, 64)
						if !checker {
							statusDataNew = refValue["status"].(string)
							switch parValue["type"] {
							case "greater-than":
								conv, _ := strconv.ParseFloat(parValue["value"].(string), 64)
								if conv < convRaw {
									checker = true
									break
								}
							case "lower-than":
								conv, _ := strconv.ParseFloat(parValue["value"].(string), 64)
								if conv > convRaw {
									checker = true
									break
								}
							case "between":
								splitVal := strings.Split(parValue["value"].(string), "-")
								fConv, _ := strconv.ParseFloat(splitVal[0], 64)
								sConv, _ := strconv.ParseFloat(splitVal[1], 64)
								if fConv <= convRaw && sConv >= convRaw {
									checker = true
									break
								}
							}
						}
					}
				}
			}
		}

		if statusDataOld != statusDataNew {
			keyIndex := key.(int)
			split[keyIndex] = "false"
		}
	}

	join := strings.Join(split, ",")
	userReadStatus = join
	return sReferences
}

var ShrimpEstateMetricKey = map[string]interface{}{
	"water-temperature": 0,
	"dissolved-oxygen":  1,
	"turbidity":         2,
	"water-ph":          3,
	"air-temperature":   4,
	"air-humidity":      5,
	"tds":               8,
}

func (u commandUsecase) Create(ctx context.Context, payload map[string]interface{}) utils.Result {
	var result utils.Result

	var data = make(map[string]interface{})
	var dataReadStatus string

	if payload["platform"] == "antares" {
		if payload["m2m:sgn"].(map[string]interface{})["m2m:nev"] != nil {
			con := payload["m2m:sgn"].(map[string]interface{})["m2m:nev"].(map[string]interface{})["m2m:rep"].(map[string]interface{})["m2m:cin"].(map[string]interface{})["con"].(string)
			json.Unmarshal([]byte(con), &data)
		}
	} else if payload["platform"] == "itdri" {
		queryDeviceRes := <-u.postgreQuery.FindOne(&queries.QueryPayload{
			Table:  "smartfarm_partner_devices",
			Select: "id",
			Where: map[string]interface{}{
				"integration_id": payload["deviceId"],
			},
		})
		if queryDeviceRes.Error != nil {
			errObj := httpError.NewNotFound()
			errObj.Message = "Device tidak terdaftar pada database"
			result.Error = errObj
			return result
		}
		if payload["payload"] != nil {
			data = payload["payload"].(map[string]interface{})
		}
		payload["device_id"] = queryDeviceRes.Data.(map[string]interface{})["id"]

		query := <-u.postgreQuery.FindOne(&queries.QueryPayload{
			Table:  "smartfarm_partner_device_metrics",
			Select: "smartfarm_partner_device_id, value->'data' AS value",
			Where: map[string]interface{}{
				"smartfarm_partner_device_id": payload["device_id"],
			},
		})

		// if query.Data == nil {
		// 	dataReadStatus = strings.Repeat("false,", 9) + "false"
		// }

		queryRes := <-u.postgreQuery.FindOne(&queries.QueryPayload{
			Table: "smartfarm_partner_device_metrics spdm",
			Select: `subvessels.commodity_variety_id,spdm.data->'user_read_status'->>'data' AS user_read_status_data,
			cv.data->>'smartfarm_references' AS smartfarm_references`,
			Join: `LEFT JOIN subvessel_devices sd ON spdm.smartfarm_partner_device_id  = sd.smartfarm_partner_device_id
			LEFT JOIN subvessels ON sd.subvessel_id = subvessels.id 
			LEFT JOIN commodity_varieties cv ON subvessels.commodity_variety_id = cv.id`,
			Order: "spdm.created_at desc",
			Where: map[string]interface{}{
				"spdm.smartfarm_partner_device_id": payload["device_id"],
			},
		})

		if query.Data == nil {
			dataReadStatus = strings.Repeat("false,", 9) + "false"
		} else {
			hasData := query.Data.(map[string]interface{})
			compareData := queryRes.Data.(map[string]interface{})
			compareData["smartfarm_references"] = helpers.MetricReadStatusMapper(compareData, compareData["smartfarm_references"], hasData["value"].(string), dataReadStatus, data["data"].(string))

			// if len(schema) > 0 {
			// 	dataReadStatus = schema[0]["user_read_status"].(string)
			// 	fmt.Println(schema[0]["user_read_status"].(string))
			// 	fmt.Println(dataReadStatus)
			// }

			// if query.Data != nil {
			// 	hasData := query.Data.(map[string]interface{})
			// 	compareData := queryRes.Data.(map[string]interface{})
			// 	schema := helpers.MetricReadStatusMapper(compareData, compareData["smartfarm_references"], hasData["value"].(string), dataReadStatus, data["data"].(string))
			// 	if len(schema) > 0 {
			// 		dataReadStatus = schema[0]["user_read_status"].(string)
			// 		fmt.Println(schema[0]["user_read_status"].(string))
			// 	}
			// fmt.Println(compareData["smartfarm_references"])
			// fmt.Println(data)
			// fmt.Println(schema)
			// fmt.Println(dataReadStatus)
			fmt.Println(hasData["value"].(string))
			// fmt.Println(data["data"].(string))
		}

		// fmt.Println(queryRes)       // old data
		// fmt.Println(query.Data)     // old data value
		// fmt.Println(dataReadStatus) // new data
		// fmt.Println(data)           // new data value

	} else {
		for key, value := range payload {
			if key != "connection" && key != "device_id" {
				data[key] = value
			}
		}
	}

	commandPayload := commands.CommandPayload{
		Table: "smartfarm_partner_device_metrics",
		Document: map[string]interface{}{
			"id":                          uuid.NewString(),
			"name":                        "",
			"type":                        "",
			"timestamp":                   "",
			"value":                       data,
			"created_at":                  time.Now(),
			"created_by":                  payload["connection"].(string),
			"smartfarm_partner_device_id": payload["device_id"],
			"data":                        map[string]interface{}{"user_read_status": map[string]interface{}{"data": dataReadStatus}},
		},
	}

	commandResult := <-u.postgreCommand.InsertOne(&commandPayload)
	if commandResult.Error != nil {
		errObj := httpError.NewInternalServerError()
		errObj.Message = "Gagal menerima data device"
		result.Error = errObj
		return result
	}

	result.Data = commandResult.Data

	return result
}