On Tue, Sep 11, 2012 at 1:10 PM, Jake Brukhman wrote:
Context:
I have a struct that will be filled in from binary data. I know field "str"
is going to be a 4-byte string when I read it in.
type Data struct {
one int32
two int32
str [4]byte
}
data := new(Data)
and will want to interpret "str" as a string -- but what's the best way to
do the conversion and/or reading in in this case?
Context:
I have a struct that will be filled in from binary data. I know field "str"
is going to be a 4-byte string when I read it in.
type Data struct {
one int32
two int32
str [4]byte
}
data := new(Data)
and will want to interpret "str" as a string -- but what's the best way to
do the conversion and/or reading in in this case?
You need to slice the array before converting it to a string.