Empty slice literal of type "[]ItemEvent" used to define "events"
778
779// GetInSynchronizationFile the files syncthing
780func (s *Syncthing) GetInSynchronizationFile(ctx context.Context) string {
781 events := []ItemEvent{} 782 params := map[string]string{
783 "device": DefaultRemoteDeviceID,
784 "since": "0",
Empty slice literal of type "[]FolderErrorEvent" used to define "folderErrorsList"
708 "timeout": "0",
709 "events": "FolderErrors",
710 }
711 folderErrorsList := []FolderErrorEvent{} 712 body, err := s.APICall(ctx, "rest/events", "GET", http.StatusOK, params, local, nil, true, maxRetries)
713 if err != nil {
714 oktetoLog.Infof("error getting events: %s", err.Error())
Empty slice literal of type "[]FolderSummaryEvent" used to define "fsList"
647 "timeout": "0",
648 "events": "FolderSummary",
649 }
650 fsList := []FolderSummaryEvent{} 651 body, err := s.APICall(ctx, "rest/events", "GET", http.StatusOK, params, local, nil, true, maxRetries)
652 if err != nil {
653 oktetoLog.Infof("error getting events: %s", err.Error())
Empty slice literal of type "[]StateChangedEvent" used to define "scList"
585 "timeout": "0",
586 "events": "StateChanged",
587 }
588 scList := []StateChangedEvent{} 589 body, err := s.APICall(ctx, "rest/events", "GET", http.StatusOK, params, local, nil, true, maxRetries)
590 if err != nil {
591 oktetoLog.Infof("error getting events: %s", err.Error())
Description
An empty slice can be represented by nil
or an empty slice literal. They are
functionally equivalent — their len
and cap
are both zero — but the nil
slice is the preferred style. For more information about empty slices,
see Declaring Empty Slices.
Bad practice
package main
func foo() {
a := []int{}
}
Recommended
package main
func foo() {
var a []int
}