package main import ( "fmt" "log" "os" serverconfig "github.com/deranjer/gvc/server/serverconfig" "github.com/deranjer/store" ) var version = "0.1" // GVCServer contains all the information needed for our server so we can pass it around as needed type GVCServer struct { configPath string config serverconfig.GvcServerConfig } func main() { // Initialize a new server struct and config struct var server GVCServer var conf serverconfig.GvcServerConfig configPath, err := serverconfig.FindConfig() // TODO: maybe make the findconfig a func of the struct? if err != nil { fmt.Printf("Unable to find config file: %s\n", err) fmt.Println("Since no config found, creating a default config to use...") pwd, err := os.Getwd() if err != nil { log.Fatal("unable to get current working dir, exiting") } conf = serverconfig.GvcServerConfig{ Version: "0.1", Port: 80, RepoRootPath: pwd, } } server.configPath = configPath // set the root path for our config err = store.Load(configPath, &conf) if err != nil { fmt.Printf("Error loading server config file into struct, please fix config, panic! \n%s", err) os.Exit(0) } server.config = conf // Write the conf to our server struct }