Moved setting sys params to sysdetect

Cleans up the main function
stable
Justin Reichardt 2021-12-09 15:21:54 -06:00
parent ad1410410b
commit 40c6572a81
1 changed files with 23 additions and 23 deletions

View File

@ -23,40 +23,40 @@ package main
import (
"runtime"
"fmt"
"os"
"bufio"
"log"
)
func main() {
// Detect which OS is running
//tmpdir := ""
//hostsloc := ""
cfgloc := ""
switch runtime.GOOS {
case "windows":
fmt.Println("Windows is currently unsupported")
os.Exit(1)
//tmpdir := "C:\\tmp"
//hostsloc := "C:\\Windows\\System32\\drivers\\etc\\hosts"
case "linux":
//tmpdir = "/tmp/"
//hostsloc = "/etc/hosts"
cfgloc ="/etc/rhosts/rhosts.cfg"
case "ios":
fmt.Println("ios")
os.Exit(1)
default:
log.Print(runtime.GOOS," is not supported")
os.Exit(1)
}
tmpdir := ""
hostsloc := ""
cfgloc := ""
sysdetect (&tmpdir, &hostsloc, &cfgloc)
// Parse Config
cfgparse(cfgloc)
}
func sysdetect (tmpdir, hostsloc, cfgloc *string) {
// Detect OS and set params
switch runtime.GOOS {
case "windows":
log.Fatal("Windows is not supported")
*tmpdir = "C:\\tmp"
*hostsloc = "C:\\Windows\\System32\\drivers\\etc\\hosts"
case "linux":
*tmpdir = "/tmp/"
*hostsloc = "/etc/hosts"
*cfgloc ="/etc/rhosts/rhosts.cfg"
case "ios":
log.Fatal("IOS is not supported")
default:
log.Fatal(runtime.GOOS," is not supported")
}
}
func cfgparse (cfgloc string){
log.Print("Opening: ", cfgloc)
file, err := os.Open(cfgloc)