// This function streams the reader to the Gearman job (through job.SendData()) func streamToGearman(reader io.Reader, job baseworker.Job) error { buffer := make([]byte, 1024) for { n, err := reader.Read(buffer) // Process the data before processing the error (as per the io.Reader docs) if n > 0 { job.SendData(buffer[:n]) } if err == io.EOF { return nil } else if err != nil { return err } } }