jonas-p / go-shp

Go library for reading and writing ESRI Shapefiles. Pure Golang implementation based on the ESRI Shapefile technical description.
MIT License
258 stars 68 forks source link

get attribute exception #55

Open ruierzhao opened 1 year ago

ruierzhao commented 1 year ago

I use this lib to read the shapefile.DBF and store it as a map Attribute. when I try to get the Value of I had stored, I get nil,I use value,ok := Attribute["OBJECTID"],it return nil,false.I store it like this:

for indFields, v := range fields {
    featureAttributes[v.String()] = shpreader.Attribute(indFields)
}

And when I do it like this:

func (f Feature) GetAttrByName(name string) string {
    for k, v := range f.Attributes {
        if k == name {
            return v
        }
    }
    mylog.Error.Printf("获取%s的值失败", name)
    return ""
}

it can work again.just slightly perplexed.Why is that?