Skip to content

'+' or ' ' flag in Printf (et al) doesn't seem to work for positive or zero values #278

@gopherbot

Description

@gopherbot

by mkoistinen:

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. Run this code:
--- snip snip ---
package main
import . "fmt"

func main() {
    Printf("Test of Printf() string '+.3e': [%+.3e] [%+.3e] [%+.3e]\n", 0.0,
-1.5, 10000.5);
}
--- snip snip ---

Output should be: 
Test of Printf() string '+.3e': [0.000e+00] [-1.500e+00] [1.000e+04]

2. Notice the lack of the '+' sign in front of the returned 1st and 3rd values

3. Compare to specification in `man printf` on your system

What is the expected output? What do you see instead?
The output SHOULD be: 
... [+0.000e+00] [-1.500e+00] [+1.000e+04]

Also, same for the ' ' flag, which should put a space before positive
numbers instead of the '+' symbol above.

What is your $GOOS?  $GOARCH?
GOARCH=amd64
GOOS=darwin


Which revision are you using?  (hg identify)
> hg identify
cb140bac9ab0 tip

Please provide any additional information below.

Sorry if this has already been fixed since this version, but I am working
on code for another system, and must maintain the same version locally as
the remote system.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions