title: Golang: How to printf % x for bytes in a struct?
body: <pre><code>var b [88]byte
  n, err := file.Read(b[:])
  fmt.Printf("bytes read: %d Bytes: [% x]\n", n, b)
  </code></pre>
  
  <p>The above prints bytes in hexdecimal</p>
  
  <p>I have a struct like this</p>
  
  <pre><code>type SomeStruct struct {
     field1 []byte
     field2 []byte
  }
  someStructInstance := SomeStruct{[249 190 180 217], [29 1 0 0]}
  fmt.Println(someStructInstance)
  =&gt; {[249 190 180 217] [29 1 0 0]}
  </code></pre>
  
  <p>But ideally I would like it to print hexdecimal</p>
  
  <pre><code>=&gt; {[f9 be b4 d9] [1d 01 00 00]}
  </code></pre>
  
  <p>How would I go about that?</p>