# README
Util
Utility and core functions used by the updater.
# Functions
CheckDigest returns no error if digest matches file.
Close closes a file and ignores the error.
CombineErrors returns a single error for multiple errors, or nil if none.
ComputeEtag returns etag for a file at path.
CopyFile copies a file safely.
Digest256 returns a SHA256 digest.
Digest512 returns a SHA256 digest.
DigestForFileAtPath returns a SHA256 digest for file at specified path.
DiscardAndCloseBody reads as much as possible from the body of the given response, and then closes it.
DiscardAndCloseBodyIgnoreError calls DiscardAndCloseBody.
DownloadURL downloads a URL to a path.
EnvBool returns a bool from an environment variable or default if invalid or not specified.
EnvDuration returns a duration from an environment variable or default if invalid or not specified.
FileExists returns whether the given file or directory exists or not.
FileModTime returns modification time for file.
HTTPClient returns http.Client with timeout.
IsDirReal returns true if directory exists and is a real directory (not a symlink).
JoinPredicate joins strings with predicate.
MakeDirs ensures directory exists for path.
MakeParentDirs ensures parent directory exist for path.
MakeTempDir creates a unique temp directory.
MoveFile moves a file safely.
NewContextLogger ...
NewFile returns a File.
NewLogger ...
PathFromURL returns path for file URL scheme For example, file:///usr/local/go/bin => /usr/local/go/bin file:///C:/Go/bin => C:\Go\bin.
RandBytes returns random bytes of length.
RandomID returns random ID (base32) string with prefix, using 256 bits as recommended by tptacek: https://gist.github.com/tqbf/be58d2d39690c3b366ad.
ReadFile returns data for file at path.
RemoveFileAtPath removes a file at path (and any children) ignoring any error.
SaveHTTPResponse saves an http.Response to path.
SetLogger sets logger for the package.
TempPath returns a temporary unique file path.
TimeFromMillis returns time.Time from milliseconds since epoch.
TimePtrToMillis returns milliseconds since epoch from time.Time.
TimeToMillis returns milliseconds since epoch from time.Time.
Touch a file, updating its modification time.
Unzip unpacks a zip file to a destination.
UnzipOver safely unzips a file and copies it contents to a destination path.
UnzipPath unzips and returns path to unzipped directory.
URLExists returns error if URL doesn't exist.
URLStringForPath returns an URL as string with file scheme for path.
URLValueForBool returns "1" for true, otherwise "0".
WriteTempFile creates a unique temp file with data.
# Interfaces
ContextLogger interface used in this package with request context.
Logger interface used in this package.
SafeWriter defines a writer that is safer (atomic).
# Type aliases
DigestType is type of digest.
LogLevel ...
TimeMs is time as number of milliseconds from epoch.