format: improve code structure for better readability
🤖
This commit is contained in:
parent
c2310f7735
commit
912dfa62f2
2 changed files with 4 additions and 1 deletions
|
@ -11,17 +11,21 @@ import (
|
||||||
|
|
||||||
func ParseConfig(filename string) ChronoTomato.Config {
|
func ParseConfig(filename string) ChronoTomato.Config {
|
||||||
var config ChronoTomato.Config
|
var config ChronoTomato.Config
|
||||||
|
|
||||||
if strings.HasPrefix(filename, "~/") {
|
if strings.HasPrefix(filename, "~/") {
|
||||||
dirname, _ := os.UserHomeDir()
|
dirname, _ := os.UserHomeDir()
|
||||||
filename = filepath.Join(dirname, filename[2:])
|
filename = filepath.Join(dirname, filename[2:])
|
||||||
}
|
}
|
||||||
|
|
||||||
yamlFile, err := os.ReadFile(filename)
|
yamlFile, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error opening config file!", "reason", err)
|
log.Fatal("Error opening config file!", "reason", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = yaml.Unmarshal(yamlFile, &config)
|
err = yaml.Unmarshal(yamlFile, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unmarshal: %v", err)
|
log.Fatalf("Unmarshal: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
var Done = make(chan struct{})
|
var Done = make(chan struct{})
|
||||||
|
|
||||||
func ProcessServerMessages(conn *websocket.Conn, channel chan<- GoTomato.ServerMessage) {
|
func ProcessServerMessages(conn *websocket.Conn, channel chan<- GoTomato.ServerMessage) {
|
||||||
|
|
||||||
var serverMessage GoTomato.ServerMessage
|
var serverMessage GoTomato.ServerMessage
|
||||||
|
|
||||||
defer close(Done)
|
defer close(Done)
|
||||||
|
|
Loading…
Reference in a new issue