helpers

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 6 Imported by: 0

README

go-helpers

Various helpers for GO projects

Documentation

Index

Examples

Constants

View Source
const (
	OK = "✅" // no comments needed
	KO = "❌" // not OK
	OH = "😯" // WARNING
	AH = "🤨" // DEBUG or TODO
)

Variables

This section is empty.

Functions

func Ah

func Ah(line string) string

Ah helper function for terminal output decoration in yellow with 😯 Debugging and exploartion purpose.

Example
fmt.Printf("%s", Ah("foo"))
Output:
�[34;3m 🤨 foo �[0m

func DurationLog

func DurationLog(start time.Time, name string)

DurationLog measure the duration of a function

Usage:

defer helpers.DurationLog(time.Now())

func Equal

func Equal(t *testing.T, actual, expected any)

Equal fails the test if not equal.

Example
t := &testing.T{}
Equal(t, []string{"foo", "bar", "ln"}, []string{"foo", "bar", "lan"})
fmt.Printf("%v", t.Failed())
Output:
true

func Ko

func Ko(line string) string

Ko helper function for terminal output decoration in red with ❌.

func NoError

func NoError(t *testing.T, err error)

NoError fails the test on error.

Example
t := &testing.T{}
NoError(t, errors.New("unexpected error"))
fmt.Printf("%v", t.Failed())
Output:
true

func NotEqual

func NotEqual(t *testing.T, actual, expected any)

NotEqual fails the test if equal.

Example
t := &testing.T{}
NotEqual(t, 2, 2)
fmt.Printf("%v", t.Failed())
Output:
true

func NotNil

func NotNil(t *testing.T, data any)

NotNil fails the test if the subject is nil.

Example
t := &testing.T{}
NotNil(t, nil)
fmt.Printf("%v", t.Failed())
Output:
true

func Ok

func Ok(line string) string

Ok helper function for terminal output decoration in green with ✅.

Example
fmt.Printf("%s", Ok("foo"))
Output:
�[32m ✅ foo �[0m

Types

type DiffReporter

type DiffReporter struct {
	// contains filtered or unexported fields
}

DiffReporter is a simple custom reporter that only records differences detected during comparison.

func (*DiffReporter) PopStep

func (r *DiffReporter) PopStep()

func (*DiffReporter) PushStep

func (r *DiffReporter) PushStep(ps cmp.PathStep)

func (*DiffReporter) Report

func (r *DiffReporter) Report(rs cmp.Result)

func (*DiffReporter) String

func (r *DiffReporter) String() string

Jump to

Keyboard shortcuts

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