util

package
v3.0.0-...-c77a060 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NumberOrString

type NumberOrString string

NumberOrString is a string that when marshalled/unmarsalled to/from json will be represented as a number if strconv.Atoi believes it is a number, or a string otherwise.

func (NumberOrString) Int

func (nos NumberOrString) Int() (int, error)

Int returns the NumberOrString as an Int, if possible.

func (NumberOrString) MarshalJSON

func (nos NumberOrString) MarshalJSON() ([]byte, error)

MarshalJSON marshals the NumberOrString, representing is as a number where appropriate.

func (NumberOrString) String

func (nos NumberOrString) String() string

String returns the NumberOrString as a string, irrespective of whether it can be represented as a number.

func (*NumberOrString) UnmarshalJSON

func (nos *NumberOrString) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a NumberOrString accepting either a json number or string.

Jump to

Keyboard shortcuts

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