🔧 Add some basic app config values
This commit is contained in:
		
					parent
					
						
							
								1e78a95e8a
							
						
					
				
			
			
				commit
				
					
						8860c53d45
					
				
			
		
					 2 changed files with 13 additions and 9 deletions
				
			
		|  | @ -2,14 +2,21 @@ package config | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
|  | 	"os" | ||||||
|  | 	"path/filepath" | ||||||
|  | 
 | ||||||
| 	"github.com/BurntSushi/toml" | 	"github.com/BurntSushi/toml" | ||||||
| 	"github.com/adrg/xdg" | 	"github.com/adrg/xdg" | ||||||
| 	"github.com/kirsle/configdir" | 	"github.com/kirsle/configdir" | ||||||
| 	"os" |  | ||||||
| 	"path/filepath" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const Version string = "0.1.0" | const ( | ||||||
|  | 	AppName   string = "strip-beats" | ||||||
|  | 	Version   string = "0.1.0" | ||||||
|  | 	Url       string = "https://codeberg.org/danjones000/strip-beats" | ||||||
|  | 	Email     string = "danjones@goodevilgenius.org" | ||||||
|  | 	UserAgent string = AppName + "/" + Version + " (" + Url + "; " + Email + ")" | ||||||
|  | ) | ||||||
| 
 | 
 | ||||||
| type Config struct { | type Config struct { | ||||||
| 	Source           string            `toml:"source"` | 	Source           string            `toml:"source"` | ||||||
|  | @ -25,10 +32,6 @@ type Config struct { | ||||||
| 	AcousticUserKey  string            `toml:"acoustic_user_key"` | 	AcousticUserKey  string            `toml:"acoustic_user_key"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c Config) Version() string { |  | ||||||
| 	return Version |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| var config Config | var config Config | ||||||
| 
 | 
 | ||||||
| func newConfig() Config { | func newConfig() Config { | ||||||
|  |  | ||||||
|  | @ -5,7 +5,8 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	//"codeberg.org/danjones000/strip-beats/config" | 
 | ||||||
|  | 	"codeberg.org/danjones000/strip-beats/config" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type MbRecording struct { | type MbRecording struct { | ||||||
|  | @ -61,7 +62,7 @@ func FillMbRecording(rec *MbRecording) error { | ||||||
| 	q.Add("fmt", "json") | 	q.Add("fmt", "json") | ||||||
| 	q.Add("inc", "releases+media") | 	q.Add("inc", "releases+media") | ||||||
| 	req.URL.RawQuery = q.Encode() | 	req.URL.RawQuery = q.Encode() | ||||||
| 	req.Header.Set("User-Agent", "strip-beats/0.1.0 (https://codeberg.org/danjones000/strip-beats/)") | 	req.Header.Set("User-Agent", config.UserAgent) | ||||||
| 
 | 
 | ||||||
| 	resp, err := http.DefaultClient.Do(req) | 	resp, err := http.DefaultClient.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue