Help us shape the future of Go! Take the 2026 Go Developer Survey

storageref

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package storageref resolves the first path segment of a file-protocol address to a storage.

Every protocol addresses a storage the same way — it is the first segment of the path (`/dav/<ref>/…`, `/<ref>/…` over SFTP and NFS, the bucket over the S3-compatible API) — and for the life of the project that segment was the storage's NAME. A name is editable, which is the point of a name, so renaming a storage silently re-addressed it and every mount, bookmark and script written against the old one answered 404 (issue #21).

Every storage now also carries a uid, assigned once and never changed. Both resolve, everywhere, through this one function: a person types the name, an automated mount is given the uid and survives every rename. Putting the rule here rather than in each server is deliberate — five copies of "which identifier is this" would drift, and a protocol where only one of them worked would be a product that behaves differently depending on how you reach it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUID

func IsUID(ref string) bool

IsUID reports whether ref is shaped like a storage uid.

func Resolve

func Resolve(ctx context.Context, store Store, ref string) (*model.Storage, error)

Resolve returns the storage a path segment addresses, or the lookup's own error when there is none.

⚠ A uid-shaped ref that matches no storage falls back to the name lookup, rather than stopping at "no such uid". Nothing forbids naming a storage something that looks like a uuid, and a name that worked before this function existed must go on working after it.

Types

type Store

type Store interface {
	GetStorageByName(ctx context.Context, name string) (*model.Storage, error)
	GetStorageByUID(ctx context.Context, uid string) (*model.Storage, error)
}

Store is the slice of the catalogue this needs.

Jump to

Keyboard shortcuts

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