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 %p should handle more types #441

Closed
rogpeppe opened this issue Dec 17, 2009 · 6 comments
Closed

fmt.Printf %p should handle more types #441

rogpeppe opened this issue Dec 17, 2009 · 6 comments

Comments

@rogpeppe
Copy link
Contributor

currently fmt.Printf %p works on pointer types only.
It would seem logical and useful to extend this to work on other
types, such as maps and channels, array pointers
and possibly slices too.
@gopherbot
Copy link
Contributor

Comment 1 by Ziyu4Huang:

You can print address of array pointer, isn't it ?
  var a = [...]int {1, 2, 3};
  fmt.Printf("pointer %p\n", &a);
maps, slice, channel are all reference type, why do you want a reference's address?
Only data that reference point to has meaning, like.
  var b = a[0:];
  fmt.Printf("pointer %p\n", &b[0]);

@rogpeppe
Copy link
Contributor Author

Comment 2:

being able to print the address of a mutable data structure is very useful for debugging 
- there's no other easy way to verify that two pieces of code are talking to the same 
thing. currently, %v will print the address of a channel, but there's no way to do the 
same with the others, except with the builtin function print, which only works to stdout.

@robpike
Copy link
Contributor

robpike commented Dec 19, 2009

Comment 3:

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Dec 19, 2009

Comment 4:

Owner changed to r...@golang.org.

@robpike
Copy link
Contributor

robpike commented Dec 19, 2009

Comment 5:

Labels changed: added packagechange.

@robpike
Copy link
Contributor

robpike commented Dec 22, 2009

Comment 6:

This issue was closed by revision 2e853ec.

Status changed to Fixed.

Merged into issue #-.

@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

3 participants