title: How to log type assertion errors in golang?
body: <p>I have an array of some data which I want to map in <code>[]string</code>. I can do it in 2 ways:</p>
  
  <p>a)</p>
  
  <pre><code>// someData
  s := someData.([]string)
  </code></pre>
  
  <p>In this case, the execution would stop after listing the error on the console.</p>
  
  <p>b)</p>
  
  <pre><code>// someData
  s, ok := someData.([]string)
  </code></pre>
  
  <p>In this case, no errors would occur but s will have its zero-value</p>
  
  <hr>
  
  <p>I want to log the errors in such type assertion failure cases without stopping the execution. However, when I am using type (b), I cannot see the error details. </p>
  
  <p>The only solution I can think is to use <code>reflect.TypeOf</code> and print both the types. </p>
  
  <p>Is there any other way we can get the error when using solution (b)?</p>