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

fmt: strings including \r are not printed correctly (darwin only?) #23722

Closed
tehsphinx opened this issue Feb 6, 2018 · 4 comments
Closed

fmt: strings including \r are not printed correctly (darwin only?) #23722

tehsphinx opened this issue Feb 6, 2018 · 4 comments

Comments

@tehsphinx
Copy link

@tehsphinx tehsphinx commented Feb 6, 2018

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

go version go1.9.3 darwin/amd64

What environment are you using (go env)?

go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8p/1rng6dl524z_7n11hnzj_gfr0000gn/T/go-build794680911=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

https://play.golang.org/p/o3pytsrv4K2

What did you expect to see?

[102 111 111 13 98 97 114 13 102 111 111 98 97 114]
14 14
foo
bar
foobar

Note: On play.golang.org it works just fine

What did you see instead?

On Mac the last print will swallow all lines except the last line. So I only see:
[102 111 111 13 98 97 114 13 102 111 111 98 97 114]
14 14
foobar

Works perfectly fine with \n, but not with \r.

@tehsphinx
Copy link
Author

@tehsphinx tehsphinx commented Feb 6, 2018

same issue when writing to a file with os.(*File).WriteString()

@tehsphinx
Copy link
Author

@tehsphinx tehsphinx commented Feb 6, 2018

just confirmed linux/amd64 has the same issue with os.(*File).WriteString()

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Feb 6, 2018

This isn't a Go thing. This is your terminal rendering that. You probably meant \n anyway. You can confirm by piping into hexdump or hd that Go is writing them.

@bradfitz bradfitz closed this Feb 6, 2018
@tehsphinx
Copy link
Author

@tehsphinx tehsphinx commented Feb 6, 2018

Thanks Brad! Just realized that too.

Sorry for the inconvenience and thank you for the awesome programming language!

@ALTree ALTree changed the title fmt.Println: strings including \r are not printed correctly (darwin only?) fmt: strings including \r are not printed correctly (darwin only?) Feb 6, 2018
@golang golang locked and limited conversation to collaborators Feb 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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