You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\TimLiu\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\TimLiu\go
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
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
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\TimLiu\AppData\Local\Temp\go-build776041726=/tmp/go-build -gno-record-gcc-switches
What did you do?
var contents string
buffer1 := bytes.NewBufferString(contents)
fmt.Printf("The length of new buffer with contents %q: %d\n", contents, buffer1.Len())
fmt.Printf("The capacity of new buffer with contents %q: %d\n", contents, buffer1.Cap())
fmt.Println()
the result:
The length of new buffer with contents "": 0
The capacity of new buffer with contents "": 32
when i start write string:
var contents string
buffer1 := bytes.NewBufferString(contents)
fmt.Printf("The length of new buffer with contents %q: %d\n", contents, buffer1.Len())
fmt.Printf("The capacity of new buffer with contents %q: %d\n", contents, buffer1.Cap())
fmt.Println()
contents = "123456"
fmt.Printf("Write contents %q ...\n", contents)
buffer1.WriteString(contents)
fmt.Printf("The length of buffer: %d\n", buffer1.Len())
fmt.Printf("The capacity of buffer: %d\n", buffer1.Cap())
fmt.Println()
the result is :
The length of new buffer with contents "": 0
The capacity of new buffer with contents "": 0
Write contents "123456" ...
The length of buffer: 6
The capacity of buffer: 6
why the initial capacity is Different?
What did you expect to see?
i think the initial capacity is always zero
What did you see instead?
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
the result:
when i start write string:
the result is :
why the initial capacity is Different?
What did you expect to see?
i think the initial capacity is always zero
What did you see instead?
The text was updated successfully, but these errors were encountered: