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
148,200
influxdata/yarpc
cmd/protoc-gen-yarpc/yarpc/plugin.go
objectNamed
func (g *Plugin) objectNamed(name string) generator.Object { g.gen.RecordTypeUse(name) return g.gen.ObjectNamed(name) }
go
func (g *Plugin) objectNamed(name string) generator.Object { g.gen.RecordTypeUse(name) return g.gen.ObjectNamed(name) }
[ "func", "(", "g", "*", "Plugin", ")", "objectNamed", "(", "name", "string", ")", "generator", ".", "Object", "{", "g", ".", "gen", ".", "RecordTypeUse", "(", "name", ")", "\n", "return", "g", ".", "gen", ".", "ObjectNamed", "(", "name", ")", "\n", ...
// Given a type name defined in a .proto, return its object. // Also record that we're using it, to guarantee the associated import.
[ "Given", "a", "type", "name", "defined", "in", "a", ".", "proto", "return", "its", "object", ".", "Also", "record", "that", "we", "re", "using", "it", "to", "guarantee", "the", "associated", "import", "." ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/yarpc/plugin.go#L91-L94
148,201
influxdata/yarpc
cmd/protoc-gen-yarpc/yarpc/plugin.go
GenerateImports
func (g *Plugin) GenerateImports(file *generator.FileDescriptor) { if len(file.FileDescriptorProto.Service) == 0 { return } g.P("import (") g.P(contextPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, contextPkgPath))) g.P(yarpcPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, yarpcPkgPath))) g.P(")") ...
go
func (g *Plugin) GenerateImports(file *generator.FileDescriptor) { if len(file.FileDescriptorProto.Service) == 0 { return } g.P("import (") g.P(contextPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, contextPkgPath))) g.P(yarpcPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, yarpcPkgPath))) g.P(")") ...
[ "func", "(", "g", "*", "Plugin", ")", "GenerateImports", "(", "file", "*", "generator", ".", "FileDescriptor", ")", "{", "if", "len", "(", "file", ".", "FileDescriptorProto", ".", "Service", ")", "==", "0", "{", "return", "\n", "}", "\n", "g", ".", "...
// GenerateImports generates the import declaration for this file.
[ "GenerateImports", "generates", "the", "import", "declaration", "for", "this", "file", "." ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/yarpc/plugin.go#L127-L136
148,202
influxdata/yarpc
cmd/protoc-gen-yarpc/yarpc/plugin.go
generateClientSignature
func (g *Plugin) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string { origMethName := method.GetName() methName := generator.CamelCase(origMethName) if reservedClientName[methName] { methName += "_" } reqArg := ", in *" + g.typeName(method.GetInputType()) if method.GetClientStream...
go
func (g *Plugin) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string { origMethName := method.GetName() methName := generator.CamelCase(origMethName) if reservedClientName[methName] { methName += "_" } reqArg := ", in *" + g.typeName(method.GetInputType()) if method.GetClientStream...
[ "func", "(", "g", "*", "Plugin", ")", "generateClientSignature", "(", "servName", "string", ",", "method", "*", "pb", ".", "MethodDescriptorProto", ")", "string", "{", "origMethName", ":=", "method", ".", "GetName", "(", ")", "\n", "methName", ":=", "generat...
// generateClientSignature returns the client-side signature for a method.
[ "generateClientSignature", "returns", "the", "client", "-", "side", "signature", "for", "a", "method", "." ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/yarpc/plugin.go#L298-L313
148,203
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
alias
func (e *EnumDescriptor) alias() (s []string) { s = e.TypeName() if gogoproto.IsEnumCustomName(e.EnumDescriptorProto) { s[len(s)-1] = gogoproto.GetEnumCustomName(e.EnumDescriptorProto) } return }
go
func (e *EnumDescriptor) alias() (s []string) { s = e.TypeName() if gogoproto.IsEnumCustomName(e.EnumDescriptorProto) { s[len(s)-1] = gogoproto.GetEnumCustomName(e.EnumDescriptorProto) } return }
[ "func", "(", "e", "*", "EnumDescriptor", ")", "alias", "(", ")", "(", "s", "[", "]", "string", ")", "{", "s", "=", "e", ".", "TypeName", "(", ")", "\n", "if", "gogoproto", ".", "IsEnumCustomName", "(", "e", ".", "EnumDescriptorProto", ")", "{", "s"...
// alias provides the TypeName corrected for the application of any naming // extensions on the enum type. It should be used for generating references to // the Go types and for calculating prefixes.
[ "alias", "provides", "the", "TypeName", "corrected", "for", "the", "application", "of", "any", "naming", "extensions", "on", "the", "enum", "type", ".", "It", "should", "be", "used", "for", "generating", "references", "to", "the", "Go", "types", "and", "for"...
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L174-L181
148,204
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
goPackageName
func (d *FileDescriptor) goPackageName() (name string, explicit bool) { // Does the file have a "go_package" option? if _, pkg, ok := d.goPackageOption(); ok { return pkg, true } // Does the file have a package clause? if pkg := d.GetPackage(); pkg != "" { return pkg, false } // Use the file base name. ret...
go
func (d *FileDescriptor) goPackageName() (name string, explicit bool) { // Does the file have a "go_package" option? if _, pkg, ok := d.goPackageOption(); ok { return pkg, true } // Does the file have a package clause? if pkg := d.GetPackage(); pkg != "" { return pkg, false } // Use the file base name. ret...
[ "func", "(", "d", "*", "FileDescriptor", ")", "goPackageName", "(", ")", "(", "name", "string", ",", "explicit", "bool", ")", "{", "// Does the file have a \"go_package\" option?", "if", "_", ",", "pkg", ",", "ok", ":=", "d", ".", "goPackageOption", "(", ")"...
// goPackageName returns the Go package name to use in the // generated Go file. The result explicit reports whether the name // came from an option go_package statement. If explicit is false, // the name was derived from the protocol buffer's package statement // or the input file name.
[ "goPackageName", "returns", "the", "Go", "package", "name", "to", "use", "in", "the", "generated", "Go", "file", ".", "The", "result", "explicit", "reports", "whether", "the", "name", "came", "from", "an", "option", "go_package", "statement", ".", "If", "exp...
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L311-L323
148,205
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
RegisterUniquePackageName
func RegisterUniquePackageName(pkg string, f *FileDescriptor) string { // Convert dots to underscores before finding a unique alias. pkg = strings.Map(badToUnderscore, pkg) var i = -1 var ptr *FileDescriptor = nil for i, ptr = range pkgNamesInUse[pkg] { if ptr == f { if i == 0 { return pkg } return...
go
func RegisterUniquePackageName(pkg string, f *FileDescriptor) string { // Convert dots to underscores before finding a unique alias. pkg = strings.Map(badToUnderscore, pkg) var i = -1 var ptr *FileDescriptor = nil for i, ptr = range pkgNamesInUse[pkg] { if ptr == f { if i == 0 { return pkg } return...
[ "func", "RegisterUniquePackageName", "(", "pkg", "string", ",", "f", "*", "FileDescriptor", ")", "string", "{", "// Convert dots to underscores before finding a unique alias.", "pkg", "=", "strings", ".", "Map", "(", "badToUnderscore", ",", "pkg", ")", "\n\n", "var", ...
// Create and remember a guaranteed unique package name for this file descriptor. // Pkg is the candidate name. If f is nil, it's a builtin package like "proto" and // has no file descriptor.
[ "Create", "and", "remember", "a", "guaranteed", "unique", "package", "name", "for", "this", "file", "descriptor", ".", "Pkg", "is", "the", "candidate", "name", ".", "If", "f", "is", "nil", "it", "s", "a", "builtin", "package", "like", "proto", "and", "ha...
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L481-L507
148,206
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
newDescriptor
func newDescriptor(desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *Descriptor { d := &Descriptor{ common: common{file}, DescriptorProto: desc, parent: parent, index: index, } if parent == nil { d.path = fmt.Sprintf("%d,%d",...
go
func newDescriptor(desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *Descriptor { d := &Descriptor{ common: common{file}, DescriptorProto: desc, parent: parent, index: index, } if parent == nil { d.path = fmt.Sprintf("%d,%d",...
[ "func", "newDescriptor", "(", "desc", "*", "descriptor", ".", "DescriptorProto", ",", "parent", "*", "Descriptor", ",", "file", "*", "descriptor", ".", "FileDescriptorProto", ",", "index", "int", ")", "*", "Descriptor", "{", "d", ":=", "&", "Descriptor", "{"...
// Construct the Descriptor
[ "Construct", "the", "Descriptor" ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L705-L739
148,207
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
wrapThisDescriptor
func wrapThisDescriptor(sl []*Descriptor, desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) []*Descriptor { sl = append(sl, newDescriptor(desc, parent, file, index)) me := sl[len(sl)-1] for i, nested := range desc.NestedType { sl = wrapThisDescriptor(sl, nested,...
go
func wrapThisDescriptor(sl []*Descriptor, desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) []*Descriptor { sl = append(sl, newDescriptor(desc, parent, file, index)) me := sl[len(sl)-1] for i, nested := range desc.NestedType { sl = wrapThisDescriptor(sl, nested,...
[ "func", "wrapThisDescriptor", "(", "sl", "[", "]", "*", "Descriptor", ",", "desc", "*", "descriptor", ".", "DescriptorProto", ",", "parent", "*", "Descriptor", ",", "file", "*", "descriptor", ".", "FileDescriptorProto", ",", "index", "int", ")", "[", "]", ...
// Wrap this Descriptor, recursively
[ "Wrap", "this", "Descriptor", "recursively" ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L751-L758
148,208
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
newEnumDescriptor
func newEnumDescriptor(desc *descriptor.EnumDescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *EnumDescriptor { ed := &EnumDescriptor{ common: common{file}, EnumDescriptorProto: desc, parent: parent, index: index, } if parent == nil ...
go
func newEnumDescriptor(desc *descriptor.EnumDescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *EnumDescriptor { ed := &EnumDescriptor{ common: common{file}, EnumDescriptorProto: desc, parent: parent, index: index, } if parent == nil ...
[ "func", "newEnumDescriptor", "(", "desc", "*", "descriptor", ".", "EnumDescriptorProto", ",", "parent", "*", "Descriptor", ",", "file", "*", "descriptor", ".", "FileDescriptorProto", ",", "index", "int", ")", "*", "EnumDescriptor", "{", "ed", ":=", "&", "EnumD...
// Construct the EnumDescriptor
[ "Construct", "the", "EnumDescriptor" ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L761-L774
148,209
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
wrapEnumDescriptors
func wrapEnumDescriptors(file *descriptor.FileDescriptorProto, descs []*Descriptor) []*EnumDescriptor { sl := make([]*EnumDescriptor, 0, len(file.EnumType)+10) // Top-level enums. for i, enum := range file.EnumType { sl = append(sl, newEnumDescriptor(enum, nil, file, i)) } // Enums within messages. Enums within ...
go
func wrapEnumDescriptors(file *descriptor.FileDescriptorProto, descs []*Descriptor) []*EnumDescriptor { sl := make([]*EnumDescriptor, 0, len(file.EnumType)+10) // Top-level enums. for i, enum := range file.EnumType { sl = append(sl, newEnumDescriptor(enum, nil, file, i)) } // Enums within messages. Enums within ...
[ "func", "wrapEnumDescriptors", "(", "file", "*", "descriptor", ".", "FileDescriptorProto", ",", "descs", "[", "]", "*", "Descriptor", ")", "[", "]", "*", "EnumDescriptor", "{", "sl", ":=", "make", "(", "[", "]", "*", "EnumDescriptor", ",", "0", ",", "len...
// Return a slice of all the EnumDescriptors defined within this file
[ "Return", "a", "slice", "of", "all", "the", "EnumDescriptors", "defined", "within", "this", "file" ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L777-L790
148,210
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
wrapImported
func wrapImported(file *descriptor.FileDescriptorProto, g *Generator) (sl []*ImportedDescriptor) { for _, index := range file.PublicDependency { df := g.fileByName(file.Dependency[index]) for _, d := range df.desc { if d.GetOptions().GetMapEntry() { continue } sl = append(sl, &ImportedDescriptor{commo...
go
func wrapImported(file *descriptor.FileDescriptorProto, g *Generator) (sl []*ImportedDescriptor) { for _, index := range file.PublicDependency { df := g.fileByName(file.Dependency[index]) for _, d := range df.desc { if d.GetOptions().GetMapEntry() { continue } sl = append(sl, &ImportedDescriptor{commo...
[ "func", "wrapImported", "(", "file", "*", "descriptor", ".", "FileDescriptorProto", ",", "g", "*", "Generator", ")", "(", "sl", "[", "]", "*", "ImportedDescriptor", ")", "{", "for", "_", ",", "index", ":=", "range", "file", ".", "PublicDependency", "{", ...
// Return a slice of all the types that are publicly imported into this file.
[ "Return", "a", "slice", "of", "all", "the", "types", "that", "are", "publicly", "imported", "into", "this", "file", "." ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L802-L819
148,211
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
FileOf
func (g *Generator) FileOf(fd *descriptor.FileDescriptorProto) *FileDescriptor { for _, file := range g.allFiles { if file.FileDescriptorProto == fd { return file } } g.Fail("could not find file in table:", fd.GetName()) return nil }
go
func (g *Generator) FileOf(fd *descriptor.FileDescriptorProto) *FileDescriptor { for _, file := range g.allFiles { if file.FileDescriptorProto == fd { return file } } g.Fail("could not find file in table:", fd.GetName()) return nil }
[ "func", "(", "g", "*", "Generator", ")", "FileOf", "(", "fd", "*", "descriptor", ".", "FileDescriptorProto", ")", "*", "FileDescriptor", "{", "for", "_", ",", "file", ":=", "range", "g", ".", "allFiles", "{", "if", "file", ".", "FileDescriptorProto", "==...
// FileOf return the FileDescriptor for this FileDescriptorProto.
[ "FileOf", "return", "the", "FileDescriptor", "for", "this", "FileDescriptorProto", "." ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L962-L970
148,212
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
Comments
func (g *Generator) Comments(path string) string { loc, ok := g.file.comments[path] if !ok { return "" } text := strings.TrimSuffix(loc.GetLeadingComments(), "\n") return text }
go
func (g *Generator) Comments(path string) string { loc, ok := g.file.comments[path] if !ok { return "" } text := strings.TrimSuffix(loc.GetLeadingComments(), "\n") return text }
[ "func", "(", "g", "*", "Generator", ")", "Comments", "(", "path", "string", ")", "string", "{", "loc", ",", "ok", ":=", "g", ".", "file", ".", "comments", "[", "path", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "tex...
// Comments returns any comments from the source .proto file and empty string if comments not found. // The path is a comma-separated list of intergers. // See descriptor.proto for its format.
[ "Comments", "returns", "any", "comments", "from", "the", "source", ".", "proto", "file", "and", "empty", "string", "if", "comments", "not", "found", ".", "The", "path", "is", "a", "comma", "-", "separated", "list", "of", "intergers", ".", "See", "descripto...
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L1040-L1047
148,213
influxdata/yarpc
cmd/protoc-gen-yarpc/generator/generator.go
TypeNameWithPackage
func (g *Generator) TypeNameWithPackage(obj Object) string { return obj.PackageName() + CamelCaseSlice(obj.TypeName()) }
go
func (g *Generator) TypeNameWithPackage(obj Object) string { return obj.PackageName() + CamelCaseSlice(obj.TypeName()) }
[ "func", "(", "g", "*", "Generator", ")", "TypeNameWithPackage", "(", "obj", "Object", ")", "string", "{", "return", "obj", ".", "PackageName", "(", ")", "+", "CamelCaseSlice", "(", "obj", ".", "TypeName", "(", ")", ")", "\n", "}" ]
// TypeNameWithPackage is like TypeName, but always includes the package // name even if the object is in our own package.
[ "TypeNameWithPackage", "is", "like", "TypeName", "but", "always", "includes", "the", "package", "name", "even", "if", "the", "object", "is", "in", "our", "own", "package", "." ]
b13d74d757bf9ea3e5574a491eb6646bdc4e2a04
https://github.com/influxdata/yarpc/blob/b13d74d757bf9ea3e5574a491eb6646bdc4e2a04/cmd/protoc-gen-yarpc/generator/generator.go#L1361-L1363
148,214
cppforlife/go-semi-semantic
version/version_segment.go
compareArrays
func (s VersionSegment) compareArrays(a, b []VerSegComp) int { for i, v1 := range a { v2 := b[i] _, v1IsStr := v1.(VerSegCompStr) _, v1IsInt := v1.(VerSegCompInt) _, v2IsStr := v2.(VerSegCompStr) _, v2IsInt := v2.(VerSegCompInt) if v1IsStr && v2IsInt { return 1 } else if v1IsInt && v2IsStr { retu...
go
func (s VersionSegment) compareArrays(a, b []VerSegComp) int { for i, v1 := range a { v2 := b[i] _, v1IsStr := v1.(VerSegCompStr) _, v1IsInt := v1.(VerSegCompInt) _, v2IsStr := v2.(VerSegCompStr) _, v2IsInt := v2.(VerSegCompInt) if v1IsStr && v2IsInt { return 1 } else if v1IsInt && v2IsStr { retu...
[ "func", "(", "s", "VersionSegment", ")", "compareArrays", "(", "a", ",", "b", "[", "]", "VerSegComp", ")", "int", "{", "for", "i", ",", "v1", ":=", "range", "a", "{", "v2", ":=", "b", "[", "i", "]", "\n\n", "_", ",", "v1IsStr", ":=", "v1", ".",...
// compareArrays compares 2 equally sized a & b
[ "compareArrays", "compares", "2", "equally", "sized", "a", "&", "b" ]
576b6af77ae4f3ccef356902fb3b9a9ae22e0b11
https://github.com/cppforlife/go-semi-semantic/blob/576b6af77ae4f3ccef356902fb3b9a9ae22e0b11/version/version_segment.go#L149-L171
148,215
zombiezen/cardcpx
third_party/webapp/template.go
AddFuncs
func AddFuncs(t *template.Template, router *mux.Router) { t.Funcs(template.FuncMap{ "path": RoutePath(router), "url": RouteURL(router), "cycle": Cycle, }) }
go
func AddFuncs(t *template.Template, router *mux.Router) { t.Funcs(template.FuncMap{ "path": RoutePath(router), "url": RouteURL(router), "cycle": Cycle, }) }
[ "func", "AddFuncs", "(", "t", "*", "template", ".", "Template", ",", "router", "*", "mux", ".", "Router", ")", "{", "t", ".", "Funcs", "(", "template", ".", "FuncMap", "{", "\"", "\"", ":", "RoutePath", "(", "router", ")", ",", "\"", "\"", ":", "...
// AddFuncs adds the package's template functions.
[ "AddFuncs", "adds", "the", "package", "s", "template", "functions", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/template.go#L10-L16
148,216
zombiezen/cardcpx
third_party/webapp/template.go
Cycle
func Cycle(i int, arg0 string, args ...string) string { if j := i % (len(args) + 1); j != 0 { return args[j-1] } return arg0 }
go
func Cycle(i int, arg0 string, args ...string) string { if j := i % (len(args) + 1); j != 0 { return args[j-1] } return arg0 }
[ "func", "Cycle", "(", "i", "int", ",", "arg0", "string", ",", "args", "...", "string", ")", "string", "{", "if", "j", ":=", "i", "%", "(", "len", "(", "args", ")", "+", "1", ")", ";", "j", "!=", "0", "{", "return", "args", "[", "j", "-", "1...
// Cycle cycles among the given strings given an index.
[ "Cycle", "cycles", "among", "the", "given", "strings", "given", "an", "index", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/template.go#L19-L24
148,217
zombiezen/cardcpx
third_party/webapp/template.go
RouteURL
func RouteURL(router *mux.Router) func(string, ...interface{}) (template.URL, error) { return func(name string, pairs ...interface{}) (template.URL, error) { route := router.Get(name) if route == nil { return "", fmt.Errorf("path: no such route %q", name) } spairs := make([]string, len(pairs)) for i := ra...
go
func RouteURL(router *mux.Router) func(string, ...interface{}) (template.URL, error) { return func(name string, pairs ...interface{}) (template.URL, error) { route := router.Get(name) if route == nil { return "", fmt.Errorf("path: no such route %q", name) } spairs := make([]string, len(pairs)) for i := ra...
[ "func", "RouteURL", "(", "router", "*", "mux", ".", "Router", ")", "func", "(", "string", ",", "...", "interface", "{", "}", ")", "(", "template", ".", "URL", ",", "error", ")", "{", "return", "func", "(", "name", "string", ",", "pairs", "...", "in...
// RouteURL returns a function suitable for a template that returns the full URL // for a route and its parameters.
[ "RouteURL", "returns", "a", "function", "suitable", "for", "a", "template", "that", "returns", "the", "full", "URL", "for", "a", "route", "and", "its", "parameters", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/template.go#L45-L58
148,218
libkermit/docker
start.go
Start
func (p *Project) Start(image string) (types.ContainerJSON, error) { return p.StartWithConfig(image, ContainerConfig{}) }
go
func (p *Project) Start(image string) (types.ContainerJSON, error) { return p.StartWithConfig(image, ContainerConfig{}) }
[ "func", "(", "p", "*", "Project", ")", "Start", "(", "image", "string", ")", "(", "types", ".", "ContainerJSON", ",", "error", ")", "{", "return", "p", ".", "StartWithConfig", "(", "image", ",", "ContainerConfig", "{", "}", ")", "\n", "}" ]
// Start lets you create and start a container with the specified image, and // default configuration.
[ "Start", "lets", "you", "create", "and", "start", "a", "container", "with", "the", "specified", "image", "and", "default", "configuration", "." ]
e6674d32b80712b563ed8a0187af2bc93448b82f
https://github.com/libkermit/docker/blob/e6674d32b80712b563ed8a0187af2bc93448b82f/start.go#L11-L13
148,219
libkermit/docker
start.go
StartWithConfig
func (p *Project) StartWithConfig(image string, containerConfig ContainerConfig) (types.ContainerJSON, error) { container, err := p.CreateWithConfig(image, containerConfig) if err != nil { return types.ContainerJSON{}, err } if err := p.Client.ContainerStart(context.Background(), container.ID, types.ContainerSta...
go
func (p *Project) StartWithConfig(image string, containerConfig ContainerConfig) (types.ContainerJSON, error) { container, err := p.CreateWithConfig(image, containerConfig) if err != nil { return types.ContainerJSON{}, err } if err := p.Client.ContainerStart(context.Background(), container.ID, types.ContainerSta...
[ "func", "(", "p", "*", "Project", ")", "StartWithConfig", "(", "image", "string", ",", "containerConfig", "ContainerConfig", ")", "(", "types", ".", "ContainerJSON", ",", "error", ")", "{", "container", ",", "err", ":=", "p", ".", "CreateWithConfig", "(", ...
// StartWithConfig lets you create and start a container with the specified // image, and some custom simple configuration.
[ "StartWithConfig", "lets", "you", "create", "and", "start", "a", "container", "with", "the", "specified", "image", "and", "some", "custom", "simple", "configuration", "." ]
e6674d32b80712b563ed8a0187af2bc93448b82f
https://github.com/libkermit/docker/blob/e6674d32b80712b563ed8a0187af2bc93448b82f/start.go#L17-L28
148,220
choria-io/go-validator
validator.go
ValidateStruct
func ValidateStruct(target interface{}) (bool, error) { val := reflect.ValueOf(target) if val.Kind() == reflect.Ptr { val = val.Elem() } return validateStructValue(val) }
go
func ValidateStruct(target interface{}) (bool, error) { val := reflect.ValueOf(target) if val.Kind() == reflect.Ptr { val = val.Elem() } return validateStructValue(val) }
[ "func", "ValidateStruct", "(", "target", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "target", ")", "\n\n", "if", "val", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "val...
// ValidateStruct validates all keys in a struct using their validate tag
[ "ValidateStruct", "validates", "all", "keys", "in", "a", "struct", "using", "their", "validate", "tag" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/validator.go#L25-L33
148,221
choria-io/go-validator
validator.go
ValidateStructField
func ValidateStructField(target interface{}, field string) (bool, error) { val := reflect.ValueOf(target) if val.Kind() == reflect.Ptr { val = val.Elem() } valueField := val.FieldByName(field) typeField, ok := val.Type().FieldByName(field) if !ok { return false, fmt.Errorf("unknown field %s", field) } va...
go
func ValidateStructField(target interface{}, field string) (bool, error) { val := reflect.ValueOf(target) if val.Kind() == reflect.Ptr { val = val.Elem() } valueField := val.FieldByName(field) typeField, ok := val.Type().FieldByName(field) if !ok { return false, fmt.Errorf("unknown field %s", field) } va...
[ "func", "ValidateStructField", "(", "target", "interface", "{", "}", ",", "field", "string", ")", "(", "bool", ",", "error", ")", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "target", ")", "\n\n", "if", "val", ".", "Kind", "(", ")", "==", "refl...
// ValidateStructField validates one field in a struct
[ "ValidateStructField", "validates", "one", "field", "in", "a", "struct" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/validator.go#L36-L57
148,222
zombiezen/cardcpx
takedata/csv.go
NewCSVStorage
func NewCSVStorage(rw io.ReadWriter) (Storage, error) { cs := &csvStorage{ w: csv.NewWriter(rw), cache: NewMemoryStorage(), } if err := readCSV(cs.cache, rw); err != nil { return nil, err } return cs, nil }
go
func NewCSVStorage(rw io.ReadWriter) (Storage, error) { cs := &csvStorage{ w: csv.NewWriter(rw), cache: NewMemoryStorage(), } if err := readCSV(cs.cache, rw); err != nil { return nil, err } return cs, nil }
[ "func", "NewCSVStorage", "(", "rw", "io", ".", "ReadWriter", ")", "(", "Storage", ",", "error", ")", "{", "cs", ":=", "&", "csvStorage", "{", "w", ":", "csv", ".", "NewWriter", "(", "rw", ")", ",", "cache", ":", "NewMemoryStorage", "(", ")", ",", "...
// NewCSVStorage creates a CSV-file-backed storage from rw. // rw is first read to get the initial contents, then mutations are // written afterward. No attempt is made to deduplicate records.
[ "NewCSVStorage", "creates", "a", "CSV", "-", "file", "-", "backed", "storage", "from", "rw", ".", "rw", "is", "first", "read", "to", "get", "the", "initial", "contents", "then", "mutations", "are", "written", "afterward", ".", "No", "attempt", "is", "made"...
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/takedata/csv.go#L36-L45
148,223
zombiezen/cardcpx
httputil/httputil.go
DecodeJSON
func DecodeJSON(res *http.Response, dest interface{}) error { defer CloseBody(res.Body) buf := getBuf() defer putBuf(buf) if err := json.NewDecoder(io.TeeReader(io.LimitReader(res.Body, 8<<20), buf)).Decode(dest); err != nil { return fmt.Errorf("httputil.DecodeJSON: %v, on input: %s", err, buf.Bytes()) } return...
go
func DecodeJSON(res *http.Response, dest interface{}) error { defer CloseBody(res.Body) buf := getBuf() defer putBuf(buf) if err := json.NewDecoder(io.TeeReader(io.LimitReader(res.Body, 8<<20), buf)).Decode(dest); err != nil { return fmt.Errorf("httputil.DecodeJSON: %v, on input: %s", err, buf.Bytes()) } return...
[ "func", "DecodeJSON", "(", "res", "*", "http", ".", "Response", ",", "dest", "interface", "{", "}", ")", "error", "{", "defer", "CloseBody", "(", "res", ".", "Body", ")", "\n", "buf", ":=", "getBuf", "(", ")", "\n", "defer", "putBuf", "(", "buf", "...
// DecodeJSON decodes the JSON in res.Body into dest and then closes // res.Body. // It defensively caps the JSON at 8 MB for now.
[ "DecodeJSON", "decodes", "the", "JSON", "in", "res", ".", "Body", "into", "dest", "and", "then", "closes", "res", ".", "Body", ".", "It", "defensively", "caps", "the", "JSON", "at", "8", "MB", "for", "now", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/httputil/httputil.go#L282-L290
148,224
libkermit/docker
stop.go
Stop
func (p *Project) Stop(containerID string) error { return p.StopWithTimeout(containerID, DefaultStopTimeout) }
go
func (p *Project) Stop(containerID string) error { return p.StopWithTimeout(containerID, DefaultStopTimeout) }
[ "func", "(", "p", "*", "Project", ")", "Stop", "(", "containerID", "string", ")", "error", "{", "return", "p", ".", "StopWithTimeout", "(", "containerID", ",", "DefaultStopTimeout", ")", "\n", "}" ]
// Stop stops the container with a default timeout.
[ "Stop", "stops", "the", "container", "with", "a", "default", "timeout", "." ]
e6674d32b80712b563ed8a0187af2bc93448b82f
https://github.com/libkermit/docker/blob/e6674d32b80712b563ed8a0187af2bc93448b82f/stop.go#L10-L12
148,225
choria-io/go-validator
ipv6/ipv6.go
ValidateString
func ValidateString(input string) (bool, error) { ip := net.ParseIP(input) if ip == nil { return false, fmt.Errorf("%s is not an IPv6 address", input) } if ip.To4() != nil { return false, fmt.Errorf("%s is not an IPv6 address", input) } return true, nil }
go
func ValidateString(input string) (bool, error) { ip := net.ParseIP(input) if ip == nil { return false, fmt.Errorf("%s is not an IPv6 address", input) } if ip.To4() != nil { return false, fmt.Errorf("%s is not an IPv6 address", input) } return true, nil }
[ "func", "ValidateString", "(", "input", "string", ")", "(", "bool", ",", "error", ")", "{", "ip", ":=", "net", ".", "ParseIP", "(", "input", ")", "\n\n", "if", "ip", "==", "nil", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// ValidateString validates that the given string is an IPv4 address
[ "ValidateString", "validates", "that", "the", "given", "string", "is", "an", "IPv4", "address" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/ipv6/ipv6.go#L10-L22
148,226
choria-io/go-validator
ipv6/ipv6.go
ValidateStructField
func ValidateStructField(value reflect.Value, tag string) (bool, error) { if value.Kind() != reflect.String { return false, fmt.Errorf("only strings can be IPv6 validated") } return ValidateString(value.String()) }
go
func ValidateStructField(value reflect.Value, tag string) (bool, error) { if value.Kind() != reflect.String { return false, fmt.Errorf("only strings can be IPv6 validated") } return ValidateString(value.String()) }
[ "func", "ValidateStructField", "(", "value", "reflect", ".", "Value", ",", "tag", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "value", ".", "Kind", "(", ")", "!=", "reflect", ".", "String", "{", "return", "false", ",", "fmt", ".", "Erro...
// ValidateStructField validates a struct field holds an IPv4 address
[ "ValidateStructField", "validates", "a", "struct", "field", "holds", "an", "IPv4", "address" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/ipv6/ipv6.go#L25-L31
148,227
zombiezen/cardcpx
importer/importer.go
New
func New(s video.Storage) *Importer { return &Importer{ s: s, ncopied: *estimatedMiBps * (2 << 20), elapsed: 1 * time.Second, } }
go
func New(s video.Storage) *Importer { return &Importer{ s: s, ncopied: *estimatedMiBps * (2 << 20), elapsed: 1 * time.Second, } }
[ "func", "New", "(", "s", "video", ".", "Storage", ")", "*", "Importer", "{", "return", "&", "Importer", "{", "s", ":", "s", ",", "ncopied", ":", "*", "estimatedMiBps", "*", "(", "2", "<<", "20", ")", ",", "elapsed", ":", "1", "*", "time", ".", ...
// New returns an importer that copies to storage s.
[ "New", "returns", "an", "importer", "that", "copies", "to", "storage", "s", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/importer/importer.go#L53-L59
148,228
zombiezen/cardcpx
importer/importer.go
Status
func (imp *Importer) Status() *Status { imp.m.Lock() defer imp.m.Unlock() if imp.updates == nil { return imp.newStatus() } return <-imp.updates }
go
func (imp *Importer) Status() *Status { imp.m.Lock() defer imp.m.Unlock() if imp.updates == nil { return imp.newStatus() } return <-imp.updates }
[ "func", "(", "imp", "*", "Importer", ")", "Status", "(", ")", "*", "Status", "{", "imp", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "imp", ".", "m", ".", "Unlock", "(", ")", "\n", "if", "imp", ".", "updates", "==", "nil", "{", "return", ...
// Status returns the current status of the importer. This method is // safe to call from multiple goroutines.
[ "Status", "returns", "the", "current", "status", "of", "the", "importer", ".", "This", "method", "is", "safe", "to", "call", "from", "multiple", "goroutines", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/importer/importer.go#L80-L87
148,229
zombiezen/cardcpx
importer/importer.go
Import
func (imp *Importer) Import(src video.Source, subdir string, clips []*video.Clip) *Status { updates := imp.init(clips) defer func() { imp.m.Lock() defer imp.m.Unlock() imp.updates = nil }() for _, clip := range clips { result := Result{ Clip: clip, Start: time.Now(), } var clipWritten int64 for...
go
func (imp *Importer) Import(src video.Source, subdir string, clips []*video.Clip) *Status { updates := imp.init(clips) defer func() { imp.m.Lock() defer imp.m.Unlock() imp.updates = nil }() for _, clip := range clips { result := Result{ Clip: clip, Start: time.Now(), } var clipWritten int64 for...
[ "func", "(", "imp", "*", "Importer", ")", "Import", "(", "src", "video", ".", "Source", ",", "subdir", "string", ",", "clips", "[", "]", "*", "video", ".", "Clip", ")", "*", "Status", "{", "updates", ":=", "imp", ".", "init", "(", "clips", ")", "...
// Import copies the files specified by clips from src into its storage.
[ "Import", "copies", "the", "files", "specified", "by", "clips", "from", "src", "into", "its", "storage", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/importer/importer.go#L90-L125
148,230
zombiezen/cardcpx
importer/importer.go
copyWithProgress
func copyWithProgress(dst io.Writer, src io.Reader, ch chan<- copyProgress) { var written int64 var err error buf := make([]byte, 32*1024) for { nr, er := src.Read(buf) if nr > 0 { nw, ew := dst.Write(buf[0:nr]) if nw > 0 { written += int64(nw) } if ew != nil { err = ew break } if ...
go
func copyWithProgress(dst io.Writer, src io.Reader, ch chan<- copyProgress) { var written int64 var err error buf := make([]byte, 32*1024) for { nr, er := src.Read(buf) if nr > 0 { nw, ew := dst.Write(buf[0:nr]) if nw > 0 { written += int64(nw) } if ew != nil { err = ew break } if ...
[ "func", "copyWithProgress", "(", "dst", "io", ".", "Writer", ",", "src", "io", ".", "Reader", ",", "ch", "chan", "<-", "copyProgress", ")", "{", "var", "written", "int64", "\n", "var", "err", "error", "\n", "buf", ":=", "make", "(", "[", "]", "byte",...
// copyWithProgress copies from src to dst and sends updates on ch. // ch is closed when the copy is finished. There will be at least one // value sent on ch.
[ "copyWithProgress", "copies", "from", "src", "to", "dst", "and", "sends", "updates", "on", "ch", ".", "ch", "is", "closed", "when", "the", "copy", "is", "finished", ".", "There", "will", "be", "at", "least", "one", "value", "sent", "on", "ch", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/importer/importer.go#L184-L220
148,231
zombiezen/cardcpx
third_party/webapp/accept.go
Quality
func (h AcceptHeader) Quality(contentType string, params map[string][]string) float64 { results := make(mediaRangeMatches, 0, len(h)) for i := range h { mr := &h[i] if m := mr.match(contentType, params); m.Valid { results = append(results, m) } } if len(results) == 0 { return 0.0 } // find most specif...
go
func (h AcceptHeader) Quality(contentType string, params map[string][]string) float64 { results := make(mediaRangeMatches, 0, len(h)) for i := range h { mr := &h[i] if m := mr.match(contentType, params); m.Valid { results = append(results, m) } } if len(results) == 0 { return 0.0 } // find most specif...
[ "func", "(", "h", "AcceptHeader", ")", "Quality", "(", "contentType", "string", ",", "params", "map", "[", "string", "]", "[", "]", "string", ")", "float64", "{", "results", ":=", "make", "(", "mediaRangeMatches", ",", "0", ",", "len", "(", "h", ")", ...
// Quality returns the quality of a content type based on the media ranges in h.
[ "Quality", "returns", "the", "quality", "of", "a", "content", "type", "based", "on", "the", "media", "ranges", "in", "h", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/accept.go#L24-L44
148,232
zombiezen/cardcpx
third_party/webapp/accept.go
ParseAcceptHeader
func ParseAcceptHeader(accept string) (AcceptHeader, error) { ranges := make(AcceptHeader, 0) p := httpParser{r: []rune(accept)} p.space() for !p.eof() { if len(ranges) > 0 { if !p.consume(",") { return ranges, &parseError{Expected: "','", Found: p.peek(), EOF: p.eof()} } p.space() } r, err := p...
go
func ParseAcceptHeader(accept string) (AcceptHeader, error) { ranges := make(AcceptHeader, 0) p := httpParser{r: []rune(accept)} p.space() for !p.eof() { if len(ranges) > 0 { if !p.consume(",") { return ranges, &parseError{Expected: "','", Found: p.peek(), EOF: p.eof()} } p.space() } r, err := p...
[ "func", "ParseAcceptHeader", "(", "accept", "string", ")", "(", "AcceptHeader", ",", "error", ")", "{", "ranges", ":=", "make", "(", "AcceptHeader", ",", "0", ")", "\n", "p", ":=", "httpParser", "{", "r", ":", "[", "]", "rune", "(", "accept", ")", "}...
// ParseAcceptHeader parses an Accept header of an HTTP request. The media // ranges are unsorted.
[ "ParseAcceptHeader", "parses", "an", "Accept", "header", "of", "an", "HTTP", "request", ".", "The", "media", "ranges", "are", "unsorted", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/accept.go#L48-L75
148,233
zombiezen/cardcpx
third_party/webapp/accept.go
Match
func (mr *MediaRange) Match(contentType string, params map[string][]string) bool { return mr.match(contentType, params).Valid }
go
func (mr *MediaRange) Match(contentType string, params map[string][]string) bool { return mr.match(contentType, params).Valid }
[ "func", "(", "mr", "*", "MediaRange", ")", "Match", "(", "contentType", "string", ",", "params", "map", "[", "string", "]", "[", "]", "string", ")", "bool", "{", "return", "mr", ".", "match", "(", "contentType", ",", "params", ")", ".", "Valid", "\n"...
// Match reports whether the range applies to a content type.
[ "Match", "reports", "whether", "the", "range", "applies", "to", "a", "content", "type", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/accept.go#L141-L143
148,234
zombiezen/cardcpx
third_party/webapp/http.go
MethodNotAllowed
func MethodNotAllowed(w http.ResponseWriter, methods ...string) { w.Header().Set(HeaderAllow, strings.Join(methods, ", ")) http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) }
go
func MethodNotAllowed(w http.ResponseWriter, methods ...string) { w.Header().Set(HeaderAllow, strings.Join(methods, ", ")) http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) }
[ "func", "MethodNotAllowed", "(", "w", "http", ".", "ResponseWriter", ",", "methods", "...", "string", ")", "{", "w", ".", "Header", "(", ")", ".", "Set", "(", "HeaderAllow", ",", "strings", ".", "Join", "(", "methods", ",", "\"", "\"", ")", ")", "\n"...
// MethodNotAllowed replies to a request with an HTTP 405 method not allowed error.
[ "MethodNotAllowed", "replies", "to", "a", "request", "with", "an", "HTTP", "405", "method", "not", "allowed", "error", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/http.go#L29-L32
148,235
zombiezen/cardcpx
third_party/webapp/http.go
ContentLength
func ContentLength(h http.Header, size int64) { h.Set(HeaderContentLength, strconv.FormatInt(size, 10)) }
go
func ContentLength(h http.Header, size int64) { h.Set(HeaderContentLength, strconv.FormatInt(size, 10)) }
[ "func", "ContentLength", "(", "h", "http", ".", "Header", ",", "size", "int64", ")", "{", "h", ".", "Set", "(", "HeaderContentLength", ",", "strconv", ".", "FormatInt", "(", "size", ",", "10", ")", ")", "\n", "}" ]
// ContentLength sets the Content-Length header to size.
[ "ContentLength", "sets", "the", "Content", "-", "Length", "header", "to", "size", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/http.go#L35-L37
148,236
zombiezen/cardcpx
third_party/webapp/http.go
Attachment
func Attachment(h http.Header, base, ext string) { h.Set(HeaderContentDisposition, "attachment; filename="+base+"."+ext) }
go
func Attachment(h http.Header, base, ext string) { h.Set(HeaderContentDisposition, "attachment; filename="+base+"."+ext) }
[ "func", "Attachment", "(", "h", "http", ".", "Header", ",", "base", ",", "ext", "string", ")", "{", "h", ".", "Set", "(", "HeaderContentDisposition", ",", "\"", "\"", "+", "base", "+", "\"", "\"", "+", "ext", ")", "\n", "}" ]
// Attachment sets the Content-Disposition header to an attachment with the given file name.
[ "Attachment", "sets", "the", "Content", "-", "Disposition", "header", "to", "an", "attachment", "with", "the", "given", "file", "name", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/http.go#L40-L42
148,237
zombiezen/cardcpx
third_party/webapp/http.go
JSONResponse
func JSONResponse(w http.ResponseWriter, v interface{}) error { w.Header().Set(HeaderContentType, JSONType) return json.NewEncoder(w).Encode(v) }
go
func JSONResponse(w http.ResponseWriter, v interface{}) error { w.Header().Set(HeaderContentType, JSONType) return json.NewEncoder(w).Encode(v) }
[ "func", "JSONResponse", "(", "w", "http", ".", "ResponseWriter", ",", "v", "interface", "{", "}", ")", "error", "{", "w", ".", "Header", "(", ")", ".", "Set", "(", "HeaderContentType", ",", "JSONType", ")", "\n", "return", "json", ".", "NewEncoder", "(...
// JSONResponse writes a JSON value to w, setting the Content-Type.
[ "JSONResponse", "writes", "a", "JSON", "value", "to", "w", "setting", "the", "Content", "-", "Type", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/http.go#L45-L48
148,238
choria-io/go-validator
duration/duration.go
ValidateString
func ValidateString(input string) (bool, error) { _, err := time.ParseDuration(input) if err != nil { return false, err } return true, nil }
go
func ValidateString(input string) (bool, error) { _, err := time.ParseDuration(input) if err != nil { return false, err } return true, nil }
[ "func", "ValidateString", "(", "input", "string", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "err", ":=", "time", ".", "ParseDuration", "(", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n...
// ValidateString validates that input is a valid duration
[ "ValidateString", "validates", "that", "input", "is", "a", "valid", "duration" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/duration/duration.go#L10-L17
148,239
libkermit/docker
status.go
IsPaused
func (p *Project) IsPaused(containerID string) (bool, error) { return p.containerStatus(containerID, "paused") }
go
func (p *Project) IsPaused(containerID string) (bool, error) { return p.containerStatus(containerID, "paused") }
[ "func", "(", "p", "*", "Project", ")", "IsPaused", "(", "containerID", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "p", ".", "containerStatus", "(", "containerID", ",", "\"", "\"", ")", "\n", "}" ]
// IsPaused checks if the container is running or not
[ "IsPaused", "checks", "if", "the", "container", "is", "running", "or", "not" ]
e6674d32b80712b563ed8a0187af2bc93448b82f
https://github.com/libkermit/docker/blob/e6674d32b80712b563ed8a0187af2bc93448b82f/status.go#L14-L16
148,240
zombiezen/cardcpx
httputil/auth.go
IsLocalhost
func IsLocalhost(req *http.Request) bool { uid := os.Getuid() from, err := netutil.HostPortToIP(req.RemoteAddr, nil) if err != nil { return false } to, err := netutil.HostPortToIP(req.Host, from) if err != nil { return false } // If our OS doesn't support uid. // TODO(bradfitz): netutil on OS X uses "lsof...
go
func IsLocalhost(req *http.Request) bool { uid := os.Getuid() from, err := netutil.HostPortToIP(req.RemoteAddr, nil) if err != nil { return false } to, err := netutil.HostPortToIP(req.Host, from) if err != nil { return false } // If our OS doesn't support uid. // TODO(bradfitz): netutil on OS X uses "lsof...
[ "func", "IsLocalhost", "(", "req", "*", "http", ".", "Request", ")", "bool", "{", "uid", ":=", "os", ".", "Getuid", "(", ")", "\n", "from", ",", "err", ":=", "netutil", ".", "HostPortToIP", "(", "req", ".", "RemoteAddr", ",", "nil", ")", "\n", "if"...
// IsLocalhost reports whether the requesting connection is from this machine // and has the same owner as this process.
[ "IsLocalhost", "reports", "whether", "the", "requesting", "connection", "is", "from", "this", "machine", "and", "has", "the", "same", "owner", "as", "this", "process", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/httputil/auth.go#L36-L73
148,241
zombiezen/cardcpx
httputil/auth.go
BasicAuth
func BasicAuth(req *http.Request) (username, password string, err error) { auth := req.Header.Get("Authorization") if auth == "" { err = fmt.Errorf("Missing \"Authorization\" in header") return } matches := kBasicAuthPattern.FindStringSubmatch(auth) if len(matches) != 2 { err = fmt.Errorf("Bogus Authorizatio...
go
func BasicAuth(req *http.Request) (username, password string, err error) { auth := req.Header.Get("Authorization") if auth == "" { err = fmt.Errorf("Missing \"Authorization\" in header") return } matches := kBasicAuthPattern.FindStringSubmatch(auth) if len(matches) != 2 { err = fmt.Errorf("Bogus Authorizatio...
[ "func", "BasicAuth", "(", "req", "*", "http", ".", "Request", ")", "(", "username", ",", "password", "string", ",", "err", "error", ")", "{", "auth", ":=", "req", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "auth", "==", "\"", "\...
// BasicAuth parses the Authorization header on req // If absent or invalid, an error is returned.
[ "BasicAuth", "parses", "the", "Authorization", "header", "on", "req", "If", "absent", "or", "invalid", "an", "error", "is", "returned", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/httputil/auth.go#L77-L101
148,242
zombiezen/cardcpx
third_party/webapp/handler.go
IsNotFound
func IsNotFound(e error) bool { if e == NotFound { return true } if e, ok := e.(*URLError); ok && e.Err == NotFound { return true } return false }
go
func IsNotFound(e error) bool { if e == NotFound { return true } if e, ok := e.(*URLError); ok && e.Err == NotFound { return true } return false }
[ "func", "IsNotFound", "(", "e", "error", ")", "bool", "{", "if", "e", "==", "NotFound", "{", "return", "true", "\n", "}", "\n", "if", "e", ",", "ok", ":=", "e", ".", "(", "*", "URLError", ")", ";", "ok", "&&", "e", ".", "Err", "==", "NotFound",...
// IsNotFound reports whether an error is a NotFound error.
[ "IsNotFound", "reports", "whether", "an", "error", "is", "a", "NotFound", "error", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/handler.go#L26-L34
148,243
zombiezen/cardcpx
third_party/webapp/handler.go
Copy
func (br *ResponseBuffer) Copy(w http.ResponseWriter) error { for k, v := range br.sent { w.Header()[k] = v } w.WriteHeader(br.code) _, err := io.Copy(w, br) return err }
go
func (br *ResponseBuffer) Copy(w http.ResponseWriter) error { for k, v := range br.sent { w.Header()[k] = v } w.WriteHeader(br.code) _, err := io.Copy(w, br) return err }
[ "func", "(", "br", "*", "ResponseBuffer", ")", "Copy", "(", "w", "http", ".", "ResponseWriter", ")", "error", "{", "for", "k", ",", "v", ":=", "range", "br", ".", "sent", "{", "w", ".", "Header", "(", ")", "[", "k", "]", "=", "v", "\n", "}", ...
// Copy sends br's data to another ResponseWriter.
[ "Copy", "sends", "br", "s", "data", "to", "another", "ResponseWriter", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/handler.go#L60-L67
148,244
choria-io/go-validator
shellsafe/shellsafe.go
Validate
func Validate(input string) (bool, error) { badchars := []string{"`", "$", ";", "|", "&&", ">", "<"} for _, c := range badchars { if strings.Contains(input, c) { return false, fmt.Errorf("may not contain '%s'", c) } } return true, nil }
go
func Validate(input string) (bool, error) { badchars := []string{"`", "$", ";", "|", "&&", ">", "<"} for _, c := range badchars { if strings.Contains(input, c) { return false, fmt.Errorf("may not contain '%s'", c) } } return true, nil }
[ "func", "Validate", "(", "input", "string", ")", "(", "bool", ",", "error", ")", "{", "badchars", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"",...
// Validate checks if a string is safe to use in a shell without any escapes or redirects
[ "Validate", "checks", "if", "a", "string", "is", "safe", "to", "use", "in", "a", "shell", "without", "any", "escapes", "or", "redirects" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/shellsafe/shellsafe.go#L11-L21
148,245
choria-io/go-validator
shellsafe/shellsafe.go
ValidateStructField
func ValidateStructField(value reflect.Value, tag string) (bool, error) { if value.Kind() != reflect.String { return false, errors.New("should be a string") } return Validate(value.String()) }
go
func ValidateStructField(value reflect.Value, tag string) (bool, error) { if value.Kind() != reflect.String { return false, errors.New("should be a string") } return Validate(value.String()) }
[ "func", "ValidateStructField", "(", "value", "reflect", ".", "Value", ",", "tag", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "value", ".", "Kind", "(", ")", "!=", "reflect", ".", "String", "{", "return", "false", ",", "errors", ".", "N...
// ValidateStructField validates a reflect.Value is shellsafe
[ "ValidateStructField", "validates", "a", "reflect", ".", "Value", "is", "shellsafe" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/shellsafe/shellsafe.go#L24-L30
148,246
choria-io/go-validator
enum/enum.go
ValidateSlice
func ValidateSlice(target []string, valid []string) (bool, error) { for _, item := range target { found, _ := ValidateString(item, valid) if !found { return false, fmt.Errorf("'%s' is not in the allowed list: %s", item, strings.Join(valid, ", ")) } } return true, nil }
go
func ValidateSlice(target []string, valid []string) (bool, error) { for _, item := range target { found, _ := ValidateString(item, valid) if !found { return false, fmt.Errorf("'%s' is not in the allowed list: %s", item, strings.Join(valid, ", ")) } } return true, nil }
[ "func", "ValidateSlice", "(", "target", "[", "]", "string", ",", "valid", "[", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "for", "_", ",", "item", ":=", "range", "target", "{", "found", ",", "_", ":=", "ValidateString", "(", "item", "...
// ValidateSlice validates that all items in target is one of valid
[ "ValidateSlice", "validates", "that", "all", "items", "in", "target", "is", "one", "of", "valid" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/enum/enum.go#L11-L20
148,247
choria-io/go-validator
enum/enum.go
ValidateString
func ValidateString(target string, valid []string) (bool, error) { found := false for _, e := range valid { if e == target { found = true } } if !found { return false, fmt.Errorf("'%s' is not in the allowed list: %s", target, strings.Join(valid, ", ")) } return true, nil }
go
func ValidateString(target string, valid []string) (bool, error) { found := false for _, e := range valid { if e == target { found = true } } if !found { return false, fmt.Errorf("'%s' is not in the allowed list: %s", target, strings.Join(valid, ", ")) } return true, nil }
[ "func", "ValidateString", "(", "target", "string", ",", "valid", "[", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "found", ":=", "false", "\n\n", "for", "_", ",", "e", ":=", "range", "valid", "{", "if", "e", "==", "target", "{", "found...
// ValidateString validates that a string is in the list of allowed values
[ "ValidateString", "validates", "that", "a", "string", "is", "in", "the", "list", "of", "allowed", "values" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/enum/enum.go#L23-L37
148,248
zombiezen/cardcpx
multiwriter/multiwriter.go
Write
func (mw multiWriter) Write(p []byte) (int, error) { done := make(chan result, len(mw)) for _, w := range mw { go send(w, p, done) } endResult := result{n: len(p)} for _ = range mw { res := <-done if res.err != nil && (endResult.err == nil || res.n < endResult.n) { endResult = res } } return endResult...
go
func (mw multiWriter) Write(p []byte) (int, error) { done := make(chan result, len(mw)) for _, w := range mw { go send(w, p, done) } endResult := result{n: len(p)} for _ = range mw { res := <-done if res.err != nil && (endResult.err == nil || res.n < endResult.n) { endResult = res } } return endResult...
[ "func", "(", "mw", "multiWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "done", ":=", "make", "(", "chan", "result", ",", "len", "(", "mw", ")", ")", "\n", "for", "_", ",", "w", ":=", "range", "mw"...
// Write writes p to all writers concurrently. If any errors occur, the shortest write is returned.
[ "Write", "writes", "p", "to", "all", "writers", "concurrently", ".", "If", "any", "errors", "occur", "the", "shortest", "write", "is", "returned", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/multiwriter/multiwriter.go#L33-L46
148,249
zombiezen/cardcpx
takedata/takedata.go
Less
func (id1 ID) Less(id2 ID) bool { if id1.Scene == id2.Scene { return natsort.Less(id1.Num, id2.Num) } else { return natsort.Less(id1.Scene, id2.Scene) } }
go
func (id1 ID) Less(id2 ID) bool { if id1.Scene == id2.Scene { return natsort.Less(id1.Num, id2.Num) } else { return natsort.Less(id1.Scene, id2.Scene) } }
[ "func", "(", "id1", "ID", ")", "Less", "(", "id2", "ID", ")", "bool", "{", "if", "id1", ".", "Scene", "==", "id2", ".", "Scene", "{", "return", "natsort", ".", "Less", "(", "id1", ".", "Num", ",", "id2", ".", "Num", ")", "\n", "}", "else", "{...
// Less reports whether id1 is less than id2.
[ "Less", "reports", "whether", "id1", "is", "less", "than", "id2", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/takedata/takedata.go#L36-L42
148,250
zombiezen/cardcpx
third_party/webapp/db.go
ScanOneStruct
func ScanOneStruct(rows *sql.Rows, val interface{}) error { defer rows.Close() if !rows.Next() { return sql.ErrNoRows } return ScanStruct(rows, val) }
go
func ScanOneStruct(rows *sql.Rows, val interface{}) error { defer rows.Close() if !rows.Next() { return sql.ErrNoRows } return ScanStruct(rows, val) }
[ "func", "ScanOneStruct", "(", "rows", "*", "sql", ".", "Rows", ",", "val", "interface", "{", "}", ")", "error", "{", "defer", "rows", ".", "Close", "(", ")", "\n", "if", "!", "rows", ".", "Next", "(", ")", "{", "return", "sql", ".", "ErrNoRows", ...
// ScanOneStruct is equivalent to calling rows.Next, ScanStruct, then rows.Close. // If there is no next row, sql.ErrNoRows is returned.
[ "ScanOneStruct", "is", "equivalent", "to", "calling", "rows", ".", "Next", "ScanStruct", "then", "rows", ".", "Close", ".", "If", "there", "is", "no", "next", "row", "sql", ".", "ErrNoRows", "is", "returned", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/db.go#L12-L18
148,251
zombiezen/cardcpx
third_party/webapp/db.go
ScanStruct
func ScanStruct(rows *sql.Rows, val interface{}) error { v := reflect.ValueOf(val) if v.Kind() != reflect.Ptr { return errors.New("db: val is not a pointer") } v = v.Elem() if v.Kind() != reflect.Struct { return errors.New("db: val is not a pointer to a struct") } cols, err := rows.Columns() if err != nil {...
go
func ScanStruct(rows *sql.Rows, val interface{}) error { v := reflect.ValueOf(val) if v.Kind() != reflect.Ptr { return errors.New("db: val is not a pointer") } v = v.Elem() if v.Kind() != reflect.Struct { return errors.New("db: val is not a pointer to a struct") } cols, err := rows.Columns() if err != nil {...
[ "func", "ScanStruct", "(", "rows", "*", "sql", ".", "Rows", ",", "val", "interface", "{", "}", ")", "error", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n", "if", "v", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "...
// ScanStruct extracts a single row into the struct pointed to by val. // // Each exported struct field is converted to a column name by using the "sql" // tag of that field, or by transforming the field name from upper camel case to // lowercase underscore-separated words if there is no tag. If the field tag is // "-...
[ "ScanStruct", "extracts", "a", "single", "row", "into", "the", "struct", "pointed", "to", "by", "val", ".", "Each", "exported", "struct", "field", "is", "converted", "to", "a", "column", "name", "by", "using", "the", "sql", "tag", "of", "that", "field", ...
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/db.go#L28-L61
148,252
zombiezen/cardcpx
third_party/webapp/db.go
RunInTransaction
func RunInTransaction(db *sql.DB, f func(*sql.Tx) error) error { tx, err := db.Begin() if err != nil { return &TransactionError{nil, err} } err = f(tx) var txErr error if err == nil { txErr = tx.Commit() } else { txErr = tx.Rollback() } if err != nil || txErr != nil { return &TransactionError{err, txEr...
go
func RunInTransaction(db *sql.DB, f func(*sql.Tx) error) error { tx, err := db.Begin() if err != nil { return &TransactionError{nil, err} } err = f(tx) var txErr error if err == nil { txErr = tx.Commit() } else { txErr = tx.Rollback() } if err != nil || txErr != nil { return &TransactionError{err, txEr...
[ "func", "RunInTransaction", "(", "db", "*", "sql", ".", "DB", ",", "f", "func", "(", "*", "sql", ".", "Tx", ")", "error", ")", "error", "{", "tx", ",", "err", ":=", "db", ".", "Begin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// RunInTransaction executes a SQL operation in a transaction. Any non-nil // error will be wrapped in a TransactionError.
[ "RunInTransaction", "executes", "a", "SQL", "operation", "in", "a", "transaction", ".", "Any", "non", "-", "nil", "error", "will", "be", "wrapped", "in", "a", "TransactionError", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/db.go#L78-L94
148,253
zombiezen/cardcpx
third_party/webapp/db.go
fieldColumn
func fieldColumn(f reflect.StructField) string { if tag := f.Tag.Get("sql"); tag == "-" { return "" } else if tag != "" { return tag } return colname(f.Name) }
go
func fieldColumn(f reflect.StructField) string { if tag := f.Tag.Get("sql"); tag == "-" { return "" } else if tag != "" { return tag } return colname(f.Name) }
[ "func", "fieldColumn", "(", "f", "reflect", ".", "StructField", ")", "string", "{", "if", "tag", ":=", "f", ".", "Tag", ".", "Get", "(", "\"", "\"", ")", ";", "tag", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "else", "if", "tag", "...
// fieldColumn returns the SQL column name for a struct field. An empty string // means this field should not be persisted.
[ "fieldColumn", "returns", "the", "SQL", "column", "name", "for", "a", "struct", "field", ".", "An", "empty", "string", "means", "this", "field", "should", "not", "be", "persisted", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/db.go#L98-L105
148,254
zombiezen/cardcpx
third_party/webapp/db.go
colname
func colname(s string) string { words := make([]string, 0) var start int lastIdx, lastRune := -1, rune(0) for i, r := range s { if i == 0 { // don't create a new word, just grab the rune } else if isUpper(lastRune) && isLower(r) && start != lastIdx { words = append(words, strings.ToLower(s[start:lastIdx])...
go
func colname(s string) string { words := make([]string, 0) var start int lastIdx, lastRune := -1, rune(0) for i, r := range s { if i == 0 { // don't create a new word, just grab the rune } else if isUpper(lastRune) && isLower(r) && start != lastIdx { words = append(words, strings.ToLower(s[start:lastIdx])...
[ "func", "colname", "(", "s", "string", ")", "string", "{", "words", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "var", "start", "int", "\n", "lastIdx", ",", "lastRune", ":=", "-", "1", ",", "rune", "(", "0", ")", "\n", "for", "i...
// colname converts from upper camel case to underscore-separated words.
[ "colname", "converts", "from", "upper", "camel", "case", "to", "underscore", "-", "separated", "words", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/third_party/webapp/db.go#L108-L126
148,255
choria-io/go-validator
regex/regex.go
ValidateString
func ValidateString(input string, regex string) (bool, error) { re, err := regexp.Compile(regex) if err != nil { return false, fmt.Errorf("invalid regex '%s'", regex) } if !re.MatchString(input) { return false, fmt.Errorf("input does not match '%s'", regex) } return true, nil }
go
func ValidateString(input string, regex string) (bool, error) { re, err := regexp.Compile(regex) if err != nil { return false, fmt.Errorf("invalid regex '%s'", regex) } if !re.MatchString(input) { return false, fmt.Errorf("input does not match '%s'", regex) } return true, nil }
[ "func", "ValidateString", "(", "input", "string", ",", "regex", "string", ")", "(", "bool", ",", "error", ")", "{", "re", ",", "err", ":=", "regexp", ".", "Compile", "(", "regex", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "f...
// ValidateString validates that a string matches a regex
[ "ValidateString", "validates", "that", "a", "string", "matches", "a", "regex" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/regex/regex.go#L10-L21
148,256
zombiezen/cardcpx
natsort/sort.go
Less
func Less(s, t string) bool { return LessRunes([]rune(s), []rune(t)) }
go
func Less(s, t string) bool { return LessRunes([]rune(s), []rune(t)) }
[ "func", "Less", "(", "s", ",", "t", "string", ")", "bool", "{", "return", "LessRunes", "(", "[", "]", "rune", "(", "s", ")", ",", "[", "]", "rune", "(", "t", ")", ")", "\n", "}" ]
// Less reports whether s is less than t.
[ "Less", "reports", "whether", "s", "is", "less", "than", "t", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/natsort/sort.go#L32-L34
148,257
zombiezen/cardcpx
natsort/sort.go
LessRunes
func LessRunes(s, t []rune) bool { nprefix := commonPrefix(s, t) if len(s) == nprefix && len(t) == nprefix { // equal return false } sEnd := leadDigits(s[nprefix:]) + nprefix tEnd := leadDigits(t[nprefix:]) + nprefix if sEnd > nprefix || tEnd > nprefix { start := trailDigits(s[:nprefix]) if sEnd-start > 0...
go
func LessRunes(s, t []rune) bool { nprefix := commonPrefix(s, t) if len(s) == nprefix && len(t) == nprefix { // equal return false } sEnd := leadDigits(s[nprefix:]) + nprefix tEnd := leadDigits(t[nprefix:]) + nprefix if sEnd > nprefix || tEnd > nprefix { start := trailDigits(s[:nprefix]) if sEnd-start > 0...
[ "func", "LessRunes", "(", "s", ",", "t", "[", "]", "rune", ")", "bool", "{", "nprefix", ":=", "commonPrefix", "(", "s", ",", "t", ")", "\n", "if", "len", "(", "s", ")", "==", "nprefix", "&&", "len", "(", "t", ")", "==", "nprefix", "{", "// equa...
// LessRunes reports whether s is less than t.
[ "LessRunes", "reports", "whether", "s", "is", "less", "than", "t", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/natsort/sort.go#L37-L64
148,258
choria-io/go-validator
maxlength/maxlength.go
ValidateString
func ValidateString(input string, max int) (bool, error) { if len(input) > max { return false, fmt.Errorf("%d characters, max allowed %d", len(input), max) } return true, nil }
go
func ValidateString(input string, max int) (bool, error) { if len(input) > max { return false, fmt.Errorf("%d characters, max allowed %d", len(input), max) } return true, nil }
[ "func", "ValidateString", "(", "input", "string", ",", "max", "int", ")", "(", "bool", ",", "error", ")", "{", "if", "len", "(", "input", ")", ">", "max", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "input...
// ValidateString validates that input is not longer than max
[ "ValidateString", "validates", "that", "input", "is", "not", "longer", "than", "max" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/maxlength/maxlength.go#L11-L17
148,259
choria-io/go-validator
maxlength/maxlength.go
ValidateStructField
func ValidateStructField(value reflect.Value, tag string) (bool, error) { re := regexp.MustCompile(`^maxlength=(\d+)$`) parts := re.FindStringSubmatch(tag) if len(parts) != 2 { return false, fmt.Errorf("invalid tag '%s', must be maxlength=n", tag) } max, _ := strconv.Atoi(parts[1]) switch value.Kind() { cas...
go
func ValidateStructField(value reflect.Value, tag string) (bool, error) { re := regexp.MustCompile(`^maxlength=(\d+)$`) parts := re.FindStringSubmatch(tag) if len(parts) != 2 { return false, fmt.Errorf("invalid tag '%s', must be maxlength=n", tag) } max, _ := strconv.Atoi(parts[1]) switch value.Kind() { cas...
[ "func", "ValidateStructField", "(", "value", "reflect", ".", "Value", ",", "tag", "string", ")", "(", "bool", ",", "error", ")", "{", "re", ":=", "regexp", ".", "MustCompile", "(", "`^maxlength=(\\d+)$`", ")", "\n", "parts", ":=", "re", ".", "FindStringSub...
// ValidateStructField validates value based on the tag in the form maxlength=10
[ "ValidateStructField", "validates", "value", "based", "on", "the", "tag", "in", "the", "form", "maxlength", "=", "10" ]
4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc
https://github.com/choria-io/go-validator/blob/4ce2ef25983faa873cc4bcea0f1ef2a4273d42cc/maxlength/maxlength.go#L20-L44
148,260
brandfolder/gin-gorelic
gorelic.go
Handler
func Handler(c *gin.Context) { startTime := time.Now() c.Next() if agent != nil { agent.HTTPTimer.UpdateSince(startTime) } }
go
func Handler(c *gin.Context) { startTime := time.Now() c.Next() if agent != nil { agent.HTTPTimer.UpdateSince(startTime) } }
[ "func", "Handler", "(", "c", "*", "gin", ".", "Context", ")", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "c", ".", "Next", "(", ")", "\n", "if", "agent", "!=", "nil", "{", "agent", ".", "HTTPTimer", ".", "UpdateSince", "(", "star...
// Handler for the agent
[ "Handler", "for", "the", "agent" ]
11571ae2d6a2bd91863a1798bf30be68248e61d3
https://github.com/brandfolder/gin-gorelic/blob/11571ae2d6a2bd91863a1798bf30be68248e61d3/gorelic.go#L15-L21
148,261
brandfolder/gin-gorelic
gorelic.go
InitNewrelicAgent
func InitNewrelicAgent(license string, appname string, verbose bool) error { if license == "" { return fmt.Errorf("Please specify NewRelic license") } agent = gorelic.NewAgent() agent.NewrelicLicense = license agent.HTTPTimer = metrics.NewTimer() agent.CollectHTTPStat = true agent.CollectHTTPStatuses = tru...
go
func InitNewrelicAgent(license string, appname string, verbose bool) error { if license == "" { return fmt.Errorf("Please specify NewRelic license") } agent = gorelic.NewAgent() agent.NewrelicLicense = license agent.HTTPTimer = metrics.NewTimer() agent.CollectHTTPStat = true agent.CollectHTTPStatuses = tru...
[ "func", "InitNewrelicAgent", "(", "license", "string", ",", "appname", "string", ",", "verbose", "bool", ")", "error", "{", "if", "license", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "agent", "=", ...
// InitNewrelicAgent creates the new relic agent
[ "InitNewrelicAgent", "creates", "the", "new", "relic", "agent" ]
11571ae2d6a2bd91863a1798bf30be68248e61d3
https://github.com/brandfolder/gin-gorelic/blob/11571ae2d6a2bd91863a1798bf30be68248e61d3/gorelic.go#L24-L41
148,262
zombiezen/cardcpx
netutil/ident.go
Localhost
func Localhost() (net.IP, error) { ips, err := net.LookupIP("localhost") if err != nil { return nil, err } if len(ips) < 1 { return nil, errors.New("IP lookup for localhost returned no result") } return ips[0], nil }
go
func Localhost() (net.IP, error) { ips, err := net.LookupIP("localhost") if err != nil { return nil, err } if len(ips) < 1 { return nil, errors.New("IP lookup for localhost returned no result") } return ips[0], nil }
[ "func", "Localhost", "(", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "ips", ",", "err", ":=", "net", ".", "LookupIP", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len...
// Localhost returns the first address found when // doing a lookup of "localhost".
[ "Localhost", "returns", "the", "first", "address", "found", "when", "doing", "a", "lookup", "of", "localhost", "." ]
d31a084824fd3351fab7c204a80514df5c7691de
https://github.com/zombiezen/cardcpx/blob/d31a084824fd3351fab7c204a80514df5c7691de/netutil/ident.go#L279-L288
148,263
CloudyKit/fastprinter
printers.go
formatBits
func formatBits(dst io.Writer, u uint64, neg bool) (int, error) { var a = pool_integerBuffer.Get().(*byteSliceBuffer) i := integerBufferSize if neg { u = -u } // common case: use constants for / because // the compiler can optimize it into a multiply+shift if ^uintptr(0)>>32 == 0 { for u > uint64(^uintp...
go
func formatBits(dst io.Writer, u uint64, neg bool) (int, error) { var a = pool_integerBuffer.Get().(*byteSliceBuffer) i := integerBufferSize if neg { u = -u } // common case: use constants for / because // the compiler can optimize it into a multiply+shift if ^uintptr(0)>>32 == 0 { for u > uint64(^uintp...
[ "func", "formatBits", "(", "dst", "io", ".", "Writer", ",", "u", "uint64", ",", "neg", "bool", ")", "(", "int", ",", "error", ")", "{", "var", "a", "=", "pool_integerBuffer", ".", "Get", "(", ")", ".", "(", "*", "byteSliceBuffer", ")", "\n\n", "i",...
// formatBits computes the string representation of u in the given base. // If neg is set, u is treated as negative int64 value. // Extracted from std package strconv
[ "formatBits", "computes", "the", "string", "representation", "of", "u", "in", "the", "given", "base", ".", "If", "neg", "is", "set", "u", "is", "treated", "as", "negative", "int64", "value", ".", "Extracted", "from", "std", "package", "strconv" ]
74b38d55f37af5d6c05ca11147d616b613a3420e
https://github.com/CloudyKit/fastprinter/blob/74b38d55f37af5d6c05ca11147d616b613a3420e/printers.go#L116-L163
148,264
CloudyKit/fastprinter
printers.go
PrintValue
func PrintValue(w io.Writer, v reflect.Value) (int, error) { t := v.Type() k := t.Kind() if t.Implements(fmtStringerType) { return PrintString(w, v.Interface().(fmt.Stringer).String()) } if t.Implements(errorType) { return PrintString(w, v.Interface().(error).Error()) } if k == reflect.String { return P...
go
func PrintValue(w io.Writer, v reflect.Value) (int, error) { t := v.Type() k := t.Kind() if t.Implements(fmtStringerType) { return PrintString(w, v.Interface().(fmt.Stringer).String()) } if t.Implements(errorType) { return PrintString(w, v.Interface().(error).Error()) } if k == reflect.String { return P...
[ "func", "PrintValue", "(", "w", "io", ".", "Writer", ",", "v", "reflect", ".", "Value", ")", "(", "int", ",", "error", ")", "{", "t", ":=", "v", ".", "Type", "(", ")", "\n", "k", ":=", "t", ".", "Kind", "(", ")", "\n\n", "if", "t", ".", "Im...
// PrintValue prints a reflect.Value
[ "PrintValue", "prints", "a", "reflect", ".", "Value" ]
74b38d55f37af5d6c05ca11147d616b613a3420e
https://github.com/CloudyKit/fastprinter/blob/74b38d55f37af5d6c05ca11147d616b613a3420e/printers.go#L166-L203
148,265
gobs/cmd
cmd.go
NewWordCompleter
func NewWordCompleter(words CompleterWords, cond CompleterCond) *WordCompleter { return &WordCompleter{Words: words, Cond: cond} }
go
func NewWordCompleter(words CompleterWords, cond CompleterCond) *WordCompleter { return &WordCompleter{Words: words, Cond: cond} }
[ "func", "NewWordCompleter", "(", "words", "CompleterWords", ",", "cond", "CompleterCond", ")", "*", "WordCompleter", "{", "return", "&", "WordCompleter", "{", "Words", ":", "words", ",", "Cond", ":", "cond", "}", "\n", "}" ]
// // Create a WordCompleter and initialize with list of words //
[ "Create", "a", "WordCompleter", "and", "initialize", "with", "list", "of", "words" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L109-L111
148,266
gobs/cmd
cmd.go
Init
func (cmd *Cmd) Init(plugins ...Plugin) { if cmd.PreLoop == nil { cmd.PreLoop = func() {} } if cmd.PostLoop == nil { cmd.PostLoop = func() {} } if cmd.PreCmd == nil { cmd.PreCmd = func(string) {} } if cmd.PostCmd == nil { cmd.PostCmd = func(line string, stop bool) bool { return stop } } if cmd.OneCmd =...
go
func (cmd *Cmd) Init(plugins ...Plugin) { if cmd.PreLoop == nil { cmd.PreLoop = func() {} } if cmd.PostLoop == nil { cmd.PostLoop = func() {} } if cmd.PreCmd == nil { cmd.PreCmd = func(string) {} } if cmd.PostCmd == nil { cmd.PostCmd = func(line string, stop bool) bool { return stop } } if cmd.OneCmd =...
[ "func", "(", "cmd", "*", "Cmd", ")", "Init", "(", "plugins", "...", "Plugin", ")", "{", "if", "cmd", ".", "PreLoop", "==", "nil", "{", "cmd", ".", "PreLoop", "=", "func", "(", ")", "{", "}", "\n", "}", "\n", "if", "cmd", ".", "PostLoop", "==", ...
// // Initialize the command interpreter context //
[ "Initialize", "the", "command", "interpreter", "context" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L206-L259
148,267
gobs/cmd
cmd.go
shellExec
func shellExec(command string) { args := args.GetArgs(command) if len(args) < 1 { fmt.Println("No command to exec") } else { if strings.ContainsAny(command, "$*~") { if _, err := exec.LookPath("sh"); err == nil { args = []string{"sh", "-c", command} } } cmd := exec.Command(args[0]) cmd.Args = arg...
go
func shellExec(command string) { args := args.GetArgs(command) if len(args) < 1 { fmt.Println("No command to exec") } else { if strings.ContainsAny(command, "$*~") { if _, err := exec.LookPath("sh"); err == nil { args = []string{"sh", "-c", command} } } cmd := exec.Command(args[0]) cmd.Args = arg...
[ "func", "shellExec", "(", "command", "string", ")", "{", "args", ":=", "args", ".", "GetArgs", "(", "command", ")", "\n", "if", "len", "(", "args", ")", "<", "1", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "else", "{", "if", "...
// // execute shell command //
[ "execute", "shell", "command" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L351-L370
148,268
gobs/cmd
cmd.go
Add
func (cmd *Cmd) Add(command Command) { if command.HelpFunc == nil { command.HelpFunc = command.DefaultHelp } cmd.Commands[command.Name] = command }
go
func (cmd *Cmd) Add(command Command) { if command.HelpFunc == nil { command.HelpFunc = command.DefaultHelp } cmd.Commands[command.Name] = command }
[ "func", "(", "cmd", "*", "Cmd", ")", "Add", "(", "command", "Command", ")", "{", "if", "command", ".", "HelpFunc", "==", "nil", "{", "command", ".", "HelpFunc", "=", "command", ".", "DefaultHelp", "\n", "}", "\n\n", "cmd", ".", "Commands", "[", "comm...
// Add a command to the command interpreter. // Overrides a command with the same name, if there was one //
[ "Add", "a", "command", "to", "the", "command", "interpreter", ".", "Overrides", "a", "command", "with", "the", "same", "name", "if", "there", "was", "one" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L375-L381
148,269
gobs/cmd
cmd.go
help
func (cmd *Cmd) help(line string) (stop bool) { fmt.Println("") if line == "--all" { fmt.Println("Available commands (use 'help <topic>'):") fmt.Println("================================================================") for _, c := range cmd.commandNames { fmt.Printf("%v: ", c) cmd.Commands[c].HelpFunc(...
go
func (cmd *Cmd) help(line string) (stop bool) { fmt.Println("") if line == "--all" { fmt.Println("Available commands (use 'help <topic>'):") fmt.Println("================================================================") for _, c := range cmd.commandNames { fmt.Printf("%v: ", c) cmd.Commands[c].HelpFunc(...
[ "func", "(", "cmd", "*", "Cmd", ")", "help", "(", "line", "string", ")", "(", "stop", "bool", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n\n", "if", "line", "==", "\"", "\"", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n...
// // Default help command. // It lists all available commands or it displays the help for the specified command //
[ "Default", "help", "command", ".", "It", "lists", "all", "available", "commands", "or", "it", "displays", "the", "help", "for", "the", "specified", "command" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L387-L426
148,270
gobs/cmd
cmd.go
oneCmd
func (cmd *Cmd) oneCmd(line string) (stop bool) { if cmd.GetBoolVar("timing") { start := time.Now() defer func() { d := time.Since(start).Truncate(time.Millisecond) cmd.SetVar("elapsed", d.Seconds()) if !cmd.SilentResult() { fmt.Println("Elapsed:", d) } }() } if cmd.GetBoolVar("echo") { fmt...
go
func (cmd *Cmd) oneCmd(line string) (stop bool) { if cmd.GetBoolVar("timing") { start := time.Now() defer func() { d := time.Since(start).Truncate(time.Millisecond) cmd.SetVar("elapsed", d.Seconds()) if !cmd.SilentResult() { fmt.Println("Elapsed:", d) } }() } if cmd.GetBoolVar("echo") { fmt...
[ "func", "(", "cmd", "*", "Cmd", ")", "oneCmd", "(", "line", "string", ")", "(", "stop", "bool", ")", "{", "if", "cmd", ".", "GetBoolVar", "(", "\"", "\"", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n", "defer", "func", "(", ")", ...
// // This method executes one command //
[ "This", "method", "executes", "one", "command" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L597-L635
148,271
gobs/cmd
cmd.go
CmdLoop
func (cmd *Cmd) CmdLoop() { if len(cmd.Prompt) == 0 { cmd.Prompt = "> " } if len(cmd.ContinuationPrompt) == 0 { cmd.ContinuationPrompt = ": " } cmd.context.StartLiner(cmd.HistoryFile) cmd.context.SetWordCompleter(cmd.wordCompleter) cmd.updateCompleters() cmd.PreLoop() defer func() { cmd.context.StopLi...
go
func (cmd *Cmd) CmdLoop() { if len(cmd.Prompt) == 0 { cmd.Prompt = "> " } if len(cmd.ContinuationPrompt) == 0 { cmd.ContinuationPrompt = ": " } cmd.context.StartLiner(cmd.HistoryFile) cmd.context.SetWordCompleter(cmd.wordCompleter) cmd.updateCompleters() cmd.PreLoop() defer func() { cmd.context.StopLi...
[ "func", "(", "cmd", "*", "Cmd", ")", "CmdLoop", "(", ")", "{", "if", "len", "(", "cmd", ".", "Prompt", ")", "==", "0", "{", "cmd", ".", "Prompt", "=", "\"", "\"", "\n", "}", "\n", "if", "len", "(", "cmd", ".", "ContinuationPrompt", ")", "==", ...
// // This is the command interpreter entry point. // It displays a prompt, waits for a command and executes it until the selected command returns true //
[ "This", "is", "the", "command", "interpreter", "entry", "point", ".", "It", "displays", "a", "prompt", "waits", "for", "a", "command", "and", "executes", "it", "until", "the", "selected", "command", "returns", "true" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L641-L685
148,272
gobs/cmd
cmd.go
SetVar
func (cmd *Cmd) SetVar(k string, v interface{}) { cmd.context.SetVar(k, v, internal.LocalScope) }
go
func (cmd *Cmd) SetVar(k string, v interface{}) { cmd.context.SetVar(k, v, internal.LocalScope) }
[ "func", "(", "cmd", "*", "Cmd", ")", "SetVar", "(", "k", "string", ",", "v", "interface", "{", "}", ")", "{", "cmd", ".", "context", ".", "SetVar", "(", "k", ",", "v", ",", "internal", ".", "LocalScope", ")", "\n", "}" ]
// // SetVar sets a variable in the current scope //
[ "SetVar", "sets", "a", "variable", "in", "the", "current", "scope" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L755-L757
148,273
gobs/cmd
cmd.go
UnsetVar
func (cmd *Cmd) UnsetVar(k string) { cmd.context.UnsetVar(k, internal.LocalScope) }
go
func (cmd *Cmd) UnsetVar(k string) { cmd.context.UnsetVar(k, internal.LocalScope) }
[ "func", "(", "cmd", "*", "Cmd", ")", "UnsetVar", "(", "k", "string", ")", "{", "cmd", ".", "context", ".", "UnsetVar", "(", "k", ",", "internal", ".", "LocalScope", ")", "\n", "}" ]
// // UnsetVar removes a variable from the current scope //
[ "UnsetVar", "removes", "a", "variable", "from", "the", "current", "scope" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L762-L764
148,274
gobs/cmd
cmd.go
ChangeVar
func (cmd *Cmd) ChangeVar(k string, v interface{}) { var oldv interface{} = NoVar if cur, ok := cmd.context.GetVar(k); ok { oldv = cur } if newv := cmd.OnChange(k, oldv, v); newv == NoVar { cmd.context.UnsetVar(k, internal.LocalScope) } else { cmd.context.SetVar(k, newv, internal.LocalScope) } }
go
func (cmd *Cmd) ChangeVar(k string, v interface{}) { var oldv interface{} = NoVar if cur, ok := cmd.context.GetVar(k); ok { oldv = cur } if newv := cmd.OnChange(k, oldv, v); newv == NoVar { cmd.context.UnsetVar(k, internal.LocalScope) } else { cmd.context.SetVar(k, newv, internal.LocalScope) } }
[ "func", "(", "cmd", "*", "Cmd", ")", "ChangeVar", "(", "k", "string", ",", "v", "interface", "{", "}", ")", "{", "var", "oldv", "interface", "{", "}", "=", "NoVar", "\n", "if", "cur", ",", "ok", ":=", "cmd", ".", "context", ".", "GetVar", "(", ...
// // ChangeVar sets a variable in the current scope // and calls the OnChange method //
[ "ChangeVar", "sets", "a", "variable", "in", "the", "current", "scope", "and", "calls", "the", "OnChange", "method" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L770-L780
148,275
gobs/cmd
cmd.go
GetBoolVar
func (cmd *Cmd) GetBoolVar(name string) (val bool) { sval, _ := cmd.context.GetVar(name) val, _ = strconv.ParseBool(sval) return }
go
func (cmd *Cmd) GetBoolVar(name string) (val bool) { sval, _ := cmd.context.GetVar(name) val, _ = strconv.ParseBool(sval) return }
[ "func", "(", "cmd", "*", "Cmd", ")", "GetBoolVar", "(", "name", "string", ")", "(", "val", "bool", ")", "{", "sval", ",", "_", ":=", "cmd", ".", "context", ".", "GetVar", "(", "name", ")", "\n", "val", ",", "_", "=", "strconv", ".", "ParseBool", ...
// // GetBoolVar returns the value of the variable as boolean //
[ "GetBoolVar", "returns", "the", "value", "of", "the", "variable", "as", "boolean" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L792-L796
148,276
gobs/cmd
cmd.go
GetIntVar
func (cmd *Cmd) GetIntVar(name string) (val int) { sval, _ := cmd.context.GetVar(name) val, _ = strconv.Atoi(sval) return }
go
func (cmd *Cmd) GetIntVar(name string) (val int) { sval, _ := cmd.context.GetVar(name) val, _ = strconv.Atoi(sval) return }
[ "func", "(", "cmd", "*", "Cmd", ")", "GetIntVar", "(", "name", "string", ")", "(", "val", "int", ")", "{", "sval", ",", "_", ":=", "cmd", ".", "context", ".", "GetVar", "(", "name", ")", "\n", "val", ",", "_", "=", "strconv", ".", "Atoi", "(", ...
// // GetIntVar returns the value of the variable as int //
[ "GetIntVar", "returns", "the", "value", "of", "the", "variable", "as", "int" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/cmd.go#L801-L805
148,277
johanneswuerbach/nfsexports
nfsexports.go
ReloadDaemon
func ReloadDaemon() error { cmd := exec.Command("sudo", "nfsd", "update") cmd.Stderr = &bytes.Buffer{} if err := cmd.Run(); err != nil { return fmt.Errorf("Reloading nfds failed: %s\n%s", err.Error(), cmd.Stderr) } return nil }
go
func ReloadDaemon() error { cmd := exec.Command("sudo", "nfsd", "update") cmd.Stderr = &bytes.Buffer{} if err := cmd.Run(); err != nil { return fmt.Errorf("Reloading nfds failed: %s\n%s", err.Error(), cmd.Stderr) } return nil }
[ "func", "ReloadDaemon", "(", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "cmd", ".", "Stderr", "=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "if", "err", ":=", "cmd...
// ReloadDaemon reload NFS daemon
[ "ReloadDaemon", "reload", "NFS", "daemon" ]
1aa528dcb3451733ef505b9a268843831cb44b3f
https://github.com/johanneswuerbach/nfsexports/blob/1aa528dcb3451733ef505b9a268843831cb44b3f/nfsexports.go#L85-L94
148,278
gobs/cmd
plugins/json/json.go
StringJson
func StringJson(v interface{}, unq bool) (ret string) { ret = simplejson.MustDumpString(v) if unq { ret, _ = unquote(strings.TrimSpace(ret), '"') } return }
go
func StringJson(v interface{}, unq bool) (ret string) { ret = simplejson.MustDumpString(v) if unq { ret, _ = unquote(strings.TrimSpace(ret), '"') } return }
[ "func", "StringJson", "(", "v", "interface", "{", "}", ",", "unq", "bool", ")", "(", "ret", "string", ")", "{", "ret", "=", "simplejson", ".", "MustDumpString", "(", "v", ")", "\n", "if", "unq", "{", "ret", ",", "_", "=", "unquote", "(", "strings",...
// Function StringJson return the specified object as a JSON string
[ "Function", "StringJson", "return", "the", "specified", "object", "as", "a", "JSON", "string" ]
4980f07f0e1e95ac7da8fd33097708a86ffb46d3
https://github.com/gobs/cmd/blob/4980f07f0e1e95ac7da8fd33097708a86ffb46d3/plugins/json/json.go#L96-L103
148,279
barnybug/gorfxtrx
packet.go
Parse
func Parse(data []byte) (Packet, error) { if data[0] == 0 { // ignore the empty packet - not an error return nil, nil } dlen := len(data) - 1 if int(data[0]) != dlen { return nil, fmt.Errorf("Packet unexpected length: %d != %d", dlen, int(data[0])) } var pkt Packet if packetType, ok := PacketTypes[data[1]...
go
func Parse(data []byte) (Packet, error) { if data[0] == 0 { // ignore the empty packet - not an error return nil, nil } dlen := len(data) - 1 if int(data[0]) != dlen { return nil, fmt.Errorf("Packet unexpected length: %d != %d", dlen, int(data[0])) } var pkt Packet if packetType, ok := PacketTypes[data[1]...
[ "func", "Parse", "(", "data", "[", "]", "byte", ")", "(", "Packet", ",", "error", ")", "{", "if", "data", "[", "0", "]", "==", "0", "{", "// ignore the empty packet - not an error", "return", "nil", ",", "nil", "\n", "}", "\n", "dlen", ":=", "len", "...
// Parse a packet from a byte array.
[ "Parse", "a", "packet", "from", "a", "byte", "array", "." ]
fab70020949d94b49779ae91ef18c56ff8febc4f
https://github.com/barnybug/gorfxtrx/blob/fab70020949d94b49779ae91ef18c56ff8febc4f/packet.go#L41-L63
148,280
barnybug/gorfxtrx
status.go
TypeString
func (self *Status) TypeString() string { if statusTypes[self.TransceiverType] != "" { return statusTypes[self.TransceiverType] } return "unknown" }
go
func (self *Status) TypeString() string { if statusTypes[self.TransceiverType] != "" { return statusTypes[self.TransceiverType] } return "unknown" }
[ "func", "(", "self", "*", "Status", ")", "TypeString", "(", ")", "string", "{", "if", "statusTypes", "[", "self", ".", "TransceiverType", "]", "!=", "\"", "\"", "{", "return", "statusTypes", "[", "self", ".", "TransceiverType", "]", "\n", "}", "\n", "r...
// Type of connected device.
[ "Type", "of", "connected", "device", "." ]
fab70020949d94b49779ae91ef18c56ff8febc4f
https://github.com/barnybug/gorfxtrx/blob/fab70020949d94b49779ae91ef18c56ff8febc4f/status.go#L30-L35
148,281
barnybug/gorfxtrx
status.go
Protocols
func (self *Status) Protocols() []string { devs := []string{} devs = append(devs, decodeFlags(self.data[7], []string{"ae blyss", "rubicson", "fineoffset/viking", "lighting4", "rsl", "byron sx", "rfu6", "edisplay"})...) devs = append(devs, decodeFlags(self.data[8], []string{"mertik", "lightwarerf", "hideki", "lacross...
go
func (self *Status) Protocols() []string { devs := []string{} devs = append(devs, decodeFlags(self.data[7], []string{"ae blyss", "rubicson", "fineoffset/viking", "lighting4", "rsl", "byron sx", "rfu6", "edisplay"})...) devs = append(devs, decodeFlags(self.data[8], []string{"mertik", "lightwarerf", "hideki", "lacross...
[ "func", "(", "self", "*", "Status", ")", "Protocols", "(", ")", "[", "]", "string", "{", "devs", ":=", "[", "]", "string", "{", "}", "\n", "devs", "=", "append", "(", "devs", ",", "decodeFlags", "(", "self", ".", "data", "[", "7", "]", ",", "["...
// Protocols enabled for the device.
[ "Protocols", "enabled", "for", "the", "device", "." ]
fab70020949d94b49779ae91ef18c56ff8febc4f
https://github.com/barnybug/gorfxtrx/blob/fab70020949d94b49779ae91ef18c56ff8febc4f/status.go#L38-L45
148,282
mundipagg/goseq
seq_entities.go
AddProperty
func (p *Properties) AddProperty(key string, value interface{}) { p.Property[key] = value }
go
func (p *Properties) AddProperty(key string, value interface{}) { p.Property[key] = value }
[ "func", "(", "p", "*", "Properties", ")", "AddProperty", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "p", ".", "Property", "[", "key", "]", "=", "value", "\n", "}" ]
//AddProperty adds new property to log
[ "AddProperty", "adds", "new", "property", "to", "log" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/seq_entities.go#L22-L24
148,283
barnybug/gorfxtrx
device.go
Open
func Open(path string, debug bool) (*Device, error) { dev := Device{debug: debug} c := &serial.Config{Name: path, Baud: 38400} ser, err := serial.OpenPort(c) if err != nil { return nil, err } if debug { dev.ser = LogReadWriteCloser{ser} } else { dev.ser = ser } log.Println("Sending reset") reset, _ :...
go
func Open(path string, debug bool) (*Device, error) { dev := Device{debug: debug} c := &serial.Config{Name: path, Baud: 38400} ser, err := serial.OpenPort(c) if err != nil { return nil, err } if debug { dev.ser = LogReadWriteCloser{ser} } else { dev.ser = ser } log.Println("Sending reset") reset, _ :...
[ "func", "Open", "(", "path", "string", ",", "debug", "bool", ")", "(", "*", "Device", ",", "error", ")", "{", "dev", ":=", "Device", "{", "debug", ":", "debug", "}", "\n\n", "c", ":=", "&", "serial", ".", "Config", "{", "Name", ":", "path", ",", ...
// Open the device at the given path.
[ "Open", "the", "device", "at", "the", "given", "path", "." ]
fab70020949d94b49779ae91ef18c56ff8febc4f
https://github.com/barnybug/gorfxtrx/blob/fab70020949d94b49779ae91ef18c56ff8febc4f/device.go#L60-L83
148,284
barnybug/gorfxtrx
device.go
Read
func (self *Device) Read() (Packet, error) { buf := make([]byte, 257) for { // read length i, err := self.ser.Read(buf[0:1]) if i == 0 && err == io.EOF { // empty read, sleep a bit recheck time.Sleep(time.Millisecond * 200) continue } if err != nil { return nil, err } if i == 0 { continue...
go
func (self *Device) Read() (Packet, error) { buf := make([]byte, 257) for { // read length i, err := self.ser.Read(buf[0:1]) if i == 0 && err == io.EOF { // empty read, sleep a bit recheck time.Sleep(time.Millisecond * 200) continue } if err != nil { return nil, err } if i == 0 { continue...
[ "func", "(", "self", "*", "Device", ")", "Read", "(", ")", "(", "Packet", ",", "error", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "257", ")", "\n", "for", "{", "// read length", "i", ",", "err", ":=", "self", ".", "ser", ".", ...
// Read a packet from the device. Blocks until data is available.
[ "Read", "a", "packet", "from", "the", "device", ".", "Blocks", "until", "data", "is", "available", "." ]
fab70020949d94b49779ae91ef18c56ff8febc4f
https://github.com/barnybug/gorfxtrx/blob/fab70020949d94b49779ae91ef18c56ff8febc4f/device.go#L91-L129
148,285
mundipagg/goseq
background.go
newBackground
func (l *Logger) newBackground(qtyConsumer int) error { if qtyConsumer < 1 { qtyConsumer = 1 } var consumers []*background consumers = make([]*background, 0, 0) ch := make(chan *event) for i := 0; i < qtyConsumer; i++ { var a = &background{ ch: ch, url: l.baseURL, apiKey: l.APIKey, } consu...
go
func (l *Logger) newBackground(qtyConsumer int) error { if qtyConsumer < 1 { qtyConsumer = 1 } var consumers []*background consumers = make([]*background, 0, 0) ch := make(chan *event) for i := 0; i < qtyConsumer; i++ { var a = &background{ ch: ch, url: l.baseURL, apiKey: l.APIKey, } consu...
[ "func", "(", "l", "*", "Logger", ")", "newBackground", "(", "qtyConsumer", "int", ")", "error", "{", "if", "qtyConsumer", "<", "1", "{", "qtyConsumer", "=", "1", "\n", "}", "\n", "var", "consumers", "[", "]", "*", "background", "\n", "consumers", "=", ...
// newBackground creates a new Background structure and creates a new Go Routine for the initBackground function
[ "newBackground", "creates", "a", "new", "Background", "structure", "and", "creates", "a", "new", "Go", "Routine", "for", "the", "initBackground", "function" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/background.go#L19-L50
148,286
mundipagg/goseq
background.go
initBackground
func (b *background) initBackground() error { var client = &seqClient{baseURL: b.url} defer b.wg.Done() var _client = &http.Client{ Transport: &http.Transport{ TLSHandshakeTimeout: 30 * time.Second, }, } for { item, ok := <-b.ch if !ok { break } seqlog := seqLog{ Events: []*event{item}, } ...
go
func (b *background) initBackground() error { var client = &seqClient{baseURL: b.url} defer b.wg.Done() var _client = &http.Client{ Transport: &http.Transport{ TLSHandshakeTimeout: 30 * time.Second, }, } for { item, ok := <-b.ch if !ok { break } seqlog := seqLog{ Events: []*event{item}, } ...
[ "func", "(", "b", "*", "background", ")", "initBackground", "(", ")", "error", "{", "var", "client", "=", "&", "seqClient", "{", "baseURL", ":", "b", ".", "url", "}", "\n", "defer", "b", ".", "wg", ".", "Done", "(", ")", "\n", "var", "_client", "...
// Background function that is responsible for sending log messages to the SEQ API
[ "Background", "function", "that", "is", "responsible", "for", "sending", "log", "messages", "to", "the", "SEQ", "API" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/background.go#L53-L77
148,287
mundipagg/goseq
seq_client.go
send
func (sc *seqClient) send(event *seqLog, apiKey string, client *http.Client) error { fullURL := sc.baseURL + endpoint serialized, _ := json.Marshal(event) request, err := http.NewRequest("POST", fullURL, bytes.NewBuffer(serialized)) if len(apiKey) > 1 { request.Header.Set("X-Seq-ApiKey", apiKey) request.Head...
go
func (sc *seqClient) send(event *seqLog, apiKey string, client *http.Client) error { fullURL := sc.baseURL + endpoint serialized, _ := json.Marshal(event) request, err := http.NewRequest("POST", fullURL, bytes.NewBuffer(serialized)) if len(apiKey) > 1 { request.Header.Set("X-Seq-ApiKey", apiKey) request.Head...
[ "func", "(", "sc", "*", "seqClient", ")", "send", "(", "event", "*", "seqLog", ",", "apiKey", "string", ",", "client", "*", "http", ".", "Client", ")", "error", "{", "fullURL", ":=", "sc", ".", "baseURL", "+", "endpoint", "\n\n", "serialized", ",", "...
// send send POST requests to the SEQ API
[ "send", "send", "POST", "requests", "to", "the", "SEQ", "API" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/seq_client.go#L20-L47
148,288
mundipagg/goseq
logger.go
GetLogger
func GetLogger(url, apiKey string) (*Logger, error) { l, err := createLogger(url, apiKey, false, 0) return l, err }
go
func GetLogger(url, apiKey string) (*Logger, error) { l, err := createLogger(url, apiKey, false, 0) return l, err }
[ "func", "GetLogger", "(", "url", ",", "apiKey", "string", ")", "(", "*", "Logger", ",", "error", ")", "{", "l", ",", "err", ":=", "createLogger", "(", "url", ",", "apiKey", ",", "false", ",", "0", ")", "\n", "return", "l", ",", "err", "\n", "}" ]
// GetLogger creates and returns a new Logger struct
[ "GetLogger", "creates", "and", "returns", "a", "new", "Logger", "struct" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L22-L25
148,289
mundipagg/goseq
logger.go
GetAsyncLogger
func GetAsyncLogger(url, apiKey string, qtyConsumer int) (*Logger, error) { l, err := createLogger(url, apiKey, true, qtyConsumer) return l, err }
go
func GetAsyncLogger(url, apiKey string, qtyConsumer int) (*Logger, error) { l, err := createLogger(url, apiKey, true, qtyConsumer) return l, err }
[ "func", "GetAsyncLogger", "(", "url", ",", "apiKey", "string", ",", "qtyConsumer", "int", ")", "(", "*", "Logger", ",", "error", ")", "{", "l", ",", "err", ":=", "createLogger", "(", "url", ",", "apiKey", ",", "true", ",", "qtyConsumer", ")", "\n", "...
// GetAsyncLogger creates and returns a new Logger struct with a Background struct ready to send log messages asynchronously
[ "GetAsyncLogger", "creates", "and", "returns", "a", "new", "Logger", "struct", "with", "a", "Background", "struct", "ready", "to", "send", "log", "messages", "asynchronously" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L28-L31
148,290
mundipagg/goseq
logger.go
SetDefaultProperties
func (l *Logger) SetDefaultProperties(props map[string]interface{}) { for key, value := range props { l.DefaultProperties.AddProperty(key, value) } }
go
func (l *Logger) SetDefaultProperties(props map[string]interface{}) { for key, value := range props { l.DefaultProperties.AddProperty(key, value) } }
[ "func", "(", "l", "*", "Logger", ")", "SetDefaultProperties", "(", "props", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "for", "key", ",", "value", ":=", "range", "props", "{", "l", ".", "DefaultProperties", ".", "AddProperty", "(", "ke...
// SetDefaultProperties sets the DefaultProperties variable
[ "SetDefaultProperties", "sets", "the", "DefaultProperties", "variable" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L61-L66
148,291
mundipagg/goseq
logger.go
Close
func (l *Logger) Close() { close(l.channel) for _, back := range l.background { back.close() } }
go
func (l *Logger) Close() { close(l.channel) for _, back := range l.background { back.close() } }
[ "func", "(", "l", "*", "Logger", ")", "Close", "(", ")", "{", "close", "(", "l", ".", "channel", ")", "\n", "for", "_", ",", "back", ":=", "range", "l", ".", "background", "{", "back", ".", "close", "(", ")", "\n", "}", "\n\n", "}" ]
// Close closes the logger background routine
[ "Close", "closes", "the", "logger", "background", "routine" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L69-L75
148,292
mundipagg/goseq
logger.go
Debug
func (l *Logger) Debug(message string, props Properties) { l.log(Debug, message, props) }
go
func (l *Logger) Debug(message string, props Properties) { l.log(Debug, message, props) }
[ "func", "(", "l", "*", "Logger", ")", "Debug", "(", "message", "string", ",", "props", "Properties", ")", "{", "l", ".", "log", "(", "Debug", ",", "message", ",", "props", ")", "\n", "}" ]
// Debug log messages with DEBUG level
[ "Debug", "log", "messages", "with", "DEBUG", "level" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L121-L123
148,293
mundipagg/goseq
logger.go
Error
func (l *Logger) Error(message string, props Properties) { l.log(Error, message, props) }
go
func (l *Logger) Error(message string, props Properties) { l.log(Error, message, props) }
[ "func", "(", "l", "*", "Logger", ")", "Error", "(", "message", "string", ",", "props", "Properties", ")", "{", "l", ".", "log", "(", "Error", ",", "message", ",", "props", ")", "\n", "}" ]
// Error log messages with ERROR level
[ "Error", "log", "messages", "with", "ERROR", "level" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L126-L128
148,294
mundipagg/goseq
logger.go
Warning
func (l *Logger) Warning(message string, props Properties) { l.log(Warning, message, props) }
go
func (l *Logger) Warning(message string, props Properties) { l.log(Warning, message, props) }
[ "func", "(", "l", "*", "Logger", ")", "Warning", "(", "message", "string", ",", "props", "Properties", ")", "{", "l", ".", "log", "(", "Warning", ",", "message", ",", "props", ")", "\n", "}" ]
// Warning log messages with WARNING level
[ "Warning", "log", "messages", "with", "WARNING", "level" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L131-L133
148,295
mundipagg/goseq
logger.go
Fatal
func (l *Logger) Fatal(message string, props Properties) { l.log(Fatal, message, props) }
go
func (l *Logger) Fatal(message string, props Properties) { l.log(Fatal, message, props) }
[ "func", "(", "l", "*", "Logger", ")", "Fatal", "(", "message", "string", ",", "props", "Properties", ")", "{", "l", ".", "log", "(", "Fatal", ",", "message", ",", "props", ")", "\n", "}" ]
// Fatal log messages with FATAL level
[ "Fatal", "log", "messages", "with", "FATAL", "level" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L136-L138
148,296
mundipagg/goseq
logger.go
Information
func (l *Logger) Information(message string, props Properties) { l.log(Information, message, props) }
go
func (l *Logger) Information(message string, props Properties) { l.log(Information, message, props) }
[ "func", "(", "l", "*", "Logger", ")", "Information", "(", "message", "string", ",", "props", "Properties", ")", "{", "l", ".", "log", "(", "Information", ",", "message", ",", "props", ")", "\n", "}" ]
// Information log messages with INFORMATION level
[ "Information", "log", "messages", "with", "INFORMATION", "level" ]
ac118d58394e95c89704f68f6594f3e6d60f70b9
https://github.com/mundipagg/goseq/blob/ac118d58394e95c89704f68f6594f3e6d60f70b9/logger.go#L141-L143
148,297
neptulon/ca
ca.go
GenCACert
func GenCACert(subject pkix.Name, validFor time.Duration, keyLength int, signingCert, signingKey []byte) (cert, key []byte, err error) { var ( sc, c *x509.Certificate sk, k *rsa.PrivateKey ) if c, k, err = createBaseCert(subject, validFor, keyLength); err != nil { return } if signingCert == nil || signingK...
go
func GenCACert(subject pkix.Name, validFor time.Duration, keyLength int, signingCert, signingKey []byte) (cert, key []byte, err error) { var ( sc, c *x509.Certificate sk, k *rsa.PrivateKey ) if c, k, err = createBaseCert(subject, validFor, keyLength); err != nil { return } if signingCert == nil || signingK...
[ "func", "GenCACert", "(", "subject", "pkix", ".", "Name", ",", "validFor", "time", ".", "Duration", ",", "keyLength", "int", ",", "signingCert", ",", "signingKey", "[", "]", "byte", ")", "(", "cert", ",", "key", "[", "]", "byte", ",", "err", "error", ...
// GenCACert generates a CA certificate. // If signingCert and signingKey are not provided, the certificate is created as a self-signed root CA. // If signingCert and signingKey are provided, the certificate is created as an intermediate CA, signed with provided certificate. // The generated certificate can only be use...
[ "GenCACert", "generates", "a", "CA", "certificate", ".", "If", "signingCert", "and", "signingKey", "are", "not", "provided", "the", "certificate", "is", "created", "as", "a", "self", "-", "signed", "root", "CA", ".", "If", "signingCert", "and", "signingKey", ...
0c1ac1eda71a770d867f1a497287c00eff48ab37
https://github.com/neptulon/ca/blob/0c1ac1eda71a770d867f1a497287c00eff48ab37/ca.go#L141-L163
148,298
neptulon/ca
ca.go
GenServerCert
func GenServerCert(subject pkix.Name, host string, validFor time.Duration, keyLength int, signingCert, signingKey []byte) (cert, key []byte, err error) { var ( sc, c *x509.Certificate sk, k *rsa.PrivateKey ) if sc, sk, err = parseCertAndKey(signingCert, signingKey); err != nil { return } if c, k, err = cre...
go
func GenServerCert(subject pkix.Name, host string, validFor time.Duration, keyLength int, signingCert, signingKey []byte) (cert, key []byte, err error) { var ( sc, c *x509.Certificate sk, k *rsa.PrivateKey ) if sc, sk, err = parseCertAndKey(signingCert, signingKey); err != nil { return } if c, k, err = cre...
[ "func", "GenServerCert", "(", "subject", "pkix", ".", "Name", ",", "host", "string", ",", "validFor", "time", ".", "Duration", ",", "keyLength", "int", ",", "signingCert", ",", "signingKey", "[", "]", "byte", ")", "(", "cert", ",", "key", "[", "]", "by...
// GenServerCert generates a hosting certificate for TLS servers. // host = Comma-separated hostnames and IPs to generate a certificate for. i.e. "localhost,127.0.0.1" // The returned slices are the PEM encoded X.509 certificate and private key pair.
[ "GenServerCert", "generates", "a", "hosting", "certificate", "for", "TLS", "servers", ".", "host", "=", "Comma", "-", "separated", "hostnames", "and", "IPs", "to", "generate", "a", "certificate", "for", ".", "i", ".", "e", ".", "localhost", "127", ".", "0"...
0c1ac1eda71a770d867f1a497287c00eff48ab37
https://github.com/neptulon/ca/blob/0c1ac1eda71a770d867f1a497287c00eff48ab37/ca.go#L168-L189
148,299
neptulon/ca
ca.go
parseCertAndKey
func parseCertAndKey(cert, key []byte) (c *x509.Certificate, k *rsa.PrivateKey, err error) { pc, _ := pem.Decode(cert) if c, err = x509.ParseCertificate(pc.Bytes); err != nil { err = fmt.Errorf("Failed to parse private key with error: %v", err) return } pk, _ := pem.Decode(key) if k, err = x509.ParsePKCS1Priv...
go
func parseCertAndKey(cert, key []byte) (c *x509.Certificate, k *rsa.PrivateKey, err error) { pc, _ := pem.Decode(cert) if c, err = x509.ParseCertificate(pc.Bytes); err != nil { err = fmt.Errorf("Failed to parse private key with error: %v", err) return } pk, _ := pem.Decode(key) if k, err = x509.ParsePKCS1Priv...
[ "func", "parseCertAndKey", "(", "cert", ",", "key", "[", "]", "byte", ")", "(", "c", "*", "x509", ".", "Certificate", ",", "k", "*", "rsa", ".", "PrivateKey", ",", "err", "error", ")", "{", "pc", ",", "_", ":=", "pem", ".", "Decode", "(", "cert",...
// Parses PEM encoded X.509 certificate and private key pair into x509.Certificate and rsa.PrivateKey objects.
[ "Parses", "PEM", "encoded", "X", ".", "509", "certificate", "and", "private", "key", "pair", "into", "x509", ".", "Certificate", "and", "rsa", ".", "PrivateKey", "objects", "." ]
0c1ac1eda71a770d867f1a497287c00eff48ab37
https://github.com/neptulon/ca/blob/0c1ac1eda71a770d867f1a497287c00eff48ab37/ca.go#L255-L269