golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
120.1k stars 17.24k forks source link

Chinese string process error on Mac #67097

Closed studyzy closed 2 weeks ago

studyzy commented 2 weeks ago

Go version

go1.21.5 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='auto'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/devinzeng/Library/Caches/go-build'
GOENV='/Users/devinzeng/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/devinzeng/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/devinzeng/go'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/h9/2yls4kmx2dj6v1fh2nlkfgww0000gn/T/go-build1295641148=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

go run main.go :

package main

import "fmt"

func main() {
    a := "测试程序: "
    b := "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
    fmt.Println(b)
    fmt.Println(a + b)
    fmt.Printf("测试程序: %s\n", b)
}

What did you see happen?

123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
测试程序: 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345672345678901234567890
测试程序: 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345672345678901234567890

What did you expect to see?

123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
测试程序: 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
测试程序: 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
seankhliao commented 2 weeks ago

does it reproduce with the latest go release? with a different terminal? writing to a file?

studyzy commented 2 weeks ago

does it reproduce with the latest go release? with a different terminal? writing to a file? Thanks! It's a GoLand terminal bug. VSCode or Mac default terminal is correct.