Ali OSS select package for go.
Codes of Auth.go basically come from Ali OSS SDK
go get -u github.com/killernova/goossselect
import(gol github.com/killernova/goossselect)
s, err := gol.NewSelector("Select * from ossobject")
You can also set options for this generator with predefined functions or functions defined by yourself:
s, err := gol.NewSelector("Select * from ossobject", gol.SetRange("line", 10, 333))
c := gol.NewConfig(func(conf *gol.Config) {
conf.AccessKeyID = "ercbcv43tgert"
conf.AccessKeySecret = "sferg456ghvbsf435435"
})
data, err = s.SelectQuery("dwl-oss", "links.csv", c)
or you can save data to file
f, err := os.OpenFile("efg.csv", os.O_RDWR|os.O_CREATE, 0755)
if err != nil {
panic(err)
}
defer f.Close()
err = s.SelectQueryToFile("dwl-oss", "links.csv", c, f)
if err != nil {
fmt.Println(err)
}
maybe you want query meta data
m, err := gol.NewMeta()
data, err = m.SelectMeta("dwl-oss", "links.csv", c)
this will return a struct which contains informations of your query csv file
type MetaResponse struct {
Lines int64
Columns int64
Splits int64
ContentLength int64
}
Most of time you can use the default options, but if you want to change it, use predefined functions as follows:
# Selector:
SetFileHeaderInfo(s string)
SetInRecordDelimiter(s string)
SetInFieldDelimiter(s string)
SetOutRecordDelimiter(s string)
SetOutFieldDelimiter(s string)
SetOutputRawData(b bool)
SetKeepAllColumns(b bool)
SetQuoteCharacter(s string)
SetCommentCharacter(s string)
SetRange(s string, start, end int)
# Meta:
SetMetaOverwriteIfExisting(b bool)
SetMetaRecordDelimiter(s string)
SetMetaFieldDelimiter(s string)
SetMetaQuoteCharacter(s string)
You can also use your own functions which receive *Selector or *Meta and return error