Documentation ¶
Overview ¶
Package gohacks implements all the small things that are needed during programming but not present in Go or its standard library.
Index ¶
- func TypeName(myvar interface{}) string
- type Counter
- type FailureCollector
- func (self *FailureCollector) Bool(value bool, err error) bool
- func (self *FailureCollector) Branches(value domain.Branches, err error) domain.Branches
- func (self *FailureCollector) BranchesSyncStatus(value domain.BranchInfos, err error) domain.BranchInfos
- func (self *FailureCollector) Check(err error) bool
- func (self *FailureCollector) Fail(format string, a ...any)
- func (self *FailureCollector) Hosting(value config.Hosting, err error) config.Hosting
- func (self *FailureCollector) PullBranchStrategy(value config.PullBranchStrategy, err error) config.PullBranchStrategy
- func (self *FailureCollector) Remotes(value domain.Remotes, err error) domain.Remotes
- func (self *FailureCollector) RepoStatus(value domain.RepoStatus, err error) domain.RepoStatus
- func (self *FailureCollector) String(value string, err error) string
- func (self *FailureCollector) Strings(value []string, err error) []string
- func (self *FailureCollector) SyncStrategy(value config.SyncStrategy, err error) config.SyncStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a Statistics implementation that counts how many commands were run.
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) 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 ¶
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 ¶
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. |