Documentation ¶
Overview ¶
Package builtin provides wrappers around builtin types to make them optional and let them fulfill a specific interface for each supported type.
Example ¶
This example shows how to distinguish values that are not set from zero values
type repo struct { Name string Desc Stringer `json:",omitempty"` Private Booler `json:",omitempty"` Age Int64er `json:",omitempty"` Price Float64er `json:",omitempty"` } print := func(r *repo) { b, _ := json.Marshal(r) fmt.Printf("%s\n", b) } notSet := &repo{Name: "not-set"} allSet := &repo{"allSet", String("the allset repo"), Bool(true), Int64(20), Float64(4.5)} zero := &repo{"", String(""), Bool(false), Int64(0), Float64(0)} print(allSet) print(notSet) print(zero)
Output: {"Name":"allSet","Desc":"the allset repo","Private":true,"Age":20,"Price":4.5} {"Name":"not-set"} {"Name":"","Desc":"","Private":false,"Age":0,"Price":0}
Index ¶
- type Bool
- type Booler
- type Byte
- type Byter
- type Complex128
- type Complex128er
- type Complex64
- type Complex64er
- type Float32
- type Float32er
- type Float64
- type Float64er
- type Int
- type Int16
- type Int16er
- type Int32
- type Int32er
- type Int64
- type Int64er
- type Int8
- type Int8er
- type Inter
- type Rune
- type Runer
- type String
- type Stringer
- type Uint
- type Uint16
- type Uint16er
- type Uint32
- type Uint32er
- type Uint64
- type Uint64er
- type Uint8
- type Uint8er
- type Uinter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Complex128 ¶
type Complex128 complex128
func (Complex128) Complex128 ¶
func (c Complex128) Complex128() complex128
type Complex128er ¶
type Complex128er interface {
Complex128() complex128
}
type Complex64er ¶
type Complex64er interface {
Complex64() complex64
}
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package sqlnull provides a wrapper around a Scanner such as *sql.Row or *sql.Rows from database/sql that simplifies the handling of nullable results.
|
Package sqlnull provides a wrapper around a Scanner such as *sql.Row or *sql.Rows from database/sql that simplifies the handling of nullable results. |
Click to show internal directories.
Click to hide internal directories.