Skip to content

strings.TrimRight works not the same #24891

Closed
@756445638

Description

@756445638

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.5 windows/amd64

Does this issue reproduce with the latest release?

no

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\backstage\newest\hmi-server\code\gopath;D:\golib
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\yuyang\AppData\Local\Temp\go-build583116219=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.TrimRight("opc.tcp://188.0.0.181:4840", ":4840"))
	fmt.Println(strings.TrimRight("opc.tcp://188.0.0.182:4840", ":4840"))
	fmt.Println(strings.TrimRight("opc.tcp://188.0.0.183:4840", ":4840"))
	fmt.Println(strings.TrimRight("opc.tcp://188.0.0.184:4840", ":4840"))
	fmt.Println(strings.TrimRight("opc.tcp://188.0.0.185:4840", ":4840"))
	fmt.Println(strings.TrimRight("opc.tcp://188.0.0.186:4840", ":4840"))
}

What did you expect to see?

opc.tcp://188.0.0.181
opc.tcp://188.0.0.182
opc.tcp://188.0.0.183
opc.tcp://188.0.0.184
opc.tcp://188.0.0.185
opc.tcp://188.0.0.186

What did you see instead?

opc.tcp://188.0.0.181
opc.tcp://188.0.0.182
opc.tcp://188.0.0.183
opc.tcp://188.0.0.1
opc.tcp://188.0.0.185
opc.tcp://188.0.0.186

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions