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

x/net/icmp: Can not access Echo struct fields #17380

Closed
wgj opened this issue Oct 8, 2016 · 2 comments
Closed

x/net/icmp: Can not access Echo struct fields #17380

wgj opened this issue Oct 8, 2016 · 2 comments

Comments

@wgj
Copy link

wgj commented Oct 8, 2016

What version of Go are you using (go version)?

go version go1.7.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOOS="darwin"
GOARCH="amd64"

What did you do?

https://play.golang.org/p/Ejp3XuTl8n
Tried to read the body of an ICMPv4 echo reply. On line 34, I'm trying to confirm that the ICMP Echo Reply received has the same data as the ICMP Echo created on line 16.

What did you expect to see?

Per https://godoc.org/golang.org/x/net/icmp#Echo, I expected access to rm.Body struct fields.

What did you see instead?

hosaka:Workspace wes$ go run test.go
# command-line-arguments
./test.go:34: rm.Body.Data undefined (type icmp.MessageBody has no field or method Data)

When line 34 is commented:

hosaka:Workspace wes$ go run test.go
2016/10/07 19:23:26 rm.Body type: *icmp.Echo
2016/10/07 19:23:26 rm.Body value: &{ID:40650 Seq:0 Data:[116 101 115 116 115 116 114 105 110 103]}
2016/10/07 19:23:26 rm.Body string: &{%!s(int=40650) %!s(int=0) teststring}
@mikioh
Copy link
Contributor

mikioh commented Oct 8, 2016

For questions, please take a look at https://golang.org/wiki/Questions. The Body field of Message structure is an interface, so you probably need to take a look at https://golang.org/ref/spec#Type_assertions too.

@mikioh mikioh closed this as completed Oct 8, 2016
@wgj
Copy link
Author

wgj commented Oct 9, 2016

I wasn't asking a question, and thought it was an actual error. Your reply made me realize that the problem was in my code, and not in x/net/icmp. Thank you, and sorry for misusing Go's issue reporting.

@golang golang locked and limited conversation to collaborators Oct 9, 2017
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