Documentation ¶
Index ¶
- Constants
- Variables
- func ByteToUint16(b []byte) uint16
- func BytesToBase64(data []byte) []byte
- func CheckIPAddress(ip string) bool
- func Int64ToUint32(n int64) (uint32, error)
- func IntToUint32(n int) (uint32, error)
- func ReadBinary(reader io.Reader) (errorCode *common.Error, err error)deprecated
- func ReadBytes(reader io.Reader) (b []byte, err error)deprecated
- func ReadBytesErr(reader io.Reader) (b []byte, errorCode *common.Error, err error)deprecated
- func ReadBytesToWriter(reader io.Reader, writer io.Writer, writeWithSize bool) (n int, err error)
- func ReadString(reader io.Reader) (str string, err error)deprecated
- func Uint16ToByte(size uint16) []byte
- func Uint32ToByte(size uint32) []byte
- func WriteBinary(writer io.Writer, filePath string) (int, error)deprecated
- func WriteBytes(writer io.Writer, b []byte) (int, error)deprecated
- func WriteBytesErr(writer io.Writer, b []byte, errorToWrite *common.Error) (n int, err error)deprecated
- func WriteConfig(fileName string, config interface{}) (err error)
- func WriteMessage(writer io.Writer, b []byte, errorToWrite *common.Error, ...) (n int, err error)
- func WriteString(writer io.Writer, msg string) (int, error)deprecated
- type Message
Constants ¶
const ( HeaderSize = 6 BufferSize = 4096 Uint32Max = 4294967295 DownloadPath = "./downloaded" )
Variables ¶
var EmptyFileName = errors.New("empty filename")
Functions ¶
func BytesToBase64 ¶
BytesToBase64 encodes raw bytes to base64-encoded bytes
func CheckIPAddress ¶
CheckIPAddress check if ip address is valid or not
func Int64ToUint32 ¶
Int64ToUint32 converts int64 value to uint32. Returns value and error. If value occurs overflow, 0 and error is returned
func IntToUint32 ¶
IntToUint32 converts int64 value to uint32. Returns value and error. If value occurs overflow, 0 and error is returned
func ReadBytesToWriter ¶
ReadBytesToWriter reads message from reader and write it to writer. First four bytes of reader should be uint32 size of the message, represented in big endian. Common usage for this function is to read from net.Conn, and write to temp file.
func ReadString
deprecated
func Uint16ToByte ¶
Uint16ToByte converts uint16 value to byte slices
func Uint32ToByte ¶
Uint32ToByte converts uint32 value to byte slices
func WriteBinary
deprecated
Deprecated: WriteBinary opens file and writes byte data to writer. Returns total length of bytes sent, and error. err == nil only if total bytes sent = file size. writer is likely to be net.Conn. File size cannot exceed max value of uint32 as of now. We can split files or change the data type to uint64 if time allows.
func WriteConfig ¶
WriteConfig writes config to fileName in yaml format
func WriteMessage ¶
func WriteMessage(writer io.Writer, b []byte, errorToWrite *common.Error, commandToWrite *common.Command) (n int, err error)
WriteMessage write msg to writer. commandToWrite should not be nil Returns int indicating the number of bytes written, and error, if any. err == nil only if length of sent bytes = length of msg