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

strings: incorrect output #63596

Closed
pelenium opened this issue Oct 17, 2023 · 2 comments
Closed

strings: incorrect output #63596

pelenium opened this issue Oct 17, 2023 · 2 comments

Comments

@pelenium
Copy link

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

$ go version
go version go1.21.1 windows/amd64

Does this issue reproduce with the latest release?

I don't know

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\piskarevaiv\AppData\Local\go-build
set GOENV=C:\Users\piskarevaiv\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\development\Go\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\development\Go\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\development\Go\projects\kin\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\PISKAR~1\AppData\Local\Temp\go-build4177227569=/tmp/go-build -gno-record-gcc-switches

What did you do?

ran go run main.go parser.go

code in parser.go

fmt.Println(strings.ReplaceAll(strings.ReplaceAll(code[i:j], " ", ""), "\n", ""))

What did you expect to see?

{"BPM":120,"HiHat":"./sounds/hihat.mp3","BassDrum":"./sounds/bassdrum.mp3","Snare":"./sounds/snare.mp3",}

What did you see instead?

}Snare":"./sounds/snare.mp3",.mp3",

@zephyrtronium
Copy link
Contributor

There are \r carriage returns in your string in addition to \n line feeds. The replacement is working, but the CRs reset the cursor position during printing.

@pelenium pelenium changed the title affected/package: affected/package: incorrect output Oct 17, 2023
@pelenium pelenium changed the title affected/package: incorrect output strings: incorrect output Oct 17, 2023
@pelenium
Copy link
Author

oh, thanks, i'd already found that it works correctly, but i didn't know why, thanks a lot again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants