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

Gu bug https://play.golang.org/p/1YFPR3ShVUx #31471

Closed
herotto opened this issue Apr 15, 2019 · 1 comment
Closed

Gu bug https://play.golang.org/p/1YFPR3ShVUx #31471

herotto opened this issue Apr 15, 2019 · 1 comment

Comments

@herotto
Copy link

herotto commented Apr 15, 2019

Please answer these questions before submitting your issue. Thanks!

What did you do?

wrote a small function with unexpected results
see https://play.golang.org/p/1YFPR3ShVUx

the 2 lines in main() are identical except for the writing of "SpeciMen40" and "Specimen40"

str := "enum('Quader','Irregular','SpeciMen40','Type1','Type2')"
fmt.Println("return: ", trimTypeString(str))

str = "enum('Quader','Irregular','Specimen40','Type1','Type2')"
fmt.Println("return: ", trimTypeString(str))

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

---> https://play.golang.org/p/1YFPR3ShVUx

What did you expect to see? same result for both runs of the function

What did you see instead? different resuts

System details

go version go1.12.4 linux/amd64
GOARCH="amd64"
GOBIN="/home/herotto/prog/go/bin"
GOCACHE="/home/herotto/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/herotto/prog/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.12/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.12/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.8 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.4
uname -sr: Linux 4.15.0-47-generic
LSB Version:	core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27.
gdb --version: GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
@ianlancetaylor
Copy link
Contributor

TrimRight doesn't do what you think it does. See the example at https://golang.org/pkg/strings/#TrimRight. You are almost certainly looking for TrimSuffix.

@golang golang locked and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants