Socket
Book a DemoInstallSign in
Socket

sweetkennedy.net/optional

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweetkennedy.net/optional

Go Modules
Version
v0.1.0
Version published
Created
Source

optional

The optional package provides an option type, which can either be empty or hold a value. In that respect, it's very similar to an ordinary pointer type, except it has methods that make its possible emptiness more explicit.

The interface of the optional.Value type is modeled on Java's java.util.Optional type and C++'s std::optional.

Usage

go get sweetkennedy.net/optional
import sweetkennedy.net/optional
full := optional.New(42)
empty := optional.Value[int]{}

fmt.Printf("full: %v\n", full)  // Output: 42
fmt.Printf("empty: %v\n", empty) // Output: None

FAQs

Package last updated on 25 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts