algernon: github.com/xyproto/algernon/utils Index | Files

package utils

import "github.com/xyproto/algernon/utils"

Index

Package Files

files.go web.go

Constants

const (
    // Pathsep is the path separator for the current platform
    Pathsep = string(filepath.Separator)

    // EveryInstance can be used when replacing strings
    EveryInstance = -1

    // KiB is a kilobyte (kibibyte)
    KiB = 1024

    // MiB is a megabyte (mibibyte)
    MiB = 1024 * 1024
)

func DescribeBytes Uses

func DescribeBytes(size int64) string

DescribeBytes converts bytes to KiB or MiB. Returns a string.

func DurationToMS Uses

func DurationToMS(d time.Duration, multiplier float64) string

DurationToMS converts time.Duration to milliseconds, as a string, (just the number as a string, no "ms" suffix).

func ExtractKeywords Uses

func ExtractKeywords(data []byte, keywordsToLookFor []string) ([]byte, map[string][]byte)

ExtractKeywords takes a source file as `data` and a list of keywords to

* look for. Lines without keywords are returned, together with a map
* from keywords to []bytes from the source `data`.
*
* The keywords in the data must be on the form "keyword: value",
* and can be within single-line HTML comments (<-- ... -->).

func FilterIntoGroups Uses

func FilterIntoGroups(bytelines [][]byte, filterfunc func([]byte) bool) ([][]byte, [][]byte)

FilterIntoGroups filters []byte slices into two groups, depending on the given filter function

func GetDomain Uses

func GetDomain(req *http.Request) string

GetDomain returns the domain of a request (up to ":", if any)

func GetFilenames Uses

func GetFilenames(dirname string) []string

GetFilenames retrieves a list of filenames from a given directory name (that must exist)

func Infostring Uses

func Infostring(functionName string, args []string) string

Infostring builds up a string on the form "functionname(arg1, arg2, arg3)"

func ReadString Uses

func ReadString(filename string) string

ReadString returns the contents of the given filename as a string. Does not use the cache. Returns an empty string if there were errors.

func URL2filename Uses

func URL2filename(dirname, urlpath string) string

URL2filename translates a given URL path to a probable full filename

func WriteStatus Uses

func WriteStatus(buf *bytes.Buffer, title string, flags map[string]bool)

WriteStatus writes a status message to a buffer, given a name and a bool

Package utils imports 10 packages (graph) and is imported by 3 packages. Updated 2017-11-22. Refresh now. Tools for package owners.