You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a column modification where the original column name and the target name (key) are equal, an index out of range exception occurs when trying to read the resulting dbf rows.
2022/08/29 15:32:51 Importing technicians...
2022/08/29 15:32:51 [importer] [0] interruption: runtime error: index out of range [-1]
exit status 0xc000013a
log.Print("Importing technicians...")
dbf, err:=dbase.Open(filepath.Join(manager.config.DBPath, "DATABASE.dbf"), &dbase.Win1250Converter{})
iferr!=nil {
log.Panicf(err.Error())
}
deferdbf.Close()
dbf.SetTrimspacesDefault(true)
dbf.SetColumnModification(dbf.ColumnPos("TECHNR"), true, "ID", nil)
dbf.SetColumnModification(dbf.ColumnPos("Name"), true, "Name", nil) //crashes because of this linefor!dbf.EOF() {
row, err:=dbf.Row()
iferr!=nil {
log.Panicf(err.Error())
}
dbf.Skip(1)
if row.Deleted {
continue
}
...
}
The error does not occur because the name is identical, but because there is no column with the name "Name". dbf.ColumnPos("Name") returns -1 and thus the index is out of range. I will, for ease of use, include a check to validate that the index is valid.
When creating a column modification where the original column name and the target name (key) are equal, an index out of range exception occurs when trying to read the resulting dbf rows.
The original column names in the dbf table:

The target struct for reference:
Reading the rows works perfectly fine when removing the line, but this action should not cause any problems...
The text was updated successfully, but these errors were encountered: