common

package module
v0.0.0-...-fc06f08 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 25 Imported by: 0

README

go-common

Documentation

Index

Constants

View Source
const (
	SERVER_RECV_LEN = 65000
)

udp config

Variables

This section is empty.

Functions

func DPanic

func DPanic(args ...interface{})

func DPanicf

func DPanicf(template string, args ...interface{})

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Execute

func Execute(command string) (string, bool)

Execute : run BASH Command

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func Generate

func Generate() uuid.UUID

Generate : create UUID

func GetIP

func GetIP() []string

GetIP :

func GetTimeStamp

func GetTimeStamp()

GetTimeStamp : get timestamp

func HTTPGet

func HTTPGet(url string) string

HTTPGet :

func HTTPGetBinary

func HTTPGetBinary(url string) ([]byte, error)

HTTPGetBinary :

func HTTPGetBinaryToFile

func HTTPGetBinaryToFile(url string, path string) (string, bool)

HTTPGetBinaryToFile :

func HTTPGetWithHeaders

func HTTPGetWithHeaders(url string, headers map[string]string) string

HTTPGetWithHeaders :

func HTTPPost

func HTTPPost(url string, data []byte)

HTTPPost :

func HTTPPostWithHeader

func HTTPPostWithHeader(url string, data []byte, headers map[string]string) []byte

HTTPPostWithHeader :

func HttpPut

func HttpPut(url string, data []byte) (string, error)

HTTPPut :

func Info

func Info(args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func Marshal

func Marshal(obj interface{}) []byte

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(template string, args ...interface{})

func PrintCPU

func PrintCPU()

PrintCPU :

func PrintIP

func PrintIP()

PrintIP :

func ReadFile

func ReadFile(filePath string, queue chan<- string)

func Run

func Run(name string, arg ...string) string

Run : Execute Commands

func RunWithStdin

func RunWithStdin(name string, arg ...string) string

RunWithStdin : Execute Commands

func SignalWatch

func SignalWatch()

SignalWatch :

func SliceContains

func SliceContains(slice []string, substr string) bool

SliceContains : slice contains substr

func StartUDPServer

func StartUDPServer(port int, output chan string)

StartUDPServer : udp server

func ToBeautifyJson

func ToBeautifyJson(obj interface{}) string

func ToJson

func ToJson(obj interface{}) string

func Unmarshal

func Unmarshal(txt string, obj interface{})

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

func WriteFile

func WriteFile(filePath string, outQ <-chan []string)

Types

type KafkaProducer

type KafkaProducer struct {
	SyncProducer sarama.SyncProducer
	Brokers      []string
}

KafkaProducer : Kafka Producer

func (*KafkaProducer) Close

func (prod *KafkaProducer) Close() error

func (*KafkaProducer) New

func (prod *KafkaProducer) New() sarama.SyncProducer

func (*KafkaProducer) Send

func (prod *KafkaProducer) Send(topic string, message string)

type MyRedis

type MyRedis struct {
	Client *redis.Client
}

func NewMyRedis

func NewMyRedis(addr string, password string) *MyRedis

NewMyRedis : init

func (*MyRedis) RateLimit

func (r *MyRedis) RateLimit(key string, limit RateLimitParam) (pass bool, err error)

RateLimit : Rate Limit

type RateLimitParam

type RateLimitParam struct {
	Threshold int64
	Period    time.Duration
}

type Response

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Success bool        `json:"success"`
	Data    interface{} `json:"data"`
}

Response : REST response

Jump to

Keyboard shortcuts

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