package MqttService import ( "errors" "strings" ) func PinNameFromTopic(topic string) (string,error) { topicComponents := strings.Split(topic, "/") if len(topicComponents) >= 2 { gpioCh := topicComponents[len(topicComponents)-2] return gpioCh, nil } else { return "", errors.New("invalid topic") } }