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
143,100
gojp/kana
kana.go
IsKanji
func IsKanji(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Ideographic}) }
go
func IsKanji(s string) bool { return isChar(s, []*unicode.RangeTable{unicode.Ideographic}) }
[ "func", "IsKanji", "(", "s", "string", ")", "bool", "{", "return", "isChar", "(", "s", ",", "[", "]", "*", "unicode", ".", "RangeTable", "{", "unicode", ".", "Ideographic", "}", ")", "\n", "}" ]
// IsKanji return strue if the string contains only kanji
[ "IsKanji", "return", "strue", "if", "the", "string", "contains", "only", "kanji" ]
6edbc04c5042be5f41cc1bd59cdcdc933a66424b
https://github.com/gojp/kana/blob/6edbc04c5042be5f41cc1bd59cdcdc933a66424b/kana.go#L159-L161
143,101
shurcooL/sanitized_anchor_name
main.go
Create
func Create(text string) string { var anchorName []rune var futureDash = false for _, r := range text { switch { case unicode.IsLetter(r) || unicode.IsNumber(r): if futureDash && len(anchorName) > 0 { anchorName = append(anchorName, '-') } futureDash = false anchorName = append(anchorName, unicod...
go
func Create(text string) string { var anchorName []rune var futureDash = false for _, r := range text { switch { case unicode.IsLetter(r) || unicode.IsNumber(r): if futureDash && len(anchorName) > 0 { anchorName = append(anchorName, '-') } futureDash = false anchorName = append(anchorName, unicod...
[ "func", "Create", "(", "text", "string", ")", "string", "{", "var", "anchorName", "[", "]", "rune", "\n", "var", "futureDash", "=", "false", "\n", "for", "_", ",", "r", ":=", "range", "text", "{", "switch", "{", "case", "unicode", ".", "IsLetter", "(...
// Create returns a sanitized anchor name for the given text.
[ "Create", "returns", "a", "sanitized", "anchor", "name", "for", "the", "given", "text", "." ]
7bfe4c7ecddb3666a94b053b422cdd8f5aaa3615
https://github.com/shurcooL/sanitized_anchor_name/blob/7bfe4c7ecddb3666a94b053b422cdd8f5aaa3615/main.go#L13-L29
143,102
goware/prefixer
prefixer.go
New
func New(r io.Reader, prefix string) *Prefixer { return &Prefixer{ reader: bufio.NewReader(r), prefix: []byte(prefix), } }
go
func New(r io.Reader, prefix string) *Prefixer { return &Prefixer{ reader: bufio.NewReader(r), prefix: []byte(prefix), } }
[ "func", "New", "(", "r", "io", ".", "Reader", ",", "prefix", "string", ")", "*", "Prefixer", "{", "return", "&", "Prefixer", "{", "reader", ":", "bufio", ".", "NewReader", "(", "r", ")", ",", "prefix", ":", "[", "]", "byte", "(", "prefix", ")", "...
// New creates a new instance of Prefixer.
[ "New", "creates", "a", "new", "instance", "of", "Prefixer", "." ]
395022866408d928fc2439f7eac73dd8d370ec1d
https://github.com/goware/prefixer/blob/395022866408d928fc2439f7eac73dd8d370ec1d/prefixer.go#L19-L24
143,103
goware/prefixer
prefixer.go
Read
func (r *Prefixer) Read(p []byte) (n int, err error) { for { // Write unread data from previous read. if len(r.unread) > 0 { m := copy(p[n:], r.unread) n += m r.unread = r.unread[m:] if len(r.unread) > 0 { return n, nil } } // The underlying Reader already returned EOF, do not read again. ...
go
func (r *Prefixer) Read(p []byte) (n int, err error) { for { // Write unread data from previous read. if len(r.unread) > 0 { m := copy(p[n:], r.unread) n += m r.unread = r.unread[m:] if len(r.unread) > 0 { return n, nil } } // The underlying Reader already returned EOF, do not read again. ...
[ "func", "(", "r", "*", "Prefixer", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "for", "{", "// Write unread data from previous read.", "if", "len", "(", "r", ".", "unread", ")", ">", "0", "{", "m", ...
// Read implements io.Reader. It reads data into p from the // underlying reader and prepends every line with a prefix. // It does not block if no data is available yet. // It returns the number of bytes read into p.
[ "Read", "implements", "io", ".", "Reader", ".", "It", "reads", "data", "into", "p", "from", "the", "underlying", "reader", "and", "prepends", "every", "line", "with", "a", "prefix", ".", "It", "does", "not", "block", "if", "no", "data", "is", "available"...
395022866408d928fc2439f7eac73dd8d370ec1d
https://github.com/goware/prefixer/blob/395022866408d928fc2439f7eac73dd8d370ec1d/prefixer.go#L30-L74
143,104
sourcegraph/go-ses
ses.go
SendEmail
func (c *Config) SendEmail(from, to, subject, body string) (string, error) { data := make(url.Values) data.Add("Action", "SendEmail") data.Add("Source", from) data.Add("Destination.ToAddresses.member.1", to) data.Add("Message.Subject.Data", subject) data.Add("Message.Body.Text.Data", body) data.Add("AWSAccessKey...
go
func (c *Config) SendEmail(from, to, subject, body string) (string, error) { data := make(url.Values) data.Add("Action", "SendEmail") data.Add("Source", from) data.Add("Destination.ToAddresses.member.1", to) data.Add("Message.Subject.Data", subject) data.Add("Message.Body.Text.Data", body) data.Add("AWSAccessKey...
[ "func", "(", "c", "*", "Config", ")", "SendEmail", "(", "from", ",", "to", ",", "subject", ",", "body", "string", ")", "(", "string", ",", "error", ")", "{", "data", ":=", "make", "(", "url", ".", "Values", ")", "\n", "data", ".", "Add", "(", "...
// SendEmail sends a plain text email. Note that from must be a verified // address in the AWS control panel.
[ "SendEmail", "sends", "a", "plain", "text", "email", ".", "Note", "that", "from", "must", "be", "a", "verified", "address", "in", "the", "AWS", "control", "panel", "." ]
6bd8d17cf7c125859a7211ae8f44126af826104b
https://github.com/sourcegraph/go-ses/blob/6bd8d17cf7c125859a7211ae8f44126af826104b/ses.go#L45-L55
143,105
sourcegraph/go-ses
ses.go
SendEmailHTML
func (c *Config) SendEmailHTML(from, to, subject, bodyText, bodyHTML string) (string, error) { data := make(url.Values) data.Add("Action", "SendEmail") data.Add("Source", from) data.Add("Destination.ToAddresses.member.1", to) data.Add("Message.Subject.Data", subject) data.Add("Message.Body.Text.Data", bodyText) ...
go
func (c *Config) SendEmailHTML(from, to, subject, bodyText, bodyHTML string) (string, error) { data := make(url.Values) data.Add("Action", "SendEmail") data.Add("Source", from) data.Add("Destination.ToAddresses.member.1", to) data.Add("Message.Subject.Data", subject) data.Add("Message.Body.Text.Data", bodyText) ...
[ "func", "(", "c", "*", "Config", ")", "SendEmailHTML", "(", "from", ",", "to", ",", "subject", ",", "bodyText", ",", "bodyHTML", "string", ")", "(", "string", ",", "error", ")", "{", "data", ":=", "make", "(", "url", ".", "Values", ")", "\n", "data...
// SendEmailHTML sends a HTML email. Note that from must be a verified address // in the AWS control panel.
[ "SendEmailHTML", "sends", "a", "HTML", "email", ".", "Note", "that", "from", "must", "be", "a", "verified", "address", "in", "the", "AWS", "control", "panel", "." ]
6bd8d17cf7c125859a7211ae8f44126af826104b
https://github.com/sourcegraph/go-ses/blob/6bd8d17cf7c125859a7211ae8f44126af826104b/ses.go#L59-L70
143,106
sourcegraph/go-ses
ses.go
SendRawEmail
func (c *Config) SendRawEmail(raw []byte) (string, error) { data := make(url.Values) data.Add("Action", "SendRawEmail") data.Add("RawMessage.Data", base64.StdEncoding.EncodeToString(raw)) data.Add("AWSAccessKeyId", c.AccessKeyID) return sesPost(data, c.Endpoint, c.AccessKeyID, c.SecretAccessKey) }
go
func (c *Config) SendRawEmail(raw []byte) (string, error) { data := make(url.Values) data.Add("Action", "SendRawEmail") data.Add("RawMessage.Data", base64.StdEncoding.EncodeToString(raw)) data.Add("AWSAccessKeyId", c.AccessKeyID) return sesPost(data, c.Endpoint, c.AccessKeyID, c.SecretAccessKey) }
[ "func", "(", "c", "*", "Config", ")", "SendRawEmail", "(", "raw", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "data", ":=", "make", "(", "url", ".", "Values", ")", "\n", "data", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ...
// SendRawEmail sends a raw email. Note that from must be a verified address // in the AWS control panel.
[ "SendRawEmail", "sends", "a", "raw", "email", ".", "Note", "that", "from", "must", "be", "a", "verified", "address", "in", "the", "AWS", "control", "panel", "." ]
6bd8d17cf7c125859a7211ae8f44126af826104b
https://github.com/sourcegraph/go-ses/blob/6bd8d17cf7c125859a7211ae8f44126af826104b/ses.go#L74-L81
143,107
kat-co/vala
validation.go
Check
func (val *Validation) Check() error { if val == nil || len(val.Errors) <= 0 { return nil } return val.constructErrorMessage() }
go
func (val *Validation) Check() error { if val == nil || len(val.Errors) <= 0 { return nil } return val.constructErrorMessage() }
[ "func", "(", "val", "*", "Validation", ")", "Check", "(", ")", "error", "{", "if", "val", "==", "nil", "||", "len", "(", "val", ".", "Errors", ")", "<=", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "val", ".", "constructErrorMessage", "...
// Check aggregates all checker errors into a single error and returns // this error.
[ "Check", "aggregates", "all", "checker", "errors", "into", "a", "single", "error", "and", "returns", "this", "error", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L86-L92
143,108
kat-co/vala
validation.go
CheckAndPanic
func (val *Validation) CheckAndPanic() *Validation { if val == nil || len(val.Errors) <= 0 { return val } panic(val.constructErrorMessage()) }
go
func (val *Validation) CheckAndPanic() *Validation { if val == nil || len(val.Errors) <= 0 { return val } panic(val.constructErrorMessage()) }
[ "func", "(", "val", "*", "Validation", ")", "CheckAndPanic", "(", ")", "*", "Validation", "{", "if", "val", "==", "nil", "||", "len", "(", "val", ".", "Errors", ")", "<=", "0", "{", "return", "val", "\n", "}", "\n\n", "panic", "(", "val", ".", "c...
// CheckAndPanic aggregates all checker errors into a single error and // panics with this error.
[ "CheckAndPanic", "aggregates", "all", "checker", "errors", "into", "a", "single", "error", "and", "panics", "with", "this", "error", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L96-L102
143,109
kat-co/vala
validation.go
CheckSetErrorAndPanic
func (val *Validation) CheckSetErrorAndPanic(retError *error) *Validation { if val == nil || len(val.Errors) <= 0 { return val } *retError = val.constructErrorMessage() panic(*retError) }
go
func (val *Validation) CheckSetErrorAndPanic(retError *error) *Validation { if val == nil || len(val.Errors) <= 0 { return val } *retError = val.constructErrorMessage() panic(*retError) }
[ "func", "(", "val", "*", "Validation", ")", "CheckSetErrorAndPanic", "(", "retError", "*", "error", ")", "*", "Validation", "{", "if", "val", "==", "nil", "||", "len", "(", "val", ".", "Errors", ")", "<=", "0", "{", "return", "val", "\n", "}", "\n\n"...
// CheckSetErrorAndPanic aggregates any Errors produced by the // Checkers into a single error, and sets the address of retError to // this, and panics. The canonical use-case of this is to pass in the // address of an error you would like to return, and then to catch the // panic and do nothing.
[ "CheckSetErrorAndPanic", "aggregates", "any", "Errors", "produced", "by", "the", "Checkers", "into", "a", "single", "error", "and", "sets", "the", "address", "of", "retError", "to", "this", "and", "panics", ".", "The", "canonical", "use", "-", "case", "of", ...
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L109-L116
143,110
kat-co/vala
validation.go
Not
func Not(checker Checker) Checker { return func() (passed bool, errorMessage string) { if passed, errorMessage = checker(); passed { return false, fmt.Sprintf("Not(%s)", errorMessage) } return true, "" } }
go
func Not(checker Checker) Checker { return func() (passed bool, errorMessage string) { if passed, errorMessage = checker(); passed { return false, fmt.Sprintf("Not(%s)", errorMessage) } return true, "" } }
[ "func", "Not", "(", "checker", "Checker", ")", "Checker", "{", "return", "func", "(", ")", "(", "passed", "bool", ",", "errorMessage", "string", ")", "{", "if", "passed", ",", "errorMessage", "=", "checker", "(", ")", ";", "passed", "{", "return", "fal...
// Not returns the inverse of any Checker passed in.
[ "Not", "returns", "the", "inverse", "of", "any", "Checker", "passed", "in", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L161-L170
143,111
kat-co/vala
validation.go
Equals
func Equals(param, value interface{}, paramName string) Checker { return func() (pass bool, errMsg string) { return (param == value), fmt.Sprintf("Parameters were not equal: %s(%v) != %v", paramName, param, value) } }
go
func Equals(param, value interface{}, paramName string) Checker { return func() (pass bool, errMsg string) { return (param == value), fmt.Sprintf("Parameters were not equal: %s(%v) != %v", paramName, param, value) } }
[ "func", "Equals", "(", "param", ",", "value", "interface", "{", "}", ",", "paramName", "string", ")", "Checker", "{", "return", "func", "(", ")", "(", "pass", "bool", ",", "errMsg", "string", ")", "{", "return", "(", "param", "==", "value", ")", ",",...
// Equals performs a basic == on the given parameters and fails if // they are not equal.
[ "Equals", "performs", "a", "basic", "==", "on", "the", "given", "parameters", "and", "fails", "if", "they", "are", "not", "equal", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L174-L182
143,112
kat-co/vala
validation.go
IsNotNil
func IsNotNil(obtained interface{}, paramName string) Checker { return func() (isNotNil bool, errMsg string) { if obtained == nil { isNotNil = false } else if str, ok := obtained.(string); ok { isNotNil = str != "" } else { switch v := reflect.ValueOf(obtained); v.Kind() { case reflect.Chan, ...
go
func IsNotNil(obtained interface{}, paramName string) Checker { return func() (isNotNil bool, errMsg string) { if obtained == nil { isNotNil = false } else if str, ok := obtained.(string); ok { isNotNil = str != "" } else { switch v := reflect.ValueOf(obtained); v.Kind() { case reflect.Chan, ...
[ "func", "IsNotNil", "(", "obtained", "interface", "{", "}", ",", "paramName", "string", ")", "Checker", "{", "return", "func", "(", ")", "(", "isNotNil", "bool", ",", "errMsg", "string", ")", "{", "if", "obtained", "==", "nil", "{", "isNotNil", "=", "f...
// IsNotNil checks to see if the value passed in is nil. This Checker // attempts to check the most performant things first, and then // degrade into the less-performant, but accurate checks for nil.
[ "IsNotNil", "checks", "to", "see", "if", "the", "value", "passed", "in", "is", "nil", ".", "This", "Checker", "attempts", "to", "check", "the", "most", "performant", "things", "first", "and", "then", "degrade", "into", "the", "less", "-", "performant", "bu...
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L187-L211
143,113
kat-co/vala
validation.go
HasLen
func HasLen(param interface{}, desiredLength int, paramName string) Checker { return func() (hasLen bool, errMsg string) { hasLen = desiredLength == reflect.ValueOf(param).Len() return hasLen, "Parameter did not contain the correct number of elements: " + paramName } }
go
func HasLen(param interface{}, desiredLength int, paramName string) Checker { return func() (hasLen bool, errMsg string) { hasLen = desiredLength == reflect.ValueOf(param).Len() return hasLen, "Parameter did not contain the correct number of elements: " + paramName } }
[ "func", "HasLen", "(", "param", "interface", "{", "}", ",", "desiredLength", "int", ",", "paramName", "string", ")", "Checker", "{", "return", "func", "(", ")", "(", "hasLen", "bool", ",", "errMsg", "string", ")", "{", "hasLen", "=", "desiredLength", "==...
// HasLen checks to ensure the given argument is the desired length.
[ "HasLen", "checks", "to", "ensure", "the", "given", "argument", "is", "the", "desired", "length", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L214-L220
143,114
kat-co/vala
validation.go
GreaterThan
func GreaterThan(param int, comparativeVal int, paramName string) Checker { return func() (isGreaterThan bool, errMsg string) { if isGreaterThan = param > comparativeVal; !isGreaterThan { errMsg = fmt.Sprintf( "Parameter's length was not greater than: %s(%d) < %d", paramName, param, comparativeV...
go
func GreaterThan(param int, comparativeVal int, paramName string) Checker { return func() (isGreaterThan bool, errMsg string) { if isGreaterThan = param > comparativeVal; !isGreaterThan { errMsg = fmt.Sprintf( "Parameter's length was not greater than: %s(%d) < %d", paramName, param, comparativeV...
[ "func", "GreaterThan", "(", "param", "int", ",", "comparativeVal", "int", ",", "paramName", "string", ")", "Checker", "{", "return", "func", "(", ")", "(", "isGreaterThan", "bool", ",", "errMsg", "string", ")", "{", "if", "isGreaterThan", "=", "param", ">"...
// GreaterThan checks to ensure the given argument is greater than the // given value.
[ "GreaterThan", "checks", "to", "ensure", "the", "given", "argument", "is", "greater", "than", "the", "given", "value", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L224-L237
143,115
kat-co/vala
validation.go
StringNotEmpty
func StringNotEmpty(obtained, paramName string) Checker { return func() (isNotEmpty bool, errMsg string) { isNotEmpty = obtained != "" errMsg = fmt.Sprintf("Parameter is an empty string: %s", paramName) return } }
go
func StringNotEmpty(obtained, paramName string) Checker { return func() (isNotEmpty bool, errMsg string) { isNotEmpty = obtained != "" errMsg = fmt.Sprintf("Parameter is an empty string: %s", paramName) return } }
[ "func", "StringNotEmpty", "(", "obtained", ",", "paramName", "string", ")", "Checker", "{", "return", "func", "(", ")", "(", "isNotEmpty", "bool", ",", "errMsg", "string", ")", "{", "isNotEmpty", "=", "obtained", "!=", "\"", "\"", "\n", "errMsg", "=", "f...
// StringNotEmpty checks to ensure the given string is not empty.
[ "StringNotEmpty", "checks", "to", "ensure", "the", "given", "string", "is", "not", "empty", "." ]
42e1d8b61f12b4fcadea0c062782e466924a3aaa
https://github.com/kat-co/vala/blob/42e1d8b61f12b4fcadea0c062782e466924a3aaa/validation.go#L240-L246
143,116
stvp/rollbar
stack.go
BuildStack
func BuildStack(skip int) Stack { stack := make(Stack, 0) for i := skip; ; i++ { pc, file, line, ok := runtime.Caller(i) if !ok { break } file = shortenFilePath(file) stack = append(stack, Frame{file, functionName(pc), line}) } return stack }
go
func BuildStack(skip int) Stack { stack := make(Stack, 0) for i := skip; ; i++ { pc, file, line, ok := runtime.Caller(i) if !ok { break } file = shortenFilePath(file) stack = append(stack, Frame{file, functionName(pc), line}) } return stack }
[ "func", "BuildStack", "(", "skip", "int", ")", "Stack", "{", "stack", ":=", "make", "(", "Stack", ",", "0", ")", "\n\n", "for", "i", ":=", "skip", ";", ";", "i", "++", "{", "pc", ",", "file", ",", "line", ",", "ok", ":=", "runtime", ".", "Calle...
// BuildStack builds a full stacktrace for the current execution location.
[ "BuildStack", "builds", "a", "full", "stacktrace", "for", "the", "current", "execution", "location", "." ]
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/stack.go#L29-L42
143,117
stvp/rollbar
stack.go
BuildStackWithCallers
func BuildStackWithCallers(callers []uintptr) Stack { stack := make(Stack, 0, len(callers)) for _, caller := range callers { if fn := runtime.FuncForPC(caller); fn != nil { file, line := fn.FileLine(caller) stack = append(stack, Frame{shortenFilePath(file), functionNameFromFunc(fn), line}) } } return st...
go
func BuildStackWithCallers(callers []uintptr) Stack { stack := make(Stack, 0, len(callers)) for _, caller := range callers { if fn := runtime.FuncForPC(caller); fn != nil { file, line := fn.FileLine(caller) stack = append(stack, Frame{shortenFilePath(file), functionNameFromFunc(fn), line}) } } return st...
[ "func", "BuildStackWithCallers", "(", "callers", "[", "]", "uintptr", ")", "Stack", "{", "stack", ":=", "make", "(", "Stack", ",", "0", ",", "len", "(", "callers", ")", ")", "\n\n", "for", "_", ",", "caller", ":=", "range", "callers", "{", "if", "fn"...
// BuildStackWithCallers builds a full stackstrace from the given list of callees.
[ "BuildStackWithCallers", "builds", "a", "full", "stackstrace", "from", "the", "given", "list", "of", "callees", "." ]
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/stack.go#L45-L56
143,118
stvp/rollbar
rollbar.go
Error
func Error(level string, err error, fields ...*Field) { ErrorWithStackSkip(level, err, 1, fields...) }
go
func Error(level string, err error, fields ...*Field) { ErrorWithStackSkip(level, err, 1, fields...) }
[ "func", "Error", "(", "level", "string", ",", "err", "error", ",", "fields", "...", "*", "Field", ")", "{", "ErrorWithStackSkip", "(", "level", ",", "err", ",", "1", ",", "fields", "...", ")", "\n", "}" ]
// Error asynchronously sends an error to Rollbar with the given severity // level. You can pass, optionally, custom Fields to be passed on to Rollbar.
[ "Error", "asynchronously", "sends", "an", "error", "to", "Rollbar", "with", "the", "given", "severity", "level", ".", "You", "can", "pass", "optionally", "custom", "Fields", "to", "be", "passed", "on", "to", "Rollbar", "." ]
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L129-L131
143,119
stvp/rollbar
rollbar.go
ErrorWithStackSkip
func ErrorWithStackSkip(level string, err error, skip int, fields ...*Field) { stack := BuildStack(2 + skip) ErrorWithStack(level, err, stack, fields...) }
go
func ErrorWithStackSkip(level string, err error, skip int, fields ...*Field) { stack := BuildStack(2 + skip) ErrorWithStack(level, err, stack, fields...) }
[ "func", "ErrorWithStackSkip", "(", "level", "string", ",", "err", "error", ",", "skip", "int", ",", "fields", "...", "*", "Field", ")", "{", "stack", ":=", "BuildStack", "(", "2", "+", "skip", ")", "\n", "ErrorWithStack", "(", "level", ",", "err", ",",...
// ErrorWithStackSkip asynchronously sends an error to Rollbar with the given // severity level and a given number of stack trace frames skipped. You can // pass, optionally, custom Fields to be passed on to Rollbar.
[ "ErrorWithStackSkip", "asynchronously", "sends", "an", "error", "to", "Rollbar", "with", "the", "given", "severity", "level", "and", "a", "given", "number", "of", "stack", "trace", "frames", "skipped", ".", "You", "can", "pass", "optionally", "custom", "Fields",...
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L136-L139
143,120
stvp/rollbar
rollbar.go
RequestError
func RequestError(level string, r *http.Request, err error, fields ...*Field) { RequestErrorWithStackSkip(level, r, err, 1, fields...) }
go
func RequestError(level string, r *http.Request, err error, fields ...*Field) { RequestErrorWithStackSkip(level, r, err, 1, fields...) }
[ "func", "RequestError", "(", "level", "string", ",", "r", "*", "http", ".", "Request", ",", "err", "error", ",", "fields", "...", "*", "Field", ")", "{", "RequestErrorWithStackSkip", "(", "level", ",", "r", ",", "err", ",", "1", ",", "fields", "...", ...
// RequestError asynchronously sends an error to Rollbar with the given // severity level and request-specific information. You can pass, optionally, // custom Fields to be passed on to Rollbar.
[ "RequestError", "asynchronously", "sends", "an", "error", "to", "Rollbar", "with", "the", "given", "severity", "level", "and", "request", "-", "specific", "information", ".", "You", "can", "pass", "optionally", "custom", "Fields", "to", "be", "passed", "on", "...
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L150-L152
143,121
stvp/rollbar
rollbar.go
RequestErrorWithStackSkip
func RequestErrorWithStackSkip(level string, r *http.Request, err error, skip int, fields ...*Field) { stack := BuildStack(2 + skip) RequestErrorWithStack(level, r, err, stack, fields...) }
go
func RequestErrorWithStackSkip(level string, r *http.Request, err error, skip int, fields ...*Field) { stack := BuildStack(2 + skip) RequestErrorWithStack(level, r, err, stack, fields...) }
[ "func", "RequestErrorWithStackSkip", "(", "level", "string", ",", "r", "*", "http", ".", "Request", ",", "err", "error", ",", "skip", "int", ",", "fields", "...", "*", "Field", ")", "{", "stack", ":=", "BuildStack", "(", "2", "+", "skip", ")", "\n", ...
// RequestErrorWithStackSkip asynchronously sends an error to Rollbar with the // given severity level and a given number of stack trace frames skipped, in // addition to extra request-specific information. You can pass, optionally, // custom Fields to be passed on to Rollbar.
[ "RequestErrorWithStackSkip", "asynchronously", "sends", "an", "error", "to", "Rollbar", "with", "the", "given", "severity", "level", "and", "a", "given", "number", "of", "stack", "trace", "frames", "skipped", "in", "addition", "to", "extra", "request", "-", "spe...
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L158-L161
143,122
stvp/rollbar
rollbar.go
RequestErrorWithStack
func RequestErrorWithStack(level string, r *http.Request, err error, stack Stack, fields ...*Field) { buildAndPushError(level, err, stack, append(fields, &Field{Name: "request", Data: errorRequest(r)})...) }
go
func RequestErrorWithStack(level string, r *http.Request, err error, stack Stack, fields ...*Field) { buildAndPushError(level, err, stack, append(fields, &Field{Name: "request", Data: errorRequest(r)})...) }
[ "func", "RequestErrorWithStack", "(", "level", "string", ",", "r", "*", "http", ".", "Request", ",", "err", "error", ",", "stack", "Stack", ",", "fields", "...", "*", "Field", ")", "{", "buildAndPushError", "(", "level", ",", "err", ",", "stack", ",", ...
// RequestErrorWithStack asynchronously sends an error to Rollbar with the // given severity level, request-specific information provided by the given // http.Request, and a custom Stack. You You can pass, optionally, custom // Fields to be passed on to Rollbar.
[ "RequestErrorWithStack", "asynchronously", "sends", "an", "error", "to", "Rollbar", "with", "the", "given", "severity", "level", "request", "-", "specific", "information", "provided", "by", "the", "given", "http", ".", "Request", "and", "a", "custom", "Stack", "...
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L167-L169
143,123
stvp/rollbar
rollbar.go
errorBody
func errorBody(err error, stack Stack) map[string]interface{} { message := nilErrTitle if err != nil { message = err.Error() } errBody := map[string]interface{}{ "trace": map[string]interface{}{ "frames": stack, "exception": map[string]interface{}{ "class": errorClass(err), "message": message, ...
go
func errorBody(err error, stack Stack) map[string]interface{} { message := nilErrTitle if err != nil { message = err.Error() } errBody := map[string]interface{}{ "trace": map[string]interface{}{ "frames": stack, "exception": map[string]interface{}{ "class": errorClass(err), "message": message, ...
[ "func", "errorBody", "(", "err", "error", ",", "stack", "Stack", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "message", ":=", "nilErrTitle", "\n", "if", "err", "!=", "nil", "{", "message", "=", "err", ".", "Error", "(", ")", "\n", "...
// errorBody generates a Rollbar error body with a given stack trace.
[ "errorBody", "generates", "a", "Rollbar", "error", "body", "with", "a", "given", "stack", "trace", "." ]
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L252-L268
143,124
stvp/rollbar
rollbar.go
errorRequest
func errorRequest(r *http.Request) map[string]interface{} { cleanQuery := filterParams(r.URL.Query()) return map[string]interface{}{ "url": r.URL.String(), "method": r.Method, "headers": flattenValues(r.Header), // GET params "query_string": url.Values(cleanQuery).Encode(), "GET": flattenV...
go
func errorRequest(r *http.Request) map[string]interface{} { cleanQuery := filterParams(r.URL.Query()) return map[string]interface{}{ "url": r.URL.String(), "method": r.Method, "headers": flattenValues(r.Header), // GET params "query_string": url.Values(cleanQuery).Encode(), "GET": flattenV...
[ "func", "errorRequest", "(", "r", "*", "http", ".", "Request", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "cleanQuery", ":=", "filterParams", "(", "r", ".", "URL", ".", "Query", "(", ")", ")", "\n\n", "return", "map", "[", "string", ...
// errorRequest extracts details from a Request in a format that Rollbar // accepts.
[ "errorRequest", "extracts", "details", "from", "a", "Request", "in", "a", "format", "that", "Rollbar", "accepts", "." ]
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L272-L288
143,125
stvp/rollbar
rollbar.go
post
func post(body map[string]interface{}) error { if len(Token) == 0 { stderr("empty token") return nil } jsonBody, err := json.Marshal(body) if err != nil { stderr("failed to encode payload: %s", err.Error()) return err } resp, err := http.Post(Endpoint, "application/json", bytes.NewReader(jsonBody)) if ...
go
func post(body map[string]interface{}) error { if len(Token) == 0 { stderr("empty token") return nil } jsonBody, err := json.Marshal(body) if err != nil { stderr("failed to encode payload: %s", err.Error()) return err } resp, err := http.Post(Endpoint, "application/json", bytes.NewReader(jsonBody)) if ...
[ "func", "post", "(", "body", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "Token", ")", "==", "0", "{", "stderr", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "jsonBody", ",", "err", ...
// POST the given JSON body to Rollbar synchronously.
[ "POST", "the", "given", "JSON", "body", "to", "Rollbar", "synchronously", "." ]
b30392424fcaf4495c458d59cc39a96b97217933
https://github.com/stvp/rollbar/blob/b30392424fcaf4495c458d59cc39a96b97217933/rollbar.go#L354-L379
143,126
wantedly/apig
apig/generate.go
camelToLowerCamel
func camelToLowerCamel(s string) string { ss := strings.Split(s, "") ss[0] = strings.ToLower(ss[0]) return strings.Join(ss, "") }
go
func camelToLowerCamel(s string) string { ss := strings.Split(s, "") ss[0] = strings.ToLower(ss[0]) return strings.Join(ss, "") }
[ "func", "camelToLowerCamel", "(", "s", "string", ")", "string", "{", "ss", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", "\n", "ss", "[", "0", "]", "=", "strings", ".", "ToLower", "(", "ss", "[", "0", "]", ")", "\n\n", "return", ...
// AccountName -> accountName
[ "AccountName", "-", ">", "accountName" ]
93191507b5baefafbac42bdfd39da97523c83593
https://github.com/wantedly/apig/blob/93191507b5baefafbac42bdfd39da97523c83593/apig/generate.go#L137-L142
143,127
wantedly/apig
apig/generate.go
camelToOriginal
func camelToOriginal(s string) string { var words []string var lastPos int rs := []rune(s) for i := 0; i < len(rs); i++ { if i > 0 && unicode.IsUpper(rs[i]) { words = append(words, strings.ToLower(s[lastPos:i])) lastPos = i } } // append the last word if s[lastPos:] != "" { words = append(words, st...
go
func camelToOriginal(s string) string { var words []string var lastPos int rs := []rune(s) for i := 0; i < len(rs); i++ { if i > 0 && unicode.IsUpper(rs[i]) { words = append(words, strings.ToLower(s[lastPos:i])) lastPos = i } } // append the last word if s[lastPos:] != "" { words = append(words, st...
[ "func", "camelToOriginal", "(", "s", "string", ")", "string", "{", "var", "words", "[", "]", "string", "\n", "var", "lastPos", "int", "\n", "rs", ":=", "[", "]", "rune", "(", "s", ")", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "...
// accountName -> account name
[ "accountName", "-", ">", "account", "name" ]
93191507b5baefafbac42bdfd39da97523c83593
https://github.com/wantedly/apig/blob/93191507b5baefafbac42bdfd39da97523c83593/apig/generate.go#L145-L163
143,128
AndrewBurian/powermux
example/logger_middleware.go
ServeHTTPMiddleware
func (m *LoggerMiddleware) ServeHTTPMiddleware(rw http.ResponseWriter, req *http.Request, next func(rw http.ResponseWriter, req *http.Request)) { // inject the log into the context along with some info entry := m.baseEntry.WithField("id", uuid.NewV4()) req = req.WithContext(context.WithValue(req.Context(), logCtxK...
go
func (m *LoggerMiddleware) ServeHTTPMiddleware(rw http.ResponseWriter, req *http.Request, next func(rw http.ResponseWriter, req *http.Request)) { // inject the log into the context along with some info entry := m.baseEntry.WithField("id", uuid.NewV4()) req = req.WithContext(context.WithValue(req.Context(), logCtxK...
[ "func", "(", "m", "*", "LoggerMiddleware", ")", "ServeHTTPMiddleware", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "next", "func", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Reques...
// Injects a new log entry with a request UUID into the request context
[ "Injects", "a", "new", "log", "entry", "with", "a", "request", "UUID", "into", "the", "request", "context" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/example/logger_middleware.go#L28-L36
143,129
AndrewBurian/powermux
example/logger_middleware.go
getLogEntry
func getLogEntry(req *http.Request) *logrus.Entry { return req.Context().Value(logCtxKey).(*logrus.Entry) }
go
func getLogEntry(req *http.Request) *logrus.Entry { return req.Context().Value(logCtxKey).(*logrus.Entry) }
[ "func", "getLogEntry", "(", "req", "*", "http", ".", "Request", ")", "*", "logrus", ".", "Entry", "{", "return", "req", ".", "Context", "(", ")", ".", "Value", "(", "logCtxKey", ")", ".", "(", "*", "logrus", ".", "Entry", ")", "\n", "}" ]
// Gets the data out of the request context for use
[ "Gets", "the", "data", "out", "of", "the", "request", "context", "for", "use" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/example/logger_middleware.go#L39-L41
143,130
AndrewBurian/powermux
handlers.go
Redirect
func (r *Route) Redirect(url string, permanent bool) *Route { var h http.Handler if permanent { h = http.RedirectHandler(url, http.StatusPermanentRedirect) } else { h = http.RedirectHandler(url, http.StatusTemporaryRedirect) } return r.Any(h) }
go
func (r *Route) Redirect(url string, permanent bool) *Route { var h http.Handler if permanent { h = http.RedirectHandler(url, http.StatusPermanentRedirect) } else { h = http.RedirectHandler(url, http.StatusTemporaryRedirect) } return r.Any(h) }
[ "func", "(", "r", "*", "Route", ")", "Redirect", "(", "url", "string", ",", "permanent", "bool", ")", "*", "Route", "{", "var", "h", "http", ".", "Handler", "\n", "if", "permanent", "{", "h", "=", "http", ".", "RedirectHandler", "(", "url", ",", "h...
// Redirect adds a redirect handler for ANY method for this route. // // Redirects use either http.StatusPermanentRedirect or http.StatusTemporaryRedirect as their code.
[ "Redirect", "adds", "a", "redirect", "handler", "for", "ANY", "method", "for", "this", "route", ".", "Redirects", "use", "either", "http", ".", "StatusPermanentRedirect", "or", "http", ".", "StatusTemporaryRedirect", "as", "their", "code", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/handlers.go#L11-L19
143,131
AndrewBurian/powermux
handlers.go
ServeHTTP
func (h methodNotAllowedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Sets the Allow header w.Header().Add("Allow", strings.Join(h, ", ")) w.WriteHeader(http.StatusMethodNotAllowed) }
go
func (h methodNotAllowedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Sets the Allow header w.Header().Add("Allow", strings.Join(h, ", ")) w.WriteHeader(http.StatusMethodNotAllowed) }
[ "func", "(", "h", "methodNotAllowedHandler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "// Sets the Allow header", "w", ".", "Header", "(", ")", ".", "Add", "(", "\"", "\"", ",", "strings"...
// ServeHTTP responses with a Method Not Allowed and includes an "Allow" header containing the // valid methods for this route.
[ "ServeHTTP", "responses", "with", "a", "Method", "Not", "Allowed", "and", "includes", "an", "Allow", "header", "containing", "the", "valid", "methods", "for", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/handlers.go#L25-L29
143,132
AndrewBurian/powermux
handlers.go
methodNotAllowed
func (r *Route) methodNotAllowed() http.Handler { // determine what methods ARE supported by this route methods := make([]string, 0, 8) for method := range r.handlers { if method != methodAny && method != notFound { methods = append(methods, method) } } // 405 only makes sense if some methods are allowed...
go
func (r *Route) methodNotAllowed() http.Handler { // determine what methods ARE supported by this route methods := make([]string, 0, 8) for method := range r.handlers { if method != methodAny && method != notFound { methods = append(methods, method) } } // 405 only makes sense if some methods are allowed...
[ "func", "(", "r", "*", "Route", ")", "methodNotAllowed", "(", ")", "http", ".", "Handler", "{", "// determine what methods ARE supported by this route", "methods", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "8", ")", "\n\n", "for", "method", ":=",...
// methodNotAllowed is called internally by Route to generate a 405 handler
[ "methodNotAllowed", "is", "called", "internally", "by", "Route", "to", "generate", "a", "405", "handler" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/handlers.go#L36-L53
143,133
AndrewBurian/powermux
route.go
Matches
func (f verbFlag) Matches(v verbFlag) bool { if v == 0 { return false } return f&v == v }
go
func (f verbFlag) Matches(v verbFlag) bool { if v == 0 { return false } return f&v == v }
[ "func", "(", "f", "verbFlag", ")", "Matches", "(", "v", "verbFlag", ")", "bool", "{", "if", "v", "==", "0", "{", "return", "false", "\n", "}", "\n", "return", "f", "&", "v", "==", "v", "\n", "}" ]
// Check if the verb matches the available flags // never match a zero flag
[ "Check", "if", "the", "verb", "matches", "the", "available", "flags", "never", "match", "a", "zero", "flag" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L58-L63
143,134
AndrewBurian/powermux
route.go
newRoute
func newRoute() *Route { return &Route{ handlers: make(map[string]http.Handler), middleware: make([]*middlewareForVerb, 0), children: make([]*Route, 0), } }
go
func newRoute() *Route { return &Route{ handlers: make(map[string]http.Handler), middleware: make([]*middlewareForVerb, 0), children: make([]*Route, 0), } }
[ "func", "newRoute", "(", ")", "*", "Route", "{", "return", "&", "Route", "{", "handlers", ":", "make", "(", "map", "[", "string", "]", "http", ".", "Handler", ")", ",", "middleware", ":", "make", "(", "[", "]", "*", "middlewareForVerb", ",", "0", "...
// newRoute allocates all the structures required for a route node. // Default pattern is "" which matches only the top level node.
[ "newRoute", "allocates", "all", "the", "structures", "required", "for", "a", "route", "node", ".", "Default", "pattern", "is", "which", "matches", "only", "the", "top", "level", "node", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L126-L132
143,135
AndrewBurian/powermux
route.go
execute
func (r *Route) execute(ex *routeExecution, method, pattern string) { pathParts := pathPartsPool.Get().([]string)[0:0] pathParts = append(pathParts, "") start := 1 for i := 1; i < len(pattern); i++ { if pattern[i] == '/' { pathParts = append(pathParts, pattern[start:i]) i++ start = i } } // get the...
go
func (r *Route) execute(ex *routeExecution, method, pattern string) { pathParts := pathPartsPool.Get().([]string)[0:0] pathParts = append(pathParts, "") start := 1 for i := 1; i < len(pattern); i++ { if pattern[i] == '/' { pathParts = append(pathParts, pattern[start:i]) i++ start = i } } // get the...
[ "func", "(", "r", "*", "Route", ")", "execute", "(", "ex", "*", "routeExecution", ",", "method", ",", "pattern", "string", ")", "{", "pathParts", ":=", "pathPartsPool", ".", "Get", "(", ")", ".", "(", "[", "]", "string", ")", "[", "0", ":", "0", ...
// execute sets up the tree traversal required to get the execution instructions for // a route.
[ "execute", "sets", "up", "the", "tree", "traversal", "required", "to", "get", "the", "execution", "instructions", "for", "a", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L136-L159
143,136
AndrewBurian/powermux
route.go
getExecution
func (r *Route) getExecution(method string, pathParts []string, ex *routeExecution) { curRoute := r verb := getVerbFlagForMethod(method) for { // save all the middleware for matching verbs for i := range curRoute.middleware { if curRoute.middleware[i].verb.Matches(verb) { ex.middleware = append(ex.midd...
go
func (r *Route) getExecution(method string, pathParts []string, ex *routeExecution) { curRoute := r verb := getVerbFlagForMethod(method) for { // save all the middleware for matching verbs for i := range curRoute.middleware { if curRoute.middleware[i].verb.Matches(verb) { ex.middleware = append(ex.midd...
[ "func", "(", "r", "*", "Route", ")", "getExecution", "(", "method", "string", ",", "pathParts", "[", "]", "string", ",", "ex", "*", "routeExecution", ")", "{", "curRoute", ":=", "r", "\n", "verb", ":=", "getVerbFlagForMethod", "(", "method", ")", "\n\n",...
// getExecution is a recursive step in the tree traversal. It checks to see if this node matches, // fills out any instructions in the execution, and returns. The return value indicates only if // this node matched, not if anything was added to the execution.
[ "getExecution", "is", "a", "recursive", "step", "in", "the", "tree", "traversal", ".", "It", "checks", "to", "see", "if", "this", "node", "matches", "fills", "out", "any", "instructions", "in", "the", "execution", "and", "returns", ".", "The", "return", "v...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L164-L236
143,137
AndrewBurian/powermux
route.go
Route
func (r *Route) Route(path string) *Route { // prepend a leading slash if not present if path[0] != '/' { path = "/" + path } // remove the tailing slash if it is present if path != "/" { path = strings.TrimRight(path, "/") } // append our node name to the search if we're not root if r.pattern != "" { ...
go
func (r *Route) Route(path string) *Route { // prepend a leading slash if not present if path[0] != '/' { path = "/" + path } // remove the tailing slash if it is present if path != "/" { path = strings.TrimRight(path, "/") } // append our node name to the search if we're not root if r.pattern != "" { ...
[ "func", "(", "r", "*", "Route", ")", "Route", "(", "path", "string", ")", "*", "Route", "{", "// prepend a leading slash if not present", "if", "path", "[", "0", "]", "!=", "'/'", "{", "path", "=", "\"", "\"", "+", "path", "\n", "}", "\n\n", "// remove...
// Route walks down the route tree following pattern and returns either a new or previously // existing node that represents that specific path.
[ "Route", "walks", "down", "the", "route", "tree", "following", "pattern", "and", "returns", "either", "a", "new", "or", "previously", "existing", "node", "that", "represents", "that", "specific", "path", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L277-L306
143,138
AndrewBurian/powermux
route.go
create
func (r *Route) create(path []string, parentPath string) *Route { // ensure this path matches us if r.pattern != path[0] { // not us return nil } // if this is us, return, no creation necessary if len(path) == 1 { return r } // iterate over all children looking for a place to put this for _, child := r...
go
func (r *Route) create(path []string, parentPath string) *Route { // ensure this path matches us if r.pattern != path[0] { // not us return nil } // if this is us, return, no creation necessary if len(path) == 1 { return r } // iterate over all children looking for a place to put this for _, child := r...
[ "func", "(", "r", "*", "Route", ")", "create", "(", "path", "[", "]", "string", ",", "parentPath", "string", ")", "*", "Route", "{", "// ensure this path matches us", "if", "r", ".", "pattern", "!=", "path", "[", "0", "]", "{", "// not us", "return", "...
// Create descends the tree following path, creating nodes as needed and returns the target node
[ "Create", "descends", "the", "tree", "following", "path", "creating", "nodes", "as", "needed", "and", "returns", "the", "target", "node" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L309-L363
143,139
AndrewBurian/powermux
route.go
stringRoutes
func (r *Route) stringRoutes(routes *[]string) { var thisRoute string // handle root node if r.fullPath == "" { thisRoute = "/" } else { thisRoute = r.fullPath } if len(r.handlers) > 0 { thisRoute = thisRoute + "\t[" methods := make([]string, 0, 8) for method := range r.handlers { methods = append...
go
func (r *Route) stringRoutes(routes *[]string) { var thisRoute string // handle root node if r.fullPath == "" { thisRoute = "/" } else { thisRoute = r.fullPath } if len(r.handlers) > 0 { thisRoute = thisRoute + "\t[" methods := make([]string, 0, 8) for method := range r.handlers { methods = append...
[ "func", "(", "r", "*", "Route", ")", "stringRoutes", "(", "routes", "*", "[", "]", "string", ")", "{", "var", "thisRoute", "string", "\n\n", "// handle root node", "if", "r", ".", "fullPath", "==", "\"", "\"", "{", "thisRoute", "=", "\"", "\"", "\n", ...
// stringRoutes returns the stringRoutes representation of this route and all below it.
[ "stringRoutes", "returns", "the", "stringRoutes", "representation", "of", "this", "route", "and", "all", "below", "it", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L366-L391
143,140
AndrewBurian/powermux
route.go
getChildren
func (r *Route) getChildren() []*Route { // allocate once allRoutes := make([]*Route, 0, len(r.children)+2) // start with the normal routes allRoutes = append(allRoutes, r.children...) // then add the param child if r.paramChild != nil { allRoutes = append(allRoutes, r.paramChild) } // then add the wildca...
go
func (r *Route) getChildren() []*Route { // allocate once allRoutes := make([]*Route, 0, len(r.children)+2) // start with the normal routes allRoutes = append(allRoutes, r.children...) // then add the param child if r.paramChild != nil { allRoutes = append(allRoutes, r.paramChild) } // then add the wildca...
[ "func", "(", "r", "*", "Route", ")", "getChildren", "(", ")", "[", "]", "*", "Route", "{", "// allocate once", "allRoutes", ":=", "make", "(", "[", "]", "*", "Route", ",", "0", ",", "len", "(", "r", ".", "children", ")", "+", "2", ")", "\n\n", ...
// getChildren returns all the routes with the correct order of precedence
[ "getChildren", "returns", "all", "the", "routes", "with", "the", "correct", "order", "of", "precedence" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L394-L413
143,141
AndrewBurian/powermux
route.go
Middleware
func (r *Route) Middleware(m Middleware) *Route { r.middleware = append(r.middleware, &middlewareForVerb{ mid: m, verb: flagAny, }) return r }
go
func (r *Route) Middleware(m Middleware) *Route { r.middleware = append(r.middleware, &middlewareForVerb{ mid: m, verb: flagAny, }) return r }
[ "func", "(", "r", "*", "Route", ")", "Middleware", "(", "m", "Middleware", ")", "*", "Route", "{", "r", ".", "middleware", "=", "append", "(", "r", ".", "middleware", ",", "&", "middlewareForVerb", "{", "mid", ":", "m", ",", "verb", ":", "flagAny", ...
// Middleware adds a middleware to this Route. // // Middlewares are executed if the path to the target route crosses this route.
[ "Middleware", "adds", "a", "middleware", "to", "this", "Route", ".", "Middlewares", "are", "executed", "if", "the", "path", "to", "the", "target", "route", "crosses", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L418-L424
143,142
AndrewBurian/powermux
route.go
MiddlewareExceptForOptions
func (r *Route) MiddlewareExceptForOptions(m Middleware) *Route { return r.MiddlewareExceptFor(m, http.MethodOptions) }
go
func (r *Route) MiddlewareExceptForOptions(m Middleware) *Route { return r.MiddlewareExceptFor(m, http.MethodOptions) }
[ "func", "(", "r", "*", "Route", ")", "MiddlewareExceptForOptions", "(", "m", "Middleware", ")", "*", "Route", "{", "return", "r", ".", "MiddlewareExceptFor", "(", "m", ",", "http", ".", "MethodOptions", ")", "\n", "}" ]
// MiddlewareExceptForOptions is shorthand for MiddlewareExceptFor with // http.MethodOptions as the only excepted method
[ "MiddlewareExceptForOptions", "is", "shorthand", "for", "MiddlewareExceptFor", "with", "http", ".", "MethodOptions", "as", "the", "only", "excepted", "method" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L490-L492
143,143
AndrewBurian/powermux
route.go
Any
func (r *Route) Any(handler http.Handler) *Route { r.handlers[methodAny] = handler return r }
go
func (r *Route) Any(handler http.Handler) *Route { r.handlers[methodAny] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Any", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "methodAny", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Any registers a catch-all handler for any method sent to this route. // This takes lower precedence than a specific method match.
[ "Any", "registers", "a", "catch", "-", "all", "handler", "for", "any", "method", "sent", "to", "this", "route", ".", "This", "takes", "lower", "precedence", "than", "a", "specific", "method", "match", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L501-L504
143,144
AndrewBurian/powermux
route.go
AnyFunc
func (r *Route) AnyFunc(f http.HandlerFunc) *Route { return r.Any(http.HandlerFunc(f)) }
go
func (r *Route) AnyFunc(f http.HandlerFunc) *Route { return r.Any(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "AnyFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Any", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// AnyFunc registers a plain function as a catch-all handler // for any method sent to this route. // This takes lower precedence than a specific method match.
[ "AnyFunc", "registers", "a", "plain", "function", "as", "a", "catch", "-", "all", "handler", "for", "any", "method", "sent", "to", "this", "route", ".", "This", "takes", "lower", "precedence", "than", "a", "specific", "method", "match", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L509-L511
143,145
AndrewBurian/powermux
route.go
Post
func (r *Route) Post(handler http.Handler) *Route { r.handlers[http.MethodPost] = handler return r }
go
func (r *Route) Post(handler http.Handler) *Route { r.handlers[http.MethodPost] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Post", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodPost", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Post adds a handler for POST methods to this route.
[ "Post", "adds", "a", "handler", "for", "POST", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L514-L517
143,146
AndrewBurian/powermux
route.go
PostFunc
func (r *Route) PostFunc(f http.HandlerFunc) *Route { return r.Post(http.HandlerFunc(f)) }
go
func (r *Route) PostFunc(f http.HandlerFunc) *Route { return r.Post(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "PostFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Post", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// PostFunc adds a plain function as a handler // for POST methods to this route.
[ "PostFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "POST", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L521-L523
143,147
AndrewBurian/powermux
route.go
Put
func (r *Route) Put(handler http.Handler) *Route { r.handlers[http.MethodPut] = handler return r }
go
func (r *Route) Put(handler http.Handler) *Route { r.handlers[http.MethodPut] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Put", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodPut", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Put adds a handler for PUT methods to this route.
[ "Put", "adds", "a", "handler", "for", "PUT", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L526-L529
143,148
AndrewBurian/powermux
route.go
PutFunc
func (r *Route) PutFunc(f http.HandlerFunc) *Route { return r.Put(http.HandlerFunc(f)) }
go
func (r *Route) PutFunc(f http.HandlerFunc) *Route { return r.Put(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "PutFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Put", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// PutFunc adds a plain function as a handler // for PUT methods to this route.
[ "PutFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "PUT", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L533-L535
143,149
AndrewBurian/powermux
route.go
Patch
func (r *Route) Patch(handler http.Handler) *Route { r.handlers[http.MethodPatch] = handler return r }
go
func (r *Route) Patch(handler http.Handler) *Route { r.handlers[http.MethodPatch] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Patch", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodPatch", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Patch adds a handler for PATCH methods to this route.
[ "Patch", "adds", "a", "handler", "for", "PATCH", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L538-L541
143,150
AndrewBurian/powermux
route.go
PatchFunc
func (r *Route) PatchFunc(f http.HandlerFunc) *Route { return r.Patch(http.HandlerFunc(f)) }
go
func (r *Route) PatchFunc(f http.HandlerFunc) *Route { return r.Patch(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "PatchFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Patch", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// PatchFunc adds a plain function as a handler // for PATCH methods to this route.
[ "PatchFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "PATCH", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L545-L547
143,151
AndrewBurian/powermux
route.go
Get
func (r *Route) Get(handler http.Handler) *Route { r.handlers[http.MethodGet] = handler return r }
go
func (r *Route) Get(handler http.Handler) *Route { r.handlers[http.MethodGet] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Get", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodGet", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Get adds a handler for GET methods to this route. // GET handlers will also be called for HEAD requests // if no specific HEAD handler is registered.
[ "Get", "adds", "a", "handler", "for", "GET", "methods", "to", "this", "route", ".", "GET", "handlers", "will", "also", "be", "called", "for", "HEAD", "requests", "if", "no", "specific", "HEAD", "handler", "is", "registered", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L552-L555
143,152
AndrewBurian/powermux
route.go
GetFunc
func (r *Route) GetFunc(f http.HandlerFunc) *Route { return r.Get(http.HandlerFunc(f)) }
go
func (r *Route) GetFunc(f http.HandlerFunc) *Route { return r.Get(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "GetFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Get", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// GetFunc adds a plain function as a handler // for GET methods to this route. // GET handlers will also be called for HEAD requests // if no specific HEAD handler is registered.
[ "GetFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "GET", "methods", "to", "this", "route", ".", "GET", "handlers", "will", "also", "be", "called", "for", "HEAD", "requests", "if", "no", "specific", "HEAD", "handler", "is", "register...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L561-L563
143,153
AndrewBurian/powermux
route.go
Delete
func (r *Route) Delete(handler http.Handler) *Route { r.handlers[http.MethodDelete] = handler return r }
go
func (r *Route) Delete(handler http.Handler) *Route { r.handlers[http.MethodDelete] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Delete", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodDelete", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Delete adds a handler for DELETE methods to this route.
[ "Delete", "adds", "a", "handler", "for", "DELETE", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L566-L569
143,154
AndrewBurian/powermux
route.go
DeleteFunc
func (r *Route) DeleteFunc(f http.HandlerFunc) *Route { return r.Delete(http.HandlerFunc(f)) }
go
func (r *Route) DeleteFunc(f http.HandlerFunc) *Route { return r.Delete(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "DeleteFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Delete", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// DeleteFunc adds a plain function as a handler // for DELETE methods to this route.
[ "DeleteFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "DELETE", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L573-L575
143,155
AndrewBurian/powermux
route.go
Head
func (r *Route) Head(handler http.Handler) *Route { r.handlers[http.MethodHead] = handler return r }
go
func (r *Route) Head(handler http.Handler) *Route { r.handlers[http.MethodHead] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Head", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodHead", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Head adds a handler for HEAD methods to this route.
[ "Head", "adds", "a", "handler", "for", "HEAD", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L578-L581
143,156
AndrewBurian/powermux
route.go
HeadFunc
func (r *Route) HeadFunc(f http.HandlerFunc) *Route { return r.Head(http.HandlerFunc(f)) }
go
func (r *Route) HeadFunc(f http.HandlerFunc) *Route { return r.Head(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "HeadFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Head", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// HeadFunc adds a plain function as a handler // for HEAD methods to this route.
[ "HeadFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "HEAD", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L585-L587
143,157
AndrewBurian/powermux
route.go
Connect
func (r *Route) Connect(handler http.Handler) *Route { r.handlers[http.MethodConnect] = handler return r }
go
func (r *Route) Connect(handler http.Handler) *Route { r.handlers[http.MethodConnect] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Connect", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodConnect", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Connect adds a handler for CONNECT methods to this route.
[ "Connect", "adds", "a", "handler", "for", "CONNECT", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L590-L593
143,158
AndrewBurian/powermux
route.go
ConnectFunc
func (r *Route) ConnectFunc(f http.HandlerFunc) *Route { return r.Connect(http.HandlerFunc(f)) }
go
func (r *Route) ConnectFunc(f http.HandlerFunc) *Route { return r.Connect(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "ConnectFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Connect", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// ConnectFunc adds a plain function as a handler // for CONNECT methods to this route.
[ "ConnectFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "CONNECT", "methods", "to", "this", "route", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L597-L599
143,159
AndrewBurian/powermux
route.go
Options
func (r *Route) Options(handler http.Handler) *Route { r.handlers[http.MethodOptions] = handler return r }
go
func (r *Route) Options(handler http.Handler) *Route { r.handlers[http.MethodOptions] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "Options", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "http", ".", "MethodOptions", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// Options adds a handler for OPTIONS methods to this route. // This handler will also be called for any routes further down the path // from this point if no other OPTIONS handlers are registered below.
[ "Options", "adds", "a", "handler", "for", "OPTIONS", "methods", "to", "this", "route", ".", "This", "handler", "will", "also", "be", "called", "for", "any", "routes", "further", "down", "the", "path", "from", "this", "point", "if", "no", "other", "OPTIONS"...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L604-L607
143,160
AndrewBurian/powermux
route.go
OptionsFunc
func (r *Route) OptionsFunc(f http.HandlerFunc) *Route { return r.Options(http.HandlerFunc(f)) }
go
func (r *Route) OptionsFunc(f http.HandlerFunc) *Route { return r.Options(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "OptionsFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "Options", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// OptionsFunc adds a plain function as a handler // for OPTIONS methods to this route. // This handler will also be called for any routes further down the path // from this point if no other OPTIONS handlers are registered below.
[ "OptionsFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "OPTIONS", "methods", "to", "this", "route", ".", "This", "handler", "will", "also", "be", "called", "for", "any", "routes", "further", "down", "the", "path", "from", "this", "po...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L613-L615
143,161
AndrewBurian/powermux
route.go
NotFound
func (r *Route) NotFound(handler http.Handler) *Route { r.handlers[notFound] = handler return r }
go
func (r *Route) NotFound(handler http.Handler) *Route { r.handlers[notFound] = handler return r }
[ "func", "(", "r", "*", "Route", ")", "NotFound", "(", "handler", "http", ".", "Handler", ")", "*", "Route", "{", "r", ".", "handlers", "[", "notFound", "]", "=", "handler", "\n", "return", "r", "\n", "}" ]
// NotFound adds a handler for requests that do not correspond to a route. // This handler will also be called for any routes further down the path // from this point if no other not found handlers are registered below.
[ "NotFound", "adds", "a", "handler", "for", "requests", "that", "do", "not", "correspond", "to", "a", "route", ".", "This", "handler", "will", "also", "be", "called", "for", "any", "routes", "further", "down", "the", "path", "from", "this", "point", "if", ...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L620-L623
143,162
AndrewBurian/powermux
route.go
NotFoundFunc
func (r *Route) NotFoundFunc(f http.HandlerFunc) *Route { return r.NotFound(http.HandlerFunc(f)) }
go
func (r *Route) NotFoundFunc(f http.HandlerFunc) *Route { return r.NotFound(http.HandlerFunc(f)) }
[ "func", "(", "r", "*", "Route", ")", "NotFoundFunc", "(", "f", "http", ".", "HandlerFunc", ")", "*", "Route", "{", "return", "r", ".", "NotFound", "(", "http", ".", "HandlerFunc", "(", "f", ")", ")", "\n", "}" ]
// NotFoundFunc adds a plain function as a handler for requests // that do not correspond to a route. // This handler will also be called for any routes further down the path // from this point if no other not found handlers are registered below.
[ "NotFoundFunc", "adds", "a", "plain", "function", "as", "a", "handler", "for", "requests", "that", "do", "not", "correspond", "to", "a", "route", ".", "This", "handler", "will", "also", "be", "called", "for", "any", "routes", "further", "down", "the", "pat...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/route.go#L629-L631
143,163
AndrewBurian/powermux
example/user_handler.go
Setup
func (h *UserHandler) Setup(r *powermux.Route) { // using path parameters // these functions don't know or care what the route is above them r.Route("/:id").GetFunc(h.Get) // use the root of this section of the route tree r.PostFunc(h.CreateUser) }
go
func (h *UserHandler) Setup(r *powermux.Route) { // using path parameters // these functions don't know or care what the route is above them r.Route("/:id").GetFunc(h.Get) // use the root of this section of the route tree r.PostFunc(h.CreateUser) }
[ "func", "(", "h", "*", "UserHandler", ")", "Setup", "(", "r", "*", "powermux", ".", "Route", ")", "{", "// using path parameters", "// these functions don't know or care what the route is above them", "r", ".", "Route", "(", "\"", "\"", ")", ".", "GetFunc", "(", ...
// Sets up a user handler with all the required functions // // Note that this function takes a powermux Route, not the entire ServeMux. This is so that it can be agnostic // about the path leading up to it, but still have complete control over it's section of the route tree.
[ "Sets", "up", "a", "user", "handler", "with", "all", "the", "required", "functions", "Note", "that", "this", "function", "takes", "a", "powermux", "Route", "not", "the", "entire", "ServeMux", ".", "This", "is", "so", "that", "it", "can", "be", "agnostic", ...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/example/user_handler.go#L24-L32
143,164
AndrewBurian/powermux
servemux.go
PathParams
func PathParams(req *http.Request) (params map[string]string) { ex := getRequestExecution(req) params = make(map[string]string) for k, v := range ex.params { params[k] = v } return }
go
func PathParams(req *http.Request) (params map[string]string) { ex := getRequestExecution(req) params = make(map[string]string) for k, v := range ex.params { params[k] = v } return }
[ "func", "PathParams", "(", "req", "*", "http", ".", "Request", ")", "(", "params", "map", "[", "string", "]", "string", ")", "{", "ex", ":=", "getRequestExecution", "(", "req", ")", "\n", "params", "=", "make", "(", "map", "[", "string", "]", "string...
// PathParams returns the map of all path parameters and their values from the request. // // Altering the values of this map will not affect future calls to PathParam and PathParams.
[ "PathParams", "returns", "the", "map", "of", "all", "path", "parameters", "and", "their", "values", "from", "the", "request", ".", "Altering", "the", "values", "of", "this", "map", "will", "not", "affect", "future", "calls", "to", "PathParam", "and", "PathPa...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L41-L48
143,165
AndrewBurian/powermux
servemux.go
RequestPath
func RequestPath(req *http.Request) (value string) { ex := getRequestExecution(req) return ex.pattern }
go
func RequestPath(req *http.Request) (value string) { ex := getRequestExecution(req) return ex.pattern }
[ "func", "RequestPath", "(", "req", "*", "http", ".", "Request", ")", "(", "value", "string", ")", "{", "ex", ":=", "getRequestExecution", "(", "req", ")", "\n", "return", "ex", ".", "pattern", "\n", "}" ]
// RequestPath returns the path definition that the router used to serve this request, // without any parameter substitution.
[ "RequestPath", "returns", "the", "path", "definition", "that", "the", "router", "used", "to", "serve", "this", "request", "without", "any", "parameter", "substitution", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L52-L55
143,166
AndrewBurian/powermux
servemux.go
NewServeMux
func NewServeMux() *ServeMux { s := &ServeMux{ baseRoute: newRoute(), hostRoutes: make(map[string]*Route), executionPool: newExecutionPool(), } s.NotFound(http.NotFoundHandler()) return s }
go
func NewServeMux() *ServeMux { s := &ServeMux{ baseRoute: newRoute(), hostRoutes: make(map[string]*Route), executionPool: newExecutionPool(), } s.NotFound(http.NotFoundHandler()) return s }
[ "func", "NewServeMux", "(", ")", "*", "ServeMux", "{", "s", ":=", "&", "ServeMux", "{", "baseRoute", ":", "newRoute", "(", ")", ",", "hostRoutes", ":", "make", "(", "map", "[", "string", "]", "*", "Route", ")", ",", "executionPool", ":", "newExecutionP...
// NewServeMux creates a new multiplexer, and sets up a default not found handler
[ "NewServeMux", "creates", "a", "new", "multiplexer", "and", "sets", "up", "a", "default", "not", "found", "handler" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L58-L66
143,167
AndrewBurian/powermux
servemux.go
ServeHTTP
func (s *ServeMux) ServeHTTP(rw http.ResponseWriter, req *http.Request) { // Get a route execution from the pool ex := s.executionPool.Get() s.getAll(req, ex) // Save the execution ctx := context.WithValue(req.Context(), executionKey, ex) // Save context into request req = req.WithContext(ctx) // Run a midd...
go
func (s *ServeMux) ServeHTTP(rw http.ResponseWriter, req *http.Request) { // Get a route execution from the pool ex := s.executionPool.Get() s.getAll(req, ex) // Save the execution ctx := context.WithValue(req.Context(), executionKey, ex) // Save context into request req = req.WithContext(ctx) // Run a midd...
[ "func", "(", "s", "*", "ServeMux", ")", "ServeHTTP", "(", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "// Get a route execution from the pool", "ex", ":=", "s", ".", "executionPool", ".", "Get", "(", ")", "\n\n",...
// ServeHTTP dispatches the request to the handler whose pattern most closely matches the request URL.
[ "ServeHTTP", "dispatches", "the", "request", "to", "the", "handler", "whose", "pattern", "most", "closely", "matches", "the", "request", "URL", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L95-L112
143,168
AndrewBurian/powermux
servemux.go
Handle
func (s *ServeMux) Handle(path string, handler http.Handler) { s.Route(path).Any(handler) }
go
func (s *ServeMux) Handle(path string, handler http.Handler) { s.Route(path).Any(handler) }
[ "func", "(", "s", "*", "ServeMux", ")", "Handle", "(", "path", "string", ",", "handler", "http", ".", "Handler", ")", "{", "s", ".", "Route", "(", "path", ")", ".", "Any", "(", "handler", ")", "\n", "}" ]
// Handle registers the handler for the given pattern. // If a handler already exists for pattern it is overwritten.
[ "Handle", "registers", "the", "handler", "for", "the", "given", "pattern", ".", "If", "a", "handler", "already", "exists", "for", "pattern", "it", "is", "overwritten", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L116-L118
143,169
AndrewBurian/powermux
servemux.go
HandleHost
func (s *ServeMux) HandleHost(host, path string, handler http.Handler) { s.RouteHost(host, path).Any(handler) }
go
func (s *ServeMux) HandleHost(host, path string, handler http.Handler) { s.RouteHost(host, path).Any(handler) }
[ "func", "(", "s", "*", "ServeMux", ")", "HandleHost", "(", "host", ",", "path", "string", ",", "handler", "http", ".", "Handler", ")", "{", "s", ".", "RouteHost", "(", "host", ",", "path", ")", ".", "Any", "(", "handler", ")", "\n", "}" ]
// HandleHost registers the handler for the given pattern and host. // If a handler already exists for pattern it is overwritten.
[ "HandleHost", "registers", "the", "handler", "for", "the", "given", "pattern", "and", "host", ".", "If", "a", "handler", "already", "exists", "for", "pattern", "it", "is", "overwritten", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L122-L124
143,170
AndrewBurian/powermux
servemux.go
Middleware
func (s *ServeMux) Middleware(path string, middleware Middleware) { s.Route(path).Middleware(middleware) }
go
func (s *ServeMux) Middleware(path string, middleware Middleware) { s.Route(path).Middleware(middleware) }
[ "func", "(", "s", "*", "ServeMux", ")", "Middleware", "(", "path", "string", ",", "middleware", "Middleware", ")", "{", "s", ".", "Route", "(", "path", ")", ".", "Middleware", "(", "middleware", ")", "\n", "}" ]
// Middleware adds middleware for the given pattern.
[ "Middleware", "adds", "middleware", "for", "the", "given", "pattern", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L127-L129
143,171
AndrewBurian/powermux
servemux.go
MiddlewareHost
func (s *ServeMux) MiddlewareHost(host, path string, middleware Middleware) { s.RouteHost(host, path).Middleware(middleware) }
go
func (s *ServeMux) MiddlewareHost(host, path string, middleware Middleware) { s.RouteHost(host, path).Middleware(middleware) }
[ "func", "(", "s", "*", "ServeMux", ")", "MiddlewareHost", "(", "host", ",", "path", "string", ",", "middleware", "Middleware", ")", "{", "s", ".", "RouteHost", "(", "host", ",", "path", ")", ".", "Middleware", "(", "middleware", ")", "\n", "}" ]
// MiddlewareHost adds middleware for the given pattern.
[ "MiddlewareHost", "adds", "middleware", "for", "the", "given", "pattern", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L153-L155
143,172
AndrewBurian/powermux
servemux.go
HandleFunc
func (s *ServeMux) HandleFunc(path string, handler func(http.ResponseWriter, *http.Request)) { s.Handle(path, http.HandlerFunc(handler)) }
go
func (s *ServeMux) HandleFunc(path string, handler func(http.ResponseWriter, *http.Request)) { s.Handle(path, http.HandlerFunc(handler)) }
[ "func", "(", "s", "*", "ServeMux", ")", "HandleFunc", "(", "path", "string", ",", "handler", "func", "(", "http", ".", "ResponseWriter", ",", "*", "http", ".", "Request", ")", ")", "{", "s", ".", "Handle", "(", "path", ",", "http", ".", "HandlerFunc"...
// HandleFunc registers the handler function for the given pattern.
[ "HandleFunc", "registers", "the", "handler", "function", "for", "the", "given", "pattern", "." ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L158-L160
143,173
AndrewBurian/powermux
servemux.go
HandlerAndMiddleware
func (s *ServeMux) HandlerAndMiddleware(r *http.Request) (http.Handler, []Middleware, string) { // create a new execution so fields will live outside of this function ex := newExecution() s.getAll(r, ex) return ex.handler, ex.middleware, ex.pattern }
go
func (s *ServeMux) HandlerAndMiddleware(r *http.Request) (http.Handler, []Middleware, string) { // create a new execution so fields will live outside of this function ex := newExecution() s.getAll(r, ex) return ex.handler, ex.middleware, ex.pattern }
[ "func", "(", "s", "*", "ServeMux", ")", "HandlerAndMiddleware", "(", "r", "*", "http", ".", "Request", ")", "(", "http", ".", "Handler", ",", "[", "]", "Middleware", ",", "string", ")", "{", "// create a new execution so fields will live outside of this function",...
// HandlerAndMiddleware returns the same as Handler, but with the addition of an array of middleware, in the order // they would have been executed
[ "HandlerAndMiddleware", "returns", "the", "same", "as", "Handler", "but", "with", "the", "addition", "of", "an", "array", "of", "middleware", "in", "the", "order", "they", "would", "have", "been", "executed" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L178-L183
143,174
AndrewBurian/powermux
servemux.go
Route
func (s *ServeMux) Route(path string) *Route { return s.baseRoute.Route(path) }
go
func (s *ServeMux) Route(path string) *Route { return s.baseRoute.Route(path) }
[ "func", "(", "s", "*", "ServeMux", ")", "Route", "(", "path", "string", ")", "*", "Route", "{", "return", "s", ".", "baseRoute", ".", "Route", "(", "path", ")", "\n", "}" ]
// Route returns the route from the root of the domain to the given pattern
[ "Route", "returns", "the", "route", "from", "the", "root", "of", "the", "domain", "to", "the", "given", "pattern" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L186-L188
143,175
AndrewBurian/powermux
servemux.go
RouteHost
func (s *ServeMux) RouteHost(host, path string) *Route { r, ok := s.hostRoutes[host] if !ok { r = newRoute() s.hostRoutes[host] = r } return r.Route(path) }
go
func (s *ServeMux) RouteHost(host, path string) *Route { r, ok := s.hostRoutes[host] if !ok { r = newRoute() s.hostRoutes[host] = r } return r.Route(path) }
[ "func", "(", "s", "*", "ServeMux", ")", "RouteHost", "(", "host", ",", "path", "string", ")", "*", "Route", "{", "r", ",", "ok", ":=", "s", ".", "hostRoutes", "[", "host", "]", "\n", "if", "!", "ok", "{", "r", "=", "newRoute", "(", ")", "\n", ...
// RouteHost returns the route from the root of the domain to the given pattern on a specific domain
[ "RouteHost", "returns", "the", "route", "from", "the", "root", "of", "the", "domain", "to", "the", "given", "pattern", "on", "a", "specific", "domain" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L191-L198
143,176
AndrewBurian/powermux
servemux.go
NotFound
func (s *ServeMux) NotFound(handler http.Handler) { s.baseRoute.NotFound(handler) }
go
func (s *ServeMux) NotFound(handler http.Handler) { s.baseRoute.NotFound(handler) }
[ "func", "(", "s", "*", "ServeMux", ")", "NotFound", "(", "handler", "http", ".", "Handler", ")", "{", "s", ".", "baseRoute", ".", "NotFound", "(", "handler", ")", "\n", "}" ]
// NotFound sets the default not found handler for the server
[ "NotFound", "sets", "the", "default", "not", "found", "handler", "for", "the", "server" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L201-L203
143,177
AndrewBurian/powermux
servemux.go
String
func (s *ServeMux) String() string { routes := make([]string, 0, 1) s.baseRoute.stringRoutes(&routes) buf := bytes.Buffer{} for _, route := range routes { buf.WriteString(route + "\n") } for host, baseRoute := range s.hostRoutes { routes = routes[0:0] baseRoute.stringRoutes(&routes) for _, route := ran...
go
func (s *ServeMux) String() string { routes := make([]string, 0, 1) s.baseRoute.stringRoutes(&routes) buf := bytes.Buffer{} for _, route := range routes { buf.WriteString(route + "\n") } for host, baseRoute := range s.hostRoutes { routes = routes[0:0] baseRoute.stringRoutes(&routes) for _, route := ran...
[ "func", "(", "s", "*", "ServeMux", ")", "String", "(", ")", "string", "{", "routes", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "1", ")", "\n", "s", ".", "baseRoute", ".", "stringRoutes", "(", "&", "routes", ")", "\n\n", "buf", ":=", ...
// String returns a list of all routes registered with this server
[ "String", "returns", "a", "list", "of", "all", "routes", "registered", "with", "this", "server" ]
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/servemux.go#L206-L225
143,178
AndrewBurian/powermux
middleware.go
getNextMiddleware
func getNextMiddleware(mids []Middleware, h http.Handler) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { if len(mids) > 0 { mids[0].ServeHTTPMiddleware(w, r, getNextMiddleware(mids[1:], h)) } else { h.ServeHTTP(w, r) } } }
go
func getNextMiddleware(mids []Middleware, h http.Handler) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { if len(mids) > 0 { mids[0].ServeHTTPMiddleware(w, r, getNextMiddleware(mids[1:], h)) } else { h.ServeHTTP(w, r) } } }
[ "func", "getNextMiddleware", "(", "mids", "[", "]", "Middleware", ",", "h", "http", ".", "Handler", ")", "func", "(", "http", ".", "ResponseWriter", ",", "*", "http", ".", "Request", ")", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ...
// getNextMiddleware returns the first middleware of a recursive closure. // The returned middleware will have the next middleware in the array available to it as a parameter // and the last middleware will have the final handler.
[ "getNextMiddleware", "returns", "the", "first", "middleware", "of", "a", "recursive", "closure", ".", "The", "returned", "middleware", "will", "have", "the", "next", "middleware", "in", "the", "array", "available", "to", "it", "as", "a", "parameter", "and", "t...
d905ec837601bedbff48f47b476c6e16f232721d
https://github.com/AndrewBurian/powermux/blob/d905ec837601bedbff48f47b476c6e16f232721d/middleware.go#L25-L33
143,179
mitchellh/go-fs
fat/cluster_chain.go
Write
func (c *ClusterChain) Write(p []byte) (n int, err error) { bpc := c.fat.bs.BytesPerCluster() chain := c.fat.Chain(c.startCluster) chainLength := uint32(len(chain)) * bpc if chainLength < c.writeOffset+uint32(len(p)) { // We need to grow the chain bytesNeeded := (c.writeOffset + uint32(len(p))) - chainLength ...
go
func (c *ClusterChain) Write(p []byte) (n int, err error) { bpc := c.fat.bs.BytesPerCluster() chain := c.fat.Chain(c.startCluster) chainLength := uint32(len(chain)) * bpc if chainLength < c.writeOffset+uint32(len(p)) { // We need to grow the chain bytesNeeded := (c.writeOffset + uint32(len(p))) - chainLength ...
[ "func", "(", "c", "*", "ClusterChain", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "bpc", ":=", "c", ".", "fat", ".", "bs", ".", "BytesPerCluster", "(", ")", "\n", "chain", ":=", "c", ".", "f...
// Write will write to the cluster chain, expanding it if necessary.
[ "Write", "will", "write", "to", "the", "cluster", "chain", "expanding", "it", "if", "necessary", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/cluster_chain.go#L51-L92
143,180
mitchellh/go-fs
fat/filesystem.go
New
func New(device fs.BlockDevice) (*FileSystem, error) { bs, err := DecodeBootSector(device) if err != nil { return nil, err } fat, err := DecodeFAT(device, bs, 0) if err != nil { return nil, err } var rootDir *DirectoryCluster if bs.FATType() == FAT32 { panic("FAT32 not implemented yet") } else { root...
go
func New(device fs.BlockDevice) (*FileSystem, error) { bs, err := DecodeBootSector(device) if err != nil { return nil, err } fat, err := DecodeFAT(device, bs, 0) if err != nil { return nil, err } var rootDir *DirectoryCluster if bs.FATType() == FAT32 { panic("FAT32 not implemented yet") } else { root...
[ "func", "New", "(", "device", "fs", ".", "BlockDevice", ")", "(", "*", "FileSystem", ",", "error", ")", "{", "bs", ",", "err", ":=", "DecodeBootSector", "(", "device", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// New returns a new FileSystem for accessing a previously created // FAT filesystem.
[ "New", "returns", "a", "new", "FileSystem", "for", "accessing", "a", "previously", "created", "FAT", "filesystem", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/filesystem.go#L18-L47
143,181
mitchellh/go-fs
fat/directory.go
DecodeDirectoryEntry
func DecodeDirectoryEntry(d *Directory, entries []*DirectoryClusterEntry) (*DirectoryEntry, []*DirectoryClusterEntry, error) { var lfnEntries []*DirectoryClusterEntry var entry *DirectoryClusterEntry var name string // Skip all the deleted entries for len(entries) > 0 && entries[0].deleted { entries = entries[1...
go
func DecodeDirectoryEntry(d *Directory, entries []*DirectoryClusterEntry) (*DirectoryEntry, []*DirectoryClusterEntry, error) { var lfnEntries []*DirectoryClusterEntry var entry *DirectoryClusterEntry var name string // Skip all the deleted entries for len(entries) > 0 && entries[0].deleted { entries = entries[1...
[ "func", "DecodeDirectoryEntry", "(", "d", "*", "Directory", ",", "entries", "[", "]", "*", "DirectoryClusterEntry", ")", "(", "*", "DirectoryEntry", ",", "[", "]", "*", "DirectoryClusterEntry", ",", "error", ")", "{", "var", "lfnEntries", "[", "]", "*", "D...
// DecodeDirectoryEntry takes a list of entries, decodes the next full // DirectoryEntry, and returns the newly created entry, the remaining // entries, and an error, if there was one.
[ "DecodeDirectoryEntry", "takes", "a", "list", "of", "entries", "decodes", "the", "next", "full", "DirectoryEntry", "and", "returns", "the", "newly", "created", "entry", "the", "remaining", "entries", "and", "an", "error", "if", "there", "was", "one", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/directory.go#L34-L98
143,182
mitchellh/go-fs
fat/super_floppy.go
FormatSuperFloppy
func FormatSuperFloppy(device fs.BlockDevice, config *SuperFloppyConfig) error { formatter := &superFloppyFormatter{ config: config, device: device, } return formatter.format() }
go
func FormatSuperFloppy(device fs.BlockDevice, config *SuperFloppyConfig) error { formatter := &superFloppyFormatter{ config: config, device: device, } return formatter.format() }
[ "func", "FormatSuperFloppy", "(", "device", "fs", ".", "BlockDevice", ",", "config", "*", "SuperFloppyConfig", ")", "error", "{", "formatter", ":=", "&", "superFloppyFormatter", "{", "config", ":", "config", ",", "device", ":", "device", ",", "}", "\n\n", "r...
// Formats an fs.BlockDevice with the "super floppy" format according // to the given configuration. The "super floppy" standard means that the // device will be formatted so that it does not contain a partition table. // Instead, the entire device holds a single FAT file system.
[ "Formats", "an", "fs", ".", "BlockDevice", "with", "the", "super", "floppy", "format", "according", "to", "the", "given", "configuration", ".", "The", "super", "floppy", "standard", "means", "that", "the", "device", "will", "be", "formatted", "so", "that", "...
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/super_floppy.go#L29-L36
143,183
mitchellh/go-fs
fat/fat.go
NewFAT
func NewFAT(bs *BootSectorCommon) (*FAT, error) { result := &FAT{ bs: bs, entries: make([]uint32, FATEntryCount(bs)), } // Set the initial two entries according to spec result.entries[0] = (uint32(bs.Media) & 0xFF) | (0xFFFFFF00 & result.entryMask()) result.entries[1] = 0xFFFFFFFF & result.entryMask() ...
go
func NewFAT(bs *BootSectorCommon) (*FAT, error) { result := &FAT{ bs: bs, entries: make([]uint32, FATEntryCount(bs)), } // Set the initial two entries according to spec result.entries[0] = (uint32(bs.Media) & 0xFF) | (0xFFFFFF00 & result.entryMask()) result.entries[1] = 0xFFFFFFFF & result.entryMask() ...
[ "func", "NewFAT", "(", "bs", "*", "BootSectorCommon", ")", "(", "*", "FAT", ",", "error", ")", "{", "result", ":=", "&", "FAT", "{", "bs", ":", "bs", ",", "entries", ":", "make", "(", "[", "]", "uint32", ",", "FATEntryCount", "(", "bs", ")", ")",...
// NewFAT creates a new FAT data structure, properly initialized.
[ "NewFAT", "creates", "a", "new", "FAT", "data", "structure", "properly", "initialized", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/fat.go#L55-L67
143,184
mitchellh/go-fs
fat/fat.go
Bytes
func (f *FAT) Bytes() []byte { result := make([]byte, f.bs.SectorsPerFat*uint32(f.bs.BytesPerSector)) for i, entry := range f.entries { switch f.bs.FATType() { case FAT12: f.writeEntry12(result, i, entry) case FAT16: f.writeEntry16(result, i, entry) default: f.writeEntry32(result, i, entry) } } ...
go
func (f *FAT) Bytes() []byte { result := make([]byte, f.bs.SectorsPerFat*uint32(f.bs.BytesPerSector)) for i, entry := range f.entries { switch f.bs.FATType() { case FAT12: f.writeEntry12(result, i, entry) case FAT16: f.writeEntry16(result, i, entry) default: f.writeEntry32(result, i, entry) } } ...
[ "func", "(", "f", "*", "FAT", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "result", ":=", "make", "(", "[", "]", "byte", ",", "f", ".", "bs", ".", "SectorsPerFat", "*", "uint32", "(", "f", ".", "bs", ".", "BytesPerSector", ")", ")", "\n\n", ...
// Bytes returns the raw bytes for the FAT that should be written to // the block device.
[ "Bytes", "returns", "the", "raw", "bytes", "for", "the", "FAT", "that", "should", "be", "written", "to", "the", "block", "device", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/fat.go#L71-L86
143,185
mitchellh/go-fs
fat/fat.go
Chain
func (f *FAT) Chain(start uint32) []uint32 { chain := make([]uint32, 0, 2) cluster := start for { chain = append(chain, cluster) cluster = f.entries[cluster] if f.isEofCluster(cluster) || cluster == 0 { break } } return chain }
go
func (f *FAT) Chain(start uint32) []uint32 { chain := make([]uint32, 0, 2) cluster := start for { chain = append(chain, cluster) cluster = f.entries[cluster] if f.isEofCluster(cluster) || cluster == 0 { break } } return chain }
[ "func", "(", "f", "*", "FAT", ")", "Chain", "(", "start", "uint32", ")", "[", "]", "uint32", "{", "chain", ":=", "make", "(", "[", "]", "uint32", ",", "0", ",", "2", ")", "\n\n", "cluster", ":=", "start", "\n", "for", "{", "chain", "=", "append...
// Chain returns the chain of clusters starting at a certain cluster.
[ "Chain", "returns", "the", "chain", "of", "clusters", "starting", "at", "a", "certain", "cluster", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/fat.go#L119-L133
143,186
mitchellh/go-fs
fat/fat.go
ResizeChain
func (f *FAT) ResizeChain(start uint32, length int) ([]uint32, error) { chain := f.Chain(start) if len(chain) == length { return chain, nil } change := int(math.Abs(float64(length - len(chain)))) if length > len(chain) { var lastCluster uint32 lastCluster = chain[0] for i := 1; i < len(chain); i++ { i...
go
func (f *FAT) ResizeChain(start uint32, length int) ([]uint32, error) { chain := f.Chain(start) if len(chain) == length { return chain, nil } change := int(math.Abs(float64(length - len(chain)))) if length > len(chain) { var lastCluster uint32 lastCluster = chain[0] for i := 1; i < len(chain); i++ { i...
[ "func", "(", "f", "*", "FAT", ")", "ResizeChain", "(", "start", "uint32", ",", "length", "int", ")", "(", "[", "]", "uint32", ",", "error", ")", "{", "chain", ":=", "f", ".", "Chain", "(", "start", ")", "\n", "if", "len", "(", "chain", ")", "==...
// ResizeChain takes a given cluster number and resizes the chain // to the given length. It returns the new chain of clusters.
[ "ResizeChain", "takes", "a", "given", "cluster", "number", "and", "resizes", "the", "chain", "to", "the", "given", "length", ".", "It", "returns", "the", "new", "chain", "of", "clusters", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/fat.go#L137-L170
143,187
mitchellh/go-fs
fat/fat.go
FATEntryCount
func FATEntryCount(bs *BootSectorCommon) uint32 { // Determine the number of entries that'll go in the FAT. var entryCount uint32 = bs.SectorsPerFat * uint32(bs.BytesPerSector) switch bs.FATType() { case FAT12: entryCount = uint32((uint64(entryCount) * 8) / 12) case FAT16: entryCount /= 2 case FAT32: entryC...
go
func FATEntryCount(bs *BootSectorCommon) uint32 { // Determine the number of entries that'll go in the FAT. var entryCount uint32 = bs.SectorsPerFat * uint32(bs.BytesPerSector) switch bs.FATType() { case FAT12: entryCount = uint32((uint64(entryCount) * 8) / 12) case FAT16: entryCount /= 2 case FAT32: entryC...
[ "func", "FATEntryCount", "(", "bs", "*", "BootSectorCommon", ")", "uint32", "{", "// Determine the number of entries that'll go in the FAT.", "var", "entryCount", "uint32", "=", "bs", ".", "SectorsPerFat", "*", "uint32", "(", "bs", ".", "BytesPerSector", ")", "\n", ...
// FATEntryCount returns the number of entries per fat for the given // boot sector.
[ "FATEntryCount", "returns", "the", "number", "of", "entries", "per", "fat", "for", "the", "given", "boot", "sector", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/fat.go#L230-L245
143,188
mitchellh/go-fs
fat/type.go
TypeForDevice
func TypeForDevice(device fs.BlockDevice) FATType { sizeInMB := device.Len() / (1024 * 1024) switch { case sizeInMB < 4: return FAT12 case sizeInMB < 512: return FAT16 default: return FAT32 } }
go
func TypeForDevice(device fs.BlockDevice) FATType { sizeInMB := device.Len() / (1024 * 1024) switch { case sizeInMB < 4: return FAT12 case sizeInMB < 512: return FAT16 default: return FAT32 } }
[ "func", "TypeForDevice", "(", "device", "fs", ".", "BlockDevice", ")", "FATType", "{", "sizeInMB", ":=", "device", ".", "Len", "(", ")", "/", "(", "1024", "*", "1024", ")", "\n", "switch", "{", "case", "sizeInMB", "<", "4", ":", "return", "FAT12", "\...
// TypeForDevice determines the usable FAT type based solely on // size information about the block device.
[ "TypeForDevice", "determines", "the", "usable", "FAT", "type", "based", "solely", "on", "size", "information", "about", "the", "block", "device", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/type.go#L16-L26
143,189
mitchellh/go-fs
fat/boot_sector.go
DecodeBootSector
func DecodeBootSector(device fs.BlockDevice) (*BootSectorCommon, error) { var sector [512]byte if _, err := device.ReadAt(sector[:], 0); err != nil { return nil, err } if sector[510] != 0x55 || sector[511] != 0xAA { return nil, errors.New("corrupt boot sector signature") } result := new(BootSectorCommon) ...
go
func DecodeBootSector(device fs.BlockDevice) (*BootSectorCommon, error) { var sector [512]byte if _, err := device.ReadAt(sector[:], 0); err != nil { return nil, err } if sector[510] != 0x55 || sector[511] != 0xAA { return nil, errors.New("corrupt boot sector signature") } result := new(BootSectorCommon) ...
[ "func", "DecodeBootSector", "(", "device", "fs", ".", "BlockDevice", ")", "(", "*", "BootSectorCommon", ",", "error", ")", "{", "var", "sector", "[", "512", "]", "byte", "\n", "if", "_", ",", "err", ":=", "device", ".", "ReadAt", "(", "sector", "[", ...
// DecodeBootSector takes a BlockDevice and decodes the FAT boot sector // from it.
[ "DecodeBootSector", "takes", "a", "BlockDevice", "and", "decodes", "the", "FAT", "boot", "sector", "from", "it", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/boot_sector.go#L34-L86
143,190
mitchellh/go-fs
fat/boot_sector.go
BytesPerCluster
func (b *BootSectorCommon) BytesPerCluster() uint32 { return uint32(b.SectorsPerCluster) * uint32(b.BytesPerSector) }
go
func (b *BootSectorCommon) BytesPerCluster() uint32 { return uint32(b.SectorsPerCluster) * uint32(b.BytesPerSector) }
[ "func", "(", "b", "*", "BootSectorCommon", ")", "BytesPerCluster", "(", ")", "uint32", "{", "return", "uint32", "(", "b", ".", "SectorsPerCluster", ")", "*", "uint32", "(", "b", ".", "BytesPerSector", ")", "\n", "}" ]
// BytesPerCluster returns the number of bytes per cluster.
[ "BytesPerCluster", "returns", "the", "number", "of", "bytes", "per", "cluster", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/boot_sector.go#L144-L146
143,191
mitchellh/go-fs
fat/boot_sector.go
ClusterOffset
func (b *BootSectorCommon) ClusterOffset(n int) uint32 { offset := b.DataOffset() offset += (uint32(n) - FirstCluster) * b.BytesPerCluster() return offset }
go
func (b *BootSectorCommon) ClusterOffset(n int) uint32 { offset := b.DataOffset() offset += (uint32(n) - FirstCluster) * b.BytesPerCluster() return offset }
[ "func", "(", "b", "*", "BootSectorCommon", ")", "ClusterOffset", "(", "n", "int", ")", "uint32", "{", "offset", ":=", "b", ".", "DataOffset", "(", ")", "\n", "offset", "+=", "(", "uint32", "(", "n", ")", "-", "FirstCluster", ")", "*", "b", ".", "By...
// ClusterOffset returns the offset of the data section of a particular // cluster.
[ "ClusterOffset", "returns", "the", "offset", "of", "the", "data", "section", "of", "a", "particular", "cluster", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/boot_sector.go#L150-L154
143,192
mitchellh/go-fs
fat/boot_sector.go
DataOffset
func (b *BootSectorCommon) DataOffset() uint32 { offset := uint32(b.RootDirOffset()) offset += uint32(b.RootEntryCount * DirectoryEntrySize) return offset }
go
func (b *BootSectorCommon) DataOffset() uint32 { offset := uint32(b.RootDirOffset()) offset += uint32(b.RootEntryCount * DirectoryEntrySize) return offset }
[ "func", "(", "b", "*", "BootSectorCommon", ")", "DataOffset", "(", ")", "uint32", "{", "offset", ":=", "uint32", "(", "b", ".", "RootDirOffset", "(", ")", ")", "\n", "offset", "+=", "uint32", "(", "b", ".", "RootEntryCount", "*", "DirectoryEntrySize", ")...
// DataOffset returns the offset of the data section of the disk.
[ "DataOffset", "returns", "the", "offset", "of", "the", "data", "section", "of", "the", "disk", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/boot_sector.go#L157-L161
143,193
mitchellh/go-fs
fat/boot_sector.go
FATOffset
func (b *BootSectorCommon) FATOffset(n int) int { offset := uint32(b.ReservedSectorCount * b.BytesPerSector) offset += b.SectorsPerFat * uint32(b.BytesPerSector) * uint32(n) return int(offset) }
go
func (b *BootSectorCommon) FATOffset(n int) int { offset := uint32(b.ReservedSectorCount * b.BytesPerSector) offset += b.SectorsPerFat * uint32(b.BytesPerSector) * uint32(n) return int(offset) }
[ "func", "(", "b", "*", "BootSectorCommon", ")", "FATOffset", "(", "n", "int", ")", "int", "{", "offset", ":=", "uint32", "(", "b", ".", "ReservedSectorCount", "*", "b", ".", "BytesPerSector", ")", "\n", "offset", "+=", "b", ".", "SectorsPerFat", "*", "...
// FATOffset returns the offset in bytes for the given index of the FAT
[ "FATOffset", "returns", "the", "offset", "in", "bytes", "for", "the", "given", "index", "of", "the", "FAT" ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/boot_sector.go#L164-L168
143,194
mitchellh/go-fs
fat/boot_sector.go
FATType
func (b *BootSectorCommon) FATType() FATType { var rootDirSectors uint32 rootDirSectors = (uint32(b.RootEntryCount) * 32) + (uint32(b.BytesPerSector) - 1) rootDirSectors /= uint32(b.BytesPerSector) dataSectors := b.SectorsPerFat * uint32(b.NumFATs) dataSectors += uint32(b.ReservedSectorCount) dataSectors += rootD...
go
func (b *BootSectorCommon) FATType() FATType { var rootDirSectors uint32 rootDirSectors = (uint32(b.RootEntryCount) * 32) + (uint32(b.BytesPerSector) - 1) rootDirSectors /= uint32(b.BytesPerSector) dataSectors := b.SectorsPerFat * uint32(b.NumFATs) dataSectors += uint32(b.ReservedSectorCount) dataSectors += rootD...
[ "func", "(", "b", "*", "BootSectorCommon", ")", "FATType", "(", ")", "FATType", "{", "var", "rootDirSectors", "uint32", "\n", "rootDirSectors", "=", "(", "uint32", "(", "b", ".", "RootEntryCount", ")", "*", "32", ")", "+", "(", "uint32", "(", "b", ".",...
// Calculates the FAT type that this boot sector represents.
[ "Calculates", "the", "FAT", "type", "that", "this", "boot", "sector", "represents", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/boot_sector.go#L171-L189
143,195
mitchellh/go-fs
fat/directory_cluster.go
DecodeFAT16RootDirectoryCluster
func DecodeFAT16RootDirectoryCluster(device fs.BlockDevice, bs *BootSectorCommon) (*DirectoryCluster, error) { data := make([]byte, DirectoryEntrySize*bs.RootEntryCount) if _, err := device.ReadAt(data, int64(bs.RootDirOffset())); err != nil { return nil, err } result, err := decodeDirectoryCluster(data, bs) if...
go
func DecodeFAT16RootDirectoryCluster(device fs.BlockDevice, bs *BootSectorCommon) (*DirectoryCluster, error) { data := make([]byte, DirectoryEntrySize*bs.RootEntryCount) if _, err := device.ReadAt(data, int64(bs.RootDirOffset())); err != nil { return nil, err } result, err := decodeDirectoryCluster(data, bs) if...
[ "func", "DecodeFAT16RootDirectoryCluster", "(", "device", "fs", ".", "BlockDevice", ",", "bs", "*", "BootSectorCommon", ")", "(", "*", "DirectoryCluster", ",", "error", ")", "{", "data", ":=", "make", "(", "[", "]", "byte", ",", "DirectoryEntrySize", "*", "b...
// DecodeFAT16RootDirectory decodes the FAT16 root directory structure // from the device.
[ "DecodeFAT16RootDirectory", "decodes", "the", "FAT16", "root", "directory", "structure", "from", "the", "device", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/directory_cluster.go#L85-L98
143,196
mitchellh/go-fs
fat/directory_cluster.go
Bytes
func (d *DirectoryCluster) Bytes() []byte { result := make([]byte, cap(d.entries)*DirectoryEntrySize) for i, entry := range d.entries { offset := i * DirectoryEntrySize entryBytes := entry.Bytes() copy(result[offset:offset+DirectoryEntrySize], entryBytes) } return result }
go
func (d *DirectoryCluster) Bytes() []byte { result := make([]byte, cap(d.entries)*DirectoryEntrySize) for i, entry := range d.entries { offset := i * DirectoryEntrySize entryBytes := entry.Bytes() copy(result[offset:offset+DirectoryEntrySize], entryBytes) } return result }
[ "func", "(", "d", "*", "DirectoryCluster", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "result", ":=", "make", "(", "[", "]", "byte", ",", "cap", "(", "d", ".", "entries", ")", "*", "DirectoryEntrySize", ")", "\n\n", "for", "i", ",", "entry", ...
// Bytes returns the on-disk byte data for this directory structure.
[ "Bytes", "returns", "the", "on", "-", "disk", "byte", "data", "for", "this", "directory", "structure", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/directory_cluster.go#L173-L183
143,197
mitchellh/go-fs
fat/directory_cluster.go
WriteToDevice
func (d *DirectoryCluster) WriteToDevice(device fs.BlockDevice, fat *FAT) error { if d.fat16Root { // Write the cluster to the FAT16 root directory location offset := int64(fat.bs.RootDirOffset()) if _, err := device.WriteAt(d.Bytes(), offset); err != nil { return err } } else { chain := &ClusterChain{ ...
go
func (d *DirectoryCluster) WriteToDevice(device fs.BlockDevice, fat *FAT) error { if d.fat16Root { // Write the cluster to the FAT16 root directory location offset := int64(fat.bs.RootDirOffset()) if _, err := device.WriteAt(d.Bytes(), offset); err != nil { return err } } else { chain := &ClusterChain{ ...
[ "func", "(", "d", "*", "DirectoryCluster", ")", "WriteToDevice", "(", "device", "fs", ".", "BlockDevice", ",", "fat", "*", "FAT", ")", "error", "{", "if", "d", ".", "fat16Root", "{", "// Write the cluster to the FAT16 root directory location", "offset", ":=", "i...
// WriteToDevice writes the cluster to the device.
[ "WriteToDevice", "writes", "the", "cluster", "to", "the", "device", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/directory_cluster.go#L186-L206
143,198
mitchellh/go-fs
fat/directory_cluster.go
DecodeDirectoryClusterEntry
func DecodeDirectoryClusterEntry(data []byte) (*DirectoryClusterEntry, error) { var result DirectoryClusterEntry // Do the attributes so we can determine if we're dealing with long names result.attr = DirectoryAttr(data[11]) if (result.attr & AttrLongName) == AttrLongName { result.longOrd = data[0] chars := m...
go
func DecodeDirectoryClusterEntry(data []byte) (*DirectoryClusterEntry, error) { var result DirectoryClusterEntry // Do the attributes so we can determine if we're dealing with long names result.attr = DirectoryAttr(data[11]) if (result.attr & AttrLongName) == AttrLongName { result.longOrd = data[0] chars := m...
[ "func", "DecodeDirectoryClusterEntry", "(", "data", "[", "]", "byte", ")", "(", "*", "DirectoryClusterEntry", ",", "error", ")", "{", "var", "result", "DirectoryClusterEntry", "\n\n", "// Do the attributes so we can determine if we're dealing with long names", "result", "."...
// DecodeDirectoryClusterEntry decodes a single directory entry in the // Directory structure.
[ "DecodeDirectoryClusterEntry", "decodes", "a", "single", "directory", "entry", "in", "the", "Directory", "structure", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/directory_cluster.go#L312-L374
143,199
mitchellh/go-fs
fat/directory_cluster.go
NewLongDirectoryClusterEntry
func NewLongDirectoryClusterEntry(name string, shortName string) ([]*DirectoryClusterEntry, error) { // Split up the shortName properly checksum := checksumShortName(shortNameEntryValue(shortName)) // Calcualte the number of entries we'll actually need to store // the long name. numLongEntries := len(name) / 13 ...
go
func NewLongDirectoryClusterEntry(name string, shortName string) ([]*DirectoryClusterEntry, error) { // Split up the shortName properly checksum := checksumShortName(shortNameEntryValue(shortName)) // Calcualte the number of entries we'll actually need to store // the long name. numLongEntries := len(name) / 13 ...
[ "func", "NewLongDirectoryClusterEntry", "(", "name", "string", ",", "shortName", "string", ")", "(", "[", "]", "*", "DirectoryClusterEntry", ",", "error", ")", "{", "// Split up the shortName properly", "checksum", ":=", "checksumShortName", "(", "shortNameEntryValue", ...
// NewLongDirectoryClusterEntry returns the series of directory cluster // entries that need to be written for a long directory entry. This list // of entries does NOT contain the short name entry.
[ "NewLongDirectoryClusterEntry", "returns", "the", "series", "of", "directory", "cluster", "entries", "that", "need", "to", "be", "written", "for", "a", "long", "directory", "entry", ".", "This", "list", "of", "entries", "does", "NOT", "contain", "the", "short", ...
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/directory_cluster.go#L379-L413