Documentation ¶
Index ¶
- Constants
- Variables
- func AreFilesEqual(file1, file2 string) (bool, error)
- func Base36Hash(input string, length int) (string, error)
- func BoolPtrEqual(a, b *bool) bool
- func BuildRequestPayload(signature string, payload map[string]interface{}) *bytes.Buffer
- func CapitalizeFirst(s string) string
- func CommandFullKey(cmd *cobra.Command) string
- func ContainsUpper(s string) bool
- func CopyDir(src string, dst string) error
- func CopyFile(src, dst string) error
- func Deref[T any](p *T, defaultVal T) T
- func DisplayProfileData(op io.Writer)
- func DisplayProfileDataJsonl(op io.Writer)
- func DistributedStringIndex(message string, secret string, numberRange int64) (int64, error)
- func EmptyDir(dirPath string) error
- func EnsureDirectoryPermission(directoryPath string) error
- func FileModTime(filePath string) (time.Time, error)
- func FilenameNoExtension(fileName string) string
- func Filter[V any](elements []V, predicate func(V) bool) []V
- func FindProcess(targetPid int) (*psutils.Process, error)
- func FormatTime(localTime time.Time) string
- func GetFirstListenAddress(listenAddresses []string) string
- func GetGenericTypeName[T any]() string
- func GetNextFreePort() (int, error)
- func GetPluginName(plugin string) string
- func HumanizeDuration(duration time.Duration) string
- func IsInterface[T any](val T) bool
- func IsMacM1() (bool, error)
- func IsPointer[T any](val T) bool
- func IsPortBindable(host string, port int) error
- func IsWSL() bool
- func JsonCloneToMap(val any) (map[string]any, error)
- func ListenAddressesContainsOneOfAddresses(listenAddresses []string, addresses []string) bool
- func LocalLoopbackAddresses() ([]string, error)
- func LocalPublicAddresses() ([]string, error)
- func LogTime(operation string)
- func Map[V any, M any](elements []V, mapper func(V) M) []M
- func MapRange(value int, valueRange RangeConstraint, desiredRange RangeConstraint) int
- func MergeMaps[M ~map[K]V, K comparable, V any](old, new M) M
- func MoveFile(source string, destination string) error
- func OpenBrowser(url string) error
- func Partition[V any](elements []V, predicate func(V) bool) ([]V, []V)
- func PidExists(targetPid int) (bool, error)
- func PluginFQNToSchemaName(pluginFQN string) string
- func Pluralize(base string, count int) string
- func PrettifyJsonFromReader(dataToExport io.Reader) (io.Reader, error)
- func PtrEqual[T constraints.Ordered](a, b *T) bool
- func RemoveDirectoryContents(removePath string) error
- func RemoveElementFromSlice(slice []string, s int) []string
- func SafeIntEqual(i1, i2 *int) bool
- func SafeStringsEqual(s1, s2 interface{}) bool
- func SendRequest(ctx context.Context, signature string, method string, sendRequestTo url.URL, ...) (*http.Response, error)
- func SlicePtrEqual[T constraints.Ordered](a, b *[]T) bool
- func SliceToLookup[K comparable](src []K) map[K]struct{}
- func SortedMapKeys[V any](m map[string]V) []string
- func TimeNow() *time.Time
- func TimePtr(t time.Time) *time.Time
- func ToIntegerPointer(i int) *int
- func ToPointer[T any](value T) *T
- func ToStringPointer(s string) *string
- func ToTitleCase(s string) string
- func TrimGitUrls(urls []string) []string
- func TrimSchemaName(pluginFQN string) string
- func UnderlyingArch() (string, error)
- func UnquoteStringArray(stringArray []string) []string
- func UserConfirmation(warning string) bool
- type JSONTime
- type RangeConstraint
- type UniqueNameGenerator
Constants ¶
const RFC3339WithMS = "2006-01-02T15:04:05.000Z07:00"
Variables ¶
var Timing []timeLog
Functions ¶
func AreFilesEqual ¶
func BoolPtrEqual ¶ added in v0.3.0
func BuildRequestPayload ¶
BuildRequestPayload merges the provided payload with the standard payload that needs to be sent
func CapitalizeFirst ¶ added in v0.3.0
func CommandFullKey ¶ added in v0.3.0
func ContainsUpper ¶
ContainsUpper returns true if the string contains any uppercase characters
func Deref ¶ added in v1.5.0
func Deref[T any](p *T, defaultVal T) T
Deref safely dereferences a pointer, returning a default value if the pointer is nil
func DisplayProfileData ¶
func DisplayProfileDataJsonl ¶ added in v1.7.0
func DistributedStringIndex ¶ added in v0.2.0
func FilenameNoExtension ¶
func Filter ¶
Filter returns a new slice only containing the elements for which invoking the predicate returned true
The predicate is invoked with each element
func FindProcess ¶
FindProcess tries to find the process with the given pid returns nil if the process could not be found
func FormatTime ¶ added in v1.6.0
FormatTime formats time as RFC3339 in UTC
func GetFirstListenAddress ¶
func GetGenericTypeName ¶ added in v0.3.0
GetGenericTypeName returns lower case form of type unqualified name
func GetNextFreePort ¶ added in v1.6.0
func GetPluginName ¶
GetPluginName function is used to get the plugin name required while installing/updating/removing a plugin. External plugins require the repo names to be prefixed(eg: francois2metz/scalingo). Sample input 1: hub.steampipe.io/plugins/francois2metz/scalingo@latest Sample output 1: francois2metz/scalingo Sample input 2: hub.steampipe.io/plugins/turbot/aws@latest Sample output 2: aws
func HumanizeDuration ¶
func IsInterface ¶ added in v1.6.0
func IsPortBindable ¶
func IsWSL ¶
func IsWSL() bool
IsWSL detects whether app is running in WSL environment refer to: https://github.com/Microsoft/WSL/issues/423#issuecomment-679190758
func JsonCloneToMap ¶
JsonCloneToMap tries to JSON marshal and unmarshal the given data, returning a map[string]any if successful
func LocalLoopbackAddresses ¶
func LocalPublicAddresses ¶
func Map ¶
Map returns a new slice where every value is mapped to a new value through the mapper
The mapper is invoked with each element
func MapRange ¶
func MapRange(value int, valueRange RangeConstraint, desiredRange RangeConstraint) int
MapRange Re-maps a number from one range to another.
func MergeMaps ¶
func MergeMaps[M ~map[K]V, K comparable, V any](old, new M) M
TODO no longer needed - included on go maps MergeMaps merges 'new' onto 'old'. Values existing in old already have precedence Any value existing in new but not old is added to old
func MoveFile ¶
MoveFile moves a file from source to destination.
It first attempts the movement using OS primitives (os.Rename) If os.Rename fails, it copies the file byte-by-byte to the destination and then removes the source
func OpenBrowser ¶
https://stackoverflow.com/questions/39320371/how-start-web-server-to-open-page-in-browser-in-golang
func Partition ¶
Partition splits the array of elements into two groups: the left partition contains elements that the predicate returns `true` for. the right partition contains elements that the predicate returns `false` for.
The predicate is invoked with each element
func PidExists ¶
PidExists scans through the list of PIDs in the system and checks for the `targetPID`.
PidExists uses iteration, instead of signalling, since we have observed that signalling does not always work reliably when the destination of the signal is a child of the source of the signal - which may be the case then starting implicit services
func PluginFQNToSchemaName ¶
PluginFQNToSchemaName convert a full plugin name to a schema name schemas in postgres are limited to 63 chars - the name may be longer than this, in which case trim the length and add a hash to the end to make unique
func PrettifyJsonFromReader ¶
func PtrEqual ¶ added in v0.3.0
func PtrEqual[T constraints.Ordered](a, b *T) bool
func RemoveDirectoryContents ¶
func RemoveElementFromSlice ¶
RemoveElementFromSlice takes a slice of strings and an index to remove, and returns a new slice with the specified element removed.
func SafeIntEqual ¶
func SafeStringsEqual ¶
func SafeStringsEqual(s1, s2 interface{}) bool
func SendRequest ¶
func SendRequest(ctx context.Context, signature string, method string, sendRequestTo url.URL, payload io.Reader) (*http.Response, error)
SendRequest makes a http call to the given URL
func SlicePtrEqual ¶ added in v1.6.0
func SlicePtrEqual[T constraints.Ordered](a, b *[]T) bool
func SliceToLookup ¶
func SliceToLookup[K comparable](src []K) map[K]struct{}
func SortedMapKeys ¶
func ToIntegerPointer ¶
ToIntegerPointer converts an integer into its pointer
func ToStringPointer ¶
ToStringPointer converts a string into its pointer
func ToTitleCase ¶ added in v0.2.0
ToTitleCase correctly returns a Title cased string
func TrimGitUrls ¶
TrimGitUrls Modifies(trims) the URL if contains http ot https in arguments
func TrimSchemaName ¶
func UnderlyingArch ¶
UnderlyingArch detects the underlying architecture(amd64/arm64) of the system we need this to detect the underlying architecture to install the correct FDW package
func UnquoteStringArray ¶
UnquoteStringArray removes quote marks from elements of string array
func UserConfirmation ¶
UserConfirmation displays the warning message and asks the user for input regarding whether to continue or not
Types ¶
type JSONTime ¶ added in v1.5.0
JSONTime is a timestamp that can be serialized into JSON format
func (*JSONTime) MarshalJSON ¶ added in v1.5.0
MarshalJSON converts a JSONTime struct into a JSON byte buf
func (*JSONTime) Scan ¶ added in v1.5.0
https://stackoverflow.com/questions/61630216/converting-time-from-db-to-custom-time-fails
func (*JSONTime) UnmarshalJSON ¶ added in v1.5.0
UnmarshalJSON converts buf into a JSONTime struct
type RangeConstraint ¶
type RangeConstraint struct {
// contains filtered or unexported fields
}
func NewRangeConstraint ¶
func NewRangeConstraint(minimum int, maximum int) RangeConstraint
func (*RangeConstraint) Constrain ¶
func (r *RangeConstraint) Constrain(value int) int
Constrain a number to be within a range.
type UniqueNameGenerator ¶ added in v1.4.0
type UniqueNameGenerator struct {
// contains filtered or unexported fields
}
func NewUniqueNameGenerator ¶ added in v1.4.0
func NewUniqueNameGenerator() *UniqueNameGenerator
NewUniqueNameGenerator creates a new UniqueNameGenerator
func (*UniqueNameGenerator) GetUniqueName ¶ added in v1.4.0
func (g *UniqueNameGenerator) GetUniqueName(name string, index int) (string, error)
GetUniqueName returns a unique name based on the input name If the input name is not unique, a random lowercase string is appended to the name This is used in steampipe and powerpipe to ensure unique column names in JSON output when same columns are requested.
Source Files ¶
- arch.go
- browser.go
- collection.go
- command.go
- distributed_string_index.go
- equals.go
- file.go
- fs_permissions.go
- hash.go
- humanize.go
- json.go
- map.go
- net.go
- pid_exists.go
- plugin.go
- plural.go
- pointers.go
- range.go
- reflect.go
- remove_dir_contents.go
- string.go
- string_slice.go
- time.go
- timing.go
- unique_name_generator.go
- url.go
- user_input.go
- useragent.go
- wsl.go