title: Cannot convert nil (untyped nil value) to struct
body: <p>A Go noob's learning to use <code>sqlc</code> here. I'm trying to create a method that creates a user.</p>
  <p>How do I return <code>nil</code> for a struct?</p>
  <pre class="lang-golang prettyprint-override"><code>type user struct{}
  
  func (u *user) Create(ctx context.Context, db *sql.DB) (pg.User, error) {
      q := pg.New(db)
      user, err := q.CreateUser(ctx, &quot;Someone&quot;)
      if err != nil {
          return nil, err
          //      ^
          // [compiler] [E] cannot convert nil (untyped nil value) to pg.User
      }
      return user, nil
  }
  </code></pre>
  <p>This is the <code>pg.User</code> struct:</p>
  <pre class="lang-golang prettyprint-override"><code>type User struct {
      ID int64 `json:&quot;id&quot;`
      // can not be empty
      Name      string    `json:&quot;name&quot;`
      CreatedAt time.Time `json:&quot;created_at&quot;`
      UpdatedAt time.Time `json:&quot;updated_at&quot;`
  }
  </code></pre>
  <p>Currently, I'm returning pointer instead, which gives no error:</p>
  <pre class="lang-golang prettyprint-override"><code>func (u *user) Create(ctx context.Context, db *sql.DB) (*pg.User, error) {
      q := pg.New(db)
      var usr *pg.User
      user, err := q.CreateUser(ctx, &quot;Someone&quot;)
      if err != nil {
          return nil, err
      }
  
      fmt.Println(&quot;&gt;&gt; user:&quot;, user)
      // &gt;&gt; user: {1 Someone 2020-09-14 18:36:05.94079 +0000 UTC 2020-09-14 18:36:05.94079 +0000 UTC}
  
      usr = &amp;user
      fmt.Println(&quot;&gt;&gt; usr:&quot;, usr)
      // &gt;&gt; usr: &amp;{1 Someone 2020-09-14 18:36:05.94079 +0000 UTC 2020-09-14 18:36:05.94079 +0000 UTC}
  
      return usr, nil
  }
  </code></pre>
  <p>One more question though, which one is better, returning pointer or not?</p>