package look import ( "encoding/json" "fmt" "github.com/spf13/viper" "io/ioutil" "pgm/data" "pgm/logger" ) // the default view for a user once they load a database is called the look. // the look loads func Look(f string) { var connectionDetails data.HostDetails connectionDetails = loadHost(f) fmt.Println(connectionDetails) } // gets information for host from hostDir func loadHost(f string) data.HostDetails { var hostDir string hostDir = viper.GetString("hostsDir") file, _ := ioutil.ReadFile(hostDir + "/"+ f) data := data.HostDetails{} err := json.Unmarshal(file, &data) if err != nil { logger.Logger("[ERROR] error loading host, malformed file: " + f) logdir := viper.GetString("logsDir") fmt.Println("fatal error occured, see logs at " + logdir) } return data }