Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gofmt: alignment issue with Combining Macron `U+0304` in map literals #30939

matthewhartstonge opened this issue Mar 19, 2019 · 3 comments


Copy link

@matthewhartstonge matthewhartstonge commented Mar 19, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.1 windows/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\me\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\me\go
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\me\AppData\Local\Temp\go-build025935614=/tmp/go-build -gno-record-gcc-switches

What did you do?

Created a map[string]string for data munging bad inputs to good inputs and noticed the go formatter alignment gets out of whack due to U+0304 "Combining Macron". Which misleads the formatter as for each combining macron character, there should be 2 spaces added, instead of one.

Alignment issues 'intensifies' the more combining macrons are added.

breathing intensifies

What did you expect to see?

var simpleMap = map[string]string{
	"longKeyIsLong": "lol not really",
	"lol":           "v",
	"lāl":           "v",
	"lāl":           "v",
	"lēl":           "v",
	"lēl":           "v",
	"līl":           "v",
	"līl":           "v",
	"lōl":           "v",
	"lōl":           "v",
	"lūl":           "v",
	"lūl":           "v",
	"lōōōōōnglūl":   "v",

What did you see instead?

var simpleMap = map[string]string{
	"longKeyIsLong":     "lol not really",
	"lol":               "v",
	"lāl":               "v",
	"lāl":              "v",
	"lēl":               "v",
	"lēl":              "v",
	"līl":               "v",
	"līl":              "v",
	"lōl":               "v",
	"lōl":              "v",
	"lūl":               "v",
	"lūl":              "v",
	"lōōōōōnglūl": "v",
@matthewhartstonge matthewhartstonge changed the title go fmt alignment issue with Combining Macron `U+0304` cmd/go: fmt alignment issue with Combining Macron `U+0304` Mar 19, 2019
@agnivade agnivade changed the title cmd/go: fmt alignment issue with Combining Macron `U+0304` cmd/gofmt: alignment issue with Combining Macron `U+0304` in map literals Mar 20, 2019
Copy link

@agnivade agnivade commented Mar 20, 2019

Copy link

@griesemer griesemer commented Mar 20, 2019

This is certainly working as expected (i.e., the code was written well-knowing that this would be an issue). It may not be working as desired, but the questions are 1) how important is this, and 2) what's the best way of fixing this.

For 1) the answer seems pretty clear: This is not very important.

@griesemer griesemer added this to the Unplanned milestone Mar 20, 2019
Copy link

@matthewhartstonge matthewhartstonge commented Mar 28, 2019

haha yes.. You're right about 1).
We were dealing with a PR and it had us wondering why the code was all over the place - first thought was that it wasn't go fmt'd. Then we went down the rabbit hole to work out why it was like this...

.. Yay for macrons ..

Knowing what code does is half the battle.
Having a play with the sample code over a couple of IDEs leads to funky outcomes as well - for example, If I use a column select once the values are aligned, the select obviously uses character counting to work out where the cursors should be.


Sooooo, lets just ignore this issue...

@golang golang locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.