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

fragment

package
v0.0.0-...-c0bffe4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fragment is the one place the compiler reads a $ref fragment as a JSON pointer and spells one for the resolver (GitHub #911).

A fragment is percent-decoded and nothing else (RFC 3986 section 3.5, RFC 6901 section 6), so '+' names itself. The resolver query-unescapes it, which reads '+' as a space. Every reader of a fragment as a pointer goes through Pointer, and load hands the resolver ForResolver's spelling, so the two agree by construction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForResolver

func ForResolver(ref string) string

ForResolver returns ref spelled so the resolver reads Pointer(ref) from it.

The resolver query-unescapes a fragment (references.Reference.GetJSONPointer), reading '+' as a space, so each '+' in the part it decodes is written "%2B". A fragment it cannot decode it keeps raw, '+' included, so ref is returned unchanged, as it is when that part holds no '+'. The document part, and anything from a second '#' on, are left as written.

func Of

func Of(pointer jsontext.Pointer) string

Of spells pointer as a fragment Pointer and the resolver both read back as exactly pointer: every byte outside a plain set is percent-encoded, '+' and '%' and '#' and whitespace included.

func Pointer

func Pointer(ref string) jsontext.Pointer

Pointer returns the JSON pointer ref's fragment spells, read as RFC 3986 and RFC 6901 read it: percent escapes decoded and nothing else, so '+' names itself. It is the resolver's reading of ForResolver(ref), so it parts from the resolver's reading of ref on '+' alone. It returns "" for a ref with no fragment.

Types

This section is empty.

Jump to

Keyboard shortcuts

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