本文整理匯總了Golang中os.Error.Error方法的典型用法代碼示例。如果您正苦於以下問題:Golang Error.Error方法的具體用法?Golang Error.Error怎麽用?Golang Error.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類os.Error
的用法示例。
在下文中一共展示了Error.Error方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: OpenFile
// OpenFile() take the name of an XLSX file and returns a populated
// xlsx.File struct for it.
func OpenFile(filename string) (x *File, e os.Error) {
var f *zip.ReadCloser
var error os.Error
var file *File
var v *zip.File
var workbook *zip.File
var sharedStrings *zip.File
var reftable []string
var worksheets map[string]*zip.File
f, error = zip.OpenReader(filename)
if error != nil {
return nil, error
}
file = new(File)
worksheets = make(map[string]*zip.File, len(f.File))
for _, v = range f.File {
switch v.Name {
case "xl/sharedStrings.xml":
sharedStrings = v
case "xl/workbook.xml":
workbook = v
default:
if len(v.Name) > 12 {
if v.Name[0:13] == "xl/worksheets" {
worksheets[v.Name[14:len(v.Name)-4]] = v
}
}
}
}
file.worksheets = worksheets
reftable, error = readSharedStringsFromZipFile(sharedStrings)
if error != nil {
return nil, error
}
if reftable == nil {
error := new(XLSXReaderError)
error.Error = "No valid sharedStrings.xml found in XLSX file"
return nil, error
}
file.referenceTable = reftable
sheets, error := readSheetsFromZipFile(workbook, file)
if error != nil {
return nil, error
}
if sheets == nil {
error := new(XLSXReaderError)
error.Error = "No sheets found in XLSX File"
return nil, error
}
file.Sheets = sheets
f.Close()
return file, nil
}