mirror of
https://github.com/nxshock/mssqlbulkloader.git
synced 2024-11-28 00:21:03 +05:00
34 lines
466 B
Go
34 lines
466 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"archive/zip"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
type ProcessFunc func(io.Reader, *Options) error
|
||
|
|
||
|
type ZipReader struct{}
|
||
|
|
||
|
func (zr *ZipReader) Process(options *Options) error {
|
||
|
z, err := zip.OpenReader(options.filePath)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer z.Close()
|
||
|
|
||
|
for _, zFile := range z.File {
|
||
|
f, err := zFile.Open()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer f.Close()
|
||
|
|
||
|
err = process(f, options)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|