Documentation
¶
Index ¶
- Constants
- Variables
- func FileExist(path string) bool
- func FilterField(field string) bool
- func FilterQuery(urlString string, blackList []string) string
- func GenerateId() string
- func GetCurrentTime() string
- func GetDescFromIP(ip string) string
- func GetDescFromUserAgent(userAgent string) string
- func GetIPFromRequest(req *http.Request) string
- func GetIPInfo(clientIP string) string
- func GetIdFromOwnerAndName(owner string, name string) string
- func GetOwnerAndNameFromId(id string) (string, string)
- func GetOwnerAndNameFromId3(id string) (string, string, string)
- func GetOwnerAndNameFromId3New(id string) (string, string, string)
- func GetOwnerAndNameFromIdNoCheck(id string) (string, string)
- func IndexAt(s, sep string, n int) int
- func Init(dataFile string) (err error)
- func InitIpDb()
- func InitParser()
- func InitWithData(data []byte)
- func JsonToStruct(data string, v interface{}) error
- func ListFiles(path string) []string
- func LogInfo(ctx *context.Context, f string, v ...interface{})
- func ParseFloat(s string) float64
- func ParseInt(s string) int
- func ParseIntWithError(s string) (int, error)
- func ReadBytesFromPath(path string) []byte
- func ReadStringFromPath(path string) string
- func SnakeString(s string) string
- func StructToJson(v interface{}) string
- func WriteBytesToPath(b []byte, path string)
- func WriteStringToPath(s string, path string)
- type LocationInfo
- type Locator
Constants ¶
View Source
const Null = "N/A"
Variables ¶
View Source
var ( ReWhiteSpace *regexp.Regexp ReFieldWhiteList *regexp.Regexp )
View Source
var (
ErrInvalidIp = errors.New("invalid IP format")
)
View Source
var Parser *uaparser.Parser
Functions ¶
func FilterField ¶
func FilterQuery ¶
func GenerateId ¶
func GenerateId() string
func GetCurrentTime ¶
func GetCurrentTime() string
func GetDescFromIP ¶
func GetDescFromUserAgent ¶
func GetIPFromRequest ¶
func GetIdFromOwnerAndName ¶
func GetOwnerAndNameFromId ¶
func InitParser ¶
func InitParser()
func JsonToStruct ¶
func ParseFloat ¶
func ParseIntWithError ¶
func ReadBytesFromPath ¶
func ReadStringFromPath ¶
func StructToJson ¶
func StructToJson(v interface{}) string
func WriteBytesToPath ¶
func WriteStringToPath ¶
Types ¶
type LocationInfo ¶
func Find ¶
func Find(ipstr string) (*LocationInfo, error)
Find locationInfo by ip string It will return err when ipstr is not a valid format
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
func NewLocator ¶
New locator with dataFile
func (*Locator) Find ¶
func (loc *Locator) Find(ipstr string) (info *LocationInfo, err error)
Find locationInfo by ip string It will return err when ipstr is not a valid format
func (*Locator) FindByUint ¶
func (loc *Locator) FindByUint(ip uint32) (info *LocationInfo)
Find locationInfo by uint32
Source Files
¶
Click to show internal directories.
Click to hide internal directories.