id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
142,500
jhillyerd/go.enmime
part.go
parseParts
func parseParts(parent MIMEPart, reader io.Reader, boundary string) error { var prevSibling MIMEPart // Loop over MIME parts mr := multipart.NewReader(reader, boundary) for { // mrp is golang's built in mime-part mrp, err := mr.NextPart() if err != nil { if err == io.EOF { // This is a clean end-of-me...
go
func parseParts(parent MIMEPart, reader io.Reader, boundary string) error { var prevSibling MIMEPart // Loop over MIME parts mr := multipart.NewReader(reader, boundary) for { // mrp is golang's built in mime-part mrp, err := mr.NextPart() if err != nil { if err == io.EOF { // This is a clean end-of-me...
[ "func", "parseParts", "(", "parent", "MIMEPart", ",", "reader", "io", ".", "Reader", ",", "boundary", "string", ")", "error", "{", "var", "prevSibling", "MIMEPart", "\n\n", "// Loop over MIME parts", "mr", ":=", "multipart", ".", "NewReader", "(", "reader", ",...
// parseParts recursively parses a mime multipart document.
[ "parseParts", "recursively", "parses", "a", "mime", "multipart", "document", "." ]
1b38e76723aa41be23ca88adbb21df1972c10b7f
https://github.com/jhillyerd/go.enmime/blob/1b38e76723aa41be23ca88adbb21df1972c10b7f/part.go#L188-L272
142,501
jhillyerd/go.enmime
part.go
decodeSection
func decodeSection(encoding string, reader io.Reader) ([]byte, error) { // Default is to just read input into bytes decoder := reader switch strings.ToLower(encoding) { case "quoted-printable": decoder = quotedprintable.NewReader(reader) case "base64": cleaner := NewBase64Cleaner(reader) decoder = base64.Ne...
go
func decodeSection(encoding string, reader io.Reader) ([]byte, error) { // Default is to just read input into bytes decoder := reader switch strings.ToLower(encoding) { case "quoted-printable": decoder = quotedprintable.NewReader(reader) case "base64": cleaner := NewBase64Cleaner(reader) decoder = base64.Ne...
[ "func", "decodeSection", "(", "encoding", "string", ",", "reader", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Default is to just read input into bytes", "decoder", ":=", "reader", "\n\n", "switch", "strings", ".", "ToLower", "...
// decodeSection attempts to decode the data from reader using the algorithm listed in // the Content-Transfer-Encoding header, returning the raw data if it does not known // the encoding type.
[ "decodeSection", "attempts", "to", "decode", "the", "data", "from", "reader", "using", "the", "algorithm", "listed", "in", "the", "Content", "-", "Transfer", "-", "Encoding", "header", "returning", "the", "raw", "data", "if", "it", "does", "not", "known", "t...
1b38e76723aa41be23ca88adbb21df1972c10b7f
https://github.com/jhillyerd/go.enmime/blob/1b38e76723aa41be23ca88adbb21df1972c10b7f/part.go#L277-L296
142,502
jhillyerd/go.enmime
base64.go
Read
func (qp *Base64Cleaner) Read(p []byte) (n int, err error) { // Size our slice to theirs size := len(qp.buf) if len(p) < size { size = len(p) } buf := qp.buf[:size] bn, err := qp.in.Read(buf) for i := 0; i < bn; i++ { switch buf[i] { case ' ', '\t', '\r', '\n': // Strip these default: p[n] = buf[i]...
go
func (qp *Base64Cleaner) Read(p []byte) (n int, err error) { // Size our slice to theirs size := len(qp.buf) if len(p) < size { size = len(p) } buf := qp.buf[:size] bn, err := qp.in.Read(buf) for i := 0; i < bn; i++ { switch buf[i] { case ' ', '\t', '\r', '\n': // Strip these default: p[n] = buf[i]...
[ "func", "(", "qp", "*", "Base64Cleaner", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "// Size our slice to theirs", "size", ":=", "len", "(", "qp", ".", "buf", ")", "\n", "if", "len", "(", "p", ")...
// Read method for io.Reader interface.
[ "Read", "method", "for", "io", ".", "Reader", "interface", "." ]
1b38e76723aa41be23ca88adbb21df1972c10b7f
https://github.com/jhillyerd/go.enmime/blob/1b38e76723aa41be23ca88adbb21df1972c10b7f/base64.go#L23-L43
142,503
JackDanger/collectlinks
collectlinks.go
check
func check(sl []string, s string) bool { var check bool for _, str := range sl { if str == s { check = true break } } return check }
go
func check(sl []string, s string) bool { var check bool for _, str := range sl { if str == s { check = true break } } return check }
[ "func", "check", "(", "sl", "[", "]", "string", ",", "s", "string", ")", "bool", "{", "var", "check", "bool", "\n", "for", "_", ",", "str", ":=", "range", "sl", "{", "if", "str", "==", "s", "{", "check", "=", "true", "\n", "break", "\n", "}", ...
// check looks to see if a url exits in the slice.
[ "check", "looks", "to", "see", "if", "a", "url", "exits", "in", "the", "slice", "." ]
24c4ee2870ba625f927b59de8c421c3f0be82b90
https://github.com/JackDanger/collectlinks/blob/24c4ee2870ba625f927b59de8c421c3f0be82b90/collectlinks.go#L55-L64
142,504
JackDanger/collectlinks
collectlinks.go
resolv
func resolv(sl *[]string, ml []string) { for _, str := range ml { if check(*sl, str) == false { *sl = append(*sl, str) } } }
go
func resolv(sl *[]string, ml []string) { for _, str := range ml { if check(*sl, str) == false { *sl = append(*sl, str) } } }
[ "func", "resolv", "(", "sl", "*", "[", "]", "string", ",", "ml", "[", "]", "string", ")", "{", "for", "_", ",", "str", ":=", "range", "ml", "{", "if", "check", "(", "*", "sl", ",", "str", ")", "==", "false", "{", "*", "sl", "=", "append", "...
// resolv adds links to the link slice and insures that there is no repetition // in our collection.
[ "resolv", "adds", "links", "to", "the", "link", "slice", "and", "insures", "that", "there", "is", "no", "repetition", "in", "our", "collection", "." ]
24c4ee2870ba625f927b59de8c421c3f0be82b90
https://github.com/JackDanger/collectlinks/blob/24c4ee2870ba625f927b59de8c421c3f0be82b90/collectlinks.go#L68-L74
142,505
grokify/gotilla
math/mathutil/sliceint.go
Append
func (sint *SliceInt) Append(num int) { sint.Elements = append(sint.Elements, num) }
go
func (sint *SliceInt) Append(num int) { sint.Elements = append(sint.Elements, num) }
[ "func", "(", "sint", "*", "SliceInt", ")", "Append", "(", "num", "int", ")", "{", "sint", ".", "Elements", "=", "append", "(", "sint", ".", "Elements", ",", "num", ")", "\n", "}" ]
// Append adds an element to the integer slice.
[ "Append", "adds", "an", "element", "to", "the", "integer", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L21-L23
142,506
grokify/gotilla
math/mathutil/sliceint.go
Min
func (sint *SliceInt) Min() (int, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.IntsAreSorted(sint.Elements) { sort.Ints(sint.Elements) } return sint.Elements[0], nil }
go
func (sint *SliceInt) Min() (int, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.IntsAreSorted(sint.Elements) { sort.Ints(sint.Elements) } return sint.Elements[0], nil }
[ "func", "(", "sint", "*", "SliceInt", ")", "Min", "(", ")", "(", "int", ",", "error", ")", "{", "if", "len", "(", "sint", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", ...
// Min returns the minimum element value in the integer slice.
[ "Min", "returns", "the", "minimum", "element", "value", "in", "the", "integer", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L36-L44
142,507
grokify/gotilla
math/mathutil/sliceint.go
Sum
func (sint *SliceInt) Sum() (int, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } sum := int(0) for _, num := range sint.Elements { sum += num } return sum, nil }
go
func (sint *SliceInt) Sum() (int, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } sum := int(0) for _, num := range sint.Elements { sum += num } return sum, nil }
[ "func", "(", "sint", "*", "SliceInt", ")", "Sum", "(", ")", "(", "int", ",", "error", ")", "{", "if", "len", "(", "sint", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", ...
// Sum returns sum of all the elements in the integer slice.
[ "Sum", "returns", "sum", "of", "all", "the", "elements", "in", "the", "integer", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L58-L67
142,508
grokify/gotilla
math/mathutil/sliceint.go
Mean
func (sint *SliceInt) Mean() (float64, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } sum, err := sint.Sum() if err != nil { return 0, err } return float64(sum) / float64(len(sint.Elements)), nil }
go
func (sint *SliceInt) Mean() (float64, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } sum, err := sint.Sum() if err != nil { return 0, err } return float64(sum) / float64(len(sint.Elements)), nil }
[ "func", "(", "sint", "*", "SliceInt", ")", "Mean", "(", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "sint", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\...
// Mean returns the arithmetic mean of the integer slice.
[ "Mean", "returns", "the", "arithmetic", "mean", "of", "the", "integer", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L75-L84
142,509
grokify/gotilla
math/mathutil/sliceint.go
Median
func (sint *SliceInt) Median() (int, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.IntsAreSorted(sint.Elements) { sort.Ints(sint.Elements) } mid := int64(float64(len(sint.Elements)) / 2) return sint.Elements[mid], nil }
go
func (sint *SliceInt) Median() (int, error) { if len(sint.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.IntsAreSorted(sint.Elements) { sort.Ints(sint.Elements) } mid := int64(float64(len(sint.Elements)) / 2) return sint.Elements[mid], nil }
[ "func", "(", "sint", "*", "SliceInt", ")", "Median", "(", ")", "(", "int", ",", "error", ")", "{", "if", "len", "(", "sint", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n"...
// Median returns the median or middle value of the sorted integer slice.
[ "Median", "returns", "the", "median", "or", "middle", "value", "of", "the", "sorted", "integer", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L87-L96
142,510
grokify/gotilla
math/mathutil/sliceint.go
BuildStats
func (sint *SliceInt) BuildStats() (SliceIntStats, error) { stats := NewSliceIntStats() stats.Len = sint.Len() max, err := sint.Max() if err != nil { return stats, err } stats.Max = max min, err := sint.Min() if err != nil { return stats, err } stats.Min = min mean, err := sint.Mean() if err != nil { ...
go
func (sint *SliceInt) BuildStats() (SliceIntStats, error) { stats := NewSliceIntStats() stats.Len = sint.Len() max, err := sint.Max() if err != nil { return stats, err } stats.Max = max min, err := sint.Min() if err != nil { return stats, err } stats.Min = min mean, err := sint.Mean() if err != nil { ...
[ "func", "(", "sint", "*", "SliceInt", ")", "BuildStats", "(", ")", "(", "SliceIntStats", ",", "error", ")", "{", "stats", ":=", "NewSliceIntStats", "(", ")", "\n", "stats", ".", "Len", "=", "sint", ".", "Len", "(", ")", "\n", "max", ",", "err", ":=...
// BuildStats builds a stats struct for current integer slice elements.
[ "BuildStats", "builds", "a", "stats", "struct", "for", "current", "integer", "slice", "elements", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L99-L129
142,511
grokify/gotilla
math/mathutil/sliceint.go
NewSliceIntStats
func NewSliceIntStats() SliceIntStats { stats := SliceIntStats{ Len: 0, Max: 0, Mean: 0, Median: 0, Min: 0, Sum: 0} return stats }
go
func NewSliceIntStats() SliceIntStats { stats := SliceIntStats{ Len: 0, Max: 0, Mean: 0, Median: 0, Min: 0, Sum: 0} return stats }
[ "func", "NewSliceIntStats", "(", ")", "SliceIntStats", "{", "stats", ":=", "SliceIntStats", "{", "Len", ":", "0", ",", "Max", ":", "0", ",", "Mean", ":", "0", ",", "Median", ":", "0", ",", "Min", ":", "0", ",", "Sum", ":", "0", "}", "\n", "return...
// NewSliceIntStats returns a new initialized SliceIntStats struct.
[ "NewSliceIntStats", "returns", "a", "new", "initialized", "SliceIntStats", "struct", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/sliceint.go#L142-L151
142,512
grokify/gotilla
type/stringsutil/slice.go
SliceTrimSpace
func SliceTrimSpace(slice []string) []string { trimmed := []string{} for _, part := range slice { part := strings.TrimSpace(part) if len(part) > 0 { trimmed = append(trimmed, part) } } return trimmed }
go
func SliceTrimSpace(slice []string) []string { trimmed := []string{} for _, part := range slice { part := strings.TrimSpace(part) if len(part) > 0 { trimmed = append(trimmed, part) } } return trimmed }
[ "func", "SliceTrimSpace", "(", "slice", "[", "]", "string", ")", "[", "]", "string", "{", "trimmed", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "part", ":=", "range", "slice", "{", "part", ":=", "strings", ".", "TrimSpace", "(", "pa...
// SliceTrimSpace removes leading and trailing spaces per // string and also removes empty strings.
[ "SliceTrimSpace", "removes", "leading", "and", "trailing", "spaces", "per", "string", "and", "also", "removes", "empty", "strings", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/type/stringsutil/slice.go#L10-L19
142,513
grokify/gotilla
type/stringsutil/slice.go
SplitTrimSpace
func SplitTrimSpace(s, sep string) []string { split := strings.Split(s, sep) strs := []string{} for _, str := range split { strs = append(strs, strings.TrimSpace(str)) } return strs }
go
func SplitTrimSpace(s, sep string) []string { split := strings.Split(s, sep) strs := []string{} for _, str := range split { strs = append(strs, strings.TrimSpace(str)) } return strs }
[ "func", "SplitTrimSpace", "(", "s", ",", "sep", "string", ")", "[", "]", "string", "{", "split", ":=", "strings", ".", "Split", "(", "s", ",", "sep", ")", "\n", "strs", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "str", ":=", "ra...
// SplitTrimSpace splits a string and trims spaces on // remaining elements.
[ "SplitTrimSpace", "splits", "a", "string", "and", "trims", "spaces", "on", "remaining", "elements", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/type/stringsutil/slice.go#L71-L78
142,514
grokify/gotilla
net/mailutil/mailutil.go
ParseAddressSpec
func ParseAddressSpec(addrSpec string) (string, string, error) { rs := regexp.MustCompile(`^([^@]+)@([^@]+)$`).FindStringSubmatch(addrSpec) if len(rs) < 1 { return "", "", errors.New("RFC 5322 Address Spec not found.") } return rs[1], rs[2], nil }
go
func ParseAddressSpec(addrSpec string) (string, string, error) { rs := regexp.MustCompile(`^([^@]+)@([^@]+)$`).FindStringSubmatch(addrSpec) if len(rs) < 1 { return "", "", errors.New("RFC 5322 Address Spec not found.") } return rs[1], rs[2], nil }
[ "func", "ParseAddressSpec", "(", "addrSpec", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "rs", ":=", "regexp", ".", "MustCompile", "(", "`^([^@]+)@([^@]+)$`", ")", ".", "FindStringSubmatch", "(", "addrSpec", ")", "\n", "if", "len", ...
// ParseAddressSpec parses RFC 5322 Addr-Spec Specification
[ "ParseAddressSpec", "parses", "RFC", "5322", "Addr", "-", "Spec", "Specification" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/mailutil/mailutil.go#L120-L126
142,515
grokify/gotilla
time/timeutil/timeutil_projection.go
QuarterProjection
func QuarterProjection(dt time.Time, current float64) float64 { qtStart := QuarterStart(dt) durQ2D := dt.Sub(qtStart) qtNext := TimeDt6AddNMonths(qtStart, 3) durQtr := qtNext.Sub(qtStart) projection := current / durQ2D.Seconds() * durQtr.Seconds() return projection }
go
func QuarterProjection(dt time.Time, current float64) float64 { qtStart := QuarterStart(dt) durQ2D := dt.Sub(qtStart) qtNext := TimeDt6AddNMonths(qtStart, 3) durQtr := qtNext.Sub(qtStart) projection := current / durQ2D.Seconds() * durQtr.Seconds() return projection }
[ "func", "QuarterProjection", "(", "dt", "time", ".", "Time", ",", "current", "float64", ")", "float64", "{", "qtStart", ":=", "QuarterStart", "(", "dt", ")", "\n", "durQ2D", ":=", "dt", ".", "Sub", "(", "qtStart", ")", "\n", "qtNext", ":=", "TimeDt6AddNM...
// QuarterProjection takes a time and numeric value, estimating the // value at the end of the quarter using a straight-line projection.
[ "QuarterProjection", "takes", "a", "time", "and", "numeric", "value", "estimating", "the", "value", "at", "the", "end", "of", "the", "quarter", "using", "a", "straight", "-", "line", "projection", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil_projection.go#L12-L20
142,516
grokify/gotilla
crypto/secretboxutil/secretboxutil.go
SealBox
func SealBox(plaintext, secretKeyBytes []byte) ([]byte, error) { var secretKey [32]byte copy(secretKey[:], secretKeyBytes) var nonce [24]byte if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil { return []byte(""), err } return secretbox.Seal(nonce[:], plaintext, &nonce, &secretKey), nil }
go
func SealBox(plaintext, secretKeyBytes []byte) ([]byte, error) { var secretKey [32]byte copy(secretKey[:], secretKeyBytes) var nonce [24]byte if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil { return []byte(""), err } return secretbox.Seal(nonce[:], plaintext, &nonce, &secretKey), nil }
[ "func", "SealBox", "(", "plaintext", ",", "secretKeyBytes", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "secretKey", "[", "32", "]", "byte", "\n", "copy", "(", "secretKey", "[", ":", "]", ",", "secretKeyBytes", ")", ...
// SealBox seals a message using a supplied secret key and random nonce // which is appended to the message.
[ "SealBox", "seals", "a", "message", "using", "a", "supplied", "secret", "key", "and", "random", "nonce", "which", "is", "appended", "to", "the", "message", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/crypto/secretboxutil/secretboxutil.go#L24-L34
142,517
grokify/gotilla
crypto/secretboxutil/secretboxutil.go
OpenBase32String
func OpenBase32String(ciphertext32 string, secretKeyBytes []byte) ([]byte, error) { ciphertext, err := base32.StdEncoding.DecodeString(ciphertext32) if err != nil { return ciphertext, err } return OpenBox(ciphertext, secretKeyBytes) }
go
func OpenBase32String(ciphertext32 string, secretKeyBytes []byte) ([]byte, error) { ciphertext, err := base32.StdEncoding.DecodeString(ciphertext32) if err != nil { return ciphertext, err } return OpenBox(ciphertext, secretKeyBytes) }
[ "func", "OpenBase32String", "(", "ciphertext32", "string", ",", "secretKeyBytes", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ciphertext", ",", "err", ":=", "base32", ".", "StdEncoding", ".", "DecodeString", "(", "ciphertext32", ...
// OpenBase32String opens a base32 encoded message.
[ "OpenBase32String", "opens", "a", "base32", "encoded", "message", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/crypto/secretboxutil/secretboxutil.go#L37-L43
142,518
grokify/gotilla
crypto/secretboxutil/secretboxutil.go
OpenBox
func OpenBox(ciphertext []byte, secretKeyBytes []byte) ([]byte, error) { var secretKey [32]byte copy(secretKey[:], secretKeyBytes) var nonce [24]byte copy(nonce[:], ciphertext[:24]) plaintext, ok := secretbox.Open(nil, ciphertext[24:], &nonce, &secretKey) if !ok { return []byte(""), fmt.Errorf("Cannot decrypt"...
go
func OpenBox(ciphertext []byte, secretKeyBytes []byte) ([]byte, error) { var secretKey [32]byte copy(secretKey[:], secretKeyBytes) var nonce [24]byte copy(nonce[:], ciphertext[:24]) plaintext, ok := secretbox.Open(nil, ciphertext[24:], &nonce, &secretKey) if !ok { return []byte(""), fmt.Errorf("Cannot decrypt"...
[ "func", "OpenBox", "(", "ciphertext", "[", "]", "byte", ",", "secretKeyBytes", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "secretKey", "[", "32", "]", "byte", "\n", "copy", "(", "secretKey", "[", ":", "]", ",", "...
// OpenBox opens a message which is prefixed by a nonce.
[ "OpenBox", "opens", "a", "message", "which", "is", "prefixed", "by", "a", "nonce", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/crypto/secretboxutil/secretboxutil.go#L46-L57
142,519
grokify/gotilla
crypto/rsautil/pkcs1util.go
SignRS256
func SignRS256(r *rsa.PrivateKey, data []byte) ([]byte, error) { h := sha256.New() h.Write(data) d := h.Sum(nil) return rsa.SignPKCS1v15(rand.Reader, r, crypto.SHA256, d) }
go
func SignRS256(r *rsa.PrivateKey, data []byte) ([]byte, error) { h := sha256.New() h.Write(data) d := h.Sum(nil) return rsa.SignPKCS1v15(rand.Reader, r, crypto.SHA256, d) }
[ "func", "SignRS256", "(", "r", "*", "rsa", ".", "PrivateKey", ",", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "h", ":=", "sha256", ".", "New", "(", ")", "\n", "h", ".", "Write", "(", "data", ")", "\n", "d", ...
// SignRS256 signs data with rsa-sha256
[ "SignRS256", "signs", "data", "with", "rsa", "-", "sha256" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/crypto/rsautil/pkcs1util.go#L13-L18
142,520
grokify/gotilla
crypto/rsautil/pkcs1util.go
SignRS384
func SignRS384(r *rsa.PrivateKey, data []byte) ([]byte, error) { h := sha512.New384() h.Write(data) d := h.Sum(nil) return rsa.SignPKCS1v15(rand.Reader, r, crypto.SHA384, d) }
go
func SignRS384(r *rsa.PrivateKey, data []byte) ([]byte, error) { h := sha512.New384() h.Write(data) d := h.Sum(nil) return rsa.SignPKCS1v15(rand.Reader, r, crypto.SHA384, d) }
[ "func", "SignRS384", "(", "r", "*", "rsa", ".", "PrivateKey", ",", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "h", ":=", "sha512", ".", "New384", "(", ")", "\n", "h", ".", "Write", "(", "data", ")", "\n", "d...
// SignRS384 signs data with rsa-sha384
[ "SignRS384", "signs", "data", "with", "rsa", "-", "sha384" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/crypto/rsautil/pkcs1util.go#L21-L26
142,521
grokify/gotilla
time/timeutil/duration.go
DurationForNowSubDt8
func DurationForNowSubDt8(dt8 int32) (time.Duration, error) { t, err := TimeForDt8(dt8) if err != nil { var d time.Duration return d, err } now := time.Now() return now.Sub(t), nil }
go
func DurationForNowSubDt8(dt8 int32) (time.Duration, error) { t, err := TimeForDt8(dt8) if err != nil { var d time.Duration return d, err } now := time.Now() return now.Sub(t), nil }
[ "func", "DurationForNowSubDt8", "(", "dt8", "int32", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "t", ",", "err", ":=", "TimeForDt8", "(", "dt8", ")", "\n", "if", "err", "!=", "nil", "{", "var", "d", "time", ".", "Duration", "\n", "r...
// DurationForNowSubDt8 returns a duartion struct between a Dt8 value and the current time.
[ "DurationForNowSubDt8", "returns", "a", "duartion", "struct", "between", "a", "Dt8", "value", "and", "the", "current", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/duration.go#L63-L71
142,522
grokify/gotilla
time/timeutil/duration.go
QuarterDuration
func QuarterDuration(dt time.Time) time.Duration { start := QuarterStart(dt) end := NextQuarter(start) return end.Sub(start) }
go
func QuarterDuration(dt time.Time) time.Duration { start := QuarterStart(dt) end := NextQuarter(start) return end.Sub(start) }
[ "func", "QuarterDuration", "(", "dt", "time", ".", "Time", ")", "time", ".", "Duration", "{", "start", ":=", "QuarterStart", "(", "dt", ")", "\n", "end", ":=", "NextQuarter", "(", "start", ")", "\n", "return", "end", ".", "Sub", "(", "start", ")", "\...
// QuarterDuration returns a time.Duration representing the // calendar quarter for the time provided.
[ "QuarterDuration", "returns", "a", "time", ".", "Duration", "representing", "the", "calendar", "quarter", "for", "the", "time", "provided", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/duration.go#L90-L94
142,523
grokify/gotilla
math/mathutil/slicefloat64.go
Append
func (sf64 *SliceFloat64) Append(num float64) { sf64.Elements = append(sf64.Elements, num) }
go
func (sf64 *SliceFloat64) Append(num float64) { sf64.Elements = append(sf64.Elements, num) }
[ "func", "(", "sf64", "*", "SliceFloat64", ")", "Append", "(", "num", "float64", ")", "{", "sf64", ".", "Elements", "=", "append", "(", "sf64", ".", "Elements", ",", "num", ")", "\n", "}" ]
// Append adds an element to the float64 slice.
[ "Append", "adds", "an", "element", "to", "the", "float64", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L21-L23
142,524
grokify/gotilla
math/mathutil/slicefloat64.go
Min
func (sf64 *SliceFloat64) Min() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.Float64sAreSorted(sf64.Elements) { sort.Float64s(sf64.Elements) } return sf64.Elements[0], nil }
go
func (sf64 *SliceFloat64) Min() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.Float64sAreSorted(sf64.Elements) { sort.Float64s(sf64.Elements) } return sf64.Elements[0], nil }
[ "func", "(", "sf64", "*", "SliceFloat64", ")", "Min", "(", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "sf64", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Min returns the minimum element value in the float64 slice.
[ "Min", "returns", "the", "minimum", "element", "value", "in", "the", "float64", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L36-L44
142,525
grokify/gotilla
math/mathutil/slicefloat64.go
Sum
func (sf64 *SliceFloat64) Sum() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } sum := float64(0) for _, num := range sf64.Elements { sum += num } return sum, nil }
go
func (sf64 *SliceFloat64) Sum() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } sum := float64(0) for _, num := range sf64.Elements { sum += num } return sum, nil }
[ "func", "(", "sf64", "*", "SliceFloat64", ")", "Sum", "(", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "sf64", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Sum returns sum of all the elements in the float64 slice.
[ "Sum", "returns", "sum", "of", "all", "the", "elements", "in", "the", "float64", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L58-L67
142,526
grokify/gotilla
math/mathutil/slicefloat64.go
Mean
func (sf64 *SliceFloat64) Mean() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } sum, err := sf64.Sum() if err != nil { return 0, err } return sum / float64(len(sf64.Elements)), nil }
go
func (sf64 *SliceFloat64) Mean() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } sum, err := sf64.Sum() if err != nil { return 0, err } return sum / float64(len(sf64.Elements)), nil }
[ "func", "(", "sf64", "*", "SliceFloat64", ")", "Mean", "(", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "sf64", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// Mean returns the arithmetic mean of the float64 slice.
[ "Mean", "returns", "the", "arithmetic", "mean", "of", "the", "float64", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L75-L84
142,527
grokify/gotilla
math/mathutil/slicefloat64.go
Median
func (sf64 *SliceFloat64) Median() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.Float64sAreSorted(sf64.Elements) { sort.Float64s(sf64.Elements) } mid := int64(float64(len(sf64.Elements)) / 2) return sf64.Elements[mid], nil }
go
func (sf64 *SliceFloat64) Median() (float64, error) { if len(sf64.Elements) == 0 { return 0, errors.New("List is empty") } if !sort.Float64sAreSorted(sf64.Elements) { sort.Float64s(sf64.Elements) } mid := int64(float64(len(sf64.Elements)) / 2) return sf64.Elements[mid], nil }
[ "func", "(", "sf64", "*", "SliceFloat64", ")", "Median", "(", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "sf64", ".", "Elements", ")", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}"...
// Median returns the median or middle value of the sorted float64 slice.
[ "Median", "returns", "the", "median", "or", "middle", "value", "of", "the", "sorted", "float64", "slice", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L87-L96
142,528
grokify/gotilla
math/mathutil/slicefloat64.go
BuildStats
func (sf64 *SliceFloat64) BuildStats() (SliceFloat64Stats, error) { stats := NewSliceFloat64Stats() stats.Len = sf64.Len() max, err := sf64.Max() if err != nil { return stats, err } stats.Max = max min, err := sf64.Min() if err != nil { return stats, err } stats.Min = min mean, err := sf64.Mean() if err...
go
func (sf64 *SliceFloat64) BuildStats() (SliceFloat64Stats, error) { stats := NewSliceFloat64Stats() stats.Len = sf64.Len() max, err := sf64.Max() if err != nil { return stats, err } stats.Max = max min, err := sf64.Min() if err != nil { return stats, err } stats.Min = min mean, err := sf64.Mean() if err...
[ "func", "(", "sf64", "*", "SliceFloat64", ")", "BuildStats", "(", ")", "(", "SliceFloat64Stats", ",", "error", ")", "{", "stats", ":=", "NewSliceFloat64Stats", "(", ")", "\n", "stats", ".", "Len", "=", "sf64", ".", "Len", "(", ")", "\n", "max", ",", ...
// BuildStats builds a stats struct for current float64 slice elements.
[ "BuildStats", "builds", "a", "stats", "struct", "for", "current", "float64", "slice", "elements", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L99-L129
142,529
grokify/gotilla
math/mathutil/slicefloat64.go
NewSliceFloat64Stats
func NewSliceFloat64Stats() SliceFloat64Stats { stats := SliceFloat64Stats{ Len: 0, Max: 0, Mean: 0, Median: 0, Min: 0, Sum: 0} return stats }
go
func NewSliceFloat64Stats() SliceFloat64Stats { stats := SliceFloat64Stats{ Len: 0, Max: 0, Mean: 0, Median: 0, Min: 0, Sum: 0} return stats }
[ "func", "NewSliceFloat64Stats", "(", ")", "SliceFloat64Stats", "{", "stats", ":=", "SliceFloat64Stats", "{", "Len", ":", "0", ",", "Max", ":", "0", ",", "Mean", ":", "0", ",", "Median", ":", "0", ",", "Min", ":", "0", ",", "Sum", ":", "0", "}", "\n...
// NewSliceFloat64Stats returns a new initialized SliceFloat64Stats struct.
[ "NewSliceFloat64Stats", "returns", "a", "new", "initialized", "SliceFloat64Stats", "struct", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/math/mathutil/slicefloat64.go#L142-L151
142,530
grokify/gotilla
time/timeutil/timezones.go
ZonesSystem
func ZonesSystem(zoneDirs []string) []string { // Adapted from https://stackoverflow.com/a/40130882/1908967 zones := []string{} for _, zoneDir := range zoneDirs { zones = readZoneFile(zoneDir, "", zones) } return listutil.StripSliceElements(zones, []string{"+VERSION"}) }
go
func ZonesSystem(zoneDirs []string) []string { // Adapted from https://stackoverflow.com/a/40130882/1908967 zones := []string{} for _, zoneDir := range zoneDirs { zones = readZoneFile(zoneDir, "", zones) } return listutil.StripSliceElements(zones, []string{"+VERSION"}) }
[ "func", "ZonesSystem", "(", "zoneDirs", "[", "]", "string", ")", "[", "]", "string", "{", "// Adapted from https://stackoverflow.com/a/40130882/1908967", "zones", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "zoneDir", ":=", "range", "zoneDirs", ...
// GetZones treturns a list of timezones.
[ "GetZones", "treturns", "a", "list", "of", "timezones", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timezones.go#L28-L35
142,531
grokify/gotilla
encoding/csvutil/csvutil.go
NewWriter
func NewWriter(filepath, sep string, replaceSeparator bool, alt string) (Writer, error) { w := Writer{ Separator: sep, StripRepeatedSep: false, ReplaceSeparator: replaceSeparator, SeparatorAlt: alt} return w, w.open(filepath) }
go
func NewWriter(filepath, sep string, replaceSeparator bool, alt string) (Writer, error) { w := Writer{ Separator: sep, StripRepeatedSep: false, ReplaceSeparator: replaceSeparator, SeparatorAlt: alt} return w, w.open(filepath) }
[ "func", "NewWriter", "(", "filepath", ",", "sep", "string", ",", "replaceSeparator", "bool", ",", "alt", "string", ")", "(", "Writer", ",", "error", ")", "{", "w", ":=", "Writer", "{", "Separator", ":", "sep", ",", "StripRepeatedSep", ":", "false", ",", ...
// NewWriter returns a Writer with the separator params set.
[ "NewWriter", "returns", "a", "Writer", "with", "the", "separator", "params", "set", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/encoding/csvutil/csvutil.go#L59-L66
142,532
grokify/gotilla
encoding/csvutil/csvutil.go
open
func (w *Writer) open(filepath string) error { f, err := os.Create(filepath) if err != nil { return err } w.File = f return nil }
go
func (w *Writer) open(filepath string) error { f, err := os.Create(filepath) if err != nil { return err } w.File = f return nil }
[ "func", "(", "w", "*", "Writer", ")", "open", "(", "filepath", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Create", "(", "filepath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "w", ".", "File...
// Open opens a filepath.
[ "Open", "opens", "a", "filepath", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/encoding/csvutil/csvutil.go#L69-L76
142,533
grokify/gotilla
encoding/csvutil/csvutil.go
MergeFilterCSVFiles
func MergeFilterCSVFiles(inPaths []string, outPath string, inComma rune, inStripBom bool, andFilter map[string]stringsutil.MatchInfo) error { writer, outFile, err := NewWriterFile(outPath) if err != nil { return err } defer writer.Flush() defer outFile.Close() for i, inPath := range inPaths { reader, inFile,...
go
func MergeFilterCSVFiles(inPaths []string, outPath string, inComma rune, inStripBom bool, andFilter map[string]stringsutil.MatchInfo) error { writer, outFile, err := NewWriterFile(outPath) if err != nil { return err } defer writer.Flush() defer outFile.Close() for i, inPath := range inPaths { reader, inFile,...
[ "func", "MergeFilterCSVFiles", "(", "inPaths", "[", "]", "string", ",", "outPath", "string", ",", "inComma", "rune", ",", "inStripBom", "bool", ",", "andFilter", "map", "[", "string", "]", "stringsutil", ".", "MatchInfo", ")", "error", "{", "writer", ",", ...
// MergeFilterCSVFiles can merge and filter multiple CSV files. It expects row definitions to be the same // across all input files.
[ "MergeFilterCSVFiles", "can", "merge", "and", "filter", "multiple", "CSV", "files", ".", "It", "expects", "row", "definitions", "to", "be", "the", "same", "across", "all", "input", "files", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/encoding/csvutil/csvutil.go#L164-L189
142,534
grokify/gotilla
encoding/csvutil/csvutil.go
NewTableDataFileCSV
func NewTableDataFileCSV(path string, comma rune, stripBom bool) (table.TableData, error) { tbl := table.NewTableData() csvReader, f, err := NewReader(path, comma, stripBom) if err != nil { return tbl, err } defer f.Close() if DebugReadCSV { i := -1 for { line, err := csvReader.Read() if err == io.EOF...
go
func NewTableDataFileCSV(path string, comma rune, stripBom bool) (table.TableData, error) { tbl := table.NewTableData() csvReader, f, err := NewReader(path, comma, stripBom) if err != nil { return tbl, err } defer f.Close() if DebugReadCSV { i := -1 for { line, err := csvReader.Read() if err == io.EOF...
[ "func", "NewTableDataFileCSV", "(", "path", "string", ",", "comma", "rune", ",", "stripBom", "bool", ")", "(", "table", ".", "TableData", ",", "error", ")", "{", "tbl", ":=", "table", ".", "NewTableData", "(", ")", "\n", "csvReader", ",", "f", ",", "er...
// NewTableDataFileCSV reads in a CSV file and returns a TableData struct.
[ "NewTableDataFileCSV", "reads", "in", "a", "CSV", "file", "and", "returns", "a", "TableData", "struct", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/encoding/csvutil/csvutil.go#L357-L392
142,535
codeskyblue/dockerignore
ignore.go
ReadIgnoreFile
func ReadIgnoreFile(filename string) ([]string, error) { igrd, err := os.Open(filename) if err != nil { //if os.IsNotExist(err){ // return []string{}, nil //} return nil, err } return ReadIgnore(igrd) }
go
func ReadIgnoreFile(filename string) ([]string, error) { igrd, err := os.Open(filename) if err != nil { //if os.IsNotExist(err){ // return []string{}, nil //} return nil, err } return ReadIgnore(igrd) }
[ "func", "ReadIgnoreFile", "(", "filename", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "igrd", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "//if os.IsNotExist(err){", "// return [...
// Read ignore from file
[ "Read", "ignore", "from", "file" ]
de82dee623d9207f906d327172149cba50427a88
https://github.com/codeskyblue/dockerignore/blob/de82dee623d9207f906d327172149cba50427a88/ignore.go#L26-L35
142,536
grokify/gotilla
net/urlutil/urlutil.go
AppendURLValues
func AppendURLValues(v1, v2 url.Values) url.Values { for key, vals := range v2 { for _, val := range vals { v1.Add(key, val) } } return v1 }
go
func AppendURLValues(v1, v2 url.Values) url.Values { for key, vals := range v2 { for _, val := range vals { v1.Add(key, val) } } return v1 }
[ "func", "AppendURLValues", "(", "v1", ",", "v2", "url", ".", "Values", ")", "url", ".", "Values", "{", "for", "key", ",", "vals", ":=", "range", "v2", "{", "for", "_", ",", "val", ":=", "range", "vals", "{", "v1", ".", "Add", "(", "key", ",", "...
// AppendURLValues appends one url.Values to another url.Values.
[ "AppendURLValues", "appends", "one", "url", ".", "Values", "to", "another", "url", ".", "Values", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/urlutil/urlutil.go#L16-L23
142,537
grokify/gotilla
net/urlutil/urlutil.go
ToSlug
func ToSlug(slug []byte) []byte { // Convert punctuation and spaces to hyphens: string([]byte{45}) = "-" slug = regexp.MustCompile(`[[:punct:]\s_]+`).ReplaceAll(slug, []byte{45}) slug = regexp.MustCompile(`["']+`).ReplaceAll(slug, []byte{}) return regexp.MustCompile(`(^-+|-+$)`).ReplaceAll(slug, []byte{}) }
go
func ToSlug(slug []byte) []byte { // Convert punctuation and spaces to hyphens: string([]byte{45}) = "-" slug = regexp.MustCompile(`[[:punct:]\s_]+`).ReplaceAll(slug, []byte{45}) slug = regexp.MustCompile(`["']+`).ReplaceAll(slug, []byte{}) return regexp.MustCompile(`(^-+|-+$)`).ReplaceAll(slug, []byte{}) }
[ "func", "ToSlug", "(", "slug", "[", "]", "byte", ")", "[", "]", "byte", "{", "// Convert punctuation and spaces to hyphens: string([]byte{45}) = \"-\"", "slug", "=", "regexp", ".", "MustCompile", "(", "`[[:punct:]\\s_]+`", ")", ".", "ReplaceAll", "(", "slug", ",", ...
// ToSlug creates a slug byte array from an input byte array. // Slugs have words separated by a hyphen with no punctuation // or spaces.
[ "ToSlug", "creates", "a", "slug", "byte", "array", "from", "an", "input", "byte", "array", ".", "Slugs", "have", "words", "separated", "by", "a", "hyphen", "with", "no", "punctuation", "or", "spaces", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/urlutil/urlutil.go#L28-L33
142,538
grokify/gotilla
net/urlutil/urlutil.go
ToSlugLowerString
func ToSlugLowerString(s string) string { return string(ToSlug([]byte(strings.ToLower(s)))) }
go
func ToSlugLowerString(s string) string { return string(ToSlug([]byte(strings.ToLower(s)))) }
[ "func", "ToSlugLowerString", "(", "s", "string", ")", "string", "{", "return", "string", "(", "ToSlug", "(", "[", "]", "byte", "(", "strings", ".", "ToLower", "(", "s", ")", ")", ")", ")", "\n", "}" ]
// ToSlugLowerString creates a lower-cased slug string
[ "ToSlugLowerString", "creates", "a", "lower", "-", "cased", "slug", "string" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/urlutil/urlutil.go#L36-L38
142,539
grokify/gotilla
net/urlutil/urlutil.go
BuildURL
func BuildURL(baseUrl string, queryValues url.Values) string { qryString := queryValues.Encode() if len(qryString) > 0 { return baseUrl + "?" + qryString } return baseUrl }
go
func BuildURL(baseUrl string, queryValues url.Values) string { qryString := queryValues.Encode() if len(qryString) > 0 { return baseUrl + "?" + qryString } return baseUrl }
[ "func", "BuildURL", "(", "baseUrl", "string", ",", "queryValues", "url", ".", "Values", ")", "string", "{", "qryString", ":=", "queryValues", ".", "Encode", "(", ")", "\n", "if", "len", "(", "qryString", ")", ">", "0", "{", "return", "baseUrl", "+", "\...
// BuildURL returns a URL string from a base URL and url.Values.
[ "BuildURL", "returns", "a", "URL", "string", "from", "a", "base", "URL", "and", "url", ".", "Values", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/urlutil/urlutil.go#L54-L60
142,540
grokify/gotilla
net/urlutil/urlutil.go
GetURLBody
func GetURLBody(absoluteUrl string) ([]byte, error) { req, err := http.NewRequest("GET", absoluteUrl, nil) if err != nil { return []byte{}, err } cli := &http.Client{} res, err := cli.Do(req) if err != nil { return []byte{}, err } defer res.Body.Close() return ioutil.ReadAll(res.Body) }
go
func GetURLBody(absoluteUrl string) ([]byte, error) { req, err := http.NewRequest("GET", absoluteUrl, nil) if err != nil { return []byte{}, err } cli := &http.Client{} res, err := cli.Do(req) if err != nil { return []byte{}, err } defer res.Body.Close() return ioutil.ReadAll(res.Body) }
[ "func", "GetURLBody", "(", "absoluteUrl", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "absoluteUrl", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", ...
// GetURLBody returns an HTTP response byte array body from // a URL.
[ "GetURLBody", "returns", "an", "HTTP", "response", "byte", "array", "body", "from", "a", "URL", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/urlutil/urlutil.go#L73-L85
142,541
grokify/gotilla
net/urlutil/urlutil.go
GetURLPostBody
func GetURLPostBody(absoluteUrl string, bodyType string, reqBody io.Reader) ([]byte, error) { client := &http.Client{} res, err := client.Post(absoluteUrl, bodyType, reqBody) if err != nil { return []byte{}, err } defer res.Body.Close() return ioutil.ReadAll(res.Body) }
go
func GetURLPostBody(absoluteUrl string, bodyType string, reqBody io.Reader) ([]byte, error) { client := &http.Client{} res, err := client.Post(absoluteUrl, bodyType, reqBody) if err != nil { return []byte{}, err } defer res.Body.Close() return ioutil.ReadAll(res.Body) }
[ "func", "GetURLPostBody", "(", "absoluteUrl", "string", ",", "bodyType", "string", ",", "reqBody", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "client", ":=", "&", "http", ".", "Client", "{", "}", "\n", "res", ",", "err",...
// GetURLPostBody returns a HTTP post body as a byte array from a // URL, body type and an io.Reader.
[ "GetURLPostBody", "returns", "a", "HTTP", "post", "body", "as", "a", "byte", "array", "from", "a", "URL", "body", "type", "and", "an", "io", ".", "Reader", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/urlutil/urlutil.go#L89-L97
142,542
grokify/gotilla
config/env.go
EnvFileToJSONFile
func EnvFileToJSONFile(data interface{}, filepathENV, filepathJSON string, perm os.FileMode, prefix, indent string) error { err := godotenv.Load(filepathENV) if err != nil { return err } err = env.Parse(data) if err != nil { return err } return iom.WriteFileJSON(filepathJSON, data, perm, prefix, indent) }
go
func EnvFileToJSONFile(data interface{}, filepathENV, filepathJSON string, perm os.FileMode, prefix, indent string) error { err := godotenv.Load(filepathENV) if err != nil { return err } err = env.Parse(data) if err != nil { return err } return iom.WriteFileJSON(filepathJSON, data, perm, prefix, indent) }
[ "func", "EnvFileToJSONFile", "(", "data", "interface", "{", "}", ",", "filepathENV", ",", "filepathJSON", "string", ",", "perm", "os", ".", "FileMode", ",", "prefix", ",", "indent", "string", ")", "error", "{", "err", ":=", "godotenv", ".", "Load", "(", ...
// EnvFileToJSONFile Converts an .env file to a JSON file using the definition // provided in data.
[ "EnvFileToJSONFile", "Converts", "an", ".", "env", "file", "to", "a", "JSON", "file", "using", "the", "definition", "provided", "in", "data", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/config/env.go#L15-L27
142,543
grokify/gotilla
config/env.go
JoinEnvNumbered
func JoinEnvNumbered(prefix, delimiter string, startInt uint8, includeBase bool) string { vals := []string{} if includeBase { val := os.Getenv(prefix) if len(val) > 0 { vals = append(vals, val) } } i := startInt for { val := os.Getenv(fmt.Sprintf("%s_%d", prefix, i)) if len(val) > 0 { vals = append...
go
func JoinEnvNumbered(prefix, delimiter string, startInt uint8, includeBase bool) string { vals := []string{} if includeBase { val := os.Getenv(prefix) if len(val) > 0 { vals = append(vals, val) } } i := startInt for { val := os.Getenv(fmt.Sprintf("%s_%d", prefix, i)) if len(val) > 0 { vals = append...
[ "func", "JoinEnvNumbered", "(", "prefix", ",", "delimiter", "string", ",", "startInt", "uint8", ",", "includeBase", "bool", ")", "string", "{", "vals", ":=", "[", "]", "string", "{", "}", "\n", "if", "includeBase", "{", "val", ":=", "os", ".", "Getenv", ...
// Return a merged environment var which is split into multiple // vars. This is useful when the system has a size limit on // environment variables.
[ "Return", "a", "merged", "environment", "var", "which", "is", "split", "into", "multiple", "vars", ".", "This", "is", "useful", "when", "the", "system", "has", "a", "size", "limit", "on", "environment", "variables", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/config/env.go#L32-L51
142,544
grokify/gotilla
strconv/phonenumber/fictitiousgenerator.go
RandomAreaCode
func (fng *FakeNumberGenerator) RandomAreaCode() uint16 { return fng.AreaCodes[fng.Rand.Intn(len(fng.AreaCodes))] }
go
func (fng *FakeNumberGenerator) RandomAreaCode() uint16 { return fng.AreaCodes[fng.Rand.Intn(len(fng.AreaCodes))] }
[ "func", "(", "fng", "*", "FakeNumberGenerator", ")", "RandomAreaCode", "(", ")", "uint16", "{", "return", "fng", ".", "AreaCodes", "[", "fng", ".", "Rand", ".", "Intn", "(", "len", "(", "fng", ".", "AreaCodes", ")", ")", "]", "\n", "}" ]
// RandomAreaCode generates a random area code.
[ "RandomAreaCode", "generates", "a", "random", "area", "code", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/phonenumber/fictitiousgenerator.go#L27-L29
142,545
grokify/gotilla
strconv/phonenumber/fictitiousgenerator.go
RandomLineNumberMinMax
func (fng *FakeNumberGenerator) RandomLineNumberMinMax(min, max uint16) uint16 { return uint16(fng.Rand.Intn(int(max)-int(min))) + min }
go
func (fng *FakeNumberGenerator) RandomLineNumberMinMax(min, max uint16) uint16 { return uint16(fng.Rand.Intn(int(max)-int(min))) + min }
[ "func", "(", "fng", "*", "FakeNumberGenerator", ")", "RandomLineNumberMinMax", "(", "min", ",", "max", "uint16", ")", "uint16", "{", "return", "uint16", "(", "fng", ".", "Rand", ".", "Intn", "(", "int", "(", "max", ")", "-", "int", "(", "min", ")", "...
// RandomLineNumber generates a random line number
[ "RandomLineNumber", "generates", "a", "random", "line", "number" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/phonenumber/fictitiousgenerator.go#L37-L39
142,546
grokify/gotilla
io/ioutilmore/ioutilmore.go
ReadFileJSON
func ReadFileJSON(file string, v interface{}) error { bytes, err := ioutil.ReadFile(file) if err != nil { return err } return json.Unmarshal(bytes, v) }
go
func ReadFileJSON(file string, v interface{}) error { bytes, err := ioutil.ReadFile(file) if err != nil { return err } return json.Unmarshal(bytes, v) }
[ "func", "ReadFileJSON", "(", "file", "string", ",", "v", "interface", "{", "}", ")", "error", "{", "bytes", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "retur...
// ReadFileJSON reads and unmarshals a file.
[ "ReadFileJSON", "reads", "and", "unmarshals", "a", "file", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/io/ioutilmore/ioutilmore.go#L291-L297
142,547
grokify/gotilla
time/timeutil/compare.go
IsGreaterThan
func IsGreaterThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool { if timeLeft.After(timeRight) { return true } else if orEqual && timeLeft.Equal(timeRight) { return true } return false }
go
func IsGreaterThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool { if timeLeft.After(timeRight) { return true } else if orEqual && timeLeft.Equal(timeRight) { return true } return false }
[ "func", "IsGreaterThan", "(", "timeLeft", "time", ".", "Time", ",", "timeRight", "time", ".", "Time", ",", "orEqual", "bool", ")", "bool", "{", "if", "timeLeft", ".", "After", "(", "timeRight", ")", "{", "return", "true", "\n", "}", "else", "if", "orEq...
// IsGreaterThan compares two times and returns true if the left // time is greater than the right time.
[ "IsGreaterThan", "compares", "two", "times", "and", "returns", "true", "if", "the", "left", "time", "is", "greater", "than", "the", "right", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L12-L19
142,548
grokify/gotilla
time/timeutil/compare.go
IsLessThan
func IsLessThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool { if timeLeft.Before(timeRight) { return true } else if orEqual && timeLeft.Equal(timeRight) { return true } return false }
go
func IsLessThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool { if timeLeft.Before(timeRight) { return true } else if orEqual && timeLeft.Equal(timeRight) { return true } return false }
[ "func", "IsLessThan", "(", "timeLeft", "time", ".", "Time", ",", "timeRight", "time", ".", "Time", ",", "orEqual", "bool", ")", "bool", "{", "if", "timeLeft", ".", "Before", "(", "timeRight", ")", "{", "return", "true", "\n", "}", "else", "if", "orEqua...
// IsLessThan compares two times and returns true if the left // time is less than the right time.
[ "IsLessThan", "compares", "two", "times", "and", "returns", "true", "if", "the", "left", "time", "is", "less", "than", "the", "right", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L23-L30
142,549
grokify/gotilla
time/timeutil/compare.go
MinTime
func MinTime(t, min time.Time) time.Time { if IsLessThan(t, min, false) { return min } return t }
go
func MinTime(t, min time.Time) time.Time { if IsLessThan(t, min, false) { return min } return t }
[ "func", "MinTime", "(", "t", ",", "min", "time", ".", "Time", ")", "time", ".", "Time", "{", "if", "IsLessThan", "(", "t", ",", "min", ",", "false", ")", "{", "return", "min", "\n", "}", "\n", "return", "t", "\n", "}" ]
// MinTime returns minTime if time in question is less than min time.
[ "MinTime", "returns", "minTime", "if", "time", "in", "question", "is", "less", "than", "min", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L37-L42
142,550
grokify/gotilla
time/timeutil/compare.go
MaxTime
func MaxTime(t, max time.Time) time.Time { if IsGreaterThan(t, max, false) { return max } return t }
go
func MaxTime(t, max time.Time) time.Time { if IsGreaterThan(t, max, false) { return max } return t }
[ "func", "MaxTime", "(", "t", ",", "max", "time", ".", "Time", ")", "time", ".", "Time", "{", "if", "IsGreaterThan", "(", "t", ",", "max", ",", "false", ")", "{", "return", "max", "\n", "}", "\n", "return", "t", "\n", "}" ]
// MaxTime returns maxTime if time in question is greater than max time.
[ "MaxTime", "returns", "maxTime", "if", "time", "in", "question", "is", "greater", "than", "max", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L45-L50
142,551
grokify/gotilla
time/timeutil/compare.go
GreaterTime
func GreaterTime(t1, t2 time.Time) time.Time { if IsGreaterThan(t1, t2, false) { return t1 } return t2 }
go
func GreaterTime(t1, t2 time.Time) time.Time { if IsGreaterThan(t1, t2, false) { return t1 } return t2 }
[ "func", "GreaterTime", "(", "t1", ",", "t2", "time", ".", "Time", ")", "time", ".", "Time", "{", "if", "IsGreaterThan", "(", "t1", ",", "t2", ",", "false", ")", "{", "return", "t1", "\n", "}", "\n", "return", "t2", "\n", "}" ]
// GreaterTime returns the greater of two times.
[ "GreaterTime", "returns", "the", "greater", "of", "two", "times", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L53-L58
142,552
grokify/gotilla
time/timeutil/compare.go
LesserTime
func LesserTime(t1, t2 time.Time) time.Time { if IsLessThan(t1, t2, false) { return t1 } return t2 }
go
func LesserTime(t1, t2 time.Time) time.Time { if IsLessThan(t1, t2, false) { return t1 } return t2 }
[ "func", "LesserTime", "(", "t1", ",", "t2", "time", ".", "Time", ")", "time", ".", "Time", "{", "if", "IsLessThan", "(", "t1", ",", "t2", ",", "false", ")", "{", "return", "t1", "\n", "}", "\n", "return", "t2", "\n", "}" ]
// LesserTime returns the lesser of two times.
[ "LesserTime", "returns", "the", "lesser", "of", "two", "times", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L61-L66
142,553
grokify/gotilla
time/timeutil/compare.go
MinMax
func MinMax(min, max time.Time) (time.Time, time.Time) { if IsGreaterThan(min, max, false) { return max, min } return min, max }
go
func MinMax(min, max time.Time) (time.Time, time.Time) { if IsGreaterThan(min, max, false) { return max, min } return min, max }
[ "func", "MinMax", "(", "min", ",", "max", "time", ".", "Time", ")", "(", "time", ".", "Time", ",", "time", ".", "Time", ")", "{", "if", "IsGreaterThan", "(", "min", ",", "max", ",", "false", ")", "{", "return", "max", ",", "min", "\n", "}", "\n...
// MinMax takes two times and returns the earlier time first.
[ "MinMax", "takes", "two", "times", "and", "returns", "the", "earlier", "time", "first", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/compare.go#L69-L74
142,554
grokify/gotilla
time/timeutil/timeutil.go
Insert
func (tr *TimeRange) Insert(t time.Time) { tr.InsertMax(t) tr.InsertMin(t) }
go
func (tr *TimeRange) Insert(t time.Time) { tr.InsertMax(t) tr.InsertMin(t) }
[ "func", "(", "tr", "*", "TimeRange", ")", "Insert", "(", "t", "time", ".", "Time", ")", "{", "tr", ".", "InsertMax", "(", "t", ")", "\n", "tr", ".", "InsertMin", "(", "t", ")", "\n", "}" ]
// Insert updates a time range min and max values for a given time.
[ "Insert", "updates", "a", "time", "range", "min", "and", "max", "values", "for", "a", "given", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L94-L97
142,555
grokify/gotilla
time/timeutil/timeutil.go
InsertMax
func (tr *TimeRange) InsertMax(t time.Time) { if !tr.HaveMax { tr.Max = t tr.HaveMax = true } else if IsGreaterThan(t, tr.Max, false) { tr.Max = t } }
go
func (tr *TimeRange) InsertMax(t time.Time) { if !tr.HaveMax { tr.Max = t tr.HaveMax = true } else if IsGreaterThan(t, tr.Max, false) { tr.Max = t } }
[ "func", "(", "tr", "*", "TimeRange", ")", "InsertMax", "(", "t", "time", ".", "Time", ")", "{", "if", "!", "tr", ".", "HaveMax", "{", "tr", ".", "Max", "=", "t", "\n", "tr", ".", "HaveMax", "=", "true", "\n", "}", "else", "if", "IsGreaterThan", ...
// InsertMax updates a time range max value for a given time.
[ "InsertMax", "updates", "a", "time", "range", "max", "value", "for", "a", "given", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L100-L107
142,556
grokify/gotilla
time/timeutil/timeutil.go
InsertMin
func (tr *TimeRange) InsertMin(t time.Time) { if !tr.HaveMin { tr.Min = t tr.HaveMin = true } else if IsLessThan(t, tr.Min, false) { tr.Min = t } }
go
func (tr *TimeRange) InsertMin(t time.Time) { if !tr.HaveMin { tr.Min = t tr.HaveMin = true } else if IsLessThan(t, tr.Min, false) { tr.Min = t } }
[ "func", "(", "tr", "*", "TimeRange", ")", "InsertMin", "(", "t", "time", ".", "Time", ")", "{", "if", "!", "tr", ".", "HaveMin", "{", "tr", ".", "Min", "=", "t", "\n", "tr", ".", "HaveMin", "=", "true", "\n", "}", "else", "if", "IsLessThan", "(...
// InsertMin updates a time range min value for a given time.
[ "InsertMin", "updates", "a", "time", "range", "min", "value", "for", "a", "given", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L110-L117
142,557
grokify/gotilla
time/timeutil/timeutil.go
UnixToDay
func UnixToDay(epoch int64) time.Time { t := time.Unix(epoch, 0).UTC() return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC) }
go
func UnixToDay(epoch int64) time.Time { t := time.Unix(epoch, 0).UTC() return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC) }
[ "func", "UnixToDay", "(", "epoch", "int64", ")", "time", ".", "Time", "{", "t", ":=", "time", ".", "Unix", "(", "epoch", ",", "0", ")", ".", "UTC", "(", ")", "\n", "return", "time", ".", "Date", "(", "t", ".", "Year", "(", ")", ",", "t", ".",...
// UnixToDay converts an epoch in seconds to a time.Time for the day.
[ "UnixToDay", "converts", "an", "epoch", "in", "seconds", "to", "a", "time", ".", "Time", "for", "the", "day", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L126-L129
142,558
grokify/gotilla
time/timeutil/timeutil.go
Dt6ForTime
func Dt6ForTime(dt time.Time) int32 { dt = dt.UTC() return int32(dt.Year()*100 + int(dt.Month())) }
go
func Dt6ForTime(dt time.Time) int32 { dt = dt.UTC() return int32(dt.Year()*100 + int(dt.Month())) }
[ "func", "Dt6ForTime", "(", "dt", "time", ".", "Time", ")", "int32", "{", "dt", "=", "dt", ".", "UTC", "(", ")", "\n", "return", "int32", "(", "dt", ".", "Year", "(", ")", "*", "100", "+", "int", "(", "dt", ".", "Month", "(", ")", ")", ")", ...
// Dt6ForTime returns the Dt6 value for time.Time.
[ "Dt6ForTime", "returns", "the", "Dt6", "value", "for", "time", ".", "Time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L132-L135
142,559
grokify/gotilla
time/timeutil/timeutil.go
Dt6ForDt14
func Dt6ForDt14(dt14 int64) int32 { dt16f := float64(dt14) / float64(1000000) return int32(dt16f) }
go
func Dt6ForDt14(dt14 int64) int32 { dt16f := float64(dt14) / float64(1000000) return int32(dt16f) }
[ "func", "Dt6ForDt14", "(", "dt14", "int64", ")", "int32", "{", "dt16f", ":=", "float64", "(", "dt14", ")", "/", "float64", "(", "1000000", ")", "\n", "return", "int32", "(", "dt16f", ")", "\n", "}" ]
// Dt6ForDt14 returns the Dt6 value for Dt14.
[ "Dt6ForDt14", "returns", "the", "Dt6", "value", "for", "Dt14", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L138-L141
142,560
grokify/gotilla
time/timeutil/timeutil.go
TimeForDt6
func TimeForDt6(dt6 int32) (time.Time, error) { return time.Parse(DT6, strconv.FormatInt(int64(dt6), 10)) }
go
func TimeForDt6(dt6 int32) (time.Time, error) { return time.Parse(DT6, strconv.FormatInt(int64(dt6), 10)) }
[ "func", "TimeForDt6", "(", "dt6", "int32", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "DT6", ",", "strconv", ".", "FormatInt", "(", "int64", "(", "dt6", ")", ",", "10", ")", ")", "\n", "}" ]
// TimeForDt6 returns a time.Time value given a Dt6 value.
[ "TimeForDt6", "returns", "a", "time", ".", "Time", "value", "given", "a", "Dt6", "value", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L144-L146
142,561
grokify/gotilla
time/timeutil/timeutil.go
Dt8ForString
func Dt8ForString(layout, value string) (int32, error) { dt8 := int32(0) t, err := time.Parse(layout, value) if err == nil { dt8 = Dt8ForTime(t) } return dt8, err }
go
func Dt8ForString(layout, value string) (int32, error) { dt8 := int32(0) t, err := time.Parse(layout, value) if err == nil { dt8 = Dt8ForTime(t) } return dt8, err }
[ "func", "Dt8ForString", "(", "layout", ",", "value", "string", ")", "(", "int32", ",", "error", ")", "{", "dt8", ":=", "int32", "(", "0", ")", "\n", "t", ",", "err", ":=", "time", ".", "Parse", "(", "layout", ",", "value", ")", "\n", "if", "err",...
// Dt8ForString returns a Dt8 value given a layout and value to parse to time.Parse.
[ "Dt8ForString", "returns", "a", "Dt8", "value", "given", "a", "layout", "and", "value", "to", "parse", "to", "time", ".", "Parse", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L225-L232
142,562
grokify/gotilla
time/timeutil/timeutil.go
Dt8ForInts
func Dt8ForInts(yyyy, mm, dd int) int32 { sDt8 := fmt.Sprintf("%04d%02d%02d", yyyy, mm, dd) iDt8, err := strconv.ParseInt(sDt8, 10, 32) if err != nil { panic(err) } return int32(iDt8) }
go
func Dt8ForInts(yyyy, mm, dd int) int32 { sDt8 := fmt.Sprintf("%04d%02d%02d", yyyy, mm, dd) iDt8, err := strconv.ParseInt(sDt8, 10, 32) if err != nil { panic(err) } return int32(iDt8) }
[ "func", "Dt8ForInts", "(", "yyyy", ",", "mm", ",", "dd", "int", ")", "int32", "{", "sDt8", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "yyyy", ",", "mm", ",", "dd", ")", "\n", "iDt8", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "s...
// Dt8ForInts returns a Dt8 value for year, month, and day.
[ "Dt8ForInts", "returns", "a", "Dt8", "value", "for", "year", "month", "and", "day", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L235-L242
142,563
grokify/gotilla
time/timeutil/timeutil.go
Dt8ForTime
func Dt8ForTime(t time.Time) int32 { u := t.UTC() s := u.Format(DT8) iDt8, err := strconv.ParseInt(s, 10, 32) if err != nil { panic(err) } return int32(iDt8) }
go
func Dt8ForTime(t time.Time) int32 { u := t.UTC() s := u.Format(DT8) iDt8, err := strconv.ParseInt(s, 10, 32) if err != nil { panic(err) } return int32(iDt8) }
[ "func", "Dt8ForTime", "(", "t", "time", ".", "Time", ")", "int32", "{", "u", ":=", "t", ".", "UTC", "(", ")", "\n", "s", ":=", "u", ".", "Format", "(", "DT8", ")", "\n", "iDt8", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "s", ",", "10...
// Dt8ForTime returns a Dt8 value given a time struct.
[ "Dt8ForTime", "returns", "a", "Dt8", "value", "given", "a", "time", "struct", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L245-L253
142,564
grokify/gotilla
time/timeutil/timeutil.go
TimeForDt8
func TimeForDt8(dt8 int32) (time.Time, error) { return time.Parse(DT8, strconv.FormatInt(int64(dt8), 10)) }
go
func TimeForDt8(dt8 int32) (time.Time, error) { return time.Parse(DT8, strconv.FormatInt(int64(dt8), 10)) }
[ "func", "TimeForDt8", "(", "dt8", "int32", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "DT8", ",", "strconv", ".", "FormatInt", "(", "int64", "(", "dt8", ")", ",", "10", ")", ")", "\n", "}" ]
// TimeForDt8 returns a time.Time value given a Dt8 value.
[ "TimeForDt8", "returns", "a", "time", ".", "Time", "value", "given", "a", "Dt8", "value", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L256-L258
142,565
grokify/gotilla
time/timeutil/timeutil.go
Dt14ForString
func Dt14ForString(layout, value string) (int64, error) { dt14 := int64(0) t, err := time.Parse(layout, value) if err == nil { dt14 = Dt14ForTime(t) } return dt14, err }
go
func Dt14ForString(layout, value string) (int64, error) { dt14 := int64(0) t, err := time.Parse(layout, value) if err == nil { dt14 = Dt14ForTime(t) } return dt14, err }
[ "func", "Dt14ForString", "(", "layout", ",", "value", "string", ")", "(", "int64", ",", "error", ")", "{", "dt14", ":=", "int64", "(", "0", ")", "\n", "t", ",", "err", ":=", "time", ".", "Parse", "(", "layout", ",", "value", ")", "\n", "if", "err...
// Dt14ForString returns a Dt14 value given a layout and value to parse to time.Parse.
[ "Dt14ForString", "returns", "a", "Dt14", "value", "given", "a", "layout", "and", "value", "to", "parse", "to", "time", ".", "Parse", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L266-L273
142,566
grokify/gotilla
time/timeutil/timeutil.go
Dt14ForInts
func Dt14ForInts(yyyy, mm, dd, hr, mn, dy int) int64 { sDt14 := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", yyyy, mm, dd, hr, mn, dy) iDt14, err := strconv.ParseInt(sDt14, 10, 64) if err != nil { panic(err) } return int64(iDt14) }
go
func Dt14ForInts(yyyy, mm, dd, hr, mn, dy int) int64 { sDt14 := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", yyyy, mm, dd, hr, mn, dy) iDt14, err := strconv.ParseInt(sDt14, 10, 64) if err != nil { panic(err) } return int64(iDt14) }
[ "func", "Dt14ForInts", "(", "yyyy", ",", "mm", ",", "dd", ",", "hr", ",", "mn", ",", "dy", "int", ")", "int64", "{", "sDt14", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "yyyy", ",", "mm", ",", "dd", ",", "hr", ",", "mn", ",", "dy", ...
// Dt8ForInts returns a Dt8 value for a UTC year, month, day, hour, minute and second.
[ "Dt8ForInts", "returns", "a", "Dt8", "value", "for", "a", "UTC", "year", "month", "day", "hour", "minute", "and", "second", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L276-L283
142,567
grokify/gotilla
time/timeutil/timeutil.go
Dt14ForTime
func Dt14ForTime(t time.Time) int64 { u := t.UTC() s := u.Format(DT14) iDt14, err := strconv.ParseInt(s, 10, 64) if err != nil { panic(err) } return int64(iDt14) }
go
func Dt14ForTime(t time.Time) int64 { u := t.UTC() s := u.Format(DT14) iDt14, err := strconv.ParseInt(s, 10, 64) if err != nil { panic(err) } return int64(iDt14) }
[ "func", "Dt14ForTime", "(", "t", "time", ".", "Time", ")", "int64", "{", "u", ":=", "t", ".", "UTC", "(", ")", "\n", "s", ":=", "u", ".", "Format", "(", "DT14", ")", "\n", "iDt14", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "s", ",", ...
// Dt14ForTime returns a Dt14 value given a time.Time struct.
[ "Dt14ForTime", "returns", "a", "Dt14", "value", "given", "a", "time", ".", "Time", "struct", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L286-L294
142,568
grokify/gotilla
time/timeutil/timeutil.go
TimeForDt14
func TimeForDt14(dt14 int64) (time.Time, error) { return time.Parse(DT14, strconv.FormatInt(dt14, 10)) }
go
func TimeForDt14(dt14 int64) (time.Time, error) { return time.Parse(DT14, strconv.FormatInt(dt14, 10)) }
[ "func", "TimeForDt14", "(", "dt14", "int64", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "DT14", ",", "strconv", ".", "FormatInt", "(", "dt14", ",", "10", ")", ")", "\n", "}" ]
// TimeForDt14 returns a time.Time value given a Dt14 value.
[ "TimeForDt14", "returns", "a", "time", ".", "Time", "value", "given", "a", "Dt14", "value", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L297-L299
142,569
grokify/gotilla
time/timeutil/timeutil.go
WeekStart
func WeekStart(dt time.Time, dow time.Weekday) (time.Time, error) { return TimeDeltaDowInt(dt.UTC(), int(dow), -1, true, true) }
go
func WeekStart(dt time.Time, dow time.Weekday) (time.Time, error) { return TimeDeltaDowInt(dt.UTC(), int(dow), -1, true, true) }
[ "func", "WeekStart", "(", "dt", "time", ".", "Time", ",", "dow", "time", ".", "Weekday", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "TimeDeltaDowInt", "(", "dt", ".", "UTC", "(", ")", ",", "int", "(", "dow", ")", ",", "-", ...
// WeekStart takes a time.Time object and a week start day // in the time.Weekday format.
[ "WeekStart", "takes", "a", "time", ".", "Time", "object", "and", "a", "week", "start", "day", "in", "the", "time", ".", "Weekday", "format", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L309-L311
142,570
grokify/gotilla
time/timeutil/timeutil.go
MonthStart
func MonthStart(dt time.Time) time.Time { dt = dt.UTC() return time.Date(dt.Year(), dt.Month(), 1, 0, 0, 0, 0, time.UTC) }
go
func MonthStart(dt time.Time) time.Time { dt = dt.UTC() return time.Date(dt.Year(), dt.Month(), 1, 0, 0, 0, 0, time.UTC) }
[ "func", "MonthStart", "(", "dt", "time", ".", "Time", ")", "time", ".", "Time", "{", "dt", "=", "dt", ".", "UTC", "(", ")", "\n", "return", "time", ".", "Date", "(", "dt", ".", "Year", "(", ")", ",", "dt", ".", "Month", "(", ")", ",", "1", ...
// MonthStart returns a time.Time for the beginning of the // month in UTC time.
[ "MonthStart", "returns", "a", "time", ".", "Time", "for", "the", "beginning", "of", "the", "month", "in", "UTC", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L315-L318
142,571
grokify/gotilla
time/timeutil/timeutil.go
QuarterStart
func QuarterStart(dt time.Time) time.Time { dt = dt.UTC() qm := QuarterToMonth(MonthToQuarter(uint8(dt.Month()))) return time.Date(dt.Year(), time.Month(qm), 1, 0, 0, 0, 0, time.UTC) }
go
func QuarterStart(dt time.Time) time.Time { dt = dt.UTC() qm := QuarterToMonth(MonthToQuarter(uint8(dt.Month()))) return time.Date(dt.Year(), time.Month(qm), 1, 0, 0, 0, 0, time.UTC) }
[ "func", "QuarterStart", "(", "dt", "time", ".", "Time", ")", "time", ".", "Time", "{", "dt", "=", "dt", ".", "UTC", "(", ")", "\n", "qm", ":=", "QuarterToMonth", "(", "MonthToQuarter", "(", "uint8", "(", "dt", ".", "Month", "(", ")", ")", ")", ")...
// QuarterStart returns a time.Time for the beginning of the // quarter in UTC time.
[ "QuarterStart", "returns", "a", "time", ".", "Time", "for", "the", "beginning", "of", "the", "quarter", "in", "UTC", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L322-L326
142,572
grokify/gotilla
time/timeutil/timeutil.go
QuarterEnd
func QuarterEnd(dt time.Time) time.Time { qs := QuarterStart(dt.UTC()) qn := TimeDt6AddNMonths(qs, 3) return time.Date(qn.Year(), qn.Month(), 0, 23, 59, 59, 0, time.UTC) }
go
func QuarterEnd(dt time.Time) time.Time { qs := QuarterStart(dt.UTC()) qn := TimeDt6AddNMonths(qs, 3) return time.Date(qn.Year(), qn.Month(), 0, 23, 59, 59, 0, time.UTC) }
[ "func", "QuarterEnd", "(", "dt", "time", ".", "Time", ")", "time", ".", "Time", "{", "qs", ":=", "QuarterStart", "(", "dt", ".", "UTC", "(", ")", ")", "\n", "qn", ":=", "TimeDt6AddNMonths", "(", "qs", ",", "3", ")", "\n", "return", "time", ".", "...
// QuarterEnd returns a time.Time for the end of the // quarter by second in UTC time.
[ "QuarterEnd", "returns", "a", "time", ".", "Time", "for", "the", "end", "of", "the", "quarter", "by", "second", "in", "UTC", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L330-L334
142,573
grokify/gotilla
time/timeutil/timeutil.go
YearStart
func YearStart(dt time.Time) time.Time { return time.Date(dt.UTC().Year(), time.January, 1, 0, 0, 0, 0, time.UTC) }
go
func YearStart(dt time.Time) time.Time { return time.Date(dt.UTC().Year(), time.January, 1, 0, 0, 0, 0, time.UTC) }
[ "func", "YearStart", "(", "dt", "time", ".", "Time", ")", "time", ".", "Time", "{", "return", "time", ".", "Date", "(", "dt", ".", "UTC", "(", ")", ".", "Year", "(", ")", ",", "time", ".", "January", ",", "1", ",", "0", ",", "0", ",", "0", ...
// YearStart returns a a time.Time for the beginning of the year // in UTC time.
[ "YearStart", "returns", "a", "a", "time", ".", "Time", "for", "the", "beginning", "of", "the", "year", "in", "UTC", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L338-L340
142,574
grokify/gotilla
time/timeutil/timeutil.go
YearEnd
func YearEnd(dt time.Time) time.Time { return time.Date(dt.UTC().Year(), time.December, 31, 23, 59, 59, 999999999, time.UTC) }
go
func YearEnd(dt time.Time) time.Time { return time.Date(dt.UTC().Year(), time.December, 31, 23, 59, 59, 999999999, time.UTC) }
[ "func", "YearEnd", "(", "dt", "time", ".", "Time", ")", "time", ".", "Time", "{", "return", "time", ".", "Date", "(", "dt", ".", "UTC", "(", ")", ".", "Year", "(", ")", ",", "time", ".", "December", ",", "31", ",", "23", ",", "59", ",", "59",...
// YearEnd returns a a time.Time for the end of the year in UTC time.
[ "YearEnd", "returns", "a", "a", "time", ".", "Time", "for", "the", "end", "of", "the", "year", "in", "UTC", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L343-L345
142,575
grokify/gotilla
time/timeutil/timeutil.go
NewTimeMeta
func NewTimeMeta(dt time.Time, dow time.Weekday) (TimeMeta, error) { dt = dt.UTC() meta := TimeMeta{ This: dt, YearStart: YearStart(dt), QuarterStart: QuarterStart(dt), MonthStart: MonthStart(dt)} week, err := WeekStart(dt, dow) if err != nil { return meta, err } meta.WeekStart = week ret...
go
func NewTimeMeta(dt time.Time, dow time.Weekday) (TimeMeta, error) { dt = dt.UTC() meta := TimeMeta{ This: dt, YearStart: YearStart(dt), QuarterStart: QuarterStart(dt), MonthStart: MonthStart(dt)} week, err := WeekStart(dt, dow) if err != nil { return meta, err } meta.WeekStart = week ret...
[ "func", "NewTimeMeta", "(", "dt", "time", ".", "Time", ",", "dow", "time", ".", "Weekday", ")", "(", "TimeMeta", ",", "error", ")", "{", "dt", "=", "dt", ".", "UTC", "(", ")", "\n", "meta", ":=", "TimeMeta", "{", "This", ":", "dt", ",", "YearStar...
// NewTimeMeta returns a TimeMeta struct given `time.Time` // and `time.Weekday` parameters.
[ "NewTimeMeta", "returns", "a", "TimeMeta", "struct", "given", "time", ".", "Time", "and", "time", ".", "Weekday", "parameters", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/timeutil.go#L461-L475
142,576
grokify/gotilla
net/httputilmore/transport_headers.go
RoundTrip
func (t TransportWithHeaders) RoundTrip(req *http.Request) (*http.Response, error) { req.Header = MergeHeader(req.Header, t.Header, t.Override) return t.transport().RoundTrip(req) }
go
func (t TransportWithHeaders) RoundTrip(req *http.Request) (*http.Response, error) { req.Header = MergeHeader(req.Header, t.Header, t.Override) return t.transport().RoundTrip(req) }
[ "func", "(", "t", "TransportWithHeaders", ")", "RoundTrip", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "req", ".", "Header", "=", "MergeHeader", "(", "req", ".", "Header", ",", "t", ".", ...
// RoundTrip adds the additional headers per request implements http.RoundTripper.
[ "RoundTrip", "adds", "the", "additional", "headers", "per", "request", "implements", "http", ".", "RoundTripper", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/transport_headers.go#L19-L23
142,577
grokify/gotilla
net/httputilmore/response_info.go
ToJson
func (resIn *ResponseInfo) ToJson() []byte { bytes, err := json.Marshal(resIn) if err != nil { resIn2 := ResponseInfo{StatusCode: 500, Message: err.Error()} bytes, _ := json.Marshal(resIn2) return bytes } return bytes }
go
func (resIn *ResponseInfo) ToJson() []byte { bytes, err := json.Marshal(resIn) if err != nil { resIn2 := ResponseInfo{StatusCode: 500, Message: err.Error()} bytes, _ := json.Marshal(resIn2) return bytes } return bytes }
[ "func", "(", "resIn", "*", "ResponseInfo", ")", "ToJson", "(", ")", "[", "]", "byte", "{", "bytes", ",", "err", ":=", "json", ".", "Marshal", "(", "resIn", ")", "\n", "if", "err", "!=", "nil", "{", "resIn2", ":=", "ResponseInfo", "{", "StatusCode", ...
// ToJson returns ResponseInfo as a JSON byte array, embedding json.Marshal // errors if encountered.
[ "ToJson", "returns", "ResponseInfo", "as", "a", "JSON", "byte", "array", "embedding", "json", ".", "Marshal", "errors", "if", "encountered", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/response_info.go#L20-L28
142,578
grokify/gotilla
text/markdown/markdown.go
BoldText
func BoldText(haystack, needle string) string { output := haystack if len(needle) == 0 { return "**" + haystack + "**" } return regexp.MustCompile(`(?i)\b(`+regexp.QuoteMeta(needle)+`)`).ReplaceAllString(output, "**$1**") }
go
func BoldText(haystack, needle string) string { output := haystack if len(needle) == 0 { return "**" + haystack + "**" } return regexp.MustCompile(`(?i)\b(`+regexp.QuoteMeta(needle)+`)`).ReplaceAllString(output, "**$1**") }
[ "func", "BoldText", "(", "haystack", ",", "needle", "string", ")", "string", "{", "output", ":=", "haystack", "\n", "if", "len", "(", "needle", ")", "==", "0", "{", "return", "\"", "\"", "+", "haystack", "+", "\"", "\"", "\n", "}", "\n", "return", ...
// BoldText bodifies the identified text. It looks for start of words // using a word boundary and will arbirarily end to match words with // different suffixes.
[ "BoldText", "bodifies", "the", "identified", "text", ".", "It", "looks", "for", "start", "of", "words", "using", "a", "word", "boundary", "and", "will", "arbirarily", "end", "to", "match", "words", "with", "different", "suffixes", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/text/markdown/markdown.go#L11-L17
142,579
grokify/gotilla
net/httputilmore/httputil.go
GetWriteFile
func GetWriteFile(url string, filename string, perm os.FileMode) ([]byte, error) { _, bytes, err := GetResponseAndBytes(url) if err != nil { return bytes, err } err = ioutil.WriteFile(filename, bytes, perm) return bytes, err }
go
func GetWriteFile(url string, filename string, perm os.FileMode) ([]byte, error) { _, bytes, err := GetResponseAndBytes(url) if err != nil { return bytes, err } err = ioutil.WriteFile(filename, bytes, perm) return bytes, err }
[ "func", "GetWriteFile", "(", "url", "string", ",", "filename", "string", ",", "perm", "os", ".", "FileMode", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "_", ",", "bytes", ",", "err", ":=", "GetResponseAndBytes", "(", "url", ")", "\n", "if", ...
// GetWriteFile performs a HTTP GET request and saves the response body // to the file path specified
[ "GetWriteFile", "performs", "a", "HTTP", "GET", "request", "and", "saves", "the", "response", "body", "to", "the", "file", "path", "specified" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L36-L43
142,580
grokify/gotilla
net/httputilmore/httputil.go
ResponseBody
func ResponseBody(res *http.Response) ([]byte, error) { defer res.Body.Close() contents, err := ioutil.ReadAll(res.Body) if err != nil { return []byte{}, err } return contents, nil }
go
func ResponseBody(res *http.Response) ([]byte, error) { defer res.Body.Close() contents, err := ioutil.ReadAll(res.Body) if err != nil { return []byte{}, err } return contents, nil }
[ "func", "ResponseBody", "(", "res", "*", "http", ".", "Response", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n", "contents", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "res", "...
// ResponseBody returns the body as a byte array
[ "ResponseBody", "returns", "the", "body", "as", "a", "byte", "array" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L46-L53
142,581
grokify/gotilla
net/httputilmore/httputil.go
ResponseBodyJSONMapIndent
func ResponseBodyJSONMapIndent(res *http.Response, prefix string, indent string) ([]byte, error) { body, err := ResponseBody(res) if err != nil { return body, err } any := map[string]interface{}{} json.Unmarshal(body, &any) return json.MarshalIndent(any, prefix, indent) }
go
func ResponseBodyJSONMapIndent(res *http.Response, prefix string, indent string) ([]byte, error) { body, err := ResponseBody(res) if err != nil { return body, err } any := map[string]interface{}{} json.Unmarshal(body, &any) return json.MarshalIndent(any, prefix, indent) }
[ "func", "ResponseBodyJSONMapIndent", "(", "res", "*", "http", ".", "Response", ",", "prefix", "string", ",", "indent", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "body", ",", "err", ":=", "ResponseBody", "(", "res", ")", "\n", "if", ...
// ResponseBodyJSONMapIndent returns the body as a generic JSON dictionary
[ "ResponseBodyJSONMapIndent", "returns", "the", "body", "as", "a", "generic", "JSON", "dictionary" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L56-L64
142,582
grokify/gotilla
net/httputilmore/httputil.go
PrintRequestOut
func PrintRequestOut(req *http.Request, includeBody bool) error { reqBytes, err := httputil.DumpRequestOut(req, includeBody) if err != nil { return err } fmt.Println(string(reqBytes)) return nil }
go
func PrintRequestOut(req *http.Request, includeBody bool) error { reqBytes, err := httputil.DumpRequestOut(req, includeBody) if err != nil { return err } fmt.Println(string(reqBytes)) return nil }
[ "func", "PrintRequestOut", "(", "req", "*", "http", ".", "Request", ",", "includeBody", "bool", ")", "error", "{", "reqBytes", ",", "err", ":=", "httputil", ".", "DumpRequestOut", "(", "req", ",", "includeBody", ")", "\n", "if", "err", "!=", "nil", "{", ...
// PrintRequestOut prints a http.Request using `httputil.DumpRequestOut`.
[ "PrintRequestOut", "prints", "a", "http", ".", "Request", "using", "httputil", ".", "DumpRequestOut", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L89-L96
142,583
grokify/gotilla
net/httputilmore/httputil.go
PrintResponse
func PrintResponse(resp *http.Response, includeBody bool) error { respBytes, err := httputil.DumpResponse(resp, includeBody) if err != nil { return err } fmt.Println(string(respBytes)) return nil }
go
func PrintResponse(resp *http.Response, includeBody bool) error { respBytes, err := httputil.DumpResponse(resp, includeBody) if err != nil { return err } fmt.Println(string(respBytes)) return nil }
[ "func", "PrintResponse", "(", "resp", "*", "http", ".", "Response", ",", "includeBody", "bool", ")", "error", "{", "respBytes", ",", "err", ":=", "httputil", ".", "DumpResponse", "(", "resp", ",", "includeBody", ")", "\n", "if", "err", "!=", "nil", "{", ...
// PrintResponse prints a http.Response using `httputil.DumpResponse`.
[ "PrintResponse", "prints", "a", "http", ".", "Response", "using", "httputil", ".", "DumpResponse", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L99-L106
142,584
grokify/gotilla
net/httputilmore/httputil.go
ParseHeader
func ParseHeader(s string) http.Header { h := http.Header{} lines := strings.Split(s, "\n") rx := regexp.MustCompile(`^([^\s+]+):\s*(.*)$`) for _, line := range lines { m := rx.FindStringSubmatch(line) if len(m) == 3 { key := strings.TrimSpace(m[1]) val := strings.TrimSpace(m[2]) if len(key) > 0 { ...
go
func ParseHeader(s string) http.Header { h := http.Header{} lines := strings.Split(s, "\n") rx := regexp.MustCompile(`^([^\s+]+):\s*(.*)$`) for _, line := range lines { m := rx.FindStringSubmatch(line) if len(m) == 3 { key := strings.TrimSpace(m[1]) val := strings.TrimSpace(m[2]) if len(key) > 0 { ...
[ "func", "ParseHeader", "(", "s", "string", ")", "http", ".", "Header", "{", "h", ":=", "http", ".", "Header", "{", "}", "\n", "lines", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\\n", "\"", ")", "\n", "rx", ":=", "regexp", ".", "MustCom...
// ParseHeader converts a raw strign to a header struct.
[ "ParseHeader", "converts", "a", "raw", "strign", "to", "a", "header", "struct", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L109-L124
142,585
grokify/gotilla
net/httputilmore/httputil.go
MergeHeader
func MergeHeader(base, more http.Header, overwrite bool) http.Header { if base == nil { base = http.Header{} } if more == nil { return base } for k, vals := range more { if overwrite { base.Del(k) } for _, v := range vals { v = strings.TrimSpace(v) if len(v) > 0 { base.Add(k, v) } } }...
go
func MergeHeader(base, more http.Header, overwrite bool) http.Header { if base == nil { base = http.Header{} } if more == nil { return base } for k, vals := range more { if overwrite { base.Del(k) } for _, v := range vals { v = strings.TrimSpace(v) if len(v) > 0 { base.Add(k, v) } } }...
[ "func", "MergeHeader", "(", "base", ",", "more", "http", ".", "Header", ",", "overwrite", "bool", ")", "http", ".", "Header", "{", "if", "base", "==", "nil", "{", "base", "=", "http", ".", "Header", "{", "}", "\n", "}", "\n", "if", "more", "==", ...
// MergeHeader merges two http.Header adding the values of the second // to the first.
[ "MergeHeader", "merges", "two", "http", ".", "Header", "adding", "the", "values", "of", "the", "second", "to", "the", "first", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L128-L148
142,586
grokify/gotilla
net/httputilmore/httputil.go
NewResponseRateLimitInfo
func NewResponseRateLimitInfo(resp *http.Response, useXrlHyphen bool) RateLimitInfo { rlstat := RateLimitInfo{ StatusCode: resp.StatusCode, RetryAfter: strconvutil.AtoiWithDefault(resp.Header.Get("Retry-After"), 0)} if useXrlHyphen { rlstat.XRateLimitLimit = strconvutil.AtoiWithDefault(resp.Header.Get("X-Rate-...
go
func NewResponseRateLimitInfo(resp *http.Response, useXrlHyphen bool) RateLimitInfo { rlstat := RateLimitInfo{ StatusCode: resp.StatusCode, RetryAfter: strconvutil.AtoiWithDefault(resp.Header.Get("Retry-After"), 0)} if useXrlHyphen { rlstat.XRateLimitLimit = strconvutil.AtoiWithDefault(resp.Header.Get("X-Rate-...
[ "func", "NewResponseRateLimitInfo", "(", "resp", "*", "http", ".", "Response", ",", "useXrlHyphen", "bool", ")", "RateLimitInfo", "{", "rlstat", ":=", "RateLimitInfo", "{", "StatusCode", ":", "resp", ".", "StatusCode", ",", "RetryAfter", ":", "strconvutil", ".",...
// NewResponseRateLimitInfo returns a RateLimitInfo from a http.Response.
[ "NewResponseRateLimitInfo", "returns", "a", "RateLimitInfo", "from", "a", "http", ".", "Response", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/net/httputilmore/httputil.go#L171-L188
142,587
grokify/gotilla
strconv/strconvutil/strconvutil.go
AtoiWithDefault
func AtoiWithDefault(s string, def int) int { i, err := strconv.Atoi(s) if err != nil { return def } return i }
go
func AtoiWithDefault(s string, def int) int { i, err := strconv.Atoi(s) if err != nil { return def } return i }
[ "func", "AtoiWithDefault", "(", "s", "string", ",", "def", "int", ")", "int", "{", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "def", "\n", "}", "\n", "return", "i", "\n", "}" ]
// AtoiWithDefault is like Atoi but takes a default value // which it returns in the event of a parse error.
[ "AtoiWithDefault", "is", "like", "Atoi", "but", "takes", "a", "default", "value", "which", "it", "returns", "in", "the", "event", "of", "a", "parse", "error", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/strconvutil/strconvutil.go#L13-L19
142,588
grokify/gotilla
strconv/strconvutil/strconvutil.go
SliceStringToInt
func SliceStringToInt(strings []string) ([]int, error) { ints := []int{} for _, s := range strings { thisInt, err := strconv.Atoi(s) if err != nil { return ints, err } ints = append(ints, thisInt) } return ints, nil }
go
func SliceStringToInt(strings []string) ([]int, error) { ints := []int{} for _, s := range strings { thisInt, err := strconv.Atoi(s) if err != nil { return ints, err } ints = append(ints, thisInt) } return ints, nil }
[ "func", "SliceStringToInt", "(", "strings", "[", "]", "string", ")", "(", "[", "]", "int", ",", "error", ")", "{", "ints", ":=", "[", "]", "int", "{", "}", "\n", "for", "_", ",", "s", ":=", "range", "strings", "{", "thisInt", ",", "err", ":=", ...
// SliceStringToInt converts a slice of string integers.
[ "SliceStringToInt", "converts", "a", "slice", "of", "string", "integers", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/strconvutil/strconvutil.go#L72-L82
142,589
grokify/gotilla
strconv/strconvutil/strconvutil.go
SliceStringToIntSort
func SliceStringToIntSort(strings []string) ([]int, error) { ints, err := SliceStringToInt(strings) if err != nil { return ints, err } intSlice := sort.IntSlice(ints) intSlice.Sort() return intSlice, nil }
go
func SliceStringToIntSort(strings []string) ([]int, error) { ints, err := SliceStringToInt(strings) if err != nil { return ints, err } intSlice := sort.IntSlice(ints) intSlice.Sort() return intSlice, nil }
[ "func", "SliceStringToIntSort", "(", "strings", "[", "]", "string", ")", "(", "[", "]", "int", ",", "error", ")", "{", "ints", ",", "err", ":=", "SliceStringToInt", "(", "strings", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ints", ",", "err...
// SliceStringToIntSort converts and sorts a slice of string integers.
[ "SliceStringToIntSort", "converts", "and", "sorts", "a", "slice", "of", "string", "integers", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/strconvutil/strconvutil.go#L85-L93
142,590
grokify/gotilla
strconv/strconvutil/strconvutil.go
FormatFloat64ToAnyStringFunnel
func FormatFloat64ToAnyStringFunnel(v float64, pattern string) string { return fmt.Sprintf(pattern, ChangeToFunnelPct(v)) }
go
func FormatFloat64ToAnyStringFunnel(v float64, pattern string) string { return fmt.Sprintf(pattern, ChangeToFunnelPct(v)) }
[ "func", "FormatFloat64ToAnyStringFunnel", "(", "v", "float64", ",", "pattern", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "pattern", ",", "ChangeToFunnelPct", "(", "v", ")", ")", "\n", "}" ]
// FormatFloat64ToAnyStringFunnel is used for funnels.
[ "FormatFloat64ToAnyStringFunnel", "is", "used", "for", "funnels", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/strconvutil/strconvutil.go#L100-L102
142,591
grokify/gotilla
strconv/strconvutil/strconvutil.go
FormatFloat64ToAnyString
func FormatFloat64ToAnyString(v float64, pattern string) string { return fmt.Sprintf(pattern, ChangeToXoXPct(v)) }
go
func FormatFloat64ToAnyString(v float64, pattern string) string { return fmt.Sprintf(pattern, ChangeToXoXPct(v)) }
[ "func", "FormatFloat64ToAnyString", "(", "v", "float64", ",", "pattern", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "pattern", ",", "ChangeToXoXPct", "(", "v", ")", ")", "\n", "}" ]
// FormatFloat64ToAnyString is used for XoX growth.
[ "FormatFloat64ToAnyString", "is", "used", "for", "XoX", "growth", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/strconv/strconvutil/strconvutil.go#L109-L111
142,592
grokify/gotilla
time/timeutil/format.go
FromTo
func FromTo(value, fromLayout, toLayout string) (string, error) { t, err := time.Parse(fromLayout, strings.TrimSpace(value)) if err != nil { return "", err } return t.Format(toLayout), nil }
go
func FromTo(value, fromLayout, toLayout string) (string, error) { t, err := time.Parse(fromLayout, strings.TrimSpace(value)) if err != nil { return "", err } return t.Format(toLayout), nil }
[ "func", "FromTo", "(", "value", ",", "fromLayout", ",", "toLayout", "string", ")", "(", "string", ",", "error", ")", "{", "t", ",", "err", ":=", "time", ".", "Parse", "(", "fromLayout", ",", "strings", ".", "TrimSpace", "(", "value", ")", ")", "\n", ...
// Reformat a time string from one format to another
[ "Reformat", "a", "time", "string", "from", "one", "format", "to", "another" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/format.go#L39-L45
142,593
grokify/gotilla
time/timeutil/format.go
ParseOrZero
func ParseOrZero(layout, value string) time.Time { t, err := time.Parse(layout, value) if err != nil { return TimeRFC3339Zero() } return t }
go
func ParseOrZero(layout, value string) time.Time { t, err := time.Parse(layout, value) if err != nil { return TimeRFC3339Zero() } return t }
[ "func", "ParseOrZero", "(", "layout", ",", "value", "string", ")", "time", ".", "Time", "{", "t", ",", "err", ":=", "time", ".", "Parse", "(", "layout", ",", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "TimeRFC3339Zero", "(", ")", ...
// ParseOrZero returns a parsed time.Time or the RFC-3339 zero time.
[ "ParseOrZero", "returns", "a", "parsed", "time", ".", "Time", "or", "the", "RFC", "-", "3339", "zero", "time", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/format.go#L48-L54
142,594
grokify/gotilla
time/timeutil/format.go
ParseFirst
func ParseFirst(layouts []string, value string) (time.Time, error) { value = strings.TrimSpace(value) if len(value) == 0 || len(layouts) == 0 { return time.Now(), fmt.Errorf( "Requires value [%v] and at least one layout [%v]", value, strings.Join(layouts, ",")) } for _, layout := range layouts { layout = str...
go
func ParseFirst(layouts []string, value string) (time.Time, error) { value = strings.TrimSpace(value) if len(value) == 0 || len(layouts) == 0 { return time.Now(), fmt.Errorf( "Requires value [%v] and at least one layout [%v]", value, strings.Join(layouts, ",")) } for _, layout := range layouts { layout = str...
[ "func", "ParseFirst", "(", "layouts", "[", "]", "string", ",", "value", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "value", "=", "strings", ".", "TrimSpace", "(", "value", ")", "\n", "if", "len", "(", "value", ")", "==", "0", ...
// ParseFirst attempts to parse a string with a set of layouts.
[ "ParseFirst", "attempts", "to", "parse", "a", "string", "with", "a", "set", "of", "layouts", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/time/timeutil/format.go#L57-L74
142,595
grokify/gotilla
api/path_to_pattern.go
NewURLTransformer
func NewURLTransformer() URLTransformer { return URLTransformer{ ExactPaths: []string{}, RegexpPaths: map[string]*regexp.Regexp{}, rxMatchPattern: regexp.MustCompile(rxMatchParameterPattern), rxMatchActual: regexp.MustCompile(rxMatchParameterActual), rxStripQuery: regexp.MustCompile(`\?.*$`)} }
go
func NewURLTransformer() URLTransformer { return URLTransformer{ ExactPaths: []string{}, RegexpPaths: map[string]*regexp.Regexp{}, rxMatchPattern: regexp.MustCompile(rxMatchParameterPattern), rxMatchActual: regexp.MustCompile(rxMatchParameterActual), rxStripQuery: regexp.MustCompile(`\?.*$`)} }
[ "func", "NewURLTransformer", "(", ")", "URLTransformer", "{", "return", "URLTransformer", "{", "ExactPaths", ":", "[", "]", "string", "{", "}", ",", "RegexpPaths", ":", "map", "[", "string", "]", "*", "regexp", ".", "Regexp", "{", "}", ",", "rxMatchPattern...
// NewURLTransformer creates a new URLTransformer instance.
[ "NewURLTransformer", "creates", "a", "new", "URLTransformer", "instance", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/api/path_to_pattern.go#L27-L34
142,596
grokify/gotilla
api/path_to_pattern.go
LoadPaths
func (ut *URLTransformer) LoadPaths(paths []string) error { for _, path := range paths { err := ut.LoadPath(path) if err != nil { return err } } return nil }
go
func (ut *URLTransformer) LoadPaths(paths []string) error { for _, path := range paths { err := ut.LoadPath(path) if err != nil { return err } } return nil }
[ "func", "(", "ut", "*", "URLTransformer", ")", "LoadPaths", "(", "paths", "[", "]", "string", ")", "error", "{", "for", "_", ",", "path", ":=", "range", "paths", "{", "err", ":=", "ut", ".", "LoadPath", "(", "path", ")", "\n", "if", "err", "!=", ...
// LoadPaths loads multiple spec URL patterns. See the test file for an example.
[ "LoadPaths", "loads", "multiple", "spec", "URL", "patterns", ".", "See", "the", "test", "file", "for", "an", "example", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/api/path_to_pattern.go#L37-L45
142,597
grokify/gotilla
api/path_to_pattern.go
LoadPath
func (ut *URLTransformer) LoadPath(path string) error { path = ut.rxStripQuery.ReplaceAllString(path, "") i1 := strings.Index(path, "{") i2 := strings.Index(path, "}") if i1 < 0 && i2 < 0 { ut.ExactPaths = append(ut.ExactPaths, path) return nil } linkPattern := ut.rxMatchPattern.ReplaceAllString(path, rxMatch...
go
func (ut *URLTransformer) LoadPath(path string) error { path = ut.rxStripQuery.ReplaceAllString(path, "") i1 := strings.Index(path, "{") i2 := strings.Index(path, "}") if i1 < 0 && i2 < 0 { ut.ExactPaths = append(ut.ExactPaths, path) return nil } linkPattern := ut.rxMatchPattern.ReplaceAllString(path, rxMatch...
[ "func", "(", "ut", "*", "URLTransformer", ")", "LoadPath", "(", "path", "string", ")", "error", "{", "path", "=", "ut", ".", "rxStripQuery", ".", "ReplaceAllString", "(", "path", ",", "\"", "\"", ")", "\n", "i1", ":=", "strings", ".", "Index", "(", "...
// LoadPath loads a single spec URL pattern.
[ "LoadPath", "loads", "a", "single", "spec", "URL", "pattern", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/api/path_to_pattern.go#L48-L64
142,598
grokify/gotilla
api/path_to_pattern.go
URLActualToPattern
func (ut *URLTransformer) URLActualToPattern(s string) string { s = ut.rxStripQuery.ReplaceAllString(s, "") for _, try := range ut.ExactPaths { if s == try { return s } } for pattern, rx := range ut.RegexpPaths { if rx.MatchString(s) { return pattern } } return s }
go
func (ut *URLTransformer) URLActualToPattern(s string) string { s = ut.rxStripQuery.ReplaceAllString(s, "") for _, try := range ut.ExactPaths { if s == try { return s } } for pattern, rx := range ut.RegexpPaths { if rx.MatchString(s) { return pattern } } return s }
[ "func", "(", "ut", "*", "URLTransformer", ")", "URLActualToPattern", "(", "s", "string", ")", "string", "{", "s", "=", "ut", ".", "rxStripQuery", ".", "ReplaceAllString", "(", "s", ",", "\"", "\"", ")", "\n", "for", "_", ",", "try", ":=", "range", "u...
// URLActualToPattern is the "runtime" API that is called over and over // for URL classification purposes.
[ "URLActualToPattern", "is", "the", "runtime", "API", "that", "is", "called", "over", "and", "over", "for", "URL", "classification", "purposes", "." ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/api/path_to_pattern.go#L68-L81
142,599
grokify/gotilla
type/stringsutil/match.go
Match
func Match(s string, matchInfo MatchInfo) (bool, error) { switch matchInfo.MatchType { case Exact: if s == matchInfo.String { return true, nil } return false, nil case TrimSpace: m := strings.TrimSpace(s) if m == strings.TrimSpace(matchInfo.String) { return true, nil } return false, nil case Tri...
go
func Match(s string, matchInfo MatchInfo) (bool, error) { switch matchInfo.MatchType { case Exact: if s == matchInfo.String { return true, nil } return false, nil case TrimSpace: m := strings.TrimSpace(s) if m == strings.TrimSpace(matchInfo.String) { return true, nil } return false, nil case Tri...
[ "func", "Match", "(", "s", "string", ",", "matchInfo", "MatchInfo", ")", "(", "bool", ",", "error", ")", "{", "switch", "matchInfo", ".", "MatchType", "{", "case", "Exact", ":", "if", "s", "==", "matchInfo", ".", "String", "{", "return", "true", ",", ...
// Match provides an canonical way to match strings using multiple // approaches
[ "Match", "provides", "an", "canonical", "way", "to", "match", "strings", "using", "multiple", "approaches" ]
a89420864b4d1cc22c57bcc025cc960a91372b37
https://github.com/grokify/gotilla/blob/a89420864b4d1cc22c57bcc025cc960a91372b37/type/stringsutil/match.go#L33-L100