Documentation
¶
Overview ¶
Package lfs is experimental: its API and documented formats may change in a minor release; see https://nsgo.games/docs/stability/.
Package lfs recognizes Git LFS pointer files: the small text file that a checkout without fetched LFS content holds in place of the media or source art Git LFS tracks. The runtime loaders a release build links (pkg/gltf and pkg/scenemodel) report unfetched content in these terms, and pkg/tooling/refs records a pointer's oid as the content's hash, so the package sits flat under pkg/ rather than in the dev-time tooling group.
Index ¶
Examples ¶
Constants ¶
const PointerPrefixSize = 1024
PointerPrefixSize is how many leading bytes a loader reads to recognize a Git LFS pointer without loading the whole file: a strict pointer is the version line and the oid and size lines, far fewer than this.
Variables ¶
This section is empty.
Functions ¶
func ContentError ¶
ContentError returns the error a loader or check reports for data that is a Git LFS pointer whose content was not fetched, and nil when data is not a pointer. The pointer's oid is the SHA-256 of the content, so the caller can name the file and keep the content's identity, but cannot use the bytes.
func ContentSHA256 ¶
ContentSHA256 returns the lowercase SHA-256 digest of data.
Types ¶
type Pointer ¶
type Pointer struct {
// OID is the lowercase SHA-256 object ID.
OID string
// Size is the object's non-negative byte length.
Size int64
}
Pointer is the object ID and byte size recorded by a Git LFS pointer.
func ParsePointer ¶
ParsePointer parses a strict Git LFS pointer file: the version line, then the oid and size lines in that order, as the Git LFS specification sorts the keys. It returns false for ordinary files and malformed pointers. A strict pointer has three short lines, so anything longer than PointerPrefixSize is refused without converting the content to a string.
Example ¶
package main
import (
"fmt"
"github.com/nsgo-dev/game/pkg/lfs"
)
func main() {
p, ok := lfs.ParsePointer([]byte("version https://git-lfs.github.com/spec/v1\noid sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\nsize 12\n"))
fmt.Println(ok, p.Size)
}
Output: true 12