OK i think i found it the way just need to implement full solution but i should be good with the
func main() {
brokers := []string{BK}
kfk.Logger = log.New(os.Stdout, "", log.LstdFlags)
cfg := kfk.NewConfig()
cfg.ClientID = CID
client, _ := kfk.NewClient(brokers, cfg)
//fmt.Println(client)
offsetMg, _ := kfk.NewOffsetManagerFromClient(CG, client)
defer offsetMg.Close()
consumer, _ := kfk.NewConsumerFromClient(client)
defer consumer.Close()
partitions, _ := consumer.Partitions(TOPIC)
for _, p := range partitions {
pom, _ := offsetMg.ManagePartition(TOPIC, p)
ofs, pomStr := pom.NextOffset()
fmt.Printf("Partition: %v -> nextOffset: %v:%s\n", p, ofs, pomStr)
}
fmt.Println("--")
}
and that gives me this output:
Partition: 0 -> nextOffset: 31:
Partition: 1 -> nextOffset: 30:
Partition: 2 -> nextOffset: 45:
Partition: 3 -> nextOffset: 39:
Partition: 4 -> nextOffset: 45:
Partition: 5 -> nextOffset: 39:
Partition: 6 -> nextOffset: 37:
Partition: 7 -> nextOffset: 42:
Partition: 8 -> nextOffset: 43:
Partition: 9 -> nextOffset: 35:
Partition: 10 -> nextOffset: 41:
Partition: 11 -> nextOffset: 36:
which is exactly same as from java command:
❯ kafka-consumer-groups.sh --bootstrap-server $kfk --dry-run --reset-offsets --topic $t --group $cg1 --to-current | sort -k3 -n
GROUP TOPIC PARTITION NEW-OFFSET
propertest-cg1 propertest 0 31
propertest-cg1 propertest 1 30
propertest-cg1 propertest 2 45
propertest-cg1 propertest 3 39
propertest-cg1 propertest 4 45
propertest-cg1 propertest 5 39
propertest-cg1 propertest 6 37
propertest-cg1 propertest 7 42
propertest-cg1 propertest 8 43
propertest-cg1 propertest 9 35
propertest-cg1 propertest 10 41
propertest-cg1 propertest 11 36
so now only what left is to export this data to a file and use function
// ResetOffset resets to the provided offset, alongside a metadata string that
// represents the state of the partition consumer at that point in time. Reset
// acts as a counterpart to MarkOffset, the difference being that it allows to
// reset an offset to an earlier or smaller value, where MarkOffset only
// allows incrementing the offset. cf MarkOffset for more details.
ResetOffset(topic string, partition int32, offset int64, metadata string)
to set new offset ...