kits

package
v0.0.0-...-bbd3070 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT = 0
	SET     = 1
	CONVERT = 2
)
View Source
const (
	SETVAL         = 0x01
	SETVAL_        = 0x02 //it's pointer need elem() and set
	SETVAL_STRUCT  = 0x03 //it's struct instance
	SETVAL_STRUCT_ = 0x04 //it's struct pointer,need elem
)

problem: copy need sure whether support, if don't support, can't copy any val to dst's field

Variables

View Source
var (
	Stderr = os.Stderr
	Stdout = os.Stdout
)

bind to flag

View Source
var (
	Buffer_Size = 5 << 10 //outsid can change the buffer size
)

Functions

func CompressBoolean

func CompressBoolean(p []byte, values ...bool)

func Dial

func Dial(socket_method, address string, tcl Client, msgchan <-chan any, errchan chan<- error)

func Extract

func Extract(p uint8, dsts ...*bool)

func FlagParse

func FlagParse[T any](fs *flag.FlagSet, v *T) error

func ListenAndServe

func ListenAndServe(socket_method, address string, conreg func(net.Conn) Conn, errchan chan<- error)

func ParseMode

func ParseMode(v uint64, split uint8) []uint8

recover origin enum value

func ReflectInfo

func ReflectInfo(v, dst any, args ...any) (err error)

reflect do function

func StructCopy

func StructCopy[T, B any](dst *T, src *B) error

func Tofunc

func Tofunc[T any](src any, dst *T) bool

function type set

func UnmarshaAgain

func UnmarshaAgain[T any](fun func([]byte, any) error, v []byte, dst *T) error

unmarsha but not cover to the value already existed

Types

type Client

type Client interface {
	Register(net.Conn)    //just register the client
	IsClose() bool        //need close connection?
	NeedWaitReturn() bool //wait server response,then do next
	GetBack() error       //get server response
}

client zone start

|	|	|
|	|	|
V	V	V

type Conn

type Conn interface {
	Decode([]byte) error
	NeedSave() bool      //when decode failed,is need save here
	Save([]byte)         //save function,and never failed
	Do() error           //you should do reponse or bad_response insid it after did it's work
	IsClose() bool       //decide is close the session
	Response() error     //send response to client
	Bad_Response() error //if there is error here
}

type CustomMode

type CustomMode struct {
	Split_Num uint8
	Val       []byte
}

func (*CustomMode) Bytes

func (s *CustomMode) Bytes() []byte

func (*CustomMode) Int

func (s *CustomMode) Int() uint64

type EnumMode

type EnumMode interface {
	Int() uint64
	Bytes() []byte
}

func GetCustomMode

func GetCustomMode(v string, splitval uint8) EnumMode

type Flag

type Flag struct {
	// contains filtered or unexported fields
}

func NewFlag

func NewFlag(fs *flag.FlagSet) *Flag

func (*Flag) Bind

func (s *Flag) Bind(v any) error

func (*Flag) Parse

func (s *Flag) Parse(v []string) error

type Mode

type Mode string

func (*Mode) Bytes

func (s *Mode) Bytes() []byte

func (*Mode) Int

func (s *Mode) Int() uint64

type Set

type Set[T any] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T any](cmp func(*T, *T) int) *Set[T]

cmp func result meaning: 0 equal,-1 left<rigth

func (*Set[T]) Delete

func (s *Set[T]) Delete(v T)

func (*Set[T]) Range

func (s *Set[T]) Range(call func(T) error) error

func (*Set[T]) Set

func (s *Set[T]) Set(v T)

func (*Set[T]) Size

func (s *Set[T]) Size() int

func (*Set[T]) Valid

func (s *Set[T]) Valid(v T) bool

type SmallMode

type SmallMode string

enum value limit 0~4

func (*SmallMode) Bytes

func (s *SmallMode) Bytes() []byte

func (*SmallMode) Int

func (s *SmallMode) Int() uint64

type Sorter

type Sorter interface {
	Less(Sorter) bool
	Equal(Sorter) bool
}

set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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