Documentation
¶
Index ¶
Constants ¶
const ( // FieldCity 城市 FieldCity = "city" // FieldContinent 大洲 FieldContinent = "continent" // FieldCountry 国家 FieldCountry = "country" // FieldSubdivisions 行政区 FieldSubdivisions = "subdivisions" // FieldAccuracyRadius 定位精度 FieldAccuracyRadius = "accuracy_radius" // FieldLatitude 纬度 FieldLatitude = "latitude" // FieldLongitude 经度 FieldLongitude = "longitude" // FieldMetroCode 城市代码 FieldMetroCode = "metro_code" // FieldTimeZone 时区 FieldTimeZone = "time_zone" // FieldPostalCode 邮政编码 FieldPostalCode = "postal_code" // FieldRegisteredCountry 注册国家 FieldRegisteredCountry = "registered_country" // FieldRepresentedCountry 代表国家 FieldRepresentedCountry = "represented_country" // FieldRepresentedCountryType 代表国家类型 FieldRepresentedCountryType = "represented_country_type" // FieldIsAnonymousProxy 是否匿名代理 FieldIsAnonymousProxy = "is_anonymous_proxy" // FieldIsSatelliteProvider 是否卫星提供商 FieldIsSatelliteProvider = "is_satellite_provider" // FieldAutonomousSystemNumber 自治系统号 FieldAutonomousSystemNumber = "autonomous_system_number" // FieldAutonomousSystemOrganization 自治系统组织 FieldAutonomousSystemOrganization = "autonomous_system_organization" )
const ( DBFormat = "mmdb" DBExt = ".mmdb" )
Variables ¶
var CommonFieldsAlias = map[string]string{ model.Country: FieldCountry, model.City: FieldCity, model.Continent: FieldContinent, model.Province: FieldSubdivisions, model.UTCOffset: FieldTimeZone, model.Latitude: FieldLatitude, model.Longitude: FieldLongitude, model.ASN: FieldAutonomousSystemNumber, }
CommonFieldsAlias 公共字段到数据库字段映射
Functions ¶
func ConvertToMMDBType ¶ added in v0.2.1
ConvertToMMDBType converts a given value to an appropriate MMDB data type. If the value is a complex type (e.g., struct or map), it uses reflection to handle the conversion.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a structure that provides functionalities to read from MMDB IP database.
func NewReader ¶
NewReader initializes and returns a new Reader for the specified MMDB file. It loads metadata and sets default options for the reader.
func (*Reader) Close ¶
Close releases any resources used by the Reader and closes the MMDB database.
type ReaderOption ¶ added in v0.2.1
type ReaderOption struct { DisableExtraData bool // If true, extra data (matched via GeoNameID) won't be used. UseFullField bool // If true, all data will be combined into a single JSON string field. }
ReaderOption contains configuration options for the Reader.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer provides functionalities to write IP data into MMDB format.
func (*Writer) ConvertMap ¶ added in v0.2.1
ConvertMap converts fields and values to a map.
type WriterOption ¶
type WriterOption struct {
SelectLanguages string // SelectLanguages specifies the languages to be selected for the names.
}
WriterOption provides options for the Writer.