Movatterモバイル変換


[0]ホーム

URL:


opt

package
v1.92.2Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:5Imported by:34

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package opt defines optional types.

Index

Constants

View Source
const (// True is the encoding of an explicit true.True =Bool("true")// False is the encoding of an explicit false.False =Bool("false")// ExplicitlyUnset is the encoding used by a null// JSON value. It is a synonym for the empty string.ExplicitlyUnset =Bool("unset")// Empty means the Bool is unset and it's neither// true nor false.Empty =Bool(""))

Variables

This section is empty.

Functions

This section is empty.

Types

typeBool

type Boolstring

Bool represents an optional boolean to be JSON-encoded. The stringis either "true", "false", or the empty string to mean unset.

As a special case, the underlying string may also be the string"unset" as as a synonym for the empty string. This lets theexplicit unset value be exchanged over an encoding/json "omitempty"field without it being dropped.

funcNewBooladded inv1.58.0

func NewBool(bbool)Bool

NewBool constructs a new Bool value equal to b. The returned Bool is set,unless Set("") or Clear() methods are called.

func (*Bool)Clear

func (b *Bool) Clear()

func (Bool)EqualBooladded inv0.100.0

func (bBool) EqualBool(vbool)bool

EqualBool reports whether b is equal to v.If b is empty or not a valid bool, it reports false.

func (Bool)Get

func (bBool) Get() (vbool, okbool)

func (Bool)MarshalJSON

func (bBool) MarshalJSON() ([]byte,error)

func (Bool)Normalizedadded inv1.92.0

func (bBool) Normalized()Bool

Normalized returns the normalized form of b, mapping "unset" to ""and leaving other values unchanged.

func (*Bool)Scanadded inv1.16.0

func (b *Bool) Scan(srcany)error

Scan implements database/sql.Scanner.

func (*Bool)Set

func (b *Bool) Set(vbool)

func (*Bool)UnmarshalJSON

func (b *Bool) UnmarshalJSON(j []byte)error

typeBoolFlagadded inv1.74.0

type BoolFlag struct {*Bool}

BoolFlag is a wrapper for Bool that implementsflag.Value.

func (*BoolFlag)Setadded inv1.74.0

func (b *BoolFlag) Set(sstring)error

Set the value of b, using any value supported bystrconv.ParseBool.

func (*BoolFlag)Stringadded inv1.74.0

func (b *BoolFlag) String()string

String returns "true" or "false" if the value is set, or an empty string otherwise.

typeValueadded inv1.70.0

type Value[Tany] struct {// contains filtered or unexported fields}

Value is an optional value to be JSON-encoded.Withencoding/json, a zero Value is marshaled as a JSON null.Withgithub.com/go-json-experiment/json, a zero Value is omitted from theJSON object if the Go struct field specified with omitzero.The omitempty tag option should never be used with Value fields.

funcValueOfadded inv1.70.0

func ValueOf[Tany](v T)Value[T]

ValueOf returns an optional Value containing the specified value.It treats nil slices and maps as empty slices and maps.

func (*Value[T])Clearadded inv1.70.0

func (o *Value[T]) Clear()

Clear resets o to an empty state.

func (Value[T])Equaladded inv1.70.0

func (oValue[T]) Equal(vValue[T])bool

Equal reports whether o is equal to v.Two optional values are equal if both are empty,or if both are set and the underlying values are equal.If the template type T implements an Equal(T) bool method, it will be usedinstead of the == operator for value comparison.If T is not comparable, it returns false.

func (Value[T])Getadded inv1.70.0

func (oValue[T]) Get() T

Get returns the value of o.If a value hasn't been set, a zero value of T will be returned.

func (Value[T])GetOkadded inv1.70.0

func (oValue[T]) GetOk() (v T, okbool)

Get returns the value and a flag indicating whether the value is set.

func (Value[T])GetOradded inv1.72.0

func (oValue[T]) GetOr(def T) T

GetOr returns the value of o or def if a value hasn't been set.

func (*Value[T])IsSetadded inv1.70.0

func (o *Value[T]) IsSet()bool

IsSet reports whether o has a value set.

func (Value[T])MarshalJSONadded inv1.70.0

func (oValue[T]) MarshalJSON() ([]byte,error)

MarshalJSON implements [json.Marshaler].

func (Value[T])MarshalJSONToadded inv1.82.0

func (oValue[T]) MarshalJSONTo(enc *jsontext.Encoder)error

MarshalJSONTo implementsjsonv2.MarshalerTo.

func (*Value[T])Setadded inv1.70.0

func (o *Value[T]) Set(v T)

Set assigns the specified value to the optional value o.

func (Value[T])Stringadded inv1.70.0

func (oValue[T]) String()string

String implementsfmt.Stringer.

func (*Value[T])UnmarshalJSONadded inv1.70.0

func (o *Value[T]) UnmarshalJSON(b []byte)error

UnmarshalJSON implements [json.Unmarshaler].

func (*Value[T])UnmarshalJSONFromadded inv1.82.0

func (o *Value[T]) UnmarshalJSONFrom(dec *jsontext.Decoder)error

UnmarshalJSONFrom implementsjsonv2.UnmarshalerFrom.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp