title: Access to a remote docker repository using Go
body: <p>I need to access to a private docker registry using Go and protocol V2. I need to list repositories in the private registry, get all the tags of them and another info.  Should I use docker/distribution/registry/client for that? Are there a sample for such a task? I can't find it... The official site provides only http api documentation.</p>
  
  <p>I wrote some code:</p>
  
  <pre><code>    registry, err := client.NewRegistry("https://registry-1.docker.io/", http.DefaultTransport)
      if err != nil {
          log.Error("Error creating the registry: {}", err)
          return
      }
  
      ctx := context.Background()
  
      entries := make([]string, 5)
  
      numFilled, err := registry.Repositories(ctx, entries, "")
      if err != io.EOF {
          log.Error("Error getting the registry: {}", err)
          return
      }
  
      log.Info("Number of repositories: {}", numFilled)
  
      _ = registry
  </code></pre>
  
  <p>Of course, the docker repo needs authentication. But how should I provide it? Is there a doc for such task?</p>