title: How to remove all spaces, newlines, tabs from byte array?
body: <p>I am writing a test where I want to compare the result of <code>json.Marshal</code> with a static json string:</p>
  
  <pre><code>var json = []byte(`{
      "foo": "bar"
  }`)
  </code></pre>
  
  <p>As the result of <code>json.Marshal</code> does not have any <code>\n</code>, <code>\t</code> and spaces I thought I could easily do:</p>
  
  <pre><code>bytes.Trim(json, " \n\t")
  </code></pre>
  
  <p>to remove all of these characters.
  However unfortunately this does not work. I could write a custom trim function and use <code>bytes.TrimFunc</code> but this seems to complicated to me.</p>
  
  <p><strong>What else could I do to have a json string "compressed" with as less code as possible?</strong></p>
  
  <p>Best,
  Bo</p>