nodeid

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package nodeid encodes and decodes the opaque identifiers Githome uses for the GraphQL `id` field and the REST `node_id` field.

Two formats are supported. The legacy format is base64(standard) of "<lenprefix>:<TypeName><dbid>", matching the historical GitHub scheme. The new format is "<prefix>_" followed by base64(url, no padding) of a compact binary payload. Clients treat node IDs as opaque, so the only hard contract is that Decode inverts Encode for both formats:

Decode(Encode(kind, dbID, format)) == (kind, dbID)

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("nodeid: invalid node id")

ErrInvalid is returned when a node ID cannot be decoded.

Functions

func DecodeGitObject

func DecodeGitObject(nodeID string) (typeTag string, repoDBID int64, oid string, err error)

DecodeGitObject recovers the type tag, repository database id, and object id from a git-object node ID.

func Encode

func Encode(kind Kind, dbID int64, format Format) string

Encode builds the node ID for (kind, dbID) in the requested format.

func EncodeGitObject

func EncodeGitObject(typeTag string, repoDBID int64, oid string) string

EncodeGitObject builds the node ID for a git object of the given type tag ("commit", "blob", "tree", "tag", or "ref") in repository repoDBID with object id oid. An unknown tag yields the empty string.

Types

type Format

type Format int

Format selects the encoding.

const (
	// FormatNew is Githome's default typename-prefixed encoding.
	FormatNew Format = iota
	// FormatLegacy is the historical base64("len:TypeNameID") encoding.
	FormatLegacy
)

type Kind

type Kind int

Kind enumerates the node-bearing resource types.

const (
	KindUser Kind = iota
	KindOrganization
	KindRepository
	KindIssue
	KindPullRequest
	KindIssueComment
	KindPullRequestReview
	KindPullRequestReviewComment
	KindPullRequestReviewThread
	KindCheckRun
	KindCheckSuite
	KindStatusContext
	KindLabel
	KindMilestone
	KindCommit
	KindReaction
	KindRelease
	KindReleaseAsset
	KindGist
	KindGistComment
	KindTeam
	KindApp
	KindIssueEvent
)

The node-bearing resource kinds, in registry order.

func Decode

func Decode(nodeID string) (Kind, int64, error)

Decode recovers (kind, dbID) from a node ID in either format.

Jump to

Keyboard shortcuts

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