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,200
mitchellh/go-fs
fat/short_name.go
checksumShortName
func checksumShortName(name string) uint8 { var sum uint8 = name[0] for i := uint8(1); i < 11; i++ { sum = name[i] + (((sum & 1) << 7) + ((sum & 0xFE) >> 1)) } return sum }
go
func checksumShortName(name string) uint8 { var sum uint8 = name[0] for i := uint8(1); i < 11; i++ { sum = name[i] + (((sum & 1) << 7) + ((sum & 0xFE) >> 1)) } return sum }
[ "func", "checksumShortName", "(", "name", "string", ")", "uint8", "{", "var", "sum", "uint8", "=", "name", "[", "0", "]", "\n", "for", "i", ":=", "uint8", "(", "1", ")", ";", "i", "<", "11", ";", "i", "++", "{", "sum", "=", "name", "[", "i", ...
// checksumShortName returns the checksum for the shortname that is used // for the long name entries.
[ "checksumShortName", "returns", "the", "checksum", "for", "the", "shortname", "that", "is", "used", "for", "the", "long", "name", "entries", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/short_name.go#L11-L18
143,201
mitchellh/go-fs
fat/short_name.go
generateShortName
func generateShortName(longName string, used []string) (string, error) { longName = strings.ToUpper(longName) // Split the string at the final "." dotIdx := strings.LastIndex(longName, ".") var ext string if dotIdx == -1 { dotIdx = len(longName) } else { ext = longName[dotIdx+1:] } ext = cleanShortString...
go
func generateShortName(longName string, used []string) (string, error) { longName = strings.ToUpper(longName) // Split the string at the final "." dotIdx := strings.LastIndex(longName, ".") var ext string if dotIdx == -1 { dotIdx = len(longName) } else { ext = longName[dotIdx+1:] } ext = cleanShortString...
[ "func", "generateShortName", "(", "longName", "string", ",", "used", "[", "]", "string", ")", "(", "string", ",", "error", ")", "{", "longName", "=", "strings", ".", "ToUpper", "(", "longName", ")", "\n\n", "// Split the string at the final \".\"", "dotIdx", "...
// generateShortName takes a list of existing short names and a long // name and generates the next valid short name. This process is done // according to the MS specification.
[ "generateShortName", "takes", "a", "list", "of", "existing", "short", "names", "and", "a", "long", "name", "and", "generates", "the", "next", "valid", "short", "name", ".", "This", "process", "is", "done", "according", "to", "the", "MS", "specification", "."...
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/short_name.go#L23-L91
143,202
mitchellh/go-fs
fat/short_name.go
shortNameEntryValue
func shortNameEntryValue(name string) string { var shortParts []string if name == "." || name == ".." { shortParts = []string{name, ""} } else { shortParts = strings.Split(name, ".") } if len(shortParts) == 1 { shortParts = append(shortParts, "") } if len(shortParts[0]) < 8 { var temp bytes.Buffer te...
go
func shortNameEntryValue(name string) string { var shortParts []string if name == "." || name == ".." { shortParts = []string{name, ""} } else { shortParts = strings.Split(name, ".") } if len(shortParts) == 1 { shortParts = append(shortParts, "") } if len(shortParts[0]) < 8 { var temp bytes.Buffer te...
[ "func", "shortNameEntryValue", "(", "name", "string", ")", "string", "{", "var", "shortParts", "[", "]", "string", "\n", "if", "name", "==", "\"", "\"", "||", "name", "==", "\"", "\"", "{", "shortParts", "=", "[", "]", "string", "{", "name", ",", "\"...
// shortNameEntryValue returns the proper formatted short name value // for the directory cluster entry.
[ "shortNameEntryValue", "returns", "the", "proper", "formatted", "short", "name", "value", "for", "the", "directory", "cluster", "entry", "." ]
b7b9ca407ffff465de12fc37ccbb81ea8b428c43
https://github.com/mitchellh/go-fs/blob/b7b9ca407ffff465de12fc37ccbb81ea8b428c43/fat/short_name.go#L95-L128
143,203
pseudomuto/protokit
utils/strings.go
InStringSlice
func InStringSlice(sl []string, val string) bool { for _, s := range sl { if s == val { return true } } return false }
go
func InStringSlice(sl []string, val string) bool { for _, s := range sl { if s == val { return true } } return false }
[ "func", "InStringSlice", "(", "sl", "[", "]", "string", ",", "val", "string", ")", "bool", "{", "for", "_", ",", "s", ":=", "range", "sl", "{", "if", "s", "==", "val", "{", "return", "true", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", ...
// InStringSlice returns whether or not the supplied value is in the slice
[ "InStringSlice", "returns", "whether", "or", "not", "the", "supplied", "value", "is", "in", "the", "slice" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/utils/strings.go#L4-L12
143,204
pseudomuto/protokit
utils/protobuf.go
CreateGenRequest
func CreateGenRequest(fds *descriptor.FileDescriptorSet, filesToGen ...string) *plugin_go.CodeGeneratorRequest { req := new(plugin_go.CodeGeneratorRequest) req.ProtoFile = fds.GetFile() for _, f := range req.GetProtoFile() { if InStringSlice(filesToGen, f.GetName()) { req.FileToGenerate = append(req.FileToGene...
go
func CreateGenRequest(fds *descriptor.FileDescriptorSet, filesToGen ...string) *plugin_go.CodeGeneratorRequest { req := new(plugin_go.CodeGeneratorRequest) req.ProtoFile = fds.GetFile() for _, f := range req.GetProtoFile() { if InStringSlice(filesToGen, f.GetName()) { req.FileToGenerate = append(req.FileToGene...
[ "func", "CreateGenRequest", "(", "fds", "*", "descriptor", ".", "FileDescriptorSet", ",", "filesToGen", "...", "string", ")", "*", "plugin_go", ".", "CodeGeneratorRequest", "{", "req", ":=", "new", "(", "plugin_go", ".", "CodeGeneratorRequest", ")", "\n", "req",...
// CreateGenRequest creates a codegen request from a `FileDescriptorSet`
[ "CreateGenRequest", "creates", "a", "codegen", "request", "from", "a", "FileDescriptorSet" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/utils/protobuf.go#L14-L25
143,205
pseudomuto/protokit
utils/protobuf.go
FilesToGenerate
func FilesToGenerate(req *plugin_go.CodeGeneratorRequest) []*descriptor.FileDescriptorProto { protos := make([]*descriptor.FileDescriptorProto, 0) OUTERLOOP: for _, name := range req.GetFileToGenerate() { for _, f := range req.GetProtoFile() { if f.GetName() == name { protos = append(protos, f) continue...
go
func FilesToGenerate(req *plugin_go.CodeGeneratorRequest) []*descriptor.FileDescriptorProto { protos := make([]*descriptor.FileDescriptorProto, 0) OUTERLOOP: for _, name := range req.GetFileToGenerate() { for _, f := range req.GetProtoFile() { if f.GetName() == name { protos = append(protos, f) continue...
[ "func", "FilesToGenerate", "(", "req", "*", "plugin_go", ".", "CodeGeneratorRequest", ")", "[", "]", "*", "descriptor", ".", "FileDescriptorProto", "{", "protos", ":=", "make", "(", "[", "]", "*", "descriptor", ".", "FileDescriptorProto", ",", "0", ")", "\n\...
// FilesToGenerate iterates through the proto files in the request and returns only the ones that were requested on the // command line. Only these protos should be generated by a codegen plugin.
[ "FilesToGenerate", "iterates", "through", "the", "proto", "files", "in", "the", "request", "and", "returns", "only", "the", "ones", "that", "were", "requested", "on", "the", "command", "line", ".", "Only", "these", "protos", "should", "be", "generated", "by", ...
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/utils/protobuf.go#L29-L43
143,206
pseudomuto/protokit
utils/protobuf.go
FindDescriptor
func FindDescriptor(set *descriptor.FileDescriptorSet, name string) *descriptor.FileDescriptorProto { for _, pf := range set.GetFile() { if filepath.Base(pf.GetName()) == name { return pf } } return nil }
go
func FindDescriptor(set *descriptor.FileDescriptorSet, name string) *descriptor.FileDescriptorProto { for _, pf := range set.GetFile() { if filepath.Base(pf.GetName()) == name { return pf } } return nil }
[ "func", "FindDescriptor", "(", "set", "*", "descriptor", ".", "FileDescriptorSet", ",", "name", "string", ")", "*", "descriptor", ".", "FileDescriptorProto", "{", "for", "_", ",", "pf", ":=", "range", "set", ".", "GetFile", "(", ")", "{", "if", "filepath",...
// FindDescriptor finds the named descriptor in the given set. Only base names are searched. The first match is // returned, on `nil` if not found
[ "FindDescriptor", "finds", "the", "named", "descriptor", "in", "the", "given", "set", ".", "Only", "base", "names", "are", "searched", ".", "The", "first", "match", "is", "returned", "on", "nil", "if", "not", "found" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/utils/protobuf.go#L66-L74
143,207
pseudomuto/protokit
utils/protobuf.go
LoadDescriptor
func LoadDescriptor(name string, pathSegments ...string) (*descriptor.FileDescriptorProto, error) { set, err := LoadDescriptorSet(pathSegments...) if err != nil { return nil, err } if pf := FindDescriptor(set, name); pf != nil { return pf, nil } return nil, errors.New("FileDescriptor not found") }
go
func LoadDescriptor(name string, pathSegments ...string) (*descriptor.FileDescriptorProto, error) { set, err := LoadDescriptorSet(pathSegments...) if err != nil { return nil, err } if pf := FindDescriptor(set, name); pf != nil { return pf, nil } return nil, errors.New("FileDescriptor not found") }
[ "func", "LoadDescriptor", "(", "name", "string", ",", "pathSegments", "...", "string", ")", "(", "*", "descriptor", ".", "FileDescriptorProto", ",", "error", ")", "{", "set", ",", "err", ":=", "LoadDescriptorSet", "(", "pathSegments", "...", ")", "\n", "if",...
// LoadDescriptor loads file descriptor protos from a file on disk, and returns the named proto descriptor. This is // useful mostly for testing purposes.
[ "LoadDescriptor", "loads", "file", "descriptor", "protos", "from", "a", "file", "on", "disk", "and", "returns", "the", "named", "proto", "descriptor", ".", "This", "is", "useful", "mostly", "for", "testing", "purposes", "." ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/utils/protobuf.go#L78-L89
143,208
pseudomuto/protokit
plugin.go
RunPlugin
func RunPlugin(p Plugin) error { return RunPluginWithIO(p, os.Stdin, os.Stdout) }
go
func RunPlugin(p Plugin) error { return RunPluginWithIO(p, os.Stdin, os.Stdout) }
[ "func", "RunPlugin", "(", "p", "Plugin", ")", "error", "{", "return", "RunPluginWithIO", "(", "p", ",", "os", ".", "Stdin", ",", "os", ".", "Stdout", ")", "\n", "}" ]
// RunPlugin runs the supplied plugin by reading input from stdin and generating output to stdout.
[ "RunPlugin", "runs", "the", "supplied", "plugin", "by", "reading", "input", "from", "stdin", "and", "generating", "output", "to", "stdout", "." ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/plugin.go#L19-L21
143,209
pseudomuto/protokit
plugin.go
RunPluginWithIO
func RunPluginWithIO(p Plugin, r io.Reader, w io.Writer) error { req, err := readRequest(r) if err != nil { return err } resp, err := p.Generate(req) if err != nil { return err } return writeResponse(w, resp) }
go
func RunPluginWithIO(p Plugin, r io.Reader, w io.Writer) error { req, err := readRequest(r) if err != nil { return err } resp, err := p.Generate(req) if err != nil { return err } return writeResponse(w, resp) }
[ "func", "RunPluginWithIO", "(", "p", "Plugin", ",", "r", "io", ".", "Reader", ",", "w", "io", ".", "Writer", ")", "error", "{", "req", ",", "err", ":=", "readRequest", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}"...
// RunPluginWithIO runs the supplied plugin using the supplied reader and writer for IO.
[ "RunPluginWithIO", "runs", "the", "supplied", "plugin", "using", "the", "supplied", "reader", "and", "writer", "for", "IO", "." ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/plugin.go#L24-L36
143,210
pseudomuto/protokit
context.go
ContextWithFileDescriptor
func ContextWithFileDescriptor(ctx context.Context, fd *FileDescriptor) context.Context { return context.WithValue(ctx, fileContextKey, fd) }
go
func ContextWithFileDescriptor(ctx context.Context, fd *FileDescriptor) context.Context { return context.WithValue(ctx, fileContextKey, fd) }
[ "func", "ContextWithFileDescriptor", "(", "ctx", "context", ".", "Context", ",", "fd", "*", "FileDescriptor", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "fileContextKey", ",", "fd", ")", "\n", "}" ]
// ContextWithFileDescriptor returns a new context with the attached `FileDescriptor`
[ "ContextWithFileDescriptor", "returns", "a", "new", "context", "with", "the", "attached", "FileDescriptor" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L17-L19
143,211
pseudomuto/protokit
context.go
FileDescriptorFromContext
func FileDescriptorFromContext(ctx context.Context) (*FileDescriptor, bool) { val, ok := ctx.Value(fileContextKey).(*FileDescriptor) return val, ok }
go
func FileDescriptorFromContext(ctx context.Context) (*FileDescriptor, bool) { val, ok := ctx.Value(fileContextKey).(*FileDescriptor) return val, ok }
[ "func", "FileDescriptorFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "*", "FileDescriptor", ",", "bool", ")", "{", "val", ",", "ok", ":=", "ctx", ".", "Value", "(", "fileContextKey", ")", ".", "(", "*", "FileDescriptor", ")", "\n", "retu...
// FileDescriptorFromContext returns the `FileDescriptor` from the context and whether or not the key was found.
[ "FileDescriptorFromContext", "returns", "the", "FileDescriptor", "from", "the", "context", "and", "whether", "or", "not", "the", "key", "was", "found", "." ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L22-L25
143,212
pseudomuto/protokit
context.go
ContextWithDescriptor
func ContextWithDescriptor(ctx context.Context, d *Descriptor) context.Context { return context.WithValue(ctx, descriptorContextKey, d) }
go
func ContextWithDescriptor(ctx context.Context, d *Descriptor) context.Context { return context.WithValue(ctx, descriptorContextKey, d) }
[ "func", "ContextWithDescriptor", "(", "ctx", "context", ".", "Context", ",", "d", "*", "Descriptor", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "descriptorContextKey", ",", "d", ")", "\n", "}" ]
// ContextWithDescriptor returns a new context with the specified `Descriptor`
[ "ContextWithDescriptor", "returns", "a", "new", "context", "with", "the", "specified", "Descriptor" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L28-L30
143,213
pseudomuto/protokit
context.go
DescriptorFromContext
func DescriptorFromContext(ctx context.Context) (*Descriptor, bool) { val, ok := ctx.Value(descriptorContextKey).(*Descriptor) return val, ok }
go
func DescriptorFromContext(ctx context.Context) (*Descriptor, bool) { val, ok := ctx.Value(descriptorContextKey).(*Descriptor) return val, ok }
[ "func", "DescriptorFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "*", "Descriptor", ",", "bool", ")", "{", "val", ",", "ok", ":=", "ctx", ".", "Value", "(", "descriptorContextKey", ")", ".", "(", "*", "Descriptor", ")", "\n", "return", ...
// DescriptorFromContext returns the associated `Descriptor` for the context and whether or not it was found
[ "DescriptorFromContext", "returns", "the", "associated", "Descriptor", "for", "the", "context", "and", "whether", "or", "not", "it", "was", "found" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L33-L36
143,214
pseudomuto/protokit
context.go
ContextWithEnumDescriptor
func ContextWithEnumDescriptor(ctx context.Context, d *EnumDescriptor) context.Context { return context.WithValue(ctx, enumContextKey, d) }
go
func ContextWithEnumDescriptor(ctx context.Context, d *EnumDescriptor) context.Context { return context.WithValue(ctx, enumContextKey, d) }
[ "func", "ContextWithEnumDescriptor", "(", "ctx", "context", ".", "Context", ",", "d", "*", "EnumDescriptor", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "enumContextKey", ",", "d", ")", "\n", "}" ]
// ContextWithEnumDescriptor returns a new context with the specified `EnumDescriptor`
[ "ContextWithEnumDescriptor", "returns", "a", "new", "context", "with", "the", "specified", "EnumDescriptor" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L39-L41
143,215
pseudomuto/protokit
context.go
EnumDescriptorFromContext
func EnumDescriptorFromContext(ctx context.Context) (*EnumDescriptor, bool) { val, ok := ctx.Value(enumContextKey).(*EnumDescriptor) return val, ok }
go
func EnumDescriptorFromContext(ctx context.Context) (*EnumDescriptor, bool) { val, ok := ctx.Value(enumContextKey).(*EnumDescriptor) return val, ok }
[ "func", "EnumDescriptorFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "*", "EnumDescriptor", ",", "bool", ")", "{", "val", ",", "ok", ":=", "ctx", ".", "Value", "(", "enumContextKey", ")", ".", "(", "*", "EnumDescriptor", ")", "\n", "retu...
// EnumDescriptorFromContext returns the associated `EnumDescriptor` for the context and whether or not it was found
[ "EnumDescriptorFromContext", "returns", "the", "associated", "EnumDescriptor", "for", "the", "context", "and", "whether", "or", "not", "it", "was", "found" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L44-L47
143,216
pseudomuto/protokit
context.go
ContextWithServiceDescriptor
func ContextWithServiceDescriptor(ctx context.Context, service *ServiceDescriptor) context.Context { return context.WithValue(ctx, serviceContextKey, service) }
go
func ContextWithServiceDescriptor(ctx context.Context, service *ServiceDescriptor) context.Context { return context.WithValue(ctx, serviceContextKey, service) }
[ "func", "ContextWithServiceDescriptor", "(", "ctx", "context", ".", "Context", ",", "service", "*", "ServiceDescriptor", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "serviceContextKey", ",", "service", ")", "\n", ...
// ContextWithServiceDescriptor returns a new context with `service`
[ "ContextWithServiceDescriptor", "returns", "a", "new", "context", "with", "service" ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L50-L52
143,217
pseudomuto/protokit
context.go
ServiceDescriptorFromContext
func ServiceDescriptorFromContext(ctx context.Context) (*ServiceDescriptor, bool) { val, ok := ctx.Value(serviceContextKey).(*ServiceDescriptor) return val, ok }
go
func ServiceDescriptorFromContext(ctx context.Context) (*ServiceDescriptor, bool) { val, ok := ctx.Value(serviceContextKey).(*ServiceDescriptor) return val, ok }
[ "func", "ServiceDescriptorFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "*", "ServiceDescriptor", ",", "bool", ")", "{", "val", ",", "ok", ":=", "ctx", ".", "Value", "(", "serviceContextKey", ")", ".", "(", "*", "ServiceDescriptor", ")", "...
// ServiceDescriptorFromContext returns the `Service` from the context and whether or not the key was found.
[ "ServiceDescriptorFromContext", "returns", "the", "Service", "from", "the", "context", "and", "whether", "or", "not", "the", "key", "was", "found", "." ]
c63c13958542d70af1d1ef7826d30b25cd5bf6e9
https://github.com/pseudomuto/protokit/blob/c63c13958542d70af1d1ef7826d30b25cd5bf6e9/context.go#L55-L58
143,218
joeshaw/multierror
multierror.go
Err
func (e Errors) Err() error { if len(e) == 0 { return nil } return &MultiError{Errors: e} }
go
func (e Errors) Err() error { if len(e) == 0 { return nil } return &MultiError{Errors: e} }
[ "func", "(", "e", "Errors", ")", "Err", "(", ")", "error", "{", "if", "len", "(", "e", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "MultiError", "{", "Errors", ":", "e", "}", "\n", "}" ]
// Returns a MultiError struct containing this Errors instance, or nil // if there are zero errors contained.
[ "Returns", "a", "MultiError", "struct", "containing", "this", "Errors", "instance", "or", "nil", "if", "there", "are", "zero", "errors", "contained", "." ]
69b34d4ec901851247ae7e77d33909caf9df99ed
https://github.com/joeshaw/multierror/blob/69b34d4ec901851247ae7e77d33909caf9df99ed/multierror.go#L14-L20
143,219
bradleyfalzon/revgrep
revgrep.go
linesChanged
func (c Checker) linesChanged() map[string][]pos { type state struct { file string lineNo int // current line number within chunk hunkPos int // current line count since first @@ in file changes []pos // position of changes } var ( s state changes = make(map[string][]pos) ) for _, file ...
go
func (c Checker) linesChanged() map[string][]pos { type state struct { file string lineNo int // current line number within chunk hunkPos int // current line count since first @@ in file changes []pos // position of changes } var ( s state changes = make(map[string][]pos) ) for _, file ...
[ "func", "(", "c", "Checker", ")", "linesChanged", "(", ")", "map", "[", "string", "]", "[", "]", "pos", "{", "type", "state", "struct", "{", "file", "string", "\n", "lineNo", "int", "// current line number within chunk", "\n", "hunkPos", "int", "// current l...
// linesChanges returns a map of file names to line numbers being changed. // If key is nil, the file has been recently added, else it contains a slice // of positions that have been added.
[ "linesChanges", "returns", "a", "map", "of", "file", "names", "to", "line", "numbers", "being", "changed", ".", "If", "key", "is", "nil", "the", "file", "has", "been", "recently", "added", "else", "it", "contains", "a", "slice", "of", "positions", "that", ...
c04006dc3307c8768bda7a33c7c15d1c6f664e14
https://github.com/bradleyfalzon/revgrep/blob/c04006dc3307c8768bda7a33c7c15d1c6f664e14/revgrep.go#L213-L275
143,220
bradleyfalzon/revgrep
revgrep.go
GitPatch
func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) { var patch bytes.Buffer // check if git repo exists if err := exec.Command("git", "status").Run(); err != nil { // don't return an error, we assume the error is not repo exists return nil, nil, nil } // make a patch for untracked fi...
go
func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) { var patch bytes.Buffer // check if git repo exists if err := exec.Command("git", "status").Run(); err != nil { // don't return an error, we assume the error is not repo exists return nil, nil, nil } // make a patch for untracked fi...
[ "func", "GitPatch", "(", "revisionFrom", ",", "revisionTo", "string", ")", "(", "io", ".", "Reader", ",", "[", "]", "string", ",", "error", ")", "{", "var", "patch", "bytes", ".", "Buffer", "\n\n", "// check if git repo exists", "if", "err", ":=", "exec", ...
// GitPatch returns a patch from a git repository, if no git repository was // was found and no errors occurred, nil is returned, else an error is returned // revisionFrom and revisionTo defines the git diff parameters, if left blank // and there are unstaged changes or untracked files, only those will be returned // e...
[ "GitPatch", "returns", "a", "patch", "from", "a", "git", "repository", "if", "no", "git", "repository", "was", "was", "found", "and", "no", "errors", "occurred", "nil", "is", "returned", "else", "an", "error", "is", "returned", "revisionFrom", "and", "revisi...
c04006dc3307c8768bda7a33c7c15d1c6f664e14
https://github.com/bradleyfalzon/revgrep/blob/c04006dc3307c8768bda7a33c7c15d1c6f664e14/revgrep.go#L285-L350
143,221
ekzhu/minhash-lsh
minhash.go
NewMinhash
func NewMinhash(seed int64, numHash int) *Minhash { r := rand.New(rand.NewSource(seed)) b := binary.BigEndian b1 := make([]byte, hashValueSize) b2 := make([]byte, hashValueSize) b.PutUint64(b1, uint64(r.Int63())) b.PutUint64(b2, uint64(r.Int63())) fnv1 := fnv.New64a() fnv2 := fnv.New64a() h1 := func(b []byte) ...
go
func NewMinhash(seed int64, numHash int) *Minhash { r := rand.New(rand.NewSource(seed)) b := binary.BigEndian b1 := make([]byte, hashValueSize) b2 := make([]byte, hashValueSize) b.PutUint64(b1, uint64(r.Int63())) b.PutUint64(b2, uint64(r.Int63())) fnv1 := fnv.New64a() fnv2 := fnv.New64a() h1 := func(b []byte) ...
[ "func", "NewMinhash", "(", "seed", "int64", ",", "numHash", "int", ")", "*", "Minhash", "{", "r", ":=", "rand", ".", "New", "(", "rand", ".", "NewSource", "(", "seed", ")", ")", "\n", "b", ":=", "binary", ".", "BigEndian", "\n", "b1", ":=", "make",...
// NewMinhash initialize a MinHash object with a seed and the number of // hash functions.
[ "NewMinhash", "initialize", "a", "MinHash", "object", "with", "a", "seed", "and", "the", "number", "of", "hash", "functions", "." ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/minhash.go#L22-L47
143,222
ekzhu/minhash-lsh
minhash.go
Merge
func (m *Minhash) Merge(o *Minhash) { if m.seed != o.seed { panic("Cannot merge Minhash with different seed") } m.mw.Merge(o.mw) }
go
func (m *Minhash) Merge(o *Minhash) { if m.seed != o.seed { panic("Cannot merge Minhash with different seed") } m.mw.Merge(o.mw) }
[ "func", "(", "m", "*", "Minhash", ")", "Merge", "(", "o", "*", "Minhash", ")", "{", "if", "m", ".", "seed", "!=", "o", ".", "seed", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "m", ".", "mw", ".", "Merge", "(", "o", ".", "mw", ")...
// Merge combines the signature of the other Minhash // with this one, making this one carry the signature of // the union.
[ "Merge", "combines", "the", "signature", "of", "the", "other", "Minhash", "with", "this", "one", "making", "this", "one", "carry", "the", "signature", "of", "the", "union", "." ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/minhash.go#L63-L68
143,223
ekzhu/minhash-lsh
lsh.go
integral
func integral(f func(float64) float64, a, b, precision float64) float64 { var area float64 for x := a; x < b; x += precision { area += f(x+0.5*precision) * precision } return area }
go
func integral(f func(float64) float64, a, b, precision float64) float64 { var area float64 for x := a; x < b; x += precision { area += f(x+0.5*precision) * precision } return area }
[ "func", "integral", "(", "f", "func", "(", "float64", ")", "float64", ",", "a", ",", "b", ",", "precision", "float64", ")", "float64", "{", "var", "area", "float64", "\n", "for", "x", ":=", "a", ";", "x", "<", "b", ";", "x", "+=", "precision", "{...
// Compute the integral of function f, lower limit a, upper limit l, and // precision defined as the quantize step
[ "Compute", "the", "integral", "of", "function", "f", "lower", "limit", "a", "upper", "limit", "l", "and", "precision", "defined", "as", "the", "quantize", "step" ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L30-L36
143,224
ekzhu/minhash-lsh
lsh.go
falsePositive
func falsePositive(l, k int) func(float64) float64 { return func(j float64) float64 { return 1.0 - math.Pow(1.0-math.Pow(j, float64(k)), float64(l)) } }
go
func falsePositive(l, k int) func(float64) float64 { return func(j float64) float64 { return 1.0 - math.Pow(1.0-math.Pow(j, float64(k)), float64(l)) } }
[ "func", "falsePositive", "(", "l", ",", "k", "int", ")", "func", "(", "float64", ")", "float64", "{", "return", "func", "(", "j", "float64", ")", "float64", "{", "return", "1.0", "-", "math", ".", "Pow", "(", "1.0", "-", "math", ".", "Pow", "(", ...
// Probability density function for false positive
[ "Probability", "density", "function", "for", "false", "positive" ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L39-L43
143,225
ekzhu/minhash-lsh
lsh.go
falseNegative
func falseNegative(l, k int) func(float64) float64 { return func(j float64) float64 { return 1.0 - (1.0 - math.Pow(1.0-math.Pow(j, float64(k)), float64(l))) } }
go
func falseNegative(l, k int) func(float64) float64 { return func(j float64) float64 { return 1.0 - (1.0 - math.Pow(1.0-math.Pow(j, float64(k)), float64(l))) } }
[ "func", "falseNegative", "(", "l", ",", "k", "int", ")", "func", "(", "float64", ")", "float64", "{", "return", "func", "(", "j", "float64", ")", "float64", "{", "return", "1.0", "-", "(", "1.0", "-", "math", ".", "Pow", "(", "1.0", "-", "math", ...
// Probability density function for false negative
[ "Probability", "density", "function", "for", "false", "negative" ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L46-L50
143,226
ekzhu/minhash-lsh
lsh.go
probFalseNegative
func probFalseNegative(l, k int, t, precision float64) float64 { return integral(falseNegative(l, k), t, 1.0, precision) }
go
func probFalseNegative(l, k int, t, precision float64) float64 { return integral(falseNegative(l, k), t, 1.0, precision) }
[ "func", "probFalseNegative", "(", "l", ",", "k", "int", ",", "t", ",", "precision", "float64", ")", "float64", "{", "return", "integral", "(", "falseNegative", "(", "l", ",", "k", ")", ",", "t", ",", "1.0", ",", "precision", ")", "\n", "}" ]
// Compute the cummulative probability of false negative given threshold t
[ "Compute", "the", "cummulative", "probability", "of", "false", "negative", "given", "threshold", "t" ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L53-L55
143,227
ekzhu/minhash-lsh
lsh.go
probFalsePositive
func probFalsePositive(l, k int, t, precision float64) float64 { return integral(falsePositive(l, k), 0, t, precision) }
go
func probFalsePositive(l, k int, t, precision float64) float64 { return integral(falsePositive(l, k), 0, t, precision) }
[ "func", "probFalsePositive", "(", "l", ",", "k", "int", ",", "t", ",", "precision", "float64", ")", "float64", "{", "return", "integral", "(", "falsePositive", "(", "l", ",", "k", ")", ",", "0", ",", "t", ",", "precision", ")", "\n", "}" ]
// Compute the cummulative probability of false positive given threshold t
[ "Compute", "the", "cummulative", "probability", "of", "false", "positive", "given", "threshold", "t" ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L58-L60
143,228
ekzhu/minhash-lsh
lsh.go
optimalKL
func optimalKL(numHash int, t float64) (optK, optL int, fp, fn float64) { minError := math.MaxFloat64 for l := 1; l <= numHash; l++ { for k := 1; k <= numHash; k++ { if l*k > numHash { continue } currFp := probFalsePositive(l, k, t, integrationPrecision) currFn := probFalseNegative(l, k, t, integrat...
go
func optimalKL(numHash int, t float64) (optK, optL int, fp, fn float64) { minError := math.MaxFloat64 for l := 1; l <= numHash; l++ { for k := 1; k <= numHash; k++ { if l*k > numHash { continue } currFp := probFalsePositive(l, k, t, integrationPrecision) currFn := probFalseNegative(l, k, t, integrat...
[ "func", "optimalKL", "(", "numHash", "int", ",", "t", "float64", ")", "(", "optK", ",", "optL", "int", ",", "fp", ",", "fn", "float64", ")", "{", "minError", ":=", "math", ".", "MaxFloat64", "\n", "for", "l", ":=", "1", ";", "l", "<=", "numHash", ...
// optimalKL returns the optimal K and L for Jaccard similarity search, // and the false positive and negative probabilities. // t is the Jaccard similarity threshold.
[ "optimalKL", "returns", "the", "optimal", "K", "and", "L", "for", "Jaccard", "similarity", "search", "and", "the", "false", "positive", "and", "negative", "probabilities", ".", "t", "is", "the", "Jaccard", "similarity", "threshold", "." ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L65-L85
143,229
ekzhu/minhash-lsh
lsh.go
Params
func (f *MinhashLSH) Params() (k, l int) { return f.k, f.l }
go
func (f *MinhashLSH) Params() (k, l int) { return f.k, f.l }
[ "func", "(", "f", "*", "MinhashLSH", ")", "Params", "(", ")", "(", "k", ",", "l", "int", ")", "{", "return", "f", ".", "k", ",", "f", ".", "l", "\n", "}" ]
// Params returns the LSH parameters k and l
[ "Params", "returns", "the", "LSH", "parameters", "k", "and", "l" ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L160-L162
143,230
ekzhu/minhash-lsh
lsh.go
Index
func (f *MinhashLSH) Index() { var wg sync.WaitGroup wg.Add(len(f.hashTables)) for i := range f.hashTables { func(htPtr *hashTable, initHtPtr *initHashTable) { // Build sorted hash table using buckets from init hash tables initHt := *initHtPtr ht := *htPtr for hashKey := range initHt { ks, _ := ini...
go
func (f *MinhashLSH) Index() { var wg sync.WaitGroup wg.Add(len(f.hashTables)) for i := range f.hashTables { func(htPtr *hashTable, initHtPtr *initHashTable) { // Build sorted hash table using buckets from init hash tables initHt := *initHtPtr ht := *htPtr for hashKey := range initHt { ks, _ := ini...
[ "func", "(", "f", "*", "MinhashLSH", ")", "Index", "(", ")", "{", "var", "wg", "sync", ".", "WaitGroup", "\n", "wg", ".", "Add", "(", "len", "(", "f", ".", "hashTables", ")", ")", "\n", "for", "i", ":=", "range", "f", ".", "hashTables", "{", "f...
// Index makes all the keys added searchable.
[ "Index", "makes", "all", "the", "keys", "added", "searchable", "." ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L186-L209
143,231
ekzhu/minhash-lsh
lsh.go
Query
func (f *MinhashLSH) Query(sig []uint64) []interface{} { set := f.query(sig, f.k) results := make([]interface{}, 0, len(set)) for key := range set { results = append(results, key) } return results }
go
func (f *MinhashLSH) Query(sig []uint64) []interface{} { set := f.query(sig, f.k) results := make([]interface{}, 0, len(set)) for key := range set { results = append(results, key) } return results }
[ "func", "(", "f", "*", "MinhashLSH", ")", "Query", "(", "sig", "[", "]", "uint64", ")", "[", "]", "interface", "{", "}", "{", "set", ":=", "f", ".", "query", "(", "sig", ",", "f", ".", "k", ")", "\n", "results", ":=", "make", "(", "[", "]", ...
// Query returns candidate keys given the query signature.
[ "Query", "returns", "candidate", "keys", "given", "the", "query", "signature", "." ]
5c06ee8586a1691fbfa230842170429e2b31cc05
https://github.com/ekzhu/minhash-lsh/blob/5c06ee8586a1691fbfa230842170429e2b31cc05/lsh.go#L212-L219
143,232
aviddiviner/go-murmur
murmur2.go
mmix
func mmix(h uint32, k uint32) (uint32, uint32) { k *= M k ^= k >> R k *= M h *= M h ^= k return h, k }
go
func mmix(h uint32, k uint32) (uint32, uint32) { k *= M k ^= k >> R k *= M h *= M h ^= k return h, k }
[ "func", "mmix", "(", "h", "uint32", ",", "k", "uint32", ")", "(", "uint32", ",", "uint32", ")", "{", "k", "*=", "M", "\n", "k", "^=", "k", ">>", "R", "\n", "k", "*=", "M", "\n", "h", "*=", "M", "\n", "h", "^=", "k", "\n", "return", "h", "...
// 32-bit mixing function.
[ "32", "-", "bit", "mixing", "function", "." ]
b9740d71e571c1f4ccb570b9bc7f352329d3e600
https://github.com/aviddiviner/go-murmur/blob/b9740d71e571c1f4ccb570b9bc7f352329d3e600/murmur2.go#L18-L25
143,233
aviddiviner/go-murmur
murmur2.go
Reset
func (m *murmur32) Reset() { m.hash = m.seed m.tail = 0 m.count = 0 m.size = 0 }
go
func (m *murmur32) Reset() { m.hash = m.seed m.tail = 0 m.count = 0 m.size = 0 }
[ "func", "(", "m", "*", "murmur32", ")", "Reset", "(", ")", "{", "m", ".", "hash", "=", "m", ".", "seed", "\n", "m", ".", "tail", "=", "0", "\n", "m", ".", "count", "=", "0", "\n", "m", ".", "size", "=", "0", "\n", "}" ]
// Reset the hash to its initial state.
[ "Reset", "the", "hash", "to", "its", "initial", "state", "." ]
b9740d71e571c1f4ccb570b9bc7f352329d3e600
https://github.com/aviddiviner/go-murmur/blob/b9740d71e571c1f4ccb570b9bc7f352329d3e600/murmur2.go#L189-L194
143,234
aviddiviner/go-murmur
murmur2.go
Write
func (m *murmur32) Write(data []byte) (n int, err error) { n = len(data) m.size += uint32(n) data = m.mixTail(data) for l := len(data); l >= 4; l -= 4 { k := uint32(data[0]) | uint32(data[1])<<8 | uint32(data[2])<<16 | uint32(data[3])<<24 m.hash, k = mmix(m.hash, k) data = data[4:] } m.mixTail(data) // d...
go
func (m *murmur32) Write(data []byte) (n int, err error) { n = len(data) m.size += uint32(n) data = m.mixTail(data) for l := len(data); l >= 4; l -= 4 { k := uint32(data[0]) | uint32(data[1])<<8 | uint32(data[2])<<16 | uint32(data[3])<<24 m.hash, k = mmix(m.hash, k) data = data[4:] } m.mixTail(data) // d...
[ "func", "(", "m", "*", "murmur32", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", "=", "len", "(", "data", ")", "\n", "m", ".", "size", "+=", "uint32", "(", "n", ")", "\n\n", "data", "...
// Add some data to the running hash.
[ "Add", "some", "data", "to", "the", "running", "hash", "." ]
b9740d71e571c1f4ccb570b9bc7f352329d3e600
https://github.com/aviddiviner/go-murmur/blob/b9740d71e571c1f4ccb570b9bc7f352329d3e600/murmur2.go#L197-L211
143,235
aviddiviner/go-murmur
murmur2.go
Sum32
func (m *murmur32) Sum32() (hash uint32) { hash, _ = mmix(m.hash, m.tail) hash, _ = mmix(hash, m.size) hash ^= hash >> 13 hash *= M hash ^= hash >> 15 return }
go
func (m *murmur32) Sum32() (hash uint32) { hash, _ = mmix(m.hash, m.tail) hash, _ = mmix(hash, m.size) hash ^= hash >> 13 hash *= M hash ^= hash >> 15 return }
[ "func", "(", "m", "*", "murmur32", ")", "Sum32", "(", ")", "(", "hash", "uint32", ")", "{", "hash", ",", "_", "=", "mmix", "(", "m", ".", "hash", ",", "m", ".", "tail", ")", "\n", "hash", ",", "_", "=", "mmix", "(", "hash", ",", "m", ".", ...
// Get the hash result.
[ "Get", "the", "hash", "result", "." ]
b9740d71e571c1f4ccb570b9bc7f352329d3e600
https://github.com/aviddiviner/go-murmur/blob/b9740d71e571c1f4ccb570b9bc7f352329d3e600/murmur2.go#L214-L223
143,236
bradleypeabody/gorilla-sessions-memcache
valuestorer.go
GetValueForSessionName
func (s *CookieStorer) GetValueForSessionName(r *http.Request, name string) (string, error) { c, err := r.Cookie(name) if err != nil { return "", err } return c.Value, nil }
go
func (s *CookieStorer) GetValueForSessionName(r *http.Request, name string) (string, error) { c, err := r.Cookie(name) if err != nil { return "", err } return c.Value, nil }
[ "func", "(", "s", "*", "CookieStorer", ")", "GetValueForSessionName", "(", "r", "*", "http", ".", "Request", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "c", ",", "err", ":=", "r", ".", "Cookie", "(", "name", ")", "\n", "if",...
// GetValueForSessionName gets a value string from an http.Cookie, which should be present in the http.Request.
[ "GetValueForSessionName", "gets", "a", "value", "string", "from", "an", "http", ".", "Cookie", "which", "should", "be", "present", "in", "the", "http", ".", "Request", "." ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/valuestorer.go#L35-L41
143,237
bradleypeabody/gorilla-sessions-memcache
valuestorer.go
SetValueForSessionName
func (s *CookieStorer) SetValueForSessionName(w http.ResponseWriter, name, value string, options *sessions.Options) error { http.SetCookie(w, sessions.NewCookie(name, value, options)) return nil }
go
func (s *CookieStorer) SetValueForSessionName(w http.ResponseWriter, name, value string, options *sessions.Options) error { http.SetCookie(w, sessions.NewCookie(name, value, options)) return nil }
[ "func", "(", "s", "*", "CookieStorer", ")", "SetValueForSessionName", "(", "w", "http", ".", "ResponseWriter", ",", "name", ",", "value", "string", ",", "options", "*", "sessions", ".", "Options", ")", "error", "{", "http", ".", "SetCookie", "(", "w", ",...
// SetValueForSessionName sets a value string by creating a new http.Cookie and setting a `Set-Cookie` header
[ "SetValueForSessionName", "sets", "a", "value", "string", "by", "creating", "a", "new", "http", ".", "Cookie", "and", "setting", "a", "Set", "-", "Cookie", "header" ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/valuestorer.go#L44-L47
143,238
bradleypeabody/gorilla-sessions-memcache
valuestorer.go
GetValueForSessionName
func (s *HeaderStorer) GetValueForSessionName(r *http.Request, name string) (string, error) { // fetch header field from header. headerBase64Encoded := r.Header.Get(s.HeaderFieldName) if headerBase64Encoded == "" { return "", ErrValueNotFound } // fetch value for name from JSON map. headerMap, err := s.headerT...
go
func (s *HeaderStorer) GetValueForSessionName(r *http.Request, name string) (string, error) { // fetch header field from header. headerBase64Encoded := r.Header.Get(s.HeaderFieldName) if headerBase64Encoded == "" { return "", ErrValueNotFound } // fetch value for name from JSON map. headerMap, err := s.headerT...
[ "func", "(", "s", "*", "HeaderStorer", ")", "GetValueForSessionName", "(", "r", "*", "http", ".", "Request", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "// fetch header field from header.", "headerBase64Encoded", ":=", "r", ".", "Header...
// GetValueForSessionName gets a value string from an http.Header.
[ "GetValueForSessionName", "gets", "a", "value", "string", "from", "an", "http", ".", "Header", "." ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/valuestorer.go#L57-L74
143,239
bradleypeabody/gorilla-sessions-memcache
valuestorer.go
SetValueForSessionName
func (s *HeaderStorer) SetValueForSessionName(w http.ResponseWriter, name, value string, options *sessions.Options) error { var newHeaderMap map[string]string // try to fetch an existing headerMap to we can append our values headerBase64Encoded := w.Header().Get(s.HeaderFieldName) if headerBase64Encoded != "" { ...
go
func (s *HeaderStorer) SetValueForSessionName(w http.ResponseWriter, name, value string, options *sessions.Options) error { var newHeaderMap map[string]string // try to fetch an existing headerMap to we can append our values headerBase64Encoded := w.Header().Get(s.HeaderFieldName) if headerBase64Encoded != "" { ...
[ "func", "(", "s", "*", "HeaderStorer", ")", "SetValueForSessionName", "(", "w", "http", ".", "ResponseWriter", ",", "name", ",", "value", "string", ",", "options", "*", "sessions", ".", "Options", ")", "error", "{", "var", "newHeaderMap", "map", "[", "stri...
// SetValueForSessionName sets a value string by creating a new http.Header using the header key given by the headerStorer.HeaderKey function.
[ "SetValueForSessionName", "sets", "a", "value", "string", "by", "creating", "a", "new", "http", ".", "Header", "using", "the", "header", "key", "given", "by", "the", "headerStorer", ".", "HeaderKey", "function", "." ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/valuestorer.go#L77-L105
143,240
bradleypeabody/gorilla-sessions-memcache
valuestorer.go
headerToMap
func (s *HeaderStorer) headerToMap(headerBase64Encoded string) (map[string]string, error) { headerJson, err := base64.StdEncoding.DecodeString(headerBase64Encoded) if err != nil { return nil, err } var result map[string]string if err := json.Unmarshal([]byte(headerJson), &result); err != nil { return nil, err ...
go
func (s *HeaderStorer) headerToMap(headerBase64Encoded string) (map[string]string, error) { headerJson, err := base64.StdEncoding.DecodeString(headerBase64Encoded) if err != nil { return nil, err } var result map[string]string if err := json.Unmarshal([]byte(headerJson), &result); err != nil { return nil, err ...
[ "func", "(", "s", "*", "HeaderStorer", ")", "headerToMap", "(", "headerBase64Encoded", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "headerJson", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", ...
// headerToMap decodes a base64 encoded JSON map into a regular JSON map.
[ "headerToMap", "decodes", "a", "base64", "encoded", "JSON", "map", "into", "a", "regular", "JSON", "map", "." ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/valuestorer.go#L108-L118
143,241
bradleypeabody/gorilla-sessions-memcache
valuestorer.go
mapToHeader
func (s *HeaderStorer) mapToHeader(headerMap map[string]string) (string, error) { result, err := json.Marshal(headerMap) if err != nil { return "", err } return base64.StdEncoding.EncodeToString(result), nil }
go
func (s *HeaderStorer) mapToHeader(headerMap map[string]string) (string, error) { result, err := json.Marshal(headerMap) if err != nil { return "", err } return base64.StdEncoding.EncodeToString(result), nil }
[ "func", "(", "s", "*", "HeaderStorer", ")", "mapToHeader", "(", "headerMap", "map", "[", "string", "]", "string", ")", "(", "string", ",", "error", ")", "{", "result", ",", "err", ":=", "json", ".", "Marshal", "(", "headerMap", ")", "\n", "if", "err"...
// mapToHeader encoded a JSON map into a base64 encoded string.
[ "mapToHeader", "encoded", "a", "JSON", "map", "into", "a", "base64", "encoded", "string", "." ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/valuestorer.go#L121-L127
143,242
bradleypeabody/gorilla-sessions-memcache
gsmstub.go
NewDumbMemorySessionStoreWithValueStorer
func NewDumbMemorySessionStoreWithValueStorer(valueStorer ValueStorer) *DumbMemoryStore { if valueStorer == nil { panic("Cannot have nil ValueStorer") } keyPair := []byte("stub") return &DumbMemoryStore{ Codecs: securecookie.CodecsFromPairs(keyPair), Options: &sessions.Options{ Path: "/", MaxAge: 8...
go
func NewDumbMemorySessionStoreWithValueStorer(valueStorer ValueStorer) *DumbMemoryStore { if valueStorer == nil { panic("Cannot have nil ValueStorer") } keyPair := []byte("stub") return &DumbMemoryStore{ Codecs: securecookie.CodecsFromPairs(keyPair), Options: &sessions.Options{ Path: "/", MaxAge: 8...
[ "func", "NewDumbMemorySessionStoreWithValueStorer", "(", "valueStorer", "ValueStorer", ")", "*", "DumbMemoryStore", "{", "if", "valueStorer", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "keyPair", ":=", "[", "]", "byte", "(", "\"", "\...
// NewDumbMemorySessionStoreWithValueStorer return a new dumb in-memory // map and no expiration backed by a ValueStorer. Good for local // development so you don't have to run // memcached on your laptop just to fire up // your app and hack away. // A ValueStorer is used to store an encrypted sessionID. The encrypted...
[ "NewDumbMemorySessionStoreWithValueStorer", "return", "a", "new", "dumb", "in", "-", "memory", "map", "and", "no", "expiration", "backed", "by", "a", "ValueStorer", ".", "Good", "for", "local", "development", "so", "you", "don", "t", "have", "to", "run", "memc...
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/gsmstub.go#L18-L35
143,243
bradleypeabody/gorilla-sessions-memcache
gsm.go
NewMemcacherStoreWithValueStorer
func NewMemcacherStoreWithValueStorer(client Memcacher, valueStorer ValueStorer, keyPrefix string, keyPairs ...[]byte) *MemcacheStore { if client == nil { panic("Cannot have nil memcache client") } if valueStorer == nil { panic("Cannot have nil ValueStorer") } return &MemcacheStore{ Codecs: securecookie.C...
go
func NewMemcacherStoreWithValueStorer(client Memcacher, valueStorer ValueStorer, keyPrefix string, keyPairs ...[]byte) *MemcacheStore { if client == nil { panic("Cannot have nil memcache client") } if valueStorer == nil { panic("Cannot have nil ValueStorer") } return &MemcacheStore{ Codecs: securecookie.C...
[ "func", "NewMemcacherStoreWithValueStorer", "(", "client", "Memcacher", ",", "valueStorer", "ValueStorer", ",", "keyPrefix", "string", ",", "keyPairs", "...", "[", "]", "byte", ")", "*", "MemcacheStore", "{", "if", "client", "==", "nil", "{", "panic", "(", "\"...
// NewMemcacheStoreWithValueStorer returns a new MemcacheStore backed by a ValueStorer. // You need to provide the memcache client that // implements the Memcacher interface and // an optional prefix for the keys we store. // A ValueStorer is used to store an encrypted sessionID. The encrypted sessionID is used to acce...
[ "NewMemcacheStoreWithValueStorer", "returns", "a", "new", "MemcacheStore", "backed", "by", "a", "ValueStorer", ".", "You", "need", "to", "provide", "the", "memcache", "client", "that", "implements", "the", "Memcacher", "interface", "and", "an", "optional", "prefix",...
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/gsm.go#L25-L46
143,244
bradleypeabody/gorilla-sessions-memcache
gsm.go
NewMemcacherStore
func NewMemcacherStore(client Memcacher, keyPrefix string, keyPairs ...[]byte) *MemcacheStore { return NewMemcacherStoreWithValueStorer(client, &CookieStorer{}, keyPrefix, keyPairs...) }
go
func NewMemcacherStore(client Memcacher, keyPrefix string, keyPairs ...[]byte) *MemcacheStore { return NewMemcacherStoreWithValueStorer(client, &CookieStorer{}, keyPrefix, keyPairs...) }
[ "func", "NewMemcacherStore", "(", "client", "Memcacher", ",", "keyPrefix", "string", ",", "keyPairs", "...", "[", "]", "byte", ")", "*", "MemcacheStore", "{", "return", "NewMemcacherStoreWithValueStorer", "(", "client", ",", "&", "CookieStorer", "{", "}", ",", ...
// NewMemcacherStore returns a new MemcacheStore. // You need to provide the memcache client that // implements the Memcacher interface and // an optional prefix for the keys we store
[ "NewMemcacherStore", "returns", "a", "new", "MemcacheStore", ".", "You", "need", "to", "provide", "the", "memcache", "client", "that", "implements", "the", "Memcacher", "interface", "and", "an", "optional", "prefix", "for", "the", "keys", "we", "store" ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/gsm.go#L52-L54
143,245
bradleypeabody/gorilla-sessions-memcache
gsm.go
MaxLength
func (s *MemcacheStore) MaxLength(l int) { for _, c := range s.Codecs { if codec, ok := c.(*securecookie.SecureCookie); ok { codec.MaxLength(l) } } }
go
func (s *MemcacheStore) MaxLength(l int) { for _, c := range s.Codecs { if codec, ok := c.(*securecookie.SecureCookie); ok { codec.MaxLength(l) } } }
[ "func", "(", "s", "*", "MemcacheStore", ")", "MaxLength", "(", "l", "int", ")", "{", "for", "_", ",", "c", ":=", "range", "s", ".", "Codecs", "{", "if", "codec", ",", "ok", ":=", "c", ".", "(", "*", "securecookie", ".", "SecureCookie", ")", ";", ...
// MaxLength restricts the maximum length of new sessions to l. // If l is 0 there is no limit to the size of a session, use with caution. // The default for a new MemcacheStore is 4096.
[ "MaxLength", "restricts", "the", "maximum", "length", "of", "new", "sessions", "to", "l", ".", "If", "l", "is", "0", "there", "is", "no", "limit", "to", "the", "size", "of", "a", "session", "use", "with", "caution", ".", "The", "default", "for", "a", ...
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/gsm.go#L97-L103
143,246
bradleypeabody/gorilla-sessions-memcache
memcacher_interface.go
NewGoMemcacher
func NewGoMemcacher(c *memcache.Client) *GoMemcacher { if c == nil { panic("Cannot have nil memcache client") } return &GoMemcacher{client: c} }
go
func NewGoMemcacher(c *memcache.Client) *GoMemcacher { if c == nil { panic("Cannot have nil memcache client") } return &GoMemcacher{client: c} }
[ "func", "NewGoMemcacher", "(", "c", "*", "memcache", ".", "Client", ")", "*", "GoMemcacher", "{", "if", "c", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "&", "GoMemcacher", "{", "client", ":", "c", "}", "\n", "}" ]
// NewGoMemcacher returns a wrapped gomemcache client that implements the // Memcacher interface
[ "NewGoMemcacher", "returns", "a", "wrapped", "gomemcache", "client", "that", "implements", "the", "Memcacher", "interface" ]
659414f458e1a316113a5ca21c9964dee6655454
https://github.com/bradleypeabody/gorilla-sessions-memcache/blob/659414f458e1a316113a5ca21c9964dee6655454/memcacher_interface.go#L22-L27
143,247
qor/seo
seo_setting.go
SetGlobalSetting
func (s *QorSEOSetting) SetGlobalSetting(globalSetting map[string]string) { s.Setting.GlobalSetting = globalSetting }
go
func (s *QorSEOSetting) SetGlobalSetting(globalSetting map[string]string) { s.Setting.GlobalSetting = globalSetting }
[ "func", "(", "s", "*", "QorSEOSetting", ")", "SetGlobalSetting", "(", "globalSetting", "map", "[", "string", "]", "string", ")", "{", "s", ".", "Setting", ".", "GlobalSetting", "=", "globalSetting", "\n", "}" ]
// SetGlobalSetting set QorSeoSetting's globalSetting
[ "SetGlobalSetting", "set", "QorSeoSetting", "s", "globalSetting" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo_setting.go#L109-L111
143,248
qor/seo
seo_setting.go
Scan
func (setting *Setting) Scan(value interface{}) error { if bytes, ok := value.([]byte); ok { json.Unmarshal(bytes, setting) } else if str, ok := value.(string); ok { json.Unmarshal([]byte(str), setting) } else if strs, ok := value.([]string); ok { for _, str := range strs { json.Unmarshal([]byte(str), setti...
go
func (setting *Setting) Scan(value interface{}) error { if bytes, ok := value.([]byte); ok { json.Unmarshal(bytes, setting) } else if str, ok := value.(string); ok { json.Unmarshal([]byte(str), setting) } else if strs, ok := value.([]string); ok { for _, str := range strs { json.Unmarshal([]byte(str), setti...
[ "func", "(", "setting", "*", "Setting", ")", "Scan", "(", "value", "interface", "{", "}", ")", "error", "{", "if", "bytes", ",", "ok", ":=", "value", ".", "(", "[", "]", "byte", ")", ";", "ok", "{", "json", ".", "Unmarshal", "(", "bytes", ",", ...
// Scan scan value from database into struct
[ "Scan", "scan", "value", "from", "database", "into", "struct" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo_setting.go#L139-L150
143,249
qor/seo
seo_setting.go
Value
func (setting Setting) Value() (driver.Value, error) { result, err := json.Marshal(setting) return string(result), err }
go
func (setting Setting) Value() (driver.Value, error) { result, err := json.Marshal(setting) return string(result), err }
[ "func", "(", "setting", "Setting", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "result", ",", "err", ":=", "json", ".", "Marshal", "(", "setting", ")", "\n", "return", "string", "(", "result", ")", ",", "err", "\n",...
// Value get value from struct, and save into database
[ "Value", "get", "value", "from", "struct", "and", "save", "into", "database" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo_setting.go#L153-L156
143,250
qor/seo
seo_setting.go
FormattedHTML
func (setting Setting) FormattedHTML(context *qor.Context) template.HTML { basicMeta := fmt.Sprintf("<title>%s</title>\n<meta name=\"description\" content=\"%s\">\n<meta name=\"keywords\" content=\"%s\"/>", setting.Title, setting.Description, setting.Keywords) toAbsoluteURL := func(str string) string { if u, err :...
go
func (setting Setting) FormattedHTML(context *qor.Context) template.HTML { basicMeta := fmt.Sprintf("<title>%s</title>\n<meta name=\"description\" content=\"%s\">\n<meta name=\"keywords\" content=\"%s\"/>", setting.Title, setting.Description, setting.Keywords) toAbsoluteURL := func(str string) string { if u, err :...
[ "func", "(", "setting", "Setting", ")", "FormattedHTML", "(", "context", "*", "qor", ".", "Context", ")", "template", ".", "HTML", "{", "basicMeta", ":=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\\"", "\\\"", "\\\"", "\\\"", "\\n", "\\\"", "\\\"", "...
// FormattedHTML return formated seo setting as HTML
[ "FormattedHTML", "return", "formated", "seo", "setting", "as", "HTML" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo_setting.go#L159-L217
143,251
qor/seo
seo_setting.go
ConfigureQorMetaBeforeInitialize
func (setting Setting) ConfigureQorMetaBeforeInitialize(meta resource.Metaor) { if meta, ok := meta.(*admin.Meta); ok { meta.Type = "seo" if res, ok := meta.GetBaseResource().(*admin.Resource); ok { res.UseTheme("seo_meta") } } }
go
func (setting Setting) ConfigureQorMetaBeforeInitialize(meta resource.Metaor) { if meta, ok := meta.(*admin.Meta); ok { meta.Type = "seo" if res, ok := meta.GetBaseResource().(*admin.Resource); ok { res.UseTheme("seo_meta") } } }
[ "func", "(", "setting", "Setting", ")", "ConfigureQorMetaBeforeInitialize", "(", "meta", "resource", ".", "Metaor", ")", "{", "if", "meta", ",", "ok", ":=", "meta", ".", "(", "*", "admin", ".", "Meta", ")", ";", "ok", "{", "meta", ".", "Type", "=", "...
// ConfigureQorMetaBeforeInitialize configure SEO setting for qor admin
[ "ConfigureQorMetaBeforeInitialize", "configure", "SEO", "setting", "for", "qor", "admin" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo_setting.go#L220-L227
143,252
qor/seo
seo_setting.go
ConfigureQorResource
func (setting Setting) ConfigureQorResource(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { res.Meta(&admin.Meta{Name: "Title", Label: "HTML Title"}) res.Meta(&admin.Meta{Name: "Description", Label: "Meta Description"}) res.Meta(&admin.Meta{Name: "Keywords", Label: "Meta Keywords"}) res.Met...
go
func (setting Setting) ConfigureQorResource(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { res.Meta(&admin.Meta{Name: "Title", Label: "HTML Title"}) res.Meta(&admin.Meta{Name: "Description", Label: "Meta Description"}) res.Meta(&admin.Meta{Name: "Keywords", Label: "Meta Keywords"}) res.Met...
[ "func", "(", "setting", "Setting", ")", "ConfigureQorResource", "(", "res", "resource", ".", "Resourcer", ")", "{", "if", "res", ",", "ok", ":=", "res", ".", "(", "*", "admin", ".", "Resource", ")", ";", "ok", "{", "res", ".", "Meta", "(", "&", "ad...
// ConfigureQorResource configure resource for seo setting
[ "ConfigureQorResource", "configure", "resource", "for", "seo", "setting" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo_setting.go#L230-L261
143,253
qor/seo
seo.go
RegisterSEO
func (collection *Collection) RegisterSEO(seo *SEO) { seo.collection = collection if seo.OpenGraph == nil { seo.OpenGraph = &OpenGraphConfig{} } collection.registeredSEO = append(collection.registeredSEO, seo) }
go
func (collection *Collection) RegisterSEO(seo *SEO) { seo.collection = collection if seo.OpenGraph == nil { seo.OpenGraph = &OpenGraphConfig{} } collection.registeredSEO = append(collection.registeredSEO, seo) }
[ "func", "(", "collection", "*", "Collection", ")", "RegisterSEO", "(", "seo", "*", "SEO", ")", "{", "seo", ".", "collection", "=", "collection", "\n", "if", "seo", ".", "OpenGraph", "==", "nil", "{", "seo", ".", "OpenGraph", "=", "&", "OpenGraphConfig", ...
// RegisterSEO register a seo
[ "RegisterSEO", "register", "a", "seo" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo.go#L58-L64
143,254
qor/seo
seo.go
GetSEOSetting
func (collection Collection) GetSEOSetting(context *qor.Context, name string, objects ...interface{}) Setting { var ( seoSetting Setting db = context.GetDB() seo = collection.GetSEO(name) ) // If passed objects has customzied SEO Setting field for _, obj := range objects { if value := reflec...
go
func (collection Collection) GetSEOSetting(context *qor.Context, name string, objects ...interface{}) Setting { var ( seoSetting Setting db = context.GetDB() seo = collection.GetSEO(name) ) // If passed objects has customzied SEO Setting field for _, obj := range objects { if value := reflec...
[ "func", "(", "collection", "Collection", ")", "GetSEOSetting", "(", "context", "*", "qor", ".", "Context", ",", "name", "string", ",", "objects", "...", "interface", "{", "}", ")", "Setting", "{", "var", "(", "seoSetting", "Setting", "\n", "db", "=", "co...
// GetSEOSetting return SEO title, keywords and description and open graph settings
[ "GetSEOSetting", "return", "SEO", "title", "keywords", "and", "description", "and", "open", "graph", "settings" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo.go#L67-L108
143,255
qor/seo
seo.go
Render
func (collection Collection) Render(context *qor.Context, name string, objects ...interface{}) template.HTML { seoSetting := collection.GetSEOSetting(context, name, objects...) return seoSetting.FormattedHTML(context) }
go
func (collection Collection) Render(context *qor.Context, name string, objects ...interface{}) template.HTML { seoSetting := collection.GetSEOSetting(context, name, objects...) return seoSetting.FormattedHTML(context) }
[ "func", "(", "collection", "Collection", ")", "Render", "(", "context", "*", "qor", ".", "Context", ",", "name", "string", ",", "objects", "...", "interface", "{", "}", ")", "template", ".", "HTML", "{", "seoSetting", ":=", "collection", ".", "GetSEOSettin...
// Render render SEO Setting
[ "Render", "render", "SEO", "Setting" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo.go#L111-L114
143,256
qor/seo
seo.go
GetSEO
func (collection *Collection) GetSEO(name string) *SEO { for _, s := range collection.registeredSEO { if s.Name == name { return s } } return &SEO{Name: name, collection: collection} }
go
func (collection *Collection) GetSEO(name string) *SEO { for _, s := range collection.registeredSEO { if s.Name == name { return s } } return &SEO{Name: name, collection: collection} }
[ "func", "(", "collection", "*", "Collection", ")", "GetSEO", "(", "name", "string", ")", "*", "SEO", "{", "for", "_", ",", "s", ":=", "range", "collection", ".", "registeredSEO", "{", "if", "s", ".", "Name", "==", "name", "{", "return", "s", "\n", ...
// GetSEO get a Seo by name
[ "GetSEO", "get", "a", "Seo", "by", "name" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo.go#L117-L125
143,257
qor/seo
seo.go
SEOSettingURL
func (collection *Collection) SEOSettingURL(name string) string { qorAdmin := collection.resource.GetAdmin() return fmt.Sprintf("%v/%v/!seo_setting?name=%v", qorAdmin.GetRouter().Prefix, collection.resource.ToParam(), url.QueryEscape(name)) }
go
func (collection *Collection) SEOSettingURL(name string) string { qorAdmin := collection.resource.GetAdmin() return fmt.Sprintf("%v/%v/!seo_setting?name=%v", qorAdmin.GetRouter().Prefix, collection.resource.ToParam(), url.QueryEscape(name)) }
[ "func", "(", "collection", "*", "Collection", ")", "SEOSettingURL", "(", "name", "string", ")", "string", "{", "qorAdmin", ":=", "collection", ".", "resource", ".", "GetAdmin", "(", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "qorAd...
// SEOSettingURL get setting inline edit url by name
[ "SEOSettingURL", "get", "setting", "inline", "edit", "url", "by", "name" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo.go#L128-L131
143,258
qor/seo
seo.go
ConfigureQorResource
func (collection *Collection) ConfigureQorResource(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { Admin := res.GetAdmin() collection.resource = res if collection.SettingResource == nil { collection.SettingResource = Admin.AddResource(&QorSEOSetting{}, &admin.Config{Invisible: true}) } ...
go
func (collection *Collection) ConfigureQorResource(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { Admin := res.GetAdmin() collection.resource = res if collection.SettingResource == nil { collection.SettingResource = Admin.AddResource(&QorSEOSetting{}, &admin.Config{Invisible: true}) } ...
[ "func", "(", "collection", "*", "Collection", ")", "ConfigureQorResource", "(", "res", "resource", ".", "Resourcer", ")", "{", "if", "res", ",", "ok", ":=", "res", ".", "(", "*", "admin", ".", "Resource", ")", ";", "ok", "{", "Admin", ":=", "res", "....
// ConfigureQorResource configure seoCollection for qor admin
[ "ConfigureQorResource", "configure", "seoCollection", "for", "qor", "admin" ]
d01525bb20e1d11b2cf38cd647f13bb6b7be6e85
https://github.com/qor/seo/blob/d01525bb20e1d11b2cf38cd647f13bb6b7be6e85/seo.go#L134-L162
143,259
codeship/go-retro
examples/simple/simple_example.go
main
func main() { data := map[string]int{} for i := 0; i < 100; i++ { err := retro.DoWithRetry(func() error { return storeInt(data, i) }) if err != nil { fmt.Printf("FATAL: Failed to store %d: %s\n", i, err.Error()) os.Exit(1) } } }
go
func main() { data := map[string]int{} for i := 0; i < 100; i++ { err := retro.DoWithRetry(func() error { return storeInt(data, i) }) if err != nil { fmt.Printf("FATAL: Failed to store %d: %s\n", i, err.Error()) os.Exit(1) } } }
[ "func", "main", "(", ")", "{", "data", ":=", "map", "[", "string", "]", "int", "{", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "100", ";", "i", "++", "{", "err", ":=", "retro", ".", "DoWithRetry", "(", "func", "(", ")", "error", "{", ...
// Stores all ints from 0-99 under random unique keys in a map
[ "Stores", "all", "ints", "from", "0", "-", "99", "under", "random", "unique", "keys", "in", "a", "map" ]
7769938966875e265624df6980c916be85a4ed3b
https://github.com/codeship/go-retro/blob/7769938966875e265624df6980c916be85a4ed3b/examples/simple/simple_example.go#L21-L34
143,260
codeship/go-retro
examples/network/network_example.go
main
func main() { serverID := "abc123" var version string err := retro.DoWithRetry(func() error { var e error version, e = getServer(serverID) if e != nil { return e } fmt.Printf("Server version %s\n", version) return nil }) if err != nil { fmt.Printf("FATAL: Failed to get server info %s\n", err.Error...
go
func main() { serverID := "abc123" var version string err := retro.DoWithRetry(func() error { var e error version, e = getServer(serverID) if e != nil { return e } fmt.Printf("Server version %s\n", version) return nil }) if err != nil { fmt.Printf("FATAL: Failed to get server info %s\n", err.Error...
[ "func", "main", "(", ")", "{", "serverID", ":=", "\"", "\"", "\n", "var", "version", "string", "\n", "err", ":=", "retro", ".", "DoWithRetry", "(", "func", "(", ")", "error", "{", "var", "e", "error", "\n", "version", ",", "e", "=", "getServer", "(...
// Gets a server version by id, and tries to use it until it is ready
[ "Gets", "a", "server", "version", "by", "id", "and", "tries", "to", "use", "it", "until", "it", "is", "ready" ]
7769938966875e265624df6980c916be85a4ed3b
https://github.com/codeship/go-retro/blob/7769938966875e265624df6980c916be85a4ed3b/examples/network/network_example.go#L24-L49
143,261
codeship/go-retro
retro.go
NewStaticRetryableError
func NewStaticRetryableError(err error, maxAttempts, waitSeconds int) RetryableError { return &staticRetryableError{err, maxAttempts, time.Duration(waitSeconds)} }
go
func NewStaticRetryableError(err error, maxAttempts, waitSeconds int) RetryableError { return &staticRetryableError{err, maxAttempts, time.Duration(waitSeconds)} }
[ "func", "NewStaticRetryableError", "(", "err", "error", ",", "maxAttempts", ",", "waitSeconds", "int", ")", "RetryableError", "{", "return", "&", "staticRetryableError", "{", "err", ",", "maxAttempts", ",", "time", ".", "Duration", "(", "waitSeconds", ")", "}", ...
// NewStaticRetryableError creates a RetryableError which will retry up // to maxAttempts times sleeping waitSeconds in between tries
[ "NewStaticRetryableError", "creates", "a", "RetryableError", "which", "will", "retry", "up", "to", "maxAttempts", "times", "sleeping", "waitSeconds", "in", "between", "tries" ]
7769938966875e265624df6980c916be85a4ed3b
https://github.com/codeship/go-retro/blob/7769938966875e265624df6980c916be85a4ed3b/retro.go#L58-L60
143,262
codeship/go-retro
retro.go
NewLogarithmicRetryableError
func NewLogarithmicRetryableError(err error, maxAttempts int, baseOffset, scale, power float64) RetryableError { return &logarithmicRetryableError{err, maxAttempts, baseOffset, scale, power} }
go
func NewLogarithmicRetryableError(err error, maxAttempts int, baseOffset, scale, power float64) RetryableError { return &logarithmicRetryableError{err, maxAttempts, baseOffset, scale, power} }
[ "func", "NewLogarithmicRetryableError", "(", "err", "error", ",", "maxAttempts", "int", ",", "baseOffset", ",", "scale", ",", "power", "float64", ")", "RetryableError", "{", "return", "&", "logarithmicRetryableError", "{", "err", ",", "maxAttempts", ",", "baseOffs...
// NewLogarithmicRetryableError creates a RetryableError which will retry up // to maxAttempts times, with a sleep pattern defined by a logarithmic curve
[ "NewLogarithmicRetryableError", "creates", "a", "RetryableError", "which", "will", "retry", "up", "to", "maxAttempts", "times", "with", "a", "sleep", "pattern", "defined", "by", "a", "logarithmic", "curve" ]
7769938966875e265624df6980c916be85a4ed3b
https://github.com/codeship/go-retro/blob/7769938966875e265624df6980c916be85a4ed3b/retro.go#L81-L83
143,263
codeship/go-retro
retro.go
DoWithRetry
func DoWithRetry(f func() error) error { var err error try := true handler := &retryHandler{} for try { try, err = handler.Try(f) } return err }
go
func DoWithRetry(f func() error) error { var err error try := true handler := &retryHandler{} for try { try, err = handler.Try(f) } return err }
[ "func", "DoWithRetry", "(", "f", "func", "(", ")", "error", ")", "error", "{", "var", "err", "error", "\n", "try", ":=", "true", "\n", "handler", ":=", "&", "retryHandler", "{", "}", "\n", "for", "try", "{", "try", ",", "err", "=", "handler", ".", ...
// DoWithRetry will execute a function as many times as is dictated by any // retryable errors propagated by the function
[ "DoWithRetry", "will", "execute", "a", "function", "as", "many", "times", "as", "is", "dictated", "by", "any", "retryable", "errors", "propagated", "by", "the", "function" ]
7769938966875e265624df6980c916be85a4ed3b
https://github.com/codeship/go-retro/blob/7769938966875e265624df6980c916be85a4ed3b/retro.go#L87-L95
143,264
codeship/go-retro
retro.go
WrapRetryableError
func WrapRetryableError(err error, errorList []*regexp.Regexp, errorCreator ErrorCreator) error { if err == nil { return nil } for _, errorRegex := range errorList { if errorRegex.MatchString(err.Error()) { return errorCreator(err) } } return err }
go
func WrapRetryableError(err error, errorList []*regexp.Regexp, errorCreator ErrorCreator) error { if err == nil { return nil } for _, errorRegex := range errorList { if errorRegex.MatchString(err.Error()) { return errorCreator(err) } } return err }
[ "func", "WrapRetryableError", "(", "err", "error", ",", "errorList", "[", "]", "*", "regexp", ".", "Regexp", ",", "errorCreator", "ErrorCreator", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "for", "_", ",", "erro...
// WrapRetryableError takes an error, and given a set of retryable error regexes, returns // a suitable error type, either a standard error or a retryable error
[ "WrapRetryableError", "takes", "an", "error", "and", "given", "a", "set", "of", "retryable", "error", "regexes", "returns", "a", "suitable", "error", "type", "either", "a", "standard", "error", "or", "a", "retryable", "error" ]
7769938966875e265624df6980c916be85a4ed3b
https://github.com/codeship/go-retro/blob/7769938966875e265624df6980c916be85a4ed3b/retro.go#L116-L126
143,265
go-macaron/captcha
image.go
NewImage
func NewImage(digits []byte, width, height int, colorPalette color.Palette) *Image { m := new(Image) m.Paletted = image.NewPaletted(image.Rect(0, 0, width, height), randomPalette(colorPalette)) m.calculateSizes(width, height, len(digits)) // Randomly position captcha inside the image. maxx := width - (m.numWidth+m...
go
func NewImage(digits []byte, width, height int, colorPalette color.Palette) *Image { m := new(Image) m.Paletted = image.NewPaletted(image.Rect(0, 0, width, height), randomPalette(colorPalette)) m.calculateSizes(width, height, len(digits)) // Randomly position captcha inside the image. maxx := width - (m.numWidth+m...
[ "func", "NewImage", "(", "digits", "[", "]", "byte", ",", "width", ",", "height", "int", ",", "colorPalette", "color", ".", "Palette", ")", "*", "Image", "{", "m", ":=", "new", "(", "Image", ")", "\n", "m", ".", "Paletted", "=", "image", ".", "NewP...
// NewImage returns a new captcha image of the given width and height with the // given digits, where each digit must be in range 0-9. The digit's color is // chosen by random from the colorPalette.
[ "NewImage", "returns", "a", "new", "captcha", "image", "of", "the", "given", "width", "and", "height", "with", "the", "given", "digits", "where", "each", "digit", "must", "be", "in", "range", "0", "-", "9", ".", "The", "digit", "s", "color", "is", "cho...
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/image.go#L296-L323
143,266
steakknife/hamming
popcount_slices.go
CountBitsInt8s
func CountBitsInt8s(b []int8) int { c := 0 for _, x := range b { c += CountBitsInt8(x) } return c }
go
func CountBitsInt8s(b []int8) int { c := 0 for _, x := range b { c += CountBitsInt8(x) } return c }
[ "func", "CountBitsInt8s", "(", "b", "[", "]", "int8", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsInt8", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsInt8s count 1's in b
[ "CountBitsInt8s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L13-L19
143,267
steakknife/hamming
popcount_slices.go
CountBitsInt16s
func CountBitsInt16s(b []int16) int { c := 0 for _, x := range b { c += CountBitsInt16(x) } return c }
go
func CountBitsInt16s(b []int16) int { c := 0 for _, x := range b { c += CountBitsInt16(x) } return c }
[ "func", "CountBitsInt16s", "(", "b", "[", "]", "int16", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsInt16", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsInt16s count 1's in b
[ "CountBitsInt16s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L22-L28
143,268
steakknife/hamming
popcount_slices.go
CountBitsInt32s
func CountBitsInt32s(b []int32) int { c := 0 for _, x := range b { c += CountBitsInt32(x) } return c }
go
func CountBitsInt32s(b []int32) int { c := 0 for _, x := range b { c += CountBitsInt32(x) } return c }
[ "func", "CountBitsInt32s", "(", "b", "[", "]", "int32", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsInt32", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsInt32s count 1's in b
[ "CountBitsInt32s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L31-L37
143,269
steakknife/hamming
popcount_slices.go
CountBitsInt64s
func CountBitsInt64s(b []int64) int { c := 0 for _, x := range b { c += CountBitsInt64(x) } return c }
go
func CountBitsInt64s(b []int64) int { c := 0 for _, x := range b { c += CountBitsInt64(x) } return c }
[ "func", "CountBitsInt64s", "(", "b", "[", "]", "int64", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsInt64", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsInt64s count 1's in b
[ "CountBitsInt64s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L40-L46
143,270
steakknife/hamming
popcount_slices.go
CountBitsInts
func CountBitsInts(b []int) int { c := 0 for _, x := range b { c += CountBitsInt(x) } return c }
go
func CountBitsInts(b []int) int { c := 0 for _, x := range b { c += CountBitsInt(x) } return c }
[ "func", "CountBitsInts", "(", "b", "[", "]", "int", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsInt", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsInts count 1's in b
[ "CountBitsInts", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L49-L55
143,271
steakknife/hamming
popcount_slices.go
CountBitsUint8s
func CountBitsUint8s(b []uint8) int { c := 0 for _, x := range b { c += CountBitsUint8(x) } return c }
go
func CountBitsUint8s(b []uint8) int { c := 0 for _, x := range b { c += CountBitsUint8(x) } return c }
[ "func", "CountBitsUint8s", "(", "b", "[", "]", "uint8", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsUint8", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsUint8s count 1's in b
[ "CountBitsUint8s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L58-L64
143,272
steakknife/hamming
popcount_slices.go
CountBitsUint16s
func CountBitsUint16s(b []uint16) int { c := 0 for _, x := range b { c += CountBitsUint16(x) } return c }
go
func CountBitsUint16s(b []uint16) int { c := 0 for _, x := range b { c += CountBitsUint16(x) } return c }
[ "func", "CountBitsUint16s", "(", "b", "[", "]", "uint16", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsUint16", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsUint16s count 1's in b
[ "CountBitsUint16s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L67-L73
143,273
steakknife/hamming
popcount_slices.go
CountBitsUint32s
func CountBitsUint32s(b []uint32) int { c := 0 for _, x := range b { c += CountBitsUint32(x) } return c }
go
func CountBitsUint32s(b []uint32) int { c := 0 for _, x := range b { c += CountBitsUint32(x) } return c }
[ "func", "CountBitsUint32s", "(", "b", "[", "]", "uint32", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsUint32", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsUint32s count 1's in b
[ "CountBitsUint32s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L76-L82
143,274
steakknife/hamming
popcount_slices.go
CountBitsUint64s
func CountBitsUint64s(b []uint64) int { c := 0 for _, x := range b { c += CountBitsUint64(x) } return c }
go
func CountBitsUint64s(b []uint64) int { c := 0 for _, x := range b { c += CountBitsUint64(x) } return c }
[ "func", "CountBitsUint64s", "(", "b", "[", "]", "uint64", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsUint64", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsUint64s count 1's in b
[ "CountBitsUint64s", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L85-L91
143,275
steakknife/hamming
popcount_slices.go
CountBitsUints
func CountBitsUints(b []uint) int { c := 0 for _, x := range b { c += CountBitsUint(x) } return c }
go
func CountBitsUints(b []uint) int { c := 0 for _, x := range b { c += CountBitsUint(x) } return c }
[ "func", "CountBitsUints", "(", "b", "[", "]", "uint", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsUint", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsUints count 1's in b
[ "CountBitsUints", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L94-L100
143,276
steakknife/hamming
popcount_slices.go
CountBitsBytes
func CountBitsBytes(b []byte) int { c := 0 for _, x := range b { c += CountBitsByte(x) } return c }
go
func CountBitsBytes(b []byte) int { c := 0 for _, x := range b { c += CountBitsByte(x) } return c }
[ "func", "CountBitsBytes", "(", "b", "[", "]", "byte", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsByte", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsBytes count 1's in b
[ "CountBitsBytes", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L103-L109
143,277
steakknife/hamming
popcount_slices.go
CountBitsRunes
func CountBitsRunes(b []rune) int { c := 0 for _, x := range b { c += CountBitsRune(x) } return c }
go
func CountBitsRunes(b []rune) int { c := 0 for _, x := range b { c += CountBitsRune(x) } return c }
[ "func", "CountBitsRunes", "(", "b", "[", "]", "rune", ")", "int", "{", "c", ":=", "0", "\n", "for", "_", ",", "x", ":=", "range", "b", "{", "c", "+=", "CountBitsRune", "(", "x", ")", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsRunes count 1's in b
[ "CountBitsRunes", "count", "1", "s", "in", "b" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices.go#L112-L118
143,278
steakknife/hamming
popcount.go
CountBitsByteAlt
func CountBitsByteAlt(x byte) int { x = (x & 0x55) + ((x >> 1) & 0x55) x = (x & 0x33) + ((x >> 2) & 0x33) return int((x & 0x0f) + ((x >> 4) & 0x0f)) }
go
func CountBitsByteAlt(x byte) int { x = (x & 0x55) + ((x >> 1) & 0x55) x = (x & 0x33) + ((x >> 2) & 0x33) return int((x & 0x0f) + ((x >> 4) & 0x0f)) }
[ "func", "CountBitsByteAlt", "(", "x", "byte", ")", "int", "{", "x", "=", "(", "x", "&", "0x55", ")", "+", "(", "(", "x", ">>", "1", ")", "&", "0x55", ")", "\n", "x", "=", "(", "x", "&", "0x33", ")", "+", "(", "(", "x", ">>", "2", ")", "...
// CountBitsByteAlt table-less, branch-free implementation
[ "CountBitsByteAlt", "table", "-", "less", "branch", "-", "free", "implementation" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount.go#L38-L42
143,279
steakknife/hamming
popcount.go
CountBitsUint32
func CountBitsUint32(x uint32) int { x -= ((x >> 1) & m1d) x = (x & m2d) + ((x >> 2) & m2d) x = (x + (x >> 4)) & m4d x += x >> 8 x += x >> 16 return int(x & 0x3f) }
go
func CountBitsUint32(x uint32) int { x -= ((x >> 1) & m1d) x = (x & m2d) + ((x >> 2) & m2d) x = (x + (x >> 4)) & m4d x += x >> 8 x += x >> 16 return int(x & 0x3f) }
[ "func", "CountBitsUint32", "(", "x", "uint32", ")", "int", "{", "x", "-=", "(", "(", "x", ">>", "1", ")", "&", "m1d", ")", "\n", "x", "=", "(", "x", "&", "m2d", ")", "+", "(", "(", "x", ">>", "2", ")", "&", "m2d", ")", "\n", "x", "=", "...
// CountBitsUint32 count 1's in x
[ "CountBitsUint32", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount.go#L80-L87
143,280
steakknife/hamming
popcount.go
CountBitsUint64
func CountBitsUint64(x uint64) int { // put count of each 2 bits into those 2 bits x -= (x >> 1) & m1q // put count of each 4 bits into those 4 bits x = (x & m2q) + ((x >> 2) & m2q) // put count of each 8 bits into those 8 bits x = (x + (x >> 4)) & m4q // returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) ...
go
func CountBitsUint64(x uint64) int { // put count of each 2 bits into those 2 bits x -= (x >> 1) & m1q // put count of each 4 bits into those 4 bits x = (x & m2q) + ((x >> 2) & m2q) // put count of each 8 bits into those 8 bits x = (x + (x >> 4)) & m4q // returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) ...
[ "func", "CountBitsUint64", "(", "x", "uint64", ")", "int", "{", "// put count of each 2 bits into those 2 bits", "x", "-=", "(", "x", ">>", "1", ")", "&", "m1q", "\n\n", "// put count of each 4 bits into those 4 bits", "x", "=", "(", "x", "&", "m2q", ")", "+", ...
// CountBitsUint64 count 1's in x
[ "CountBitsUint64", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount.go#L97-L109
143,281
steakknife/hamming
popcount.go
CountBitsUint64Alt
func CountBitsUint64Alt(x uint64) int { return CountBitsUint32(uint32(x>>32)) + CountBitsUint32(uint32(x)) }
go
func CountBitsUint64Alt(x uint64) int { return CountBitsUint32(uint32(x>>32)) + CountBitsUint32(uint32(x)) }
[ "func", "CountBitsUint64Alt", "(", "x", "uint64", ")", "int", "{", "return", "CountBitsUint32", "(", "uint32", "(", "x", ">>", "32", ")", ")", "+", "CountBitsUint32", "(", "uint32", "(", "x", ")", ")", "\n", "}" ]
// CountBitsUint64Alt count 1's in x
[ "CountBitsUint64Alt", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount.go#L112-L114
143,282
steakknife/hamming
popcount.go
CountBitsUintReference
func CountBitsUintReference(x uint) int { c := 0 for x != 0 { x &= x - 1 c++ } return c }
go
func CountBitsUintReference(x uint) int { c := 0 for x != 0 { x &= x - 1 c++ } return c }
[ "func", "CountBitsUintReference", "(", "x", "uint", ")", "int", "{", "c", ":=", "0", "\n", "for", "x", "!=", "0", "{", "x", "&=", "x", "-", "1", "\n", "c", "++", "\n", "}", "\n", "return", "c", "\n", "}" ]
// CountBitsUintReference count 1's in x
[ "CountBitsUintReference", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount.go#L117-L124
143,283
steakknife/hamming
popcount.go
CountBitsUint
func CountBitsUint(x uint) int { if strconv.IntSize == 64 { return CountBitsUint64(uint64(x)) } else if strconv.IntSize == 32 { return CountBitsUint32(uint32(x)) } panic("strconv.IntSize must be 32 or 64 bits") }
go
func CountBitsUint(x uint) int { if strconv.IntSize == 64 { return CountBitsUint64(uint64(x)) } else if strconv.IntSize == 32 { return CountBitsUint32(uint32(x)) } panic("strconv.IntSize must be 32 or 64 bits") }
[ "func", "CountBitsUint", "(", "x", "uint", ")", "int", "{", "if", "strconv", ".", "IntSize", "==", "64", "{", "return", "CountBitsUint64", "(", "uint64", "(", "x", ")", ")", "\n", "}", "else", "if", "strconv", ".", "IntSize", "==", "32", "{", "return...
// CountBitsUint count 1's in x
[ "CountBitsUint", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount.go#L127-L134
143,284
go-macaron/captcha
captcha.go
genRandChars
func (c *Captcha) genRandChars() string { return string(com.RandomCreateBytes(c.ChallengeNums, defaultChars...)) }
go
func (c *Captcha) genRandChars() string { return string(com.RandomCreateBytes(c.ChallengeNums, defaultChars...)) }
[ "func", "(", "c", "*", "Captcha", ")", "genRandChars", "(", ")", "string", "{", "return", "string", "(", "com", ".", "RandomCreateBytes", "(", "c", ".", "ChallengeNums", ",", "defaultChars", "...", ")", ")", "\n", "}" ]
// generate rand chars with default chars
[ "generate", "rand", "chars", "with", "default", "chars" ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L62-L64
143,285
go-macaron/captcha
captcha.go
CreateHTML
func (c *Captcha) CreateHTML() template.HTML { value, err := c.CreateCaptcha() if err != nil { panic(fmt.Errorf("fail to create captcha: %v", err)) } return template.HTML(fmt.Sprintf(`<input type="hidden" name="%[1]s" value="%[2]s"> <a class="captcha" href="javascript:" tabindex="-1"> <img onclick="this.src=('...
go
func (c *Captcha) CreateHTML() template.HTML { value, err := c.CreateCaptcha() if err != nil { panic(fmt.Errorf("fail to create captcha: %v", err)) } return template.HTML(fmt.Sprintf(`<input type="hidden" name="%[1]s" value="%[2]s"> <a class="captcha" href="javascript:" tabindex="-1"> <img onclick="this.src=('...
[ "func", "(", "c", "*", "Captcha", ")", "CreateHTML", "(", ")", "template", ".", "HTML", "{", "value", ",", "err", ":=", "c", ".", "CreateCaptcha", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"",...
// CreateHTML outputs HTML for display and fetch new captcha images.
[ "CreateHTML", "outputs", "HTML", "for", "display", "and", "fetch", "new", "captcha", "images", "." ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L67-L76
143,286
go-macaron/captcha
captcha.go
CreateCaptcha
func (c *Captcha) CreateCaptcha() (string, error) { id := string(com.RandomCreateBytes(15)) if err := c.store.Put(c.key(id), c.genRandChars(), c.Expiration); err != nil { return "", err } return id, nil }
go
func (c *Captcha) CreateCaptcha() (string, error) { id := string(com.RandomCreateBytes(15)) if err := c.store.Put(c.key(id), c.genRandChars(), c.Expiration); err != nil { return "", err } return id, nil }
[ "func", "(", "c", "*", "Captcha", ")", "CreateCaptcha", "(", ")", "(", "string", ",", "error", ")", "{", "id", ":=", "string", "(", "com", ".", "RandomCreateBytes", "(", "15", ")", ")", "\n", "if", "err", ":=", "c", ".", "store", ".", "Put", "(",...
// create a new captcha id
[ "create", "a", "new", "captcha", "id" ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L84-L90
143,287
go-macaron/captcha
captcha.go
VerifyReq
func (c *Captcha) VerifyReq(req macaron.Request) bool { req.ParseForm() return c.Verify(req.Form.Get(c.FieldIdName), req.Form.Get(c.FieldCaptchaName)) }
go
func (c *Captcha) VerifyReq(req macaron.Request) bool { req.ParseForm() return c.Verify(req.Form.Get(c.FieldIdName), req.Form.Get(c.FieldCaptchaName)) }
[ "func", "(", "c", "*", "Captcha", ")", "VerifyReq", "(", "req", "macaron", ".", "Request", ")", "bool", "{", "req", ".", "ParseForm", "(", ")", "\n", "return", "c", ".", "Verify", "(", "req", ".", "Form", ".", "Get", "(", "c", ".", "FieldIdName", ...
// verify from a request
[ "verify", "from", "a", "request" ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L93-L96
143,288
go-macaron/captcha
captcha.go
Verify
func (c *Captcha) Verify(id string, challenge string) bool { if len(challenge) == 0 || len(id) == 0 { return false } var chars string key := c.key(id) if v, ok := c.store.Get(key).(string); ok { chars = v } else { return false } defer c.store.Delete(key) if len(chars) != len(challenge) { return fa...
go
func (c *Captcha) Verify(id string, challenge string) bool { if len(challenge) == 0 || len(id) == 0 { return false } var chars string key := c.key(id) if v, ok := c.store.Get(key).(string); ok { chars = v } else { return false } defer c.store.Delete(key) if len(chars) != len(challenge) { return fa...
[ "func", "(", "c", "*", "Captcha", ")", "Verify", "(", "id", "string", ",", "challenge", "string", ")", "bool", "{", "if", "len", "(", "challenge", ")", "==", "0", "||", "len", "(", "id", ")", "==", "0", "{", "return", "false", "\n", "}", "\n\n", ...
// direct verify id and challenge string
[ "direct", "verify", "id", "and", "challenge", "string" ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L99-L128
143,289
go-macaron/captcha
captcha.go
NewCaptcha
func NewCaptcha(opt Options) *Captcha { return &Captcha{ SubURL: opt.SubURL, URLPrefix: opt.URLPrefix, FieldIdName: opt.FieldIdName, FieldCaptchaName: opt.FieldCaptchaName, StdWidth: opt.Width, StdHeight: opt.Height, ChallengeNums: opt.ChallengeNums, Expiration: ...
go
func NewCaptcha(opt Options) *Captcha { return &Captcha{ SubURL: opt.SubURL, URLPrefix: opt.URLPrefix, FieldIdName: opt.FieldIdName, FieldCaptchaName: opt.FieldCaptchaName, StdWidth: opt.Width, StdHeight: opt.Height, ChallengeNums: opt.ChallengeNums, Expiration: ...
[ "func", "NewCaptcha", "(", "opt", "Options", ")", "*", "Captcha", "{", "return", "&", "Captcha", "{", "SubURL", ":", "opt", ".", "SubURL", ",", "URLPrefix", ":", "opt", ".", "URLPrefix", ",", "FieldIdName", ":", "opt", ".", "FieldIdName", ",", "FieldCapt...
// NewCaptcha initializes and returns a captcha with given options.
[ "NewCaptcha", "initializes", "and", "returns", "a", "captcha", "with", "given", "options", "." ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L194-L207
143,290
go-macaron/captcha
captcha.go
Captchaer
func Captchaer(options ...Options) macaron.Handler { return func(ctx *macaron.Context, cache cache.Cache) { cpt := NewCaptcha(prepareOptions(options)) cpt.store = cache if strings.HasPrefix(ctx.Req.URL.Path, cpt.URLPrefix) { var chars string id := path.Base(ctx.Req.URL.Path) if i := strings.Index(id, "...
go
func Captchaer(options ...Options) macaron.Handler { return func(ctx *macaron.Context, cache cache.Cache) { cpt := NewCaptcha(prepareOptions(options)) cpt.store = cache if strings.HasPrefix(ctx.Req.URL.Path, cpt.URLPrefix) { var chars string id := path.Base(ctx.Req.URL.Path) if i := strings.Index(id, "...
[ "func", "Captchaer", "(", "options", "...", "Options", ")", "macaron", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "macaron", ".", "Context", ",", "cache", "cache", ".", "Cache", ")", "{", "cpt", ":=", "NewCaptcha", "(", "prepareOptions", "("...
// Captchaer is a middleware that maps a captcha.Captcha service into the Macaron handler chain. // An single variadic captcha.Options struct can be optionally provided to configure. // This should be register after cache.Cacher.
[ "Captchaer", "is", "a", "middleware", "that", "maps", "a", "captcha", ".", "Captcha", "service", "into", "the", "Macaron", "handler", "chain", ".", "An", "single", "variadic", "captcha", ".", "Options", "struct", "can", "be", "optionally", "provided", "to", ...
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/captcha.go#L212-L252
143,291
steakknife/hamming
popcnt_amd64.go
CountBitsIntPopCnt
func CountBitsIntPopCnt(x int) int { if strconv.IntSize == 64 { return CountBitsInt64PopCnt(int64(x)) } else if strconv.IntSize == 32 { return CountBitsInt32PopCnt(int32(x)) } panic("strconv.IntSize must be 32 or 64") }
go
func CountBitsIntPopCnt(x int) int { if strconv.IntSize == 64 { return CountBitsInt64PopCnt(int64(x)) } else if strconv.IntSize == 32 { return CountBitsInt32PopCnt(int32(x)) } panic("strconv.IntSize must be 32 or 64") }
[ "func", "CountBitsIntPopCnt", "(", "x", "int", ")", "int", "{", "if", "strconv", ".", "IntSize", "==", "64", "{", "return", "CountBitsInt64PopCnt", "(", "int64", "(", "x", ")", ")", "\n", "}", "else", "if", "strconv", ".", "IntSize", "==", "32", "{", ...
// CountBitsIntPopCnt count 1's in x
[ "CountBitsIntPopCnt", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcnt_amd64.go#L30-L37
143,292
steakknife/hamming
popcnt_amd64.go
CountBitsUintPopCnt
func CountBitsUintPopCnt(x uint) int { if strconv.IntSize == 64 { return CountBitsUint64PopCnt(uint64(x)) } else if strconv.IntSize == 32 { return CountBitsUint32PopCnt(uint32(x)) } panic("strconv.IntSize must be 32 or 64") }
go
func CountBitsUintPopCnt(x uint) int { if strconv.IntSize == 64 { return CountBitsUint64PopCnt(uint64(x)) } else if strconv.IntSize == 32 { return CountBitsUint32PopCnt(uint32(x)) } panic("strconv.IntSize must be 32 or 64") }
[ "func", "CountBitsUintPopCnt", "(", "x", "uint", ")", "int", "{", "if", "strconv", ".", "IntSize", "==", "64", "{", "return", "CountBitsUint64PopCnt", "(", "uint64", "(", "x", ")", ")", "\n", "}", "else", "if", "strconv", ".", "IntSize", "==", "32", "{...
// CountBitsUintPopCnt count 1's in x
[ "CountBitsUintPopCnt", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcnt_amd64.go#L52-L59
143,293
go-macaron/captcha
siprng.go
Uint64
func (p *siprng) Uint64() uint64 { p.mu.Lock() if p.ctr == 0 || p.ctr > 8*1024*1024 { p.rekey() } v := siphash(p.k0, p.k1, p.ctr) p.ctr++ p.mu.Unlock() return v }
go
func (p *siprng) Uint64() uint64 { p.mu.Lock() if p.ctr == 0 || p.ctr > 8*1024*1024 { p.rekey() } v := siphash(p.k0, p.k1, p.ctr) p.ctr++ p.mu.Unlock() return v }
[ "func", "(", "p", "*", "siprng", ")", "Uint64", "(", ")", "uint64", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "p", ".", "ctr", "==", "0", "||", "p", ".", "ctr", ">", "8", "*", "1024", "*", "1024", "{", "p", ".", "rekey", "("...
// Uint64 returns a new pseudorandom uint64. // It rekeys PRNG on the first call and every 64 MB of generated data.
[ "Uint64", "returns", "a", "new", "pseudorandom", "uint64", ".", "It", "rekeys", "PRNG", "on", "the", "first", "call", "and", "every", "64", "MB", "of", "generated", "data", "." ]
d2857f392769a265d5de1aea9dc5d9d63f502416
https://github.com/go-macaron/captcha/blob/d2857f392769a265d5de1aea9dc5d9d63f502416/siprng.go#L220-L229
143,294
steakknife/hamming
popcount_slices_amd64.go
CountBitsIntsPopCnt
func CountBitsIntsPopCnt(x []int) int { if strconv.IntSize == 64 { y := (*[]int64)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsInt64sPopCnt(*y) } else if strconv.IntSize == 32 { y := (*[]int32)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsInt32sPopCnt(*y) } panic("strconv.IntSize must be 32 or ...
go
func CountBitsIntsPopCnt(x []int) int { if strconv.IntSize == 64 { y := (*[]int64)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsInt64sPopCnt(*y) } else if strconv.IntSize == 32 { y := (*[]int32)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsInt32sPopCnt(*y) } panic("strconv.IntSize must be 32 or ...
[ "func", "CountBitsIntsPopCnt", "(", "x", "[", "]", "int", ")", "int", "{", "if", "strconv", ".", "IntSize", "==", "64", "{", "y", ":=", "(", "*", "[", "]", "int64", ")", "(", "unsafe", ".", "Pointer", "(", "&", "x", ")", ")", "// #nosec G103", "\...
// CountBitsIntsPopCnt count 1's in x
[ "CountBitsIntsPopCnt", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices_amd64.go#L30-L39
143,295
steakknife/hamming
popcount_slices_amd64.go
CountBitsUintsPopCnt
func CountBitsUintsPopCnt(x []uint) int { if strconv.IntSize == 64 { y := (*[]uint64)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsUint64sPopCnt(*y) } else if strconv.IntSize == 32 { y := (*[]uint32)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsUint32sPopCnt(*y) } panic("strconv.IntSize must be ...
go
func CountBitsUintsPopCnt(x []uint) int { if strconv.IntSize == 64 { y := (*[]uint64)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsUint64sPopCnt(*y) } else if strconv.IntSize == 32 { y := (*[]uint32)(unsafe.Pointer(&x)) // #nosec G103 return CountBitsUint32sPopCnt(*y) } panic("strconv.IntSize must be ...
[ "func", "CountBitsUintsPopCnt", "(", "x", "[", "]", "uint", ")", "int", "{", "if", "strconv", ".", "IntSize", "==", "64", "{", "y", ":=", "(", "*", "[", "]", "uint64", ")", "(", "unsafe", ".", "Pointer", "(", "&", "x", ")", ")", "// #nosec G103", ...
// CountBitsUintsPopCnt count 1's in x
[ "CountBitsUintsPopCnt", "count", "1", "s", "in", "x" ]
c99c65617cd3d686aea8365fe563d6542f01d940
https://github.com/steakknife/hamming/blob/c99c65617cd3d686aea8365fe563d6542f01d940/popcount_slices_amd64.go#L54-L63
143,296
libp2p/go-libp2p-kbucket
keyspace/keyspace.go
Equal
func (k1 Key) Equal(k2 Key) bool { if k1.Space != k2.Space { panic("k1 and k2 not in same key space.") } return k1.Space.Equal(k1, k2) }
go
func (k1 Key) Equal(k2 Key) bool { if k1.Space != k2.Space { panic("k1 and k2 not in same key space.") } return k1.Space.Equal(k1, k2) }
[ "func", "(", "k1", "Key", ")", "Equal", "(", "k2", "Key", ")", "bool", "{", "if", "k1", ".", "Space", "!=", "k2", ".", "Space", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "k1", ".", "Space", ".", "Equal", "(", "k1", ",", ...
// Equal returns whether this key is equal to another.
[ "Equal", "returns", "whether", "this", "key", "is", "equal", "to", "another", "." ]
80d3b4761e24ef72711a669657ce38cd6d996d02
https://github.com/libp2p/go-libp2p-kbucket/blob/80d3b4761e24ef72711a669657ce38cd6d996d02/keyspace/keyspace.go#L25-L30
143,297
libp2p/go-libp2p-kbucket
keyspace/keyspace.go
Less
func (k1 Key) Less(k2 Key) bool { if k1.Space != k2.Space { panic("k1 and k2 not in same key space.") } return k1.Space.Less(k1, k2) }
go
func (k1 Key) Less(k2 Key) bool { if k1.Space != k2.Space { panic("k1 and k2 not in same key space.") } return k1.Space.Less(k1, k2) }
[ "func", "(", "k1", "Key", ")", "Less", "(", "k2", "Key", ")", "bool", "{", "if", "k1", ".", "Space", "!=", "k2", ".", "Space", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "k1", ".", "Space", ".", "Less", "(", "k1", ",", "...
// Less returns whether this key comes before another.
[ "Less", "returns", "whether", "this", "key", "comes", "before", "another", "." ]
80d3b4761e24ef72711a669657ce38cd6d996d02
https://github.com/libp2p/go-libp2p-kbucket/blob/80d3b4761e24ef72711a669657ce38cd6d996d02/keyspace/keyspace.go#L33-L38
143,298
libp2p/go-libp2p-kbucket
keyspace/keyspace.go
Distance
func (k1 Key) Distance(k2 Key) *big.Int { if k1.Space != k2.Space { panic("k1 and k2 not in same key space.") } return k1.Space.Distance(k1, k2) }
go
func (k1 Key) Distance(k2 Key) *big.Int { if k1.Space != k2.Space { panic("k1 and k2 not in same key space.") } return k1.Space.Distance(k1, k2) }
[ "func", "(", "k1", "Key", ")", "Distance", "(", "k2", "Key", ")", "*", "big", ".", "Int", "{", "if", "k1", ".", "Space", "!=", "k2", ".", "Space", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "k1", ".", "Space", ".", "Distan...
// Distance returns this key's distance to another
[ "Distance", "returns", "this", "key", "s", "distance", "to", "another" ]
80d3b4761e24ef72711a669657ce38cd6d996d02
https://github.com/libp2p/go-libp2p-kbucket/blob/80d3b4761e24ef72711a669657ce38cd6d996d02/keyspace/keyspace.go#L41-L46
143,299
libp2p/go-libp2p-kbucket
keyspace/keyspace.go
SortByDistance
func SortByDistance(sp KeySpace, center Key, toSort []Key) []Key { toSortCopy := make([]Key, len(toSort)) copy(toSortCopy, toSort) bdtc := &byDistanceToCenter{ Center: center, Keys: toSortCopy, // copy } sort.Sort(bdtc) return bdtc.Keys }
go
func SortByDistance(sp KeySpace, center Key, toSort []Key) []Key { toSortCopy := make([]Key, len(toSort)) copy(toSortCopy, toSort) bdtc := &byDistanceToCenter{ Center: center, Keys: toSortCopy, // copy } sort.Sort(bdtc) return bdtc.Keys }
[ "func", "SortByDistance", "(", "sp", "KeySpace", ",", "center", "Key", ",", "toSort", "[", "]", "Key", ")", "[", "]", "Key", "{", "toSortCopy", ":=", "make", "(", "[", "]", "Key", ",", "len", "(", "toSort", ")", ")", "\n", "copy", "(", "toSortCopy"...
// SortByDistance takes a KeySpace, a center Key, and a list of Keys toSort. // It returns a new list, where the Keys toSort have been sorted by their // distance to the center Key.
[ "SortByDistance", "takes", "a", "KeySpace", "a", "center", "Key", "and", "a", "list", "of", "Keys", "toSort", ".", "It", "returns", "a", "new", "list", "where", "the", "Keys", "toSort", "have", "been", "sorted", "by", "their", "distance", "to", "the", "c...
80d3b4761e24ef72711a669657ce38cd6d996d02
https://github.com/libp2p/go-libp2p-kbucket/blob/80d3b4761e24ef72711a669657ce38cd6d996d02/keyspace/keyspace.go#L88-L97