x

package module
Version: v0.0.0-...-1b4d914 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 18 Imported by: 42

README

x

GoDoc

My util library

Install

$ go get github.com/txthinking/x

Author

A project by txthinking

License

Licensed under The MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BP12 = NewBytesPool(12)
View Source
var BP16 = NewBytesPool(16)
View Source
var BP2 = NewBytesPool(2)
View Source
var BP20 = NewBytesPool(20)
View Source
var BP2048 = NewBytesPool(2048)
View Source
var BP32 = NewBytesPool(32)
View Source
var BP4 = NewBytesPool(4)
View Source
var BP40 = NewBytesPool(40)
View Source
var BP65507 = NewBytesPool(65507)
View Source
var DefaultDial = &Dial{}

DefaultDial is the default dialer in net package

Functions

func Decimal2IP

func Decimal2IP(n int64) string

Decimal2IP transform a decimal IP to x.x.x.x format.

func Decimal2IP0

func Decimal2IP0(n int64) (ip string, err error)

Decimal2IP0 transform a decimal IP to x.x.x.x format. ref: https://zh.wikipedia.org/wiki/IPv4

func Decimal2IP1

func Decimal2IP1(n int64) string

Decimal2IP1 transform a decimal IP to x.x.x.x format.

func Distance

func Distance(lng1, lat1, lng2, lat2 float64) float64

return m

func IP2Decimal

func IP2Decimal(ipstr string) (int64, error)

IP2Decimal transform ip format like x.x.x.x to decimal.

func IP2Decimal0

func IP2Decimal0(ip string) (n int64, err error)

IP2Decimal0 transform ip format like x.x.x.x to decimal. ref: https://zh.wikipedia.org/wiki/IPv4

func IP2Decimal1

func IP2Decimal1(ipstr string) (int64, error)

IP2Decimal1 transform ip format like x.x.x.x to decimal.

func IsBankCard

func IsBankCard(n int64) (ok bool, err error)

IsBankCard determine whether it is bankcard number

func IsChineseID

func IsChineseID(s string) (ok bool, err error)

IsChineseID determine whether it is Chinese ID Card Number

func IsChineseWords

func IsChineseWords(words string) (ok bool, err error)

IsChineseWords determine whether it is Chinese words Notice: NOT ALL

func IsEmail

func IsEmail(email string) (ok bool, err error)

IsEmail determine whether it is email address

func JSON

func JSON(w http.ResponseWriter, v interface{})

func MultipartFormDataFromFile

func MultipartFormDataFromFile(params, files map[string][]string, boundary string) (ior io.Reader, err error)

MultipartFormDataFromFile generate multipart form data according to RFC 2388. files is the paths of your files

func MultipartFormDataFromReader

func MultipartFormDataFromReader(params map[string][]string, files map[string][]io.Reader, boundary string) (ior io.Reader, err error)

MultipartFormDataFromReader generate multipart form data according to RFC 2388.

func NewBytesPool

func NewBytesPool(n int) sync.Pool

func Random

func Random(min, max int64) int64

Random used to get a random number between [min, max)

func RandomNumber

func RandomNumber() (i int64)

RandomNumber used to get a random number

func ReadJSON

func ReadJSON(r *http.Request, o interface{}) error

Types

type CIDRInfo

type CIDRInfo struct {
	First   string
	Last    string
	Block   int64
	Network string
	Count   int64
}

CIDRInfo is the struct of CIDR

func CIDR

func CIDR(cidr string) (c *CIDRInfo, err error)

CIDR return *CIDRInfo from like this x.x.x.x/x ref: http://goo.gl/AEUIi8

type Dial

type Dial struct {
}

func (*Dial) Dial

func (d *Dial) Dial(network, addr string) (net.Conn, error)

func (*Dial) DialTCP

func (d *Dial) DialTCP(network string, laddr, raddr *net.TCPAddr) (*net.TCPConn, error)

func (*Dial) DialUDP

func (d *Dial) DialUDP(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)

type Dialer

type Dialer interface {
	Dial(network, addr string) (net.Conn, error)
	DialTCP(network string, laddr, raddr *net.TCPAddr) (*net.TCPConn, error)
	DialUDP(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)
}

Dialer is a common interface for dialing

type Dialer1

type Dialer1 interface {
	Dial(network, addr string) (net.Conn, error)
	// net.Conn LocalAddr, RemoteAddr should be *net.TCPAddr
	DialTCP(network string, laddr, raddr *net.TCPAddr) (net.Conn, error)
	// net.Conn LocalAddr, RemoteAddr should be *net.UDPAddr
	DialUDP(network string, laddr, raddr *net.UDPAddr) (net.Conn, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL