Skip to content

go-composites/null

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-composites/null

null

ci

The Null-Object primitive of go-composites. Null is the inert, never-nil value that the other composites reach for when they need an absence that still honours an interface rather than a bare Go nil. It is the default payload of a fresh Result, so "no value yet" is itself a value.

Install

go get github.com/go-composites/null

API

symbol kind notes
Interface type interface { IsNull() bool } — the Null-Object contract
New() Interface returns a fresh, inert Null-Object
IsNull() bool always true on a Null — the defining predicate

Usage

package main

import (
	"fmt"

	Null "github.com/go-composites/null/src"
	Result "github.com/go-composites/result/src"
)

func main() {
	n := Null.New()
	fmt.Println(n) // an inert Null-Object, not nil

	// A fresh Result carries a Null payload by default.
	r := Result.New()
	fmt.Println(r.HasError())  // false
	fmt.Println(r.Payload())   // the Null-Object
}

License

BSD-3-Clause © the go-composites/null authors.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages