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: float formatting should not alter the width for other elements #14642

Closed
martisch opened this issue Mar 4, 2016 · 1 comment
Closed

fmt: float formatting should not alter the width for other elements #14642

martisch opened this issue Mar 4, 2016 · 1 comment

Comments

@martisch
Copy link
Contributor

@martisch martisch commented Mar 4, 2016

at least go1.4, go1.6, go tip:

https://play.golang.org/p/tArTXnDSma

package main

import "fmt"

func main() {
    fmt.Printf("%06v\n",[]interface{}{-10.0,10})
    fmt.Printf("%06v\n",[]interface{}{-10,10})
}

Output:

[-00010 00010]
[-00010 000010]

They should be the same.
However formatFloat alters the width field and does not restore its original value.

Discovered this while writing test cases for a float format cleanup.
Which failed for the current go but worked for my new code.

Will submit a separate fix for this referencing this issue first.

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 4, 2016

CL https://golang.org/cl/20179 mentions this issue.

@gopherbot gopherbot closed this in 7837418 Mar 5, 2016
@golang golang locked and limited conversation to collaborators Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.