utils

package
v0.0.0-...-3792e47 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package utils is the uncategorized utils for zbpack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstraintToVersion

func ConstraintToVersion(constraints string, defaultVersion string) string

ConstraintToVersion converts the Semver version constraint to a minor-only version.

func Copy

func Copy(src, dst string) error

Copy copies a file or directory from src to dst.

func ExtractErlangEntryFromGleamEntrypointShell

func ExtractErlangEntryFromGleamEntrypointShell(gleamEntryShell string) string

ExtractErlangEntryFromGleamEntrypointShell extracts the Erlang entrypoint from the Gleam entrypoint shell script

func GetExplicitServerlessConfig

func GetExplicitServerlessConfig(config plan.ImmutableProjectConfiguration) optional.Option[bool]

GetExplicitServerlessConfig gets the serverless flag from the project configuration.

When the serverless flag is not set, it will be determined by the FORCE_CONTAINERIZED and ZBPACK_SERVERLESS environment variables. If all of them are not set, it returns None for consumers to determine the default value.

func HasFile

func HasFile(src afero.Fs, fileNames ...string) bool

HasFile checks if the given file exists in the given filesystem.

func ReadFileToUTF8

func ReadFileToUTF8(fs afero.Fs, path string) ([]byte, error)

ReadFileToUTF8 reads a file from the filesystem and decode it to UTF-8.

It is basically the wrapper of afero.ReadFile.

func ReadToUTF8

func ReadToUTF8(content []byte) ([]byte, error)

ReadToUTF8 accepts a byte slice and check if it is a UTF-8, UTF-16 LE or UTF-16 BE encoded string by BOM and decode it to UTF-8 byte string.

func WeakContains

func WeakContains(a, b string) bool

WeakContains is just like strings.Contains, but it's case-insensitive.

Types

type IntOrBool

type IntOrBool struct {
	IntValue  int
	BoolValue bool
	IsInt     bool
}

IntOrBool is a type that can be either an int or a bool

func (*IntOrBool) UnmarshalJSON

func (iob *IntOrBool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Version

type Version struct {
	// Major version.
	Major uint32
	// Minor version.
	Minor uint32
	// MinorSet indicates if the minor version is set.
	MinorSet bool
	// Patch version.
	Patch uint32
	// PatchSet indicates if the patch version is set.
	PatchSet bool
	// Prerelease version. Empty = not set.
	Prerelease string
}

Version represents a semver version.

func SplitVersion

func SplitVersion(version string) (Version, error)

SplitVersion splits the version string into major, minor, patch, and prerelease.

If the version string is "8.0.0-beta1", the result will be 8, 0, 0, "beta1". If the version is a wildcard, the field will be -1.

Jump to

Keyboard shortcuts

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