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

fmt: doesn't print nil slice correctly #7639

Closed
gopherbot opened this issue Mar 26, 2014 · 4 comments
Closed

fmt: doesn't print nil slice correctly #7639

gopherbot opened this issue Mar 26, 2014 · 4 comments
Milestone

Comments

@gopherbot
Copy link

by leterip:

What does 'go version' print?
go1.2.1

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. http://play.golang.org/p/npUWWoTYip

What happened?
map[int]uint8(nil)
[]byte{}

What should have happened instead?
map[int]uint8(nil)
[]byte(nil)

Please provide any additional information below.
@robpike
Copy link
Contributor

robpike commented Mar 26, 2014

Comment 1:

The real problem is that the printing of a nil slice is wrong.
http://play.golang.org/p/68k5ZUqzKd
package main
import "fmt"
func main() {
    var y []byte
    fmt.Printf("%#v\n", y)
    y = []byte{}
    fmt.Printf("%#v\n", y)
}
prints
[]byte{}
[]byte{}
but should print
[]byte(nil)
[]byte{}
This is a bug and should be fixed.

Labels changed: added release-go1.3maybe.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Mar 26, 2014

Comment 2:

Labels changed: added repo-main.

@minux
Copy link
Member

minux commented Mar 27, 2014

Comment 3:

https://golang.org/cl/81240043

Owner changed to @minux.

Status changed to Started.

@minux
Copy link
Member

minux commented Apr 3, 2014

Comment 4:

This issue was closed by revision c274ff6.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

4 participants