utils

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: BSD-3-Clause Imports: 22 Imported by: 3

Documentation

Overview

Copyright (C) 2022, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2023, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2023, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2022, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2022, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2023, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Copyright (C) 2023, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsIgnoreCase added in v1.3.6

func ContainsIgnoreCase(s, substr string) bool

containsIgnoreCase checks if the given string contains the specified substring, ignoring case.

func ConvertInterfaceToMap added in v1.3.4

func ConvertInterfaceToMap(value interface{}) (map[string]interface{}, error)

ConvertInterfaceToMap converts a given value to a map[string]interface{}.

func FileExists added in v1.3.4

func FileExists(filename string) bool

FileExists checks if a file exists.

func Filter added in v1.3.4

func Filter[T any](input []T, f func(T) bool) []T

func FindErrorLogs added in v1.1.3

func FindErrorLogs(rootDirs ...string)

FindErrorLogs is a utility function, we will NOT do error handling, as this is supposed to be called during error handling itself we don't want to make it even more complex

func GetANRContext added in v1.3.4

func GetANRContext() (context.Context, context.CancelFunc)

Context for ANR network operations

func GetAPIContext added in v1.3.4

func GetAPIContext() (context.Context, context.CancelFunc)

Context for API requests

func GetRealFilePath added in v1.3.4

func GetRealFilePath(path string) string

func GetSHA256FromDisk added in v1.0.3

func GetSHA256FromDisk(binPath string) (string, error)

func GetSSHConnectionString added in v1.3.3

func GetSSHConnectionString(publicIP, certFilePath string) string

func IsExecutable added in v1.3.4

func IsExecutable(filename string) bool

IsExecutable checks if a file is executable.

func IsUnsignedSlice added in v1.3.5

func IsUnsignedSlice(n []int) bool

IsUnsignedSlice returns true if all elements in the slice are unsigned integers.

func Map added in v1.3.4

func Map[T, U any](input []T, f func(T) U) []U

func MapWithError added in v1.3.4

func MapWithError[T, U any](input []T, f func(T) (U, error)) ([]U, error)

func NewBlsSecretKeyBytes added in v1.3.4

func NewBlsSecretKeyBytes() ([]byte, error)

func SearchSHA256File added in v1.0.3

func SearchSHA256File(file []byte, toSearch string) (string, error)

func SetupRealtimeCLIOutput added in v1.2.7

func SetupRealtimeCLIOutput(cmd *exec.Cmd, redirectStdout bool, redirectStderr bool) (*bytes.Buffer, *bytes.Buffer)

func SortUint32 added in v1.3.5

func SortUint32(arr []uint32)

func SplitComaSeparatedInt added in v1.3.5

func SplitComaSeparatedInt(s string) []int

SplitComaSeparatedInt splits a comma-separated string into a slice of integers.

func SplitComaSeparatedString added in v1.3.5

func SplitComaSeparatedString(s string) []string

SplitComaSeparatedString splits and trims a comma-separated string into a slice of strings.

func SplitKeyValueStringToMap added in v1.3.3

func SplitKeyValueStringToMap(str string, delimiter string) (map[string]string, error)

SplitKeyValueStringToMap splits a string with multiple key-value pairs separated by delimiter. Delimiter must be a single character

func SplitStringWithQuotes added in v1.3.3

func SplitStringWithQuotes(str string, r rune) []string

SplitString split string with a rune comma ignore quoted

func TimedFunction added in v1.3.4

func TimedFunction(f func() (interface{}, error), name string, timeout time.Duration) (interface{}, error)

TimedFunction is a function that executes the given function `f` within a specified timeout duration.

func ToNodeID added in v1.3.4

func ToNodeID(certBytes []byte, keyBytes []byte) (ids.NodeID, error)

func Unique added in v1.3.5

func Unique(slice []string) []string

Unique returns a new slice containing only the unique elements from the input slice.

func UserHomePath added in v1.3.4

func UserHomePath(filePath ...string) string

UserHomePath returns the absolute path of a file located in the user's home directory.

func ValidateJSON

func ValidateJSON(path string) ([]byte, error)

ValidateJSON takes a json string and returns it's byte representation if it contains valid JSON

Types

This section is empty.

Jump to

Keyboard shortcuts

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