github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/experimental/plugin_geoip.go (about)

     1  package main
     2  
     3  import c "github.com/Azareal/Gosora/common"
     4  import "github.com/oschwald/geoip2-golang"
     5  
     6  var geoipDB *geoip.DB
     7  var geoipDBLocation = "geoip_db.mmdb"
     8  
     9  func init() {
    10  	c.Plugins.Add(&c.Plugin{UName: "geoip", Name: "Geoip", Author: "Azareal", Init: initGeoip, Deactivate: deactivateGeoip})
    11  }
    12  
    13  func initGeoip(plugin *c.Plugin) (err error) {
    14  	geoipDB, err = geoip2.Open(geoipDBLocation)
    15  	return err
    16  }
    17  
    18  func deactivateGeoip(plugin *c.Plugin) {
    19  	geoipDB.Close()
    20  }