func main() { if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "Usage: %s -h for help\n", os.Args[0]) os.Exit(1) } config_file := goopt.String([]string{"-c", "--config"}, "nrpe.cfg", "config file to use") //the first option, will be the default, if the -m isnt given run_mode := goopt.Alternatives([]string{"-m", "--mode"}, []string{"foreground", "daemon", "systemd"}, "operating mode") goopt.Parse(nil) //implement different run modes.. fmt.Println(*run_mode) config_obj := new(read_config.ReadConfig) config_obj.Init(*config_file) err := config_obj.ReadConfigFile() common.CheckError(err) //extract the commands command[cmd_name] = "/bin/foobar" config_obj.ReadCommands() config_obj.ReadPrivileges() //TODO check for errors //what we gonna do with the group? pwd := drop_privilege.Getpwnam(config_obj.Nrpe_user) drop_privilege.DropPrivileges(int(pwd.Uid), int(pwd.Gid)) //we have to read it from config service := ":5666" err = setupSocket(4, service, config_obj) common.CheckError(err) }