title: How to check if all fields of a *struct are nil?
body: <p>I'm not quite sure how to address this question, please feel free to edit.</p>
  
  <p>With the first code block below, I am able to check if a all fields of a struct are nil.</p>
  
  <p>In reality however, the values injected in the struct, are received as <strong>args.Review</strong> (see second code block below).</p>
  
  <p><strong>In the second code block, how can I check if all fields from args.Review are nil?</strong></p>
  
  <p><a href="https://play.golang.org/p/vxtxIcoy3t7" rel="nofollow noreferrer">Try it on Golang Playground</a></p>
  
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      "fmt"
      "reflect"
  )
  
  type review struct {
      Stars      *int32  `json:"stars" bson:"stars,omitempty" `
      Commentary *string `json:"commentary" bson:"commentary,omitempty"`
  }
  
  func main() {
  
      newReview := &amp;review{
          Stars: nil,
          // Stars:   func(i int32) *int32 { return &amp;i }(5),
  
          Commentary: nil,
          // Commentary: func(i string) *string { return &amp;i }("Great"),
      }
  
      if reflect.DeepEqual(review{}, *newReview) {
          fmt.Println("Nothing")
      } else {
          fmt.Println("Hello")
      }
  
  }
  </code></pre>
  
  <p><a href="https://play.golang.org/p/70exK_UYd8E" rel="nofollow noreferrer">Try the second code on Golang Playground</a>
  This code below gets two errors:</p>
  
  <blockquote>
    <p>prog.go:32:14: type args is not an expression</p>
    
    <p>prog.go:44:27: args.Review is not a type</p>
  </blockquote>
  
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      "fmt"
      "reflect"
  )
  
  type review struct {
      Stars      *int32  `json:"stars" bson:"stars,omitempty" `
      Commentary *string `json:"commentary" bson:"commentary,omitempty"`
  }
  
  type reviewInput struct {
      Stars      *int32
      Commentary *string
  }
  
  type args struct {
      PostSlug string
      Review   *reviewInput
  }
  
  func main() {
      f := &amp;args {
          PostSlug: "second-post",
          Review: &amp;reviewInput{
              Stars:  func(i int32) *int32 { return &amp;i }(5),
              Commentary: func(i string) *string { return &amp;i }("Great"),
          },
  
      }
      createReview(args)
  }
  
  func createReview(args *struct {
      PostSlug string
      Review   *reviewInput
  }) {
      g := &amp;review{
          Stars: args.Review.Stars,
          Commentary: args.Review.Commentary,
      }
  
      if reflect.DeepEqual(args.Review{}, nil) {
          fmt.Println("Nothing")
      } else {
          fmt.Println("Something")
      }
  }
  </code></pre>