fix(pkg/cli): nil pointer exeption - print empty string instead throw exeption
This commit is contained in:
		| @@ -69,10 +69,36 @@ func PrintSensors(cnf *config.Configuration, w io.Writer) error { | ||||
| 	// declar tabwriter | ||||
| 	tw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0) | ||||
|  | ||||
| 	fmt.Fprint(tw, "name\tlocation\ttype\twire-id\tgpio\tenabled\n") | ||||
| 	fmt.Fprint(tw, "name\tlocation\ttype\twire-id\ti2c-bus\ti2c-address\tgpio\tenabled\n") | ||||
|  | ||||
| 	for _, sensor := range cnf.Sensors { | ||||
| 		fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\t%v\n", sensor.SensorName, sensor.SensorLocation, sensor.SensorModel, *sensor.WireID, *sensor.GPIONumber, sensor.SensorEnabled) | ||||
| 		fmt.Fprintf(tw, "%v\t%v\t%v\t", sensor.SensorName, sensor.SensorLocation, sensor.SensorModel) | ||||
|  | ||||
| 		if sensor.WireID != nil { | ||||
| 			fmt.Fprintf(tw, "%v\t", *sensor.WireID) | ||||
| 		} else { | ||||
| 			fmt.Fprintf(tw, "\t") | ||||
| 		} | ||||
|  | ||||
| 		if sensor.I2CBus != nil { | ||||
| 			fmt.Fprintf(tw, "%v\t", *sensor.I2CBus) | ||||
| 		} else { | ||||
| 			fmt.Fprintf(tw, "\t") | ||||
| 		} | ||||
|  | ||||
| 		if sensor.I2CAddress != nil { | ||||
| 			fmt.Fprintf(tw, "%v\t", *sensor.I2CAddress) | ||||
| 		} else { | ||||
| 			fmt.Fprintf(tw, "\t") | ||||
| 		} | ||||
|  | ||||
| 		if sensor.GPIONumber != nil { | ||||
| 			fmt.Fprintf(tw, "%v\t", *sensor.GPIONumber) | ||||
| 		} else { | ||||
| 			fmt.Fprintf(tw, "\t") | ||||
| 		} | ||||
|  | ||||
| 		fmt.Fprintf(tw, "%v\n", sensor.SensorEnabled) | ||||
| 	} | ||||
|  | ||||
| 	tw.Flush() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user