lfs

package
v0.4.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func ContentError(data []byte) error

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

func ContentSHA256(data []byte) string

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

func ParsePointer(data []byte) (Pointer, bool)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL