Skip to content

nilable is a tiny Go generics library for making non-nilable values nilable

License

Notifications You must be signed in to change notification settings

otterize/nilable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nilable

nilable is a tiny Go generics library for making non-nilable values nilable, and supports JSON serialization.

You too can stop using pointers when you don't need them!

From value to JSON

nilableString := nilable.From("hello world")
println(nilableString.Set) // true
println(nilableString.Item) // "hello world"
data, _ := json.Marshal(nilableString)
println(string(data)) // `"hello world"` 

From null JSON to value

var nilableString Nilable[string]
json.Unmarshal([]byte("null"), &nilJson)
println(nilJson.Set) // false

About

nilable is a tiny Go generics library for making non-nilable values nilable

Resources

License

Stars

Watchers

Forks

Languages