scope

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: BSD-3-Clause Imports: 2 Imported by: 1

README

scope

Go Reference License Build

scope is a substitute for the Go context package.

It provides a more convenient context API than the standard library, while maintaining 100% compatibility.

Requirements

The minimum Go version is go1.23.

Install

The forms package can be added to a project with go get.

go get -u cattlecloud.net/go/scope@latest
License

The cattlecloud.net/go/scope module is open source under the BSD license.

Documentation

Overview

Package scope implements a simplified and more convenient API for creating context.Context values with often used functionality like timeouts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cancelable

func Cancelable() (C, Cancel)

Cancelable will create a fresh context not part of any preceding chain of values, and includes a Cancel function.

func TTL

func TTL(duration time.Duration) (C, Cancel)

TTL will create a fresh context not part of any preceding chain of values, and will expire after the given duration.

func WithCancel

func WithCancel(c C) (C, Cancel)

WithCancel wraps an existing Context with a Cancel function.

func WithTTL

func WithTTL(c C, duration time.Duration) (C, Cancel)

WithTTL wraps an existing Context that will expire after the given duration.

Types

type C

type C = context.Context

C is an alias for context.Context

func New

func New() C

New will create a fresh context not part of any preceding chain of values.

type Cancel

type Cancel = context.CancelFunc

Cancel is an alias for context.CancelFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL