Source File
export.go
Belonging Package
encoding/json/jsontext
// Copyright 2023 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.//go:build goexperiment.jsonv2package jsontextimport ()// TODO(https://go.dev/issue/73435): Remove the Internal symbol.//// The Go language lacks a 3rd category of visibility where// certain symbols can only be referenced from within the same module.// One solution to this is to put the entirety of a package with// both public and module-only symbols exposed as an internal package.// A separate, public package can re-export all of the public symbols// via type aliases and thus ensuring module-only symbols cannot be// referenced by the end-user. While this works, it unfortunately// leads to a poor user experience since the Go pkgsite is unable to// forward the documentation for symbols like methods and fields.// We need to improve the pkgsite experience before we can delete// the Internal symbol.// Internal is for internal use only.// This is exempt from the Go compatibility agreement.var Internal exportertype exporter struct{}// Export exposes internal functionality from "jsontext" to "json".// This cannot be dynamically called by other packages since// they cannot obtain a reference to the internal.AllowInternalUse value.func (exporter) ( *internal.NotForPublicUse) export {if != &internal.AllowInternalUse {panic("unauthorized call to Export")}return export{}}// The export type exposes functionality to packages with visibility to// the internal.AllowInternalUse variable. The "json" package uses this// to modify low-level state in the Encoder and Decoder types.// It mutates the state directly instead of calling ReadToken or WriteToken// since this is more performant. The public APIs need to track state to ensure// that users are constructing a valid JSON value, but the "json" implementation// guarantees that it emits valid JSON by the structure of the code itself.type export struct{}// Encoder returns a pointer to the underlying encoderState.func (export) ( *Encoder) *encoderState { return &.s }// Decoder returns a pointer to the underlying decoderState.func (export) ( *Decoder) *decoderState { return &.s }func (export) ( ...Options) *Encoder {return getBufferedEncoder(...)}func (export) ( *Encoder) {putBufferedEncoder()}func (export) ( io.Writer, ...Options) *Encoder {return getStreamingEncoder(, ...)}func (export) ( *Encoder) {putStreamingEncoder()}func (export) ( []byte, ...Options) *Decoder {return getBufferedDecoder(, ...)}func (export) ( *Decoder) {putBufferedDecoder()}func (export) ( io.Reader, ...Options) *Decoder {return getStreamingDecoder(, ...)}func (export) ( *Decoder) {putStreamingDecoder()}func (export) ( error) bool {, := .(*ioError)return}
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64)