utils

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 65

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpNodeNoExit

func DumpNodeNoExit(whatever any)

DumpNodeNoExit prints a formatted JSON representation of the provided interface without exiting the program. This function is primarily used for debugging purposes.

func DumpNodeWithExit

func DumpNodeWithExit(whatever any)

DumpNodeWithExit prints a formatted JSON representation of the provided interface and exits the program. This function is primarily used for debugging purposes.

func GetLocalSourcesPath

func GetLocalSourcesPath() string

GetLocalSourcesPath returns the absolute path to the local sources directory.

func IsSemanticVersionGreaterOrEqualTo added in v0.3.1

func IsSemanticVersionGreaterOrEqualTo(versionStr string, version SemanticVersion) bool

IsSemanticVersionGreaterOrEqualTo checks if the version represented by the string is greater than or equal to the provided SemanticVersion.

func IsSemanticVersionLowerOrEqualTo added in v0.3.1

func IsSemanticVersionLowerOrEqualTo(versionStr string, version SemanticVersion) bool

IsSemanticVersionLowerOrEqualTo checks if the version represented by the string is lower than or equal to the provided SemanticVersion.

func Keccak256 added in v0.3.1

func Keccak256(data []byte) []byte

Keccak256 returns the Keccak256 hash of the input data.

func SimplifyImportPaths

func SimplifyImportPaths(content string) string

SimplifyImportPaths simplifies the paths in import statements as file will already be present in the directory for future consumption and is rather corrupted for import paths to stay the same.

func StripExtraSPDXLines

func StripExtraSPDXLines(content string) string

StripExtraSPDXLines removes the extra SPDX lines from the content. This is used when passing combined source to the solc compiler as it will complain about the extra SPDX lines.

func StripImportPaths

func StripImportPaths(content string) string

StripImportPaths removes the import paths entirely from the content.

func ToJSON

func ToJSON(data any) ([]byte, error)

ToJSON converts a Go struct to its JSON representation.

func ToJSONPretty

func ToJSONPretty(data any) ([]byte, error)

ToJSONPretty returns a pretty-printed JSON representation of the provided interface. This function is primarily used for debugging purposes.

func ToProtoJSON

func ToProtoJSON(data any) ([]byte, error)

ToProtoJSON converts a Go struct to its JSON representation.

func WriteToFile

func WriteToFile(path string, data []byte) error

WriteToFile writes the provided data byte array to a file at the provided path.

Types

type NormalizationInfo added in v0.3.1

type NormalizationInfo struct {
	TypeName   string
	Normalized bool
}

NormalizationInfo represents the result of a type normalization. It includes the normalized type name and a flag indicating whether the type name was actually normalized.

type NormalizeType added in v0.3.1

type NormalizeType struct{}

NormalizeType provides methods for normalizing type names.

func NewNormalizeType added in v0.3.1

func NewNormalizeType() *NormalizeType

NewNormalizeType creates and returns a new NormalizeType instance.

func (*NormalizeType) Normalize added in v0.3.1

func (n *NormalizeType) Normalize(typeName string) NormalizationInfo

Normalize attempts to normalize the given type name. It returns the NormalizationInfo which contains the normalized type name and a flag indicating if the provided type name was actually normalized.

type SemanticVersion added in v0.3.1

type SemanticVersion struct {
	Major int `json:"major"`
	Minor int `json:"minor"`
	Patch int `json:"patch"`
}

SemanticVersion represents a version in the format Major.Minor.Patch.

func ParseSemanticVersion added in v0.3.1

func ParseSemanticVersion(version string) SemanticVersion

ParseSemanticVersion converts a string representation of a version into a SemanticVersion struct. It expects the version string to be in the format "Major.Minor.Patch".

Jump to

Keyboard shortcuts

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