title: How to create object for a struct in golang
body: <p><em>File1.go</em></p>
  
  <pre><code>Package abc
  
  type ECA struct {
      *CA
      obcKey          []byte
      obcPriv, obcPub []byte
      gRPCServer      *grpc.Server
  }
  
  
  type ECAP struct {
      eca *ECA
  }
  
  
  func (ecap *ECAP) ReadCACertificate(ctx context.Context, in *pb.Empty) (*pb.Cert, error) {
      Trace.Println("gRPC ECAP:ReadCACertificate")
  
      return &amp;pb.Cert{Cert: ecap.eca.raw}, nil
  }
  </code></pre>
  
  <p><em>File2.go</em></p>
  
  <pre><code>package main
  
  import "abc"
  
  var ecap abc.ECAP //creating instance
  
  func main() {
      err = ecap.ReadCACertificate(floo,floo)
  }
  </code></pre>
  
  <p>I am a newbie. I want to create instance of ECAP struct and call ReadCACertificate method. Right now i am creating like this "var ecap abc.ECAP //creating instance" which is giving "nil" and nil pointer error.</p>
  
  <p>Can anyone help how to call the ReadCACertificate method in efficient way.</p>
  
  <p>Thanks in advance.</p>