-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
38 lines (31 loc) · 816 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright © 2024 Ken Robertson <ken@invalidlogic.com>
package main
import (
"bytes"
"encoding/binary"
"strings"
)
func convertBytesToUInt64(b []byte) uint64 {
var n uint64
buf := bytes.NewBuffer(b)
binary.Read(buf, binary.LittleEndian, &n)
return n
}
func convertBytesToInt16(b []byte) int16 {
var n int16
buf := bytes.NewBuffer(b)
binary.Read(buf, binary.LittleEndian, &n)
return n
}
// arrayFlags can be used with flags.Var to specify the a command line argument
// multiple timmes.
type arrayFlags []string
// String returns a basic string concationation of all values.
func (i *arrayFlags) String() string {
return strings.Join(*i, ", ")
}
// Set is used to append a new value to the array by flags.Var.
func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}