title: Golang - get list of files from a shared Google Drive folder
body: <p>I am trying to list files and their IDs from a Google Drive folder using a known folder ID.</p>
  <p>The drive service set up seems to be successful. But, I get a panic attempting to populate a variable with the info. Here is a snippet of the code:</p>
  <pre><code>    driveService, err := drive.NewService(ctx, option.WithCredentialsFile(&quot;../serverFiles/credentials.json&quot;))
      if err != nil {
          log.Printf(&quot;Unable to retrieve Drive client: %v&quot;, err)
      }
  
      r, err := driveService.Files.List().
          DriveId('XXXXXXXXXX').
          PageSize(10).
          Fields(&quot;nextPageToken, files(id, name)&quot;).
          Do()
      if err != nil {
          log.Fatalf(&quot;Unable to retrieve files: %v&quot;, err)
      }
  </code></pre>
  <p>Here is the error I get:</p>
  <pre><code>panic: runtime error: invalid memory address or nil pointer dereference
  [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x14312db]
  </code></pre>
  <p>Thanks for any help.</p>
  <p><strong>EDIT</strong><br>
  Thanks to @Tanaike's answer, I learned that I was confused about some points.
  I am not attempting to get a list of files from a shared Drive, but a shared folder. <br>
  I am using a service account to access. In another script the same service account is able to write to this same drive folder. So, I think permissions are OK. <br>
  Here is how I am now trying to get the list (driveService is set up the same as above)</p>
  <pre><code>    r, err := driveService.Files.List().
          Corpora(&quot;user&quot;).
          PageSize(10).
          Q(&quot;'XXXXXXXX' in parents&quot;).
          Fields(&quot;nextPageToken, files(id, name)&quot;).
          Do()
  </code></pre>
  <p>I still get the panic and signal.</p>