summaryrefslogtreecommitdiff
path: root/lib/binstruct/binutil/binutil.go
blob: a5c65b536b0a8e7a8137e44f5e64a5b1c0ca14ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright (C) 2022-2023  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

// Package binutil provides utilities for implementing the interfaces
// consumed by binstruct.
package binutil

import (
	"fmt"
)

func NeedNBytes(dat []byte, n int) error {
	if len(dat) < n {
		return fmt.Errorf("need at least %v bytes, only have %v", n, len(dat))
	}
	return nil
}