title: How to check if parameter passed into function is nil in Go?
body: <p>Need to check if parameter being passed to func is nil and return 0.</p>
  
  <p>Below is my intended code </p>
  
  <pre><code>func (t *Transaction) GetOperationCount(input bean.Request) (int, error) {
      var result int = 0
      if input == nil { //error here
          return result, nil
      }
      // Other code here!!!!
      return result, nil
  }
  </code></pre>
  
  <p><code>bean.Reques</code> is a struct. 
  However it had issue: "cannot convert nil to type bean.Request input Request". I have trying </p>
  
  <pre><code>if (bean.Request{})== input
  </code></pre>
  
  <p>But it gives :  </p>
  
  <pre><code>"json:\"MV_STATUS\""; NDFNFFP string "json:\"NDF_NFFP\""; NDFNFMV string "json:\"NDF_NFMV\"" } "json:\"attr\"" } "json:\"marke
  t_value\"" } "json:\"market_values\"" } "json:\"tick\"" } "json:\"insertion\"" } "json:\"operation\"" } "json:\"transaction\"" 
  } cannot be compared)
  </code></pre>
  
  <p>Should I change the parameter to "input *bean.Request" ?</p>