typeutil

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

README

This package is imported from PD.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMBFromText added in v1.12.0

func ParseMBFromText(text string, value uint64) uint64

ParseMBFromText parses MB from text.

Types

type ByteSize

type ByteSize uint64

ByteSize is a retype uint64 for TOML and JSON.

func (ByteSize) MarshalJSON

func (b ByteSize) MarshalJSON() ([]byte, error)

MarshalJSON returns the size as a JSON string.

func (ByteSize) MarshalString added in v1.7.0

func (b ByteSize) MarshalString() string

MarshalString returns the size as a string.

func (*ByteSize) UnmarshalJSON

func (b *ByteSize) UnmarshalJSON(text []byte) error

UnmarshalJSON parses a JSON string into the byte size.

func (*ByteSize) UnmarshalText

func (b *ByteSize) UnmarshalText(text []byte) error

UnmarshalText parses a Toml string into the byte size.

type Duration

type Duration struct {
	time.Duration
}

Duration is a wrapper of time.Duration for TOML and JSON.

func NewDuration

func NewDuration(duration time.Duration) Duration

NewDuration creates a Duration from time.Duration.

func (*Duration) MarshalJSON

func (d *Duration) MarshalJSON() ([]byte, error)

MarshalJSON returns the duration as a JSON string.

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText returns the duration as a JSON string.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(text []byte) error

UnmarshalJSON parses a JSON string into the duration.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText parses a TOML string into the duration.

type StringSlice

type StringSlice []string

StringSlice is more friendly to json encode/decode

func (StringSlice) MarshalJSON

func (s StringSlice) MarshalJSON() ([]byte, error)

MarshalJSON returns the size as a JSON string.

func (*StringSlice) UnmarshalJSON

func (s *StringSlice) UnmarshalJSON(text []byte) error

UnmarshalJSON parses a JSON string into the byte size.

Jump to

Keyboard shortcuts

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