Pass by reference, not value, in for loop

This commit is contained in:
Chandler Swift 2020-03-29 22:18:59 -05:00
parent e24a9b1a52
commit 13c5e84d31

View file

@ -72,8 +72,8 @@ func main() {
fmt.Printf("Error parsing HTML template: %v\n", err) fmt.Printf("Error parsing HTML template: %v\n", err)
} }
for _, s := range config.Servers { for i := range config.Servers {
s.rconConnection, err = rcon.Dial(fmt.Sprintf("%v:%v", s.Host, s.RCONPort), s.RCONPassword) config.Servers[i].rconConnection, err = rcon.Dial(fmt.Sprintf("%v:%v", s.Host, s.RCONPort), s.RCONPassword)
if err != nil { if err != nil {
log.Fatalf("Error making RCON connection to %v: %v", s.Title, err) log.Fatalf("Error making RCON connection to %v: %v", s.Title, err)
} }