func (this *Consumers) displayGroupOffsets(zkcluster *zk.ZkCluster, group, topic string, echo bool) []consumerGroupOffset { offsetMap := zkcluster.ConsumerOffsetsOfGroup(group) sortedTopics := make([]string, 0, len(offsetMap)) for t, _ := range offsetMap { sortedTopics = append(sortedTopics, t) } sort.Strings(sortedTopics) r := make([]consumerGroupOffset, 0) for _, t := range sortedTopics { if !patternMatched(t, this.topicPattern) || (topic != "" && t != topic) { continue } sortedPartitionIds := make([]string, 0, len(offsetMap[t])) for partitionId, _ := range offsetMap[t] { sortedPartitionIds = append(sortedPartitionIds, partitionId) } sort.Strings(sortedPartitionIds) for _, partitionId := range sortedPartitionIds { r = append(r, consumerGroupOffset{ topic: t, partitionId: partitionId, offset: gofmt.Comma(offsetMap[t][partitionId]), }) if echo { this.Ui.Output(fmt.Sprintf("\t\t%s/%s Offset:%s", t, partitionId, gofmt.Comma(offsetMap[t][partitionId]))) } } } return r }