title: Create a function with return type of image magick object in go lang
body: <p>I want to create image magick object corresponding to images stroed in S3. So, i was writing a function which will take necessary arguments and return the image magick object. But, no luck with it. This is the <a href="https://github.com/gographics/imagick" rel="nofollow">Imagick Library</a> which i am using.</p>
  
  <pre><code>     func main() {
          mw := imagick.NewMagickWand()
          defer mw.Destroy()
          mw = ObjImagick(bucketName, keyName, region)
      }
  
  
  
    func ObjImagick(bktName string, kName string, region string) ( ) {
  
      s3Client := s3.New(session.New(), &amp;aws.Config{Region: aws.String(region)})
          params := &amp;s3.GetObjectInput{
          Bucket: aws.String(bktName),
          Key: aws.String(kName),
          }
  
      out, err := s3Client.GetObject(params)
      if err != nil {
          log.Fatal(err)
      }
  
      img, err := ioutil.ReadAll(out.Body)
      if err != nil {
          log.Fatal(err)
      }      
  
      mw := imagick.NewMagickWand()
      defer mw.Destroy()
  
      err = mw.ReadImageBlob(img)
      if err != nil {
          log.Fatal(err)
      }
  
         return mw
  }
  </code></pre>