base

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S_IRWXU FilePermisson = 00700 // user (file owner) has read, write and execute permission
	S_IRUSR               = 00400 // user has read permission
	S_IWUSR               = 00200 // user has write permission
	S_IXUSR               = 00100 // user has execute permission
	S_IRWXG               = 00070 // group has read, write and execute permission
	S_IRGRP               = 00040 // group has read permission
	S_IWGRP               = 00020 // group has write permission
	S_IXGRP               = 00010 // group has execute permission
	S_IRWXO               = 00007 // others have read, write and execute permission
	S_IROTH               = 00004 // others have read permission
	S_IWOTH               = 00002 // others have write permission
	S_IXOTH               = 00001 // others have execute permission
)
View Source
const FS_MODE = fs.FileMode(S_IRWXO | S_IRWXU)

Variables

This section is empty.

Functions

func GetLocalNetOutboundIP

func GetLocalNetOutboundIP() (net.IP, error)

Get preferred outbound ip of this machine within 192.168.0.0/24

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Get preferred outbound ip of this machine

func OpenFile

func OpenFile(name string, flag int) (f *os.File, err error)

func WriteFile

func WriteFile(name string, data []byte) error

Types

type FilePermisson

type FilePermisson int

type JsonAtomicInt

type JsonAtomicInt struct {
	atomic.Int64
}

func (*JsonAtomicInt) MarshalJSON

func (x *JsonAtomicInt) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*JsonAtomicInt) MarshalText

func (x *JsonAtomicInt) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*JsonAtomicInt) UnmarshalJSON

func (x *JsonAtomicInt) UnmarshalJSON(text []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*JsonAtomicInt) UnmarshalText

func (x *JsonAtomicInt) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type MutexedMap

type MutexedMap[T any] struct {
	sync.RWMutex
	M map[string]T `json:"map"`
	// contains filtered or unexported fields
}

func NewMutexedMap

func NewMutexedMap[T any]() MutexedMap[T]

func (*MutexedMap[T]) Clear

func (mm *MutexedMap[T]) Clear()

func (*MutexedMap[T]) Copy

func (mm *MutexedMap[T]) Copy() (new_m map[string]T, count int)

func (*MutexedMap[T]) Delete

func (mm *MutexedMap[T]) Delete(key string) (t T, ok bool)

func (*MutexedMap[T]) Get

func (mm *MutexedMap[T]) Get(key string) (t T, ok bool)

func (*MutexedMap[T]) Keys

func (mm *MutexedMap[T]) Keys() (keys []string)

func (*MutexedMap[T]) Set

func (mm *MutexedMap[T]) Set(key string, value T)

type MutexedQueue

type MutexedQueue[T any] struct {
	sync.RWMutex
	Queue   MutexedMap[T] `json:"queue"`
	Done    JsonAtomicInt `json:"done"`
	Pending JsonAtomicInt `json:"pending"`
	// contains filtered or unexported fields
}

func NewMutexedQueue

func NewMutexedQueue[T any]() (Mq *MutexedQueue[T])

func (*MutexedQueue[T]) Clear

func (mq *MutexedQueue[T]) Clear()

func (*MutexedQueue[T]) Dequeue

func (mq *MutexedQueue[T]) Dequeue() <-chan int64

func (*MutexedQueue[T]) Enqueue

func (mq *MutexedQueue[T]) Enqueue(item T) (retry bool)

func (*MutexedQueue[T]) Get

func (mq *MutexedQueue[T]) Get(n int64) (it T, ok bool)

func (*MutexedQueue[T]) Len

func (mq *MutexedQueue[T]) Len() (n int64)

func (*MutexedQueue[T]) MarkDone

func (mq *MutexedQueue[T]) MarkDone(n int64)

Jump to

Keyboard shortcuts

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