On Thu, Aug 9, 2018 at 2:03 PM, <russo...@gmail.com> wrote: > Hi Sam, I'm running 1.10.3 on High Sierra, installed via brew. > > Here's some more helpful output: > > ➜ awesomeProject go version > go version go1.10.3 darwin/amd64 > ➜ awesomeProject gofmt test.go > > package main > > var m_19_chars = map[string]int{ > "i": 0, > "iii": 0, > "iiiiiiiiiiiiiiiiiii": 0, > } > var m_18_chars = map[string]int{ > "i": 0, > "iii": 0, > "iiiiiiiiiiiiiiiiii": 0, > } > var m_19_chars_reorder = map[string]int{ > "i": 0, > "iiiiiiiiiiiiiiiiiii": 0, > "iii": 0, > }
This is https://golang.org/issue/22852. The behavior has changed in the upcoming 1.11 release. Ian > On Thursday, August 9, 2018 at 1:23:25 PM UTC-7, Sam Whited wrote: >> >> I can't reproduce this behavior. What version of Go are you running? >> >> On Thu, Aug 9, 2018, at 14:27, russ...@gmail.com wrote: >> > With the following code, running go fmt shows different behavior >> > depending >> > on the (1) length of the keys, and (2) the order of the keys. >> > >> > var m_19_chars = map[string]int{ >> > "i": 0, >> > "iii": 0, >> > "iiiiiiiiiiiiiiiiiii": 0, >> > } >> > var m_18_chars = map[string]int{ >> > "i": 0, >> > "iii": 0, >> > "iiiiiiiiiiiiiiiiii": 0, >> > } >> > var m_19_chars_reorder = map[string]int{ >> > "i": 0, >> > "iiiiiiiiiiiiiiiiiii": 0, >> > "iii": 0, >> > } >> > >> > >> > In the 1st map, the unexpected behavior is that the first two values are >> > indented a different amount than the third. >> > >> > In the 2nd map, the large key is reduced to 18 chars long. All keys are >> > indented evenly, as expected. >> > >> > In the 3rd map, the large key is now 19 chars long again, but is listed >> > second. Now all 3 values are indented differently. >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an email to golang-nuts...@googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> Sam Whited >> s...@samwhited.com > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.