gohacks

package
v10.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gohacks implements all the small things that are needed during programming but not present in Go or its standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeName

func TypeName(myvar interface{}) string

TypeName provides the name of the type of the given variable.

Types

type Counter

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

Counter is a Statistics implementation that counts how many commands were run.

func (*Counter) Count

func (self *Counter) Count() int

func (*Counter) Register

func (self *Counter) Register()

type FailureCollector

type FailureCollector struct {
	Err error `exhaustruct:"optional"`
}

FailureCollector helps avoid excessive error checking while gathering a larger number of values through fallible operations. This is based on ideas outlined in https://go.dev/blog/errors-are-values.

Please be aware that using this technique can lead to executing logic that would normally not run, using potentially invalid data, and potentially leading to unexpected runtime exceptions and side effects. Use with care and only if it's abundantly clear and obvious that there are no negative side effects. This is an anti-pattern in code to work arount an anti-pattern in the language.

func (*FailureCollector) Bool

func (self *FailureCollector) Bool(value bool, err error) bool

Bool provides the bool part of the given fallible function result while registering the given error.

func (*FailureCollector) Branches

func (self *FailureCollector) Branches(value domain.Branches, err error) domain.Branches

func (*FailureCollector) BranchesSyncStatus

func (self *FailureCollector) BranchesSyncStatus(value domain.BranchInfos, err error) domain.BranchInfos

func (*FailureCollector) Check

func (self *FailureCollector) Check(err error) bool

Check registers the given error and indicates whether this ErrorChecker contains an error now.

func (*FailureCollector) Fail

func (self *FailureCollector) Fail(format string, a ...any)

Fail registers the error constructed using the given format arguments.

func (*FailureCollector) Hosting

func (self *FailureCollector) Hosting(value config.Hosting, err error) config.Hosting

Hosting provides the config.Hosting part of the given fallible function result while registering the given error.

func (*FailureCollector) PullBranchStrategy

func (self *FailureCollector) PullBranchStrategy(value config.PullBranchStrategy, err error) config.PullBranchStrategy

PullBranchStrategy provides the string part of the given fallible function result while registering the given error.

func (*FailureCollector) Remotes

func (self *FailureCollector) Remotes(value domain.Remotes, err error) domain.Remotes

Remotes provides the domain.Remotes part of the given fallible function result while registering the given error.

func (*FailureCollector) RepoStatus

func (self *FailureCollector) RepoStatus(value domain.RepoStatus, err error) domain.RepoStatus

func (*FailureCollector) String

func (self *FailureCollector) String(value string, err error) string

String provides the string part of the given fallible function result while registering the given error.

func (*FailureCollector) Strings

func (self *FailureCollector) Strings(value []string, err error) []string

Strings provides the []string part of the given fallible function result while registering the given error.

func (*FailureCollector) SyncStrategy

func (self *FailureCollector) SyncStrategy(value config.SyncStrategy, err error) config.SyncStrategy

SyncStrategy provides the string part of the given fallible function result while registering the given error.

Directories

Path Synopsis
Package cache provides infrastructure to cache things in memory.
Package cache provides infrastructure to cache things in memory.
Package slice provides generic functions to work with slices.
Package slice provides generic functions to work with slices.
Package stringslice provides helper functions for working with slices of strings.
Package stringslice provides helper functions for working with slices of strings.

Jump to

Keyboard shortcuts

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