Not conveniently. But if you are doing it multiple times, it might be worthwhile to find the last key independently and compare inside your loop(s). Of course, any operations on the map will invalidate your cached last key.
lastKey := // function call that does a simple loop to find the last key.
for k,v := range myMap {
if k==lastKey {...
Thanks for your reply. I looked into your suggestion, specifically the lastKey function and came across this…
When iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to be the same from one iteration to the next. Go maps in action - The Go Programming Language
…therefore the last element when it is cached may not be the last element when the printing loop is run so this could have unexpected results for me, so I will stick with count for now.
…and a small question on Go styling… in the above I use count and last. Would it be more normal in the GO community to label these variables as c and l?
Sorry about the bad info. I knew iteration order was not guaranteed to be the same for the equivalent maps or the same map after changes, but I had thought that it didn’t vary on the same map without any changes on different invocations. That was probably just observed behavior which shouldn’t be relied upon, of course.
no problem, all good info, I learnt a lot from researching the direction that you pointed me in.
that is exactly why i am here for, to learn.
thanks again