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: Printf ignores width specification for nil values #4772

Closed
mxk opened this issue Feb 7, 2013 · 2 comments
Closed

fmt: Printf ignores width specification for nil values #4772

mxk opened this issue Feb 7, 2013 · 2 comments
Milestone

Comments

@mxk
Copy link

mxk commented Feb 7, 2013

When the format string passed to Printf and friends specifies a width for a value (e.g.
"%10v"), the width is ignored if the value is nil. The algorithm should
probably be changed to convert nil to the string "<nil>", and then apply
width and other specifications just like for any other string value.

What steps will reproduce the problem?
http://play.golang.org/p/tulmfQ5QYE

What is the expected output?
|         x|
|         1|
|      true|
|     <nil>|
|         y|
|     <nil>|

What do you see instead?
|         x|
|         1|
|      true|
|<nil>|
|         y|
|<nil>|

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Windows 7

Which version are you using?  (run 'go version')
go version devel +aba17f1b93db Thu Feb 07 18:54:21 2013 +0800 windows/amd64
@robpike
Copy link
Contributor

robpike commented Feb 14, 2013

Comment 1:

Labels changed: added priority-soon, removed priority-triage.

Owner changed to @robpike.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Feb 20, 2013

Comment 2:

This issue was closed by revision cbd2c7a.

Status changed to Fixed.

@mxk mxk added fixed labels Feb 20, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned robpike Jun 22, 2022
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