func (f *Fdfs) getClient() fdfs.FdfsClient { if client == nil { lock <- 0 if !initialized { if client == nil { var e error client, e = fdfs.NewFdfsClient([]string{f.TrackerDomain}, strconv.Itoa(f.Port)) if e != nil { return nil, e } } initialized = true } <-lock } return client, nil }
func (this *Fdfs) GetImage() ([]byte, error) { if client == nil { lock <- 0 if !initialized { if client == nil { var e error client, e = fdfs.NewFdfsClient([]string{this.TrackerDomain}, strconv.Itoa(this.Port)) if e != nil { return nil, e } } initialized = true } <-lock } bts, err := client.DownloadToBuffer(this.Path, this.Cat) if err != nil { return nil, err } else { return bts, nil } }