github.com/team-ide/go-dialect@v1.9.20/worker/data_source.go (about) 1 package worker 2 3 import "github.com/team-ide/go-dialect/dialect" 4 5 type DataSource interface { 6 Stop() 7 ReadStart() (err error) 8 Read(columnList []*dialect.ColumnModel, onRead func(data *DataSourceData) (err error)) (err error) 9 ReadEnd() (err error) 10 WriteStart() (err error) 11 Write(data *DataSourceData) (err error) 12 WriteEnd() (err error) 13 WriteHeader(columnList []*dialect.ColumnModel) (err error) 14 } 15 16 type DataSourceData struct { 17 HasSql bool 18 Sql string 19 HasData bool 20 Data map[string]interface{} 21 ColumnList []*dialect.ColumnModel 22 } 23 24 type DataSourceParam struct { 25 Path string 26 Separator string 27 SheetIndex int 28 StartRow int 29 SheetName string 30 Linefeed string 31 TitleList []string 32 Dia dialect.Dialect 33 } 34 35 func (this_ *DataSourceParam) GetTextSeparator() string { 36 if this_.Separator != "" { 37 return this_.Separator 38 } 39 return "|:-:|" 40 } 41 42 func (this_ *DataSourceParam) GetCsvSeparator() string { 43 if this_.Separator != "" { 44 return this_.Separator 45 } 46 return "," 47 } 48 49 func (this_ *DataSourceParam) GetLinefeed() string { 50 if this_.Linefeed != "" { 51 return this_.Linefeed 52 } 53 return "|:-n-:|" 54 }