Hi, there are some mistakes, like the codes below, that will end up registering the same template to a session.
|
for _, tr := range tfs.Records { |
|
tr.register(s) |
|
} |
|
for _, record := range ofs.Records { |
|
record.register(s) |
|
} |
|
for _, record := range ots.Records { |
|
record.register(s) |
|
} |
|
for _, tr := range ts.Records { |
|
tr.register(s) |
|
} |
The problem is described below:
prior to Go 1.22, every freshly-declared loop variable used in a for loop is shared by all iterations during executing the loop.
I find this blog very helpful, please check!
I think there are two ways to fix the problem:
-
Add go.mod and declare go 1.22 or later. This will fix the problem without modifying any existing codes.
Here is the official Go blog for the problem fix: https://go.dev/blog/loopvar-preview
-
Make a record copy in the loop and register the copy to session. This may be a better choice for backwards compatibility.
Thank you!
Hi, there are some mistakes, like the codes below, that will end up registering the same template to a session.
netflow/netflow9/packet.go
Lines 96 to 98 in 8c13bb0
netflow/netflow9/packet.go
Lines 130 to 132 in 8c13bb0
netflow/ipfix/packet.go
Lines 112 to 114 in 8c13bb0
netflow/ipfix/packet.go
Lines 100 to 102 in 8c13bb0
The problem is described below:
I find this blog very helpful, please check!
I think there are two ways to fix the problem:
Add go.mod and declare go 1.22 or later. This will fix the problem without modifying any existing codes.
Here is the official Go blog for the problem fix: https://go.dev/blog/loopvar-preview
Make a record copy in the loop and register the copy to session. This may be a better choice for backwards compatibility.
Thank you!