Skip to content

bufio: small buffer size and Unicode character trigger flush at wrong time #22883

@ooghry

Description

@ooghry

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

go version go1.9.2 windows/amd64

Does this issue reproduce with the latest release?

yes

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:\gopath
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
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

https://play.golang.org/p/wR1TryoaVK
Hi there
If create new buffer writer with a size of 3. then write 1byte character and then write 2byte character.
golang trigger flush only the first(1byte) character and put second character in buffer.
I expect flush all 2 characters.

What did you expect to see?

Buffered 0
Buffered 1
Buffered 3
Available 0
writer: "aب"
Buffered 1
Buffered 2
writer: "cd"

What did you see instead?

Buffered 0
Buffered 1
writer: "a"
Buffered 2
Available 1
Buffered 3
writer: "بc"
Buffered 1
writer: "d"

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions