Even though I set statistics_password in my config (which is /etc/speedtest-settings.toml), I got the message '_Please set statisticspassword in settings.toml to enable access'.
Root cause
In stats.go, global var conf is initialized even before main is called. At this time configFile is empty as it is not set yet. If the config path is not explicitly set using -c flag, viper initializes from settings.toml in current folder. If no settings.toml files is found, conf is initialized with default values and thus does not use the password set in config file.
Problem
Even though I set statistics_password in my config (which is
/etc/speedtest-settings.toml
), I got the message '_Please set statisticspassword in settings.toml to enable access'.Root cause
In stats.go, global var
conf
is initialized even before main is called. At this time configFile is empty as it is not set yet. If the config path is not explicitly set using-c
flag, viper initializes fromsettings.toml
in current folder. If nosettings.toml
files is found,conf
is initialized with default values and thus does not use the password set in config file.