Package tmp implements an expiring optional-type with a time-out, for the Go programming language. In other programming languages, an optional-type might be known as: a option-type, or a maybe-type.
Find a file
2025-09-02 03:44:48 -07:00
go.mod github -> codeberg 2025-08-23 06:36:04 -07:00
go.sum go.* 2025-02-04 15:34:56 -08:00
LICENSE changelog.ca -> reiver.link 2025-02-04 14:47:57 -08:00
README.md github -> codeberg 2025-08-23 06:36:49 -07:00
temporal.go tmp.Temporal.GetDuration() 2025-09-02 03:44:48 -07:00
temporal_filter_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_get_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_gostring_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_is_defunct_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_is_nothing_test.go initial commits 2023-11-01 19:22:11 -07:00
temporal_marshaljson.go sourcecode.social/reiver -> github.com/reiver 2025-02-04 14:56:31 -08:00
temporal_marshaljson_bool_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_marshaljson_int_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_marshaljson_string_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_unmarshaljson.go sourcecode.social/reiver -> github.com/reiver 2025-02-04 14:56:31 -08:00
temporal_unmarshaljson_bool_test.go github -> codeberg 2025-08-23 06:36:04 -07:00
temporal_unmarshaljson_string_test.go github -> codeberg 2025-08-23 06:36:04 -07:00

go-tmp

Package tmp implements an expiring optional-type with a time-out, for the Go programming language.

In other programming languages, an optional-type might be known as: a option-type, or a maybe-type.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-tmp

GoDoc

Example

Here is a simple example:

import "codeberg.org/reiver/go-tmp"

// ...

var until time.Time = time.Now().Add(8 * time.Hour)

var temporal tmp.Temporal[string] = tmp.Temporary(value, until)

// ...

// If the temporal has expired then this will return the optional value 'nothing'.
// Else, it will return the optional value 'something' (containing the same internal value that was inside of the temporal).
optional := temporal.Optional()

val, found := optional.Get()
if found {
	// ...
} else {
	// ...

}

Import

To import package tmp use import code like the follownig:

import "codeberg.org/reiver/go-tmp"

Installation

To install package tmp do the following:

GOPROXY=direct go get codeberg.org/reiver/go-tmp

Author

Package tmp was written by Charles Iliya Krempeaux