Documentation
¶
Overview ¶
Package utils is the uncategorized utils for zbpack.
Index ¶
- Variables
- func ConstraintToVersion(constraints string, defaultVersion string) string
- func Copy(src, dst string) error
- func ExtractErlangEntryFromGleamEntrypointShell(gleamEntryShell string) string
- func HasFile(src afero.Fs, fileNames ...string) bool
- func ReadFileToUTF8(fs afero.Fs, path string) ([]byte, error)
- func ReadToUTF8(content []byte) ([]byte, error)
- func WeakContains(a, b string) bool
- type IntOrBool
- type Version
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyVersion = errors.New("empty version")
ErrEmptyVersion is returned when the version string is empty.
Functions ¶
func ConstraintToVersion ¶
ConstraintToVersion converts the Semver version constraint to a minor-only version.
func ExtractErlangEntryFromGleamEntrypointShell ¶
ExtractErlangEntryFromGleamEntrypointShell extracts the Erlang entrypoint from the Gleam entrypoint shell script
func ReadFileToUTF8 ¶
ReadFileToUTF8 reads a file from the filesystem and decode it to UTF-8.
It is basically the wrapper of afero.ReadFile.
func ReadToUTF8 ¶
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 ¶
WeakContains is just like strings.Contains, but it's case-insensitive.
Types ¶
type IntOrBool ¶
IntOrBool is a type that can be either an int or a bool
func (*IntOrBool) UnmarshalJSON ¶
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 ¶
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.