Documentation
¶
Index ¶
- Variables
- type BinaryAppender
- type ID
- func (id ID) AppendBinary(b []byte) ([]byte, error)
- func (id ID) AppendText(b []byte) ([]byte, error)
- func (id ID) Int64() int64
- func (id ID) IsNil() bool
- func (id ID) IsZero() bool
- func (id ID) MarshalBinary() (data []byte, err error)
- func (id ID) MarshalJSON() ([]byte, error)
- func (id ID) MarshalText() (text []byte, err error)
- func (id *ID) Scan(src any) (err error)
- func (id ID) String() string
- func (id ID) Time() time.Time
- func (id *ID) UnmarshalBinary(data []byte) error
- func (id *ID) UnmarshalJSON(b []byte) (err error)
- func (id *ID) UnmarshalText(text []byte) (err error)
- func (id ID) Value() (driver.Value, error)
- type TextAppender
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidId = errors.New("invalid ID")
)
Functions ¶
This section is empty.
Types ¶
type BinaryAppender ¶
type BinaryAppender interface { // AppendText appends the binary representation of itself to the end of b // (allocating a larger slice if necessary) and returns the updated slice. // // Implementations must not retain b, nor mutate any bytes within b[:len(b)]. AppendBinary([]byte) ([]byte, error) }
BinaryAppender is the interface implemented by an object that can append the binary representation of itself. If a type implements both BinaryAppender and [BinaryMarshaler], then v.MarshalBinary() must be semantically identical to v.AppendBinary(nil).
type ID ¶
type ID int64
func FromString ¶ added in v0.3.0
func Generate ¶
func Generate() ID
Generates a unique ID. This is thread-safe.
Example ¶
for range 10 { id := Generate() fmt.Println(id.Int64(), id) }
Output: TODO
func (ID) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender.
func (ID) AppendText ¶
AppendText implements encoding.TextAppender.
func (ID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (ID) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (ID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*ID) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type TextAppender ¶
type TextAppender interface { // AppendText appends the textual representation of itself to the end of b // (allocating a larger slice if necessary) and returns the updated slice. // // Implementations must not retain b, nor mutate any bytes within b[:len(b)]. AppendText(b []byte) ([]byte, error) }
TextAppender is the interface implemented by an object that can append the textual representation of itself. If a type implements both TextAppender and [TextMarshaler], then v.MarshalText() must be semantically identical to v.AppendText(nil).