// read each message from the file
read each message from the file
// read each message from the file
func (f *File) readFile() (err error) {
	filename := strings.Replace(f.uri, "file://", "", 1)
	f.filehandle, err = os.Open(filename)
	if err != nil {
		f.pipe.Err <- adaptor.NewError(adaptor.CRITICAL, f.path, fmt.Sprintf("Can't open input file (%s)", err.Error()), nil)
		return err
	}
	decoder := json.NewDecoder(f.filehandle)
	for {
		var doc map[string]interface{}
		if err := decoder.Decode(&doc); err == io.EOF {
			break
		}
		if err != nil {
			f.pipe.Err <- adaptor.NewError(adaptor.ERROR, f.path, fmt.Sprintf("Can't marshal document (%s)", err.Error()), nil)
			return err
		}
		f.pipe.Send(message.NewMsg(message.Insert, doc, fmt.Sprintf("file.%s", filename)))
	}
	return nil
}
func ( f * File ) readFile ( ) ( err error ) { filename := strings . Replace ( f . uri , " " , " " , 1 ) f . filehandle , err = os . Open ( filename ) if err != nil { f . pipe . Err <- adaptor . NewError ( adaptor . CRITICAL , f . path , fmt . Sprintf ( " " , err . Error ( ) ) , nil ) return err } decoder := json . NewDecoder ( f . filehandle ) for { var doc map [ string ] interface { } if err := decoder . Decode ( & doc ) ; err == io . EOF { break } if err != nil { f . pipe . Err <- adaptor . NewError ( adaptor . ERROR , f . path , fmt . Sprintf ( " " , err . Error ( ) ) , nil ) return err } f . pipe . Send ( message . NewMsg ( message . Insert , doc , fmt . Sprintf ( " " , filename ) ) ) } return nil }
read each message from the file
read each message from the file