Skip to content

Commit

Permalink
fixed write requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicminer256 committed Jul 28, 2024
1 parent 0da3bf3 commit 4a0f16a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
13 changes: 6 additions & 7 deletions MetalUI.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"strconv"
"strings"

"github.com/BurntSushi/toml"
"github.com/gdamore/tcell/v2"
"github.com/ncruces/zenity"
"github.com/pelletier/go-toml"
"github.com/rivo/tview"
)

Expand Down Expand Up @@ -45,7 +45,7 @@ type MiscConfig struct {
SendErrors bool `toml:"SendErrors"`
}

var config Config = Config{
var config *Config = &Config{
General: GeneralConfig{
Name: "BeamMP Server",
Port: 30814,
Expand Down Expand Up @@ -122,19 +122,18 @@ func main() {
}

func read_config() {
file, err := os.Open("ServerConfig.toml")

_, err := toml.DecodeFile("ServerConfig.toml", &config)
if err != nil {
log("Error opening config file")
}
toml.NewDecoder(file).Decode(&config)
}

func save_config(configFile *os.File) {
if configFile == nil {
// yeah don't look at this part. it kept adding more lines instead of replacing
os.Remove("ServerConfig.toml")

var err error
configFile, err = os.OpenFile("ServerConfig.toml", os.O_WRONLY, 0644)
configFile, err = os.Create("ServerConfig.toml")
if err != nil {
log("Could not create config file")
return
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
)

require (
github.com/BurntSushi/toml v1.4.0
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.7.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down

0 comments on commit 4a0f16a

Please sign in to comment.