I have struct containing a slice of another struct. I have added methods for Addition and Deletion of an item from the slice but addition is working deletion is not. I am new to Go so I am not able to understand why slice reassignment does not gets reflected in struct
Short Version of my code below. Link to PlayGoLang : http://play.golang.org/p/4NnGh3Dtzw
type BatteryTest struct {
Name, LocalConf, JdkPath, SysProps, LocalconfPath string
NumberOfNodes int
}
type Server struct {
Port int
TestQueue, CompletedTests, RunningTests []BatteryTest
}
func (this *Server) AddBatteryTest(test BatteryTest) error {
this.TestQueue = append(this.TestQueue, test)
return nil
}
func (this *Server) TakeBatteryTest() error {
length := len(this.TestQueue)
if length == 0 {
fmt.Println("Len==", 0)
return errors.New("Queue is empty")
}
slice := this.TestQueue
i := len(this.TestQueue) - 1
slice = append(slice[:i], slice[i+1:]...)
return nil
}