utils

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCANOSS_SUPPORT_MAILBOX = "support@scanoss.com"
)

Variables

This section is empty.

Functions

func ExpandPath

func ExpandPath(path string) string

func FileExist

func FileExist(path string) error

func FullySplitPath added in v0.7.3

func FullySplitPath(path string) (split []string)

fullySplitPath splits a path into ALL its components. The gitignore library expects to be handed a slice of everything busted ALL the way apart, but the core filepath.Split ONLY breaks off the final path component.

We theoretically could split on our platform-native path separator BUT it's not quite that simple: on windows, both forward AND back slashes as path separators, plus there's special handling of potential volume specifiers.

We COULD mimic filepath.Split's implementation stepping through and checking IsPathSeparator(), but to keep it simple, we'll just repeatedly call that directly. These are all short enough it isn't that expensive.

func GetIssueReportBody

func GetIssueReportBody(ctx context.Context) string

func GetRelativePath

func GetRelativePath(absolutePath string) (string, error)

func GetValidator

func GetValidator() *validator.Validate

func IsWritableFile

func IsWritableFile(path string) bool

func JSONParse

func JSONParse[T any](file []byte) (T, error)

func JSONSerialize

func JSONSerialize(in any) ([]byte, error)

func NormalizePathToSlash added in v0.7.4

func NormalizePathToSlash(p string) string

NormalizePathToSlash converts OS-specific separators to `/` and runs `path.Clean` to collapse “…/.” or “…/..” segments. For empty input it returns ".", mimicking `path.Clean`.

func OpenMailClient

func OpenMailClient(to string, subject string, body string) error

func RemoveProtocolFromURL added in v0.8.0

func RemoveProtocolFromURL(url string) string

RemoveProtocolFromURL removes the HTTP or HTTPS protocol prefix from a URL string. If no protocol is found, returns the original string unchanged.

func SetValidator

func SetValidator(v *validator.Validate)

func ValidatePurl

func ValidatePurl(fl validator.FieldLevel) bool

func WriteFile

func WriteFile(filename string, data []byte) error

func WriteJsonFile

func WriteJsonFile(path string, in any) error

Types

type DefaultFileReader

type DefaultFileReader struct{}

func NewDefaultFileReader

func NewDefaultFileReader() *DefaultFileReader

func (*DefaultFileReader) ReadFile

func (d *DefaultFileReader) ReadFile(filePath string) ([]byte, error)

type FileReader

type FileReader interface {
	ReadFile(filePath string) ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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