fix(cmd): use pointer instead a copied object of the configFile environment
This commit is contained in:
@ -12,7 +12,7 @@ import (
|
||||
|
||||
var cleanCacheInterval string
|
||||
var compression bool
|
||||
var configFile string
|
||||
var configFile *string
|
||||
var round float64
|
||||
var temperatureUnit string
|
||||
|
||||
@ -21,7 +21,7 @@ var daemonCmd = &cobra.Command{
|
||||
Short: "Read continuously data from all enabled sensors",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// read configuration
|
||||
cnf, err := config.Read(configFile)
|
||||
cnf, err := config.Read(*configFile)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
@ -38,7 +38,7 @@ var daemonCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func InitCmd(cmd *cobra.Command, cnfFile string) {
|
||||
func InitCmd(cmd *cobra.Command, cnfFile *string) {
|
||||
configFile = cnfFile
|
||||
cmd.AddCommand(daemonCmd)
|
||||
daemonCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured values")
|
||||
|
Reference in New Issue
Block a user