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

print uint's in decimal? #185

Closed
Dieterbe opened this issue Jan 22, 2020 · 2 comments · Fixed by #199
Closed

print uint's in decimal? #185

Dieterbe opened this issue Jan 22, 2020 · 2 comments · Fixed by #199

Comments

@Dieterbe
Copy link

Hello. Great library! I enjoy using it in my unit tests.
Just one request:
This program:

package main

import (
	"fmt"

	"github.com/google/go-cmp/cmp"
)

func main() {
	fmt.Println(cmp.Diff(uint32(42), uint32(4)))
}

prints:

  uint32(
- 	0x2a,
+ 	0x04,
  )

this is hard to understand for humans. It would be nice if there was a mode to print these numbers in decimal form.

@dsnet
Copy link
Collaborator

dsnet commented Jan 29, 2020

In the past, the choice to use hexadecimal was to ensure []byte (which is really an alias for []uint8) printed in hexadecimal form, but I agree that it causes standalone unsigned integers to print in sub-par fashion. Perhaps we should always print unsigned integers in decimal form and special case []uint8 instead.

@Dieterbe
Copy link
Author

that seems pretty reasonable

dsnet pushed a commit that referenced this issue May 15, 2020
In general, decimal formatting is preferred except for []byte
where hexadecimal is preferred for individual elements.

Fixes #185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants