plugin/geoip: cleanup code (#5009)

remove unnecessary float64 convert and clean code

Signed-off-by: xuweiwei <xuweiwei_yewu@cmss.chinamobile.com>
This commit is contained in:
xuweiwei 2021-11-24 16:24:49 +08:00 committed by GitHub
parent eec4acdd96
commit 7e12327ab1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -39,11 +39,11 @@ func (g GeoIP) setCityMetadata(ctx context.Context, data *geoip2.City) {
return continentCode
})
latitude := strconv.FormatFloat(float64(data.Location.Latitude), 'f', -1, 64)
latitude := strconv.FormatFloat(data.Location.Latitude, 'f', -1, 64)
metadata.SetValueFunc(ctx, pluginName+"/latitude", func() string {
return latitude
})
longitude := strconv.FormatFloat(float64(data.Location.Longitude), 'f', -1, 64)
longitude := strconv.FormatFloat(data.Location.Longitude, 'f', -1, 64)
metadata.SetValueFunc(ctx, pluginName+"/longitude", func() string {
return longitude
})

View file

@ -58,7 +58,7 @@ func newGeoIP(dbPath string) (*GeoIP, error) {
return nil, fmt.Errorf("unexpected failure looking up database %q schema %q: %v", filepath.Base(dbPath), schema.name, err)
}
} else {
db.provides = db.provides | schema.provides
db.provides |= schema.provides
}
}