mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-22 05:27:29 +00:00
Properly check env variables in init
This commit is contained in:
parent
ee78e7cd15
commit
006ab04b8c
22
main.go
22
main.go
@ -62,14 +62,24 @@ func init() {
|
|||||||
if val, _ := strconv.Atoi(port); val > 0 {
|
if val, _ := strconv.Atoi(port); val > 0 {
|
||||||
config.PORT = port
|
config.PORT = port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.MATRIXUSERNAME = os.Getenv("MATRIXUSERNAME")
|
||||||
|
config.MATRIXACCESSTOKEN = os.Getenv("MATRIXACCESSTOKEN")
|
||||||
|
|
||||||
config.MATRIXROOM = os.Getenv("MATRIXROOM")
|
config.MATRIXROOM = os.Getenv("MATRIXROOM")
|
||||||
config.MATRIXOPENINGMESSAGE = os.Getenv("MATRIXOPENINGMESSAGE")
|
config.MATRIXOPENINGMESSAGE = os.Getenv("MATRIXOPENINGMESSAGE")
|
||||||
config.MATRIXCLOSINGMESSAGE = os.Getenv("MATRIXCLOSINGMESSAGE")
|
config.MATRIXCLOSINGMESSAGE = os.Getenv("MATRIXCLOSINGMESSAGE")
|
||||||
config.MATRIXACCESSTOKEN = os.Getenv("MATRIXACCESSTOKEN")
|
|
||||||
config.MATRIXUSERNAME = os.Getenv("MATRIXUSERNAME")
|
|
||||||
config.ESPUSERNAME = os.Getenv("ESPUSERNAME")
|
config.ESPUSERNAME = os.Getenv("ESPUSERNAME")
|
||||||
config.ESPPASSWORD = os.Getenv("ESPPASSWORD")
|
config.ESPPASSWORD = os.Getenv("ESPPASSWORD")
|
||||||
|
|
||||||
|
if config.MATRIXUSERNAME == "" {
|
||||||
|
panic("MATRIXUSERNAME is empty")
|
||||||
|
}
|
||||||
|
if config.MATRIXACCESSTOKEN == "" {
|
||||||
|
panic("MATRIXACCESSTOKEN is empty")
|
||||||
|
}
|
||||||
|
|
||||||
if config.MATRIXROOM == "" {
|
if config.MATRIXROOM == "" {
|
||||||
panic("MATRIXROOM is empty")
|
panic("MATRIXROOM is empty")
|
||||||
}
|
}
|
||||||
@ -79,11 +89,9 @@ func init() {
|
|||||||
if config.MATRIXCLOSINGMESSAGE == "" {
|
if config.MATRIXCLOSINGMESSAGE == "" {
|
||||||
panic("MATRIXCLOSINGMESSAGE is empty")
|
panic("MATRIXCLOSINGMESSAGE is empty")
|
||||||
}
|
}
|
||||||
if config.MATRIXACCESSTOKEN == "" {
|
|
||||||
panic("MATRIXACCESSTOKEN is empty")
|
if config.ESPUSERNAME == "" {
|
||||||
}
|
panic("ESPUSERNAME is empty")
|
||||||
if config.MATRIXUSERNAME == "" {
|
|
||||||
panic("MATRIXUSERNAME is empty")
|
|
||||||
}
|
}
|
||||||
if config.ESPPASSWORD == "" {
|
if config.ESPPASSWORD == "" {
|
||||||
panic("ESPPASSWORD is empty")
|
panic("ESPPASSWORD is empty")
|
||||||
|
Loading…
Reference in New Issue
Block a user