helper

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDiagnosticOnError added in v0.18.0

func AddDiagnosticOnError(diag *diag.Diagnostics, summary string, err error) bool

AddDiagnosticOnError is a helper function which will take an error and a context-specific summary of the action.

If err is nil, this function will return false. If err is non-nil, this function will return ture and take one the following actions:

  • if it is a client.DetailedError, a DetailedErrorDiagnostic will be added to diag.
  • otherwise a generic error diagnostic will be added to diag.

func AsStringSlice added in v0.18.0

func AsStringSlice[S ~string](in []S) []string

AsStringSlice converts a slice of string-like things to a slice of strings.

func FloatToPPM added in v0.20.0

func FloatToPPM(f float64) int

FloatToPPM converts a floating point percentage to a parts per million value

func FloatToPercentString added in v0.20.0

func FloatToPercentString(f float64) string

FloatToPercentString converts a floating point percentage to a string, with a maximum of 4 decimal places, no trailing zeros

func PPMToFloat added in v0.20.0

func PPMToFloat(t int) float64

converts a parts per million value to a floating point percentage

func ToPtr added in v0.16.0

func ToPtr[T any](v T) *T

ToPtr returns a pointer to the given value

Types

type DetailedErrorDiagnostic added in v0.18.0

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

DetailedErrorDiagnostic is a Diagnostic which nicely wraps a client.DetailedError

func NewDetailedErrorDiagnostic added in v0.18.0

func NewDetailedErrorDiagnostic(summary string, e *client.DetailedError) DetailedErrorDiagnostic

NewDetailedErrorDiagnostic creates a new DetailedErrorDiagnostic taking a context-specific summary of the action and a DetailedError.

func (DetailedErrorDiagnostic) Detail added in v0.18.0

func (d DetailedErrorDiagnostic) Detail() string

func (DetailedErrorDiagnostic) Equal added in v0.18.0

func (DetailedErrorDiagnostic) Severity added in v0.18.0

func (d DetailedErrorDiagnostic) Severity() diag.Severity

func (DetailedErrorDiagnostic) Summary added in v0.18.0

func (d DetailedErrorDiagnostic) Summary() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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