first commit

This commit is contained in:
Gregory Salaun
2023-11-29 11:02:30 +07:00
commit 283264a261
9 changed files with 331 additions and 0 deletions

49
config/config.go Normal file
View File

@ -0,0 +1,49 @@
package config
import (
"io/ioutil"
"log"
"os"
"path/filepath"
"gopkg.in/yaml.v2"
)
// Config from YAML
type Config struct {
CloudLog struct {
Server string `yaml:"server"`
QSOUrl string `yaml:"qso_url"`
API string `yaml:"api"`
} `yaml:"cloudlog"`
UDP struct {
Port string `yaml:"port"`
} `yaml:"udp"`
QRZ struct {
API string `yaml:"api"`
Callsign string `yaml:"callsign"`
}
Clublog struct {
EMail string `yaml:"email"`
Password string `yaml:"password"`
Callsign string `yaml:"callsign"`
API string `yaml:"api"`
URL string `yaml:"url"`
}
}
func NewConfig() Config {
var c Config
ex, err := os.Executable()
if err != nil {
log.Println(err)
}
configFile := filepath.Dir(ex) + "/config/config.yaml"
yamlFile, err := ioutil.ReadFile(configFile)
err = yaml.Unmarshal([]byte(yamlFile), &c)
if err != nil {
log.Fatalf("error: %v", err)
}
return c
}

20
config/config.yaml Normal file
View File

@ -0,0 +1,20 @@
# Cloudlog Setup
# Generate a Read/Write API Key cloudlog/api/help
cloudlog:
server: "https://log.rouggy.com"
qso_url: "https://log.rouggy.com/index.php/api/qso/"
api: "cl65388812a62d1"
udp:
port: ":2240"
qrz:
api: "4AEC-1886-2E4E-C3AF"
callsign: "XV9Q"
clublog:
email: "legreg002@hotmail.com"
password: "89DGgg290379"
callsign: "XV9Q"
api: "5767f19333363a9ef432ee9cd4141fe76b8adf38"
url: "https://clublog.org/realtime.php"