jonas-p / go-shp

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

get attribute exception #55

Open ruierzhao opened 10 months ago

ruierzhao commented 10 months 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?