must

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 0 Imported by: 0

README

Go Reference Go Report Card

go-must

general utilities for "Must" pattern. It simplifies safe initialization, handling errors in test, and so on.

Installation

This package uses generics, so you need to use Go 1.18 or later.

go get github.com/uechoco/go-must

Example Usage

import (
	"time"
	"github.com/uechoco/go-must"
)

func TestExample(t *testing.T) {
	tm := must.Get2(time.Parse(time.RFC3339, "2020-01-01T00:00:00Z"))
	fmt.Println(tm)
}

Documentation

Overview

Example (ParseFloat)
v, _ := must.Get3(big.ParseFloat("1.2345678", 10, 1000, big.ToNearestEven))
fmt.Println(v)
Output:

1.2345678
Example (TimeParse)
tm := must.Get2(time.Parse(time.RFC3339, "2020-01-01T11:22:33Z"))
fmt.Println(tm)
Output:

2020-01-01 11:22:33 +0000 UTC

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get2

func Get2[T1 any](v1 T1, err error) T1

func Get3

func Get3[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2)

func Get4

func Get4[T1, T2, T3 any](v1 T1, v2 T2, v3 T3, err error) (T1, T2, T3)

func Get5

func Get5[T1, T2, T3, T4 any](v1 T1, v2 T2, v3 T3, v4 T4, err error) (T1, T2, T3, T4)

func Get6

func Get6[T1, T2, T3, T4, T5 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, err error) (T1, T2, T3, T4, T5)

func Get7

func Get7[T1, T2, T3, T4, T5, T6 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, err error) (T1, T2, T3, T4, T5, T6)

Types

This section is empty.

Jump to

Keyboard shortcuts

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