forked from daBONDi/go-rest-wol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
envVars.go
26 lines (22 loc) · 810 Bytes
/
envVars.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main
import (
"log"
"os"
"strconv"
)
// Processing Shell Arguments
func processEnvVars(port int, computerFile string) (int, string) {
if os.Getenv(DefaultComputerFilePathEnvironmentName) != "" {
computerFile = os.Getenv(DefaultComputerFilePathEnvironmentName)
if !FileExists(computerFile) {
log.Fatalf("Environmentvariable \"%s\" is set but Value is not a Path to an existing File: %s", DefaultComputerFilePathEnvironmentName, computerFile)
}
}
if os.Getenv(DefaultHTTPPortEnvironmentVariableName) != "" {
var err error
if port, err = strconv.Atoi(os.Getenv(DefaultHTTPPortEnvironmentVariableName)); err != nil {
log.Fatalf("Environmentvariable \"%s\" should be a integer", DefaultHTTPPortEnvironmentVariableName)
}
}
return port, computerFile
}