util

package
v0.0.0-...-8cd3384 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ERR_DECODE_FILE = errors.New("ERR_DECODE_FILE")
View Source
var ERR_RAND_BYTESLICE = errors.New("ERR_RAND_BYTESLICE")

Functions

func DecodeTorrentFile

func DecodeTorrentFile(filePath string) (*metainfo.MetaInfo, error)

func GetIpAndPortFromNetAddr

func GetIpAndPortFromNetAddr(addr net.Addr) (net.IP, int)

func IntSliceAppendIfUnique

func IntSliceAppendIfUnique(slice []int, elem int) []int

func IntSliceHas

func IntSliceHas(haystack []int, needle int) bool

func IntSliceUniqueMergeSlices

func IntSliceUniqueMergeSlices(sliceA, sliceB []int) []int

func IsDirectory

func IsDirectory(path string) bool

func IsFile

func IsFile(path string) bool

func IsPortTaken

func IsPortTaken(port string) bool

func Min

func Min(a, b int) int

func MkdirAllOrPanic

func MkdirAllOrPanic(dir string)

func MkdirTempOrPanic

func MkdirTempOrPanic(dir, pattern string) string

func RandByteSlice

func RandByteSlice(max int) ([]byte, error)

func RandRange

func RandRange(min, max int) int

Types

type Bitfield

type Bitfield struct {
	Bytes     []byte
	NumOfBits int
}

func NewBitfield

func NewBitfield(numOfBits int) Bitfield

func NewBitfieldFromBytes

func NewBitfieldFromBytes(buff []byte) Bitfield

XXX This is tested in Test_bitfield_msg_assembly

func (Bitfield) AsIntSlice

func (self Bitfield) AsIntSlice(max int) []int

XXX This is tested in Test_bitfield_msg_assembly

func (Bitfield) DumpAsBitstring

func (self Bitfield) DumpAsBitstring() string

func (Bitfield) Has

func (self Bitfield) Has(i int) bool

XXX This is tested in Test_bitfield_msg_assembly

func (Bitfield) Set

func (self Bitfield) Set(i int)

XXX This is tested in Test_bitfield_msg_assembly

Jump to

Keyboard shortcuts

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