Documentation ¶
Overview ¶
Package numeric provides parsers for recognizing numeric bytes
Index ¶
- func Int16BE() parser.Parser[parser.Reader, int16]
- func Int16LE() parser.Parser[parser.Reader, int16]
- func Int32BE() parser.Parser[parser.Reader, int32]
- func Int32LE() parser.Parser[parser.Reader, int32]
- func Int64BE() parser.Parser[parser.Reader, int64]
- func Int64LE() parser.Parser[parser.Reader, int64]
- func Int8() parser.Parser[parser.Reader, int8]
- func UInt16BE() parser.Parser[parser.Reader, uint16]
- func UInt16LE() parser.Parser[parser.Reader, uint16]
- func UInt32BE() parser.Parser[parser.Reader, uint32]
- func UInt32LE() parser.Parser[parser.Reader, uint32]
- func UInt64BE() parser.Parser[parser.Reader, uint64]
- func UInt64LE() parser.Parser[parser.Reader, uint64]
- func UInt8() parser.Parser[parser.Reader, uint8]
Examples ¶
- Int16BE (EndOfFile)
- Int16BE (Match)
- Int16LE (EndOfFile)
- Int16LE (Match)
- Int32BE (EndOfFile)
- Int32BE (Match)
- Int32LE (EndOfFile)
- Int32LE (Match)
- Int64BE (EndOfFile)
- Int64BE (Match)
- Int64LE (EndOfFile)
- Int64LE (Match)
- Int8 (EndOfFile)
- Int8 (Match)
- UInt16BE (EndOfFile)
- UInt16BE (Match)
- UInt16LE (EndOfFile)
- UInt16LE (Match)
- UInt32BE (EndOfFile)
- UInt32BE (Match)
- UInt32LE (EndOfFile)
- UInt32LE (Match)
- UInt64BE (EndOfFile)
- UInt64BE (Match)
- UInt64LE (EndOfFile)
- UInt64LE (Match)
- UInt8 (EndOfFile)
- UInt8 (Match)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Int16BE ¶
Int16BE returns a big endian 2 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int16BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x00, 0x01, 3}) numericParser := numeric.Int16BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func Int16LE ¶
Int16LE returns a little endian 2 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int16LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x01, 0x00, 3}) numericParser := numeric.Int16LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func Int32BE ¶
Int32BE returns a big endian 4 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int32BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x00, 0x00, 0x00, 0x01, 3}) numericParser := numeric.Int32BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func Int32LE ¶
Int32LE returns a little endian 4 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int32LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x01, 0x00, 0x00, 0x00, 3}) numericParser := numeric.Int32LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func Int64BE ¶
Int64BE returns a big endian 8 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int64BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 3}) numericParser := numeric.Int64BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func Int64LE ¶
Int64LE returns a little endian 8 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int64LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3}) numericParser := numeric.Int64LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func Int8 ¶
Int8 returns a 1 byte signed integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.Int8() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{1, 2, 3}) numericParser := numeric.Int8() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [2 3]
func UInt16BE ¶
UInt16BE returns a big endian 2 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt16BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x00, 0x01, 3}) numericParser := numeric.UInt16BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func UInt16LE ¶
UInt16LE returns a little endian 2 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt16LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x01, 0x00, 3}) numericParser := numeric.UInt16LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func UInt32BE ¶
UInt32BE returns a big endian 4 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt32BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x00, 0x00, 0x00, 0x01, 3}) numericParser := numeric.UInt32BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func UInt32LE ¶
UInt32LE returns a little endian 4 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt32LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x01, 0x00, 0x00, 0x00, 3}) numericParser := numeric.UInt32LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func UInt64BE ¶
UInt64BE returns a big endian 8 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt64BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 3}) numericParser := numeric.UInt64BE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func UInt64LE ¶
UInt64LE returns a little endian 8 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt64LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3}) numericParser := numeric.UInt64LE() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [3]
func UInt8 ¶
UInt8 returns a 1 byte unsigned integer. io.EOF is returned if the input contains too few bytes
Example (EndOfFile) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{}) numericParser := numeric.UInt8() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: '%v', Remainder: %v", match, err, remainder) }
Output: Match: 0, Error: 'EOF', Remainder: []
Example (Match) ¶
package main import ( "bytes" "fmt" "github.com/roblovelock/gobble/pkg/parser/numeric" "io" ) func main() { input := bytes.NewReader([]byte{1, 2, 3}) numericParser := numeric.UInt8() match, err := numericParser(input) remainder, _ := io.ReadAll(input) fmt.Printf("Match: %d, Error: %v, Remainder: %v", match, err, remainder) }
Output: Match: 1, Error: <nil>, Remainder: [2 3]
Types ¶
This section is empty.