You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					37 lines
				
				622 B
			
		
		
			
		
	
	
					37 lines
				
				622 B
			| 
											2 months ago
										 | package config
 | ||
|  | 
 | ||
|  | 
 | ||
|  | import (
 | ||
|  |   "log"
 | ||
|  | 
 | ||
|  |   "github.com/BurntSushi/toml"
 | ||
|  | )
 | ||
|  | 
 | ||
|  | type config struct {
 | ||
|  |   Admin string `toml:"admin"`
 | ||
|  |   Views string `toml:"views"`
 | ||
|  |   Layouts string `toml:"layouts"`
 | ||
|  |   Port string `toml:"port"`
 | ||
|  | 
 | ||
|  |   Database struct {
 | ||
|  |     Driver string `toml:"driver"`
 | ||
|  |     Url string `toml:"url"`
 | ||
|  |   } `toml:"database"`
 | ||
|  | }
 | ||
|  | 
 | ||
|  | var Settings config
 | ||
|  | 
 | ||
|  | func Load(path string) {
 | ||
|  |   metadata, err := toml.DecodeFile(path, &Settings)
 | ||
|  | 
 | ||
|  |   if err != nil {
 | ||
|  |     log.Fatalf("error loading config.toml: %v", err)
 | ||
|  |   }
 | ||
|  | 
 | ||
|  |   bad_keys := metadata.Undecoded()
 | ||
|  | 
 | ||
|  |   if len(bad_keys) > 0 {
 | ||
|  |     log.Fatalf("unknown configuration keys: %v", bad_keys);
 | ||
|  |   }
 | ||
|  | }
 |