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
141,500
lestrrat-go/jsval
builder/builder.go
BuildWithCtx
func (b *Builder) BuildWithCtx(s *schema.Schema, jsctx interface{}) (v *jsval.JSVal, err error) { if pdebug.Enabled { g := pdebug.IPrintf("START Builder.BuildWithCtx") defer func() { if err == nil { g.IRelease("END Builder.BuildWithCtx (OK)") } else { g.IRelease("END Builder.BuildWithCtx (FAIL): %s",...
go
func (b *Builder) BuildWithCtx(s *schema.Schema, jsctx interface{}) (v *jsval.JSVal, err error) { if pdebug.Enabled { g := pdebug.IPrintf("START Builder.BuildWithCtx") defer func() { if err == nil { g.IRelease("END Builder.BuildWithCtx (OK)") } else { g.IRelease("END Builder.BuildWithCtx (FAIL): %s",...
[ "func", "(", "b", "*", "Builder", ")", "BuildWithCtx", "(", "s", "*", "schema", ".", "Schema", ",", "jsctx", "interface", "{", "}", ")", "(", "v", "*", "jsval", ".", "JSVal", ",", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g"...
// BuildWithCtx creates a new validator from the specified schema, using // the jsctx parameter as the context to resolve JSON References with. // If you expect your schema to contain JSON references to itself, // you will have to pass the context as a map with raw decoded JSON data
[ "BuildWithCtx", "creates", "a", "new", "validator", "from", "the", "specified", "schema", "using", "the", "jsctx", "parameter", "as", "the", "context", "to", "resolve", "JSON", "References", "with", ".", "If", "you", "expect", "your", "schema", "to", "contain"...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/builder/builder.go#L57-L108
141,501
lestrrat-go/jsval
array.go
AdditionalItems
func (c *ArrayConstraint) AdditionalItems(ac Constraint) *ArrayConstraint { c.additionalItems = ac return c }
go
func (c *ArrayConstraint) AdditionalItems(ac Constraint) *ArrayConstraint { c.additionalItems = ac return c }
[ "func", "(", "c", "*", "ArrayConstraint", ")", "AdditionalItems", "(", "ac", "Constraint", ")", "*", "ArrayConstraint", "{", "c", ".", "additionalItems", "=", "ac", "\n", "return", "c", "\n", "}" ]
// AdditionalItems specifies the constraint that additional items // must be validated against. Note that if you specify `Items` // with this constraint, `AdditionalItems` has no effect. This // constraint only makes sense when used along side with the // `PositionalItems` constraint. // // If you want to allow any add...
[ "AdditionalItems", "specifies", "the", "constraint", "that", "additional", "items", "must", "be", "validated", "against", ".", "Note", "that", "if", "you", "specify", "Items", "with", "this", "constraint", "AdditionalItems", "has", "no", "effect", ".", "This", "...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/array.go#L125-L128
141,502
lestrrat-go/jsval
array.go
Items
func (c *ArrayConstraint) Items(ac Constraint) *ArrayConstraint { c.items = ac return c }
go
func (c *ArrayConstraint) Items(ac Constraint) *ArrayConstraint { c.items = ac return c }
[ "func", "(", "c", "*", "ArrayConstraint", ")", "Items", "(", "ac", "Constraint", ")", "*", "ArrayConstraint", "{", "c", ".", "items", "=", "ac", "\n", "return", "c", "\n", "}" ]
// Items specifies the constraint that all items in the array // must be validated against
[ "Items", "specifies", "the", "constraint", "that", "all", "items", "in", "the", "array", "must", "be", "validated", "against" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/array.go#L132-L135
141,503
lestrrat-go/jsval
array.go
MinItems
func (c *ArrayConstraint) MinItems(i int) *ArrayConstraint { c.minItems = i return c }
go
func (c *ArrayConstraint) MinItems(i int) *ArrayConstraint { c.minItems = i return c }
[ "func", "(", "c", "*", "ArrayConstraint", ")", "MinItems", "(", "i", "int", ")", "*", "ArrayConstraint", "{", "c", ".", "minItems", "=", "i", "\n", "return", "c", "\n", "}" ]
// MinItems specifies the minimum number of items in the value. // If unspecified, the check is not performed.
[ "MinItems", "specifies", "the", "minimum", "number", "of", "items", "in", "the", "value", ".", "If", "unspecified", "the", "check", "is", "not", "performed", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/array.go#L139-L142
141,504
lestrrat-go/jsval
array.go
MaxItems
func (c *ArrayConstraint) MaxItems(i int) *ArrayConstraint { c.maxItems = i return c }
go
func (c *ArrayConstraint) MaxItems(i int) *ArrayConstraint { c.maxItems = i return c }
[ "func", "(", "c", "*", "ArrayConstraint", ")", "MaxItems", "(", "i", "int", ")", "*", "ArrayConstraint", "{", "c", ".", "maxItems", "=", "i", "\n", "return", "c", "\n", "}" ]
// MaxItems specifies the maximum number of items in the value. // If unspecified, the check is not performed.
[ "MaxItems", "specifies", "the", "maximum", "number", "of", "items", "in", "the", "value", ".", "If", "unspecified", "the", "check", "is", "not", "performed", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/array.go#L146-L149
141,505
lestrrat-go/jsval
array.go
PositionalItems
func (c *ArrayConstraint) PositionalItems(ac []Constraint) *ArrayConstraint { c.positionalItems = ac return c }
go
func (c *ArrayConstraint) PositionalItems(ac []Constraint) *ArrayConstraint { c.positionalItems = ac return c }
[ "func", "(", "c", "*", "ArrayConstraint", ")", "PositionalItems", "(", "ac", "[", "]", "Constraint", ")", "*", "ArrayConstraint", "{", "c", ".", "positionalItems", "=", "ac", "\n", "return", "c", "\n", "}" ]
// PositionalItems specifies the constraint that elements in // each position of the array being validated. Extra items in // the array are validated against the constraint specified for // `AdditionalItems`.
[ "PositionalItems", "specifies", "the", "constraint", "that", "elements", "in", "each", "position", "of", "the", "array", "being", "validated", ".", "Extra", "items", "in", "the", "array", "are", "validated", "against", "the", "constraint", "specified", "for", "A...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/array.go#L155-L158
141,506
lestrrat-go/jsval
structinfo.go
PropNames
func (si *StructInfo) PropNames(rv reflect.Value) []string { si.lock.RLock() defer si.lock.RUnlock() pnames := make([]string, 0, len(si.props)) for pname, pinfo := range si.props { if pinfo.IsMaybe { fv := rv.FieldByName(pinfo.FieldName) mv := fv.MethodByName("Valid") out := mv.Call(nil) if !out[0].B...
go
func (si *StructInfo) PropNames(rv reflect.Value) []string { si.lock.RLock() defer si.lock.RUnlock() pnames := make([]string, 0, len(si.props)) for pname, pinfo := range si.props { if pinfo.IsMaybe { fv := rv.FieldByName(pinfo.FieldName) mv := fv.MethodByName("Valid") out := mv.Call(nil) if !out[0].B...
[ "func", "(", "si", "*", "StructInfo", ")", "PropNames", "(", "rv", "reflect", ".", "Value", ")", "[", "]", "string", "{", "si", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "si", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "pnames", ":=...
// Gets the list of property names for this particuar instance of a // struct. Uninitialized types are not considered, so we remove // them depending on the state of this instance of the struct
[ "Gets", "the", "list", "of", "property", "names", "for", "this", "particuar", "instance", "of", "a", "struct", ".", "Uninitialized", "types", "are", "not", "considered", "so", "we", "remove", "them", "depending", "on", "the", "state", "of", "this", "instance...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/structinfo.go#L41-L59
141,507
lestrrat-go/jsval
generator.go
Process
func (g *Generator) Process(out io.Writer, validators ...*JSVal) error { ctx := genctx{ pkgname: "jsval", refnames: make(map[string]string), vname: "V", } buf := bytes.Buffer{} // First get all of the references so we can refer to it later refs := map[string]Constraint{} refnames := []string{} valnam...
go
func (g *Generator) Process(out io.Writer, validators ...*JSVal) error { ctx := genctx{ pkgname: "jsval", refnames: make(map[string]string), vname: "V", } buf := bytes.Buffer{} // First get all of the references so we can refer to it later refs := map[string]Constraint{} refnames := []string{} valnam...
[ "func", "(", "g", "*", "Generator", ")", "Process", "(", "out", "io", ".", "Writer", ",", "validators", "...", "*", "JSVal", ")", "error", "{", "ctx", ":=", "genctx", "{", "pkgname", ":", "\"", "\"", ",", "refnames", ":", "make", "(", "map", "[", ...
// Process takes a validator and prints out Go code to out.
[ "Process", "takes", "a", "validator", "and", "prints", "out", "Go", "code", "to", "out", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/generator.go#L27-L118
141,508
lestrrat-go/jsval
object.go
Object
func Object() *ObjectConstraint { return &ObjectConstraint{ additionalProperties: nil, minProperties: -1, maxProperties: -1, patternProperties: make(map[*regexp.Regexp]Constraint), properties: make(map[string]Constraint), propdeps: make(map[string][]string), require...
go
func Object() *ObjectConstraint { return &ObjectConstraint{ additionalProperties: nil, minProperties: -1, maxProperties: -1, patternProperties: make(map[*regexp.Regexp]Constraint), properties: make(map[string]Constraint), propdeps: make(map[string][]string), require...
[ "func", "Object", "(", ")", "*", "ObjectConstraint", "{", "return", "&", "ObjectConstraint", "{", "additionalProperties", ":", "nil", ",", "minProperties", ":", "-", "1", ",", "maxProperties", ":", "-", "1", ",", "patternProperties", ":", "make", "(", "map",...
// Object creates a new ObjectConstraint
[ "Object", "creates", "a", "new", "ObjectConstraint" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L22-L33
141,509
lestrrat-go/jsval
object.go
Required
func (o *ObjectConstraint) Required(l ...string) *ObjectConstraint { o.reqlock.Lock() defer o.reqlock.Unlock() for _, pname := range l { o.required[pname] = struct{}{} } return o }
go
func (o *ObjectConstraint) Required(l ...string) *ObjectConstraint { o.reqlock.Lock() defer o.reqlock.Unlock() for _, pname := range l { o.required[pname] = struct{}{} } return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "Required", "(", "l", "...", "string", ")", "*", "ObjectConstraint", "{", "o", ".", "reqlock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "reqlock", ".", "Unlock", "(", ")", "\n\n", "for", "_", "...
// Required specifies required property names
[ "Required", "specifies", "required", "property", "names" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L36-L44
141,510
lestrrat-go/jsval
object.go
IsPropRequired
func (o *ObjectConstraint) IsPropRequired(s string) bool { o.reqlock.Lock() defer o.reqlock.Unlock() _, ok := o.required[s] return ok }
go
func (o *ObjectConstraint) IsPropRequired(s string) bool { o.reqlock.Lock() defer o.reqlock.Unlock() _, ok := o.required[s] return ok }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "IsPropRequired", "(", "s", "string", ")", "bool", "{", "o", ".", "reqlock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "reqlock", ".", "Unlock", "(", ")", "\n\n", "_", ",", "ok", ":=", "o", "....
// IsPropRequired returns true if the given name is listed under // the required properties
[ "IsPropRequired", "returns", "true", "if", "the", "given", "name", "is", "listed", "under", "the", "required", "properties" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L48-L54
141,511
lestrrat-go/jsval
object.go
MinProperties
func (o *ObjectConstraint) MinProperties(n int) *ObjectConstraint { o.minProperties = n return o }
go
func (o *ObjectConstraint) MinProperties(n int) *ObjectConstraint { o.minProperties = n return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "MinProperties", "(", "n", "int", ")", "*", "ObjectConstraint", "{", "o", ".", "minProperties", "=", "n", "\n", "return", "o", "\n", "}" ]
// MinProperties specifies the minimum number of properties this // constraint can allow. If unspecified, it is not checked.
[ "MinProperties", "specifies", "the", "minimum", "number", "of", "properties", "this", "constraint", "can", "allow", ".", "If", "unspecified", "it", "is", "not", "checked", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L58-L61
141,512
lestrrat-go/jsval
object.go
MaxProperties
func (o *ObjectConstraint) MaxProperties(n int) *ObjectConstraint { o.maxProperties = n return o }
go
func (o *ObjectConstraint) MaxProperties(n int) *ObjectConstraint { o.maxProperties = n return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "MaxProperties", "(", "n", "int", ")", "*", "ObjectConstraint", "{", "o", ".", "maxProperties", "=", "n", "\n", "return", "o", "\n", "}" ]
// MaxProperties specifies the maximum number of properties this // constraint can allow. If unspecified, it is not checked.
[ "MaxProperties", "specifies", "the", "maximum", "number", "of", "properties", "this", "constraint", "can", "allow", ".", "If", "unspecified", "it", "is", "not", "checked", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L65-L68
141,513
lestrrat-go/jsval
object.go
AdditionalProperties
func (o *ObjectConstraint) AdditionalProperties(c Constraint) *ObjectConstraint { o.additionalProperties = c return o }
go
func (o *ObjectConstraint) AdditionalProperties(c Constraint) *ObjectConstraint { o.additionalProperties = c return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "AdditionalProperties", "(", "c", "Constraint", ")", "*", "ObjectConstraint", "{", "o", ".", "additionalProperties", "=", "c", "\n", "return", "o", "\n", "}" ]
// AdditionalProperties specifies the constraint that additional // properties should be validated against.
[ "AdditionalProperties", "specifies", "the", "constraint", "that", "additional", "properties", "should", "be", "validated", "against", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L72-L75
141,514
lestrrat-go/jsval
object.go
AddProp
func (o *ObjectConstraint) AddProp(name string, c Constraint) *ObjectConstraint { o.proplock.Lock() defer o.proplock.Unlock() o.properties[name] = c return o }
go
func (o *ObjectConstraint) AddProp(name string, c Constraint) *ObjectConstraint { o.proplock.Lock() defer o.proplock.Unlock() o.properties[name] = c return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "AddProp", "(", "name", "string", ",", "c", "Constraint", ")", "*", "ObjectConstraint", "{", "o", ".", "proplock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "proplock", ".", "Unlock", "(", ")", "\...
// AddProp adds constraints for a named property.
[ "AddProp", "adds", "constraints", "for", "a", "named", "property", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L78-L84
141,515
lestrrat-go/jsval
object.go
PatternProperties
func (o *ObjectConstraint) PatternProperties(key *regexp.Regexp, c Constraint) *ObjectConstraint { o.proplock.Lock() defer o.proplock.Unlock() o.patternProperties[key] = c return o }
go
func (o *ObjectConstraint) PatternProperties(key *regexp.Regexp, c Constraint) *ObjectConstraint { o.proplock.Lock() defer o.proplock.Unlock() o.patternProperties[key] = c return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "PatternProperties", "(", "key", "*", "regexp", ".", "Regexp", ",", "c", "Constraint", ")", "*", "ObjectConstraint", "{", "o", ".", "proplock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "proplock", ...
// PatternProperties specifies constraints that properties matching // this pattern must be validated against. Note that properties listed // using `AddProp` takes precedence.
[ "PatternProperties", "specifies", "constraints", "that", "properties", "matching", "this", "pattern", "must", "be", "validated", "against", ".", "Note", "that", "properties", "listed", "using", "AddProp", "takes", "precedence", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L89-L95
141,516
lestrrat-go/jsval
object.go
PatternPropertiesString
func (o *ObjectConstraint) PatternPropertiesString(key string, c Constraint) *ObjectConstraint { rx := regexp.MustCompile(key) return o.PatternProperties(rx, c) }
go
func (o *ObjectConstraint) PatternPropertiesString(key string, c Constraint) *ObjectConstraint { rx := regexp.MustCompile(key) return o.PatternProperties(rx, c) }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "PatternPropertiesString", "(", "key", "string", ",", "c", "Constraint", ")", "*", "ObjectConstraint", "{", "rx", ":=", "regexp", ".", "MustCompile", "(", "key", ")", "\n", "return", "o", ".", "PatternPropertie...
// PatternPropertiesString is the same as PatternProperties, but takes // a string representing a regular expression. If the regular expression // cannot be compiled, a panic occurs.
[ "PatternPropertiesString", "is", "the", "same", "as", "PatternProperties", "but", "takes", "a", "string", "representing", "a", "regular", "expression", ".", "If", "the", "regular", "expression", "cannot", "be", "compiled", "a", "panic", "occurs", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L100-L103
141,517
lestrrat-go/jsval
object.go
PropDependency
func (o *ObjectConstraint) PropDependency(from string, to ...string) *ObjectConstraint { o.deplock.Lock() defer o.deplock.Unlock() l := o.propdeps[from] l = append(l, to...) o.propdeps[from] = l return o }
go
func (o *ObjectConstraint) PropDependency(from string, to ...string) *ObjectConstraint { o.deplock.Lock() defer o.deplock.Unlock() l := o.propdeps[from] l = append(l, to...) o.propdeps[from] = l return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "PropDependency", "(", "from", "string", ",", "to", "...", "string", ")", "*", "ObjectConstraint", "{", "o", ".", "deplock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "deplock", ".", "Unlock", "(", ...
// PropDependency specifies properties that must be present when // `from` is present.
[ "PropDependency", "specifies", "properties", "that", "must", "be", "present", "when", "from", "is", "present", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L107-L115
141,518
lestrrat-go/jsval
object.go
SchemaDependency
func (o *ObjectConstraint) SchemaDependency(from string, c Constraint) *ObjectConstraint { o.deplock.Lock() defer o.deplock.Unlock() o.schemadeps[from] = c return o }
go
func (o *ObjectConstraint) SchemaDependency(from string, c Constraint) *ObjectConstraint { o.deplock.Lock() defer o.deplock.Unlock() o.schemadeps[from] = c return o }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "SchemaDependency", "(", "from", "string", ",", "c", "Constraint", ")", "*", "ObjectConstraint", "{", "o", ".", "deplock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "deplock", ".", "Unlock", "(", ")...
// SchemaDependency specifies a schema that the value being validated // must also satisfy. Note that the "object" is the target that needs to // be additionally validated, not the value of the `from` property
[ "SchemaDependency", "specifies", "a", "schema", "that", "the", "value", "being", "validated", "must", "also", "satisfy", ".", "Note", "that", "the", "object", "is", "the", "target", "that", "needs", "to", "be", "additionally", "validated", "not", "the", "value...
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L120-L126
141,519
lestrrat-go/jsval
object.go
GetPropDependencies
func (o *ObjectConstraint) GetPropDependencies(from string) []string { o.deplock.Lock() defer o.deplock.Unlock() l, ok := o.propdeps[from] if !ok { return nil } return l }
go
func (o *ObjectConstraint) GetPropDependencies(from string) []string { o.deplock.Lock() defer o.deplock.Unlock() l, ok := o.propdeps[from] if !ok { return nil } return l }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "GetPropDependencies", "(", "from", "string", ")", "[", "]", "string", "{", "o", ".", "deplock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "deplock", ".", "Unlock", "(", ")", "\n\n", "l", ",", "...
// GetPropDependencies returns the list of property names that must // be present for given property name `from`
[ "GetPropDependencies", "returns", "the", "list", "of", "property", "names", "that", "must", "be", "present", "for", "given", "property", "name", "from" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L130-L140
141,520
lestrrat-go/jsval
object.go
GetSchemaDependency
func (o *ObjectConstraint) GetSchemaDependency(from string) Constraint { o.deplock.Lock() defer o.deplock.Unlock() c, ok := o.schemadeps[from] if !ok { return nil } return c }
go
func (o *ObjectConstraint) GetSchemaDependency(from string) Constraint { o.deplock.Lock() defer o.deplock.Unlock() c, ok := o.schemadeps[from] if !ok { return nil } return c }
[ "func", "(", "o", "*", "ObjectConstraint", ")", "GetSchemaDependency", "(", "from", "string", ")", "Constraint", "{", "o", ".", "deplock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "deplock", ".", "Unlock", "(", ")", "\n\n", "c", ",", "ok", ":=...
// GetSchemaDependency returns the Constraint that must be used when // the property `from` is present.
[ "GetSchemaDependency", "returns", "the", "Constraint", "that", "must", "be", "used", "when", "the", "property", "from", "is", "present", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L144-L154
141,521
lestrrat-go/jsval
object.go
getPropNames
func (o *ObjectConstraint) getPropNames(rv reflect.Value) ([]string, error) { switch rv.Kind() { case reflect.Ptr, reflect.Interface: rv = rv.Elem() } var keys []string switch rv.Kind() { case reflect.Map: vk := rv.MapKeys() keys = make([]string, len(vk)) for i, v := range vk { if v.Kind() != reflect....
go
func (o *ObjectConstraint) getPropNames(rv reflect.Value) ([]string, error) { switch rv.Kind() { case reflect.Ptr, reflect.Interface: rv = rv.Elem() } var keys []string switch rv.Kind() { case reflect.Map: vk := rv.MapKeys() keys = make([]string, len(vk)) for i, v := range vk { if v.Kind() != reflect....
[ "func", "(", "o", "*", "ObjectConstraint", ")", "getPropNames", "(", "rv", "reflect", ".", "Value", ")", "(", "[", "]", "string", ",", "error", ")", "{", "switch", "rv", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Ptr", ",", "reflect", "."...
// getProps return all of the property names for this object. // XXX Map keys can be something other than strings, but // we can't really allow it?
[ "getProps", "return", "all", "of", "the", "property", "names", "for", "this", "object", ".", "XXX", "Map", "keys", "can", "be", "something", "other", "than", "strings", "but", "we", "can", "t", "really", "allow", "it?" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/object.go#L163-L199
141,522
lestrrat-go/jsval
bool.go
Default
func (bc *BooleanConstraint) Default(v interface{}) *BooleanConstraint { bc.defaultValue.initialized = true bc.defaultValue.value = v return bc }
go
func (bc *BooleanConstraint) Default(v interface{}) *BooleanConstraint { bc.defaultValue.initialized = true bc.defaultValue.value = v return bc }
[ "func", "(", "bc", "*", "BooleanConstraint", ")", "Default", "(", "v", "interface", "{", "}", ")", "*", "BooleanConstraint", "{", "bc", ".", "defaultValue", ".", "initialized", "=", "true", "\n", "bc", ".", "defaultValue", ".", "value", "=", "v", "\n", ...
// Default specifies the default value to apply
[ "Default", "specifies", "the", "default", "value", "to", "apply" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/bool.go#L14-L18
141,523
lestrrat-go/jsval
bool.go
Validate
func (bc *BooleanConstraint) Validate(v interface{}) error { rv := reflect.ValueOf(v) switch rv.Kind() { case reflect.Bool: default: return errors.New("value is not a boolean") } return nil }
go
func (bc *BooleanConstraint) Validate(v interface{}) error { rv := reflect.ValueOf(v) switch rv.Kind() { case reflect.Bool: default: return errors.New("value is not a boolean") } return nil }
[ "func", "(", "bc", "*", "BooleanConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "error", "{", "rv", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "switch", "rv", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Bool"...
// Validate vaidates the value against the given value
[ "Validate", "vaidates", "the", "value", "against", "the", "given", "value" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/bool.go#L21-L29
141,524
lestrrat-go/jsval
reference.go
SetReference
func (cm *ConstraintMap) SetReference(name string, c Constraint) { cm.lock.Lock() defer cm.lock.Unlock() refs := cm.refmap() refs[name] = c }
go
func (cm *ConstraintMap) SetReference(name string, c Constraint) { cm.lock.Lock() defer cm.lock.Unlock() refs := cm.refmap() refs[name] = c }
[ "func", "(", "cm", "*", "ConstraintMap", ")", "SetReference", "(", "name", "string", ",", "c", "Constraint", ")", "{", "cm", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "refs", ":=", "cm", ...
// SetReference registeres a new Constraint to a name
[ "SetReference", "registeres", "a", "new", "Constraint", "to", "a", "name" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L36-L42
141,525
lestrrat-go/jsval
reference.go
GetReference
func (cm *ConstraintMap) GetReference(name string) (Constraint, error) { cm.lock.Lock() defer cm.lock.Unlock() refs := cm.refmap() c, ok := refs[name] if !ok { return nil, errors.New("reference '" + name + "' not found") } return c, nil }
go
func (cm *ConstraintMap) GetReference(name string) (Constraint, error) { cm.lock.Lock() defer cm.lock.Unlock() refs := cm.refmap() c, ok := refs[name] if !ok { return nil, errors.New("reference '" + name + "' not found") } return c, nil }
[ "func", "(", "cm", "*", "ConstraintMap", ")", "GetReference", "(", "name", "string", ")", "(", "Constraint", ",", "error", ")", "{", "cm", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "refs"...
// GetReference fetches the Constraint associated with the given name
[ "GetReference", "fetches", "the", "Constraint", "associated", "with", "the", "given", "name" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L45-L55
141,526
lestrrat-go/jsval
reference.go
Resolved
func (r *ReferenceConstraint) Resolved() (c Constraint, err error) { if pdebug.Enabled { g := pdebug.IPrintf("START ReferenceConstraint.Resolved '%s'", r.reference) defer func() { if err == nil { g.IRelease("END ReferenceConstraint.Resolved '%s' (OK)", r.reference) } else { g.IRelease("END ReferenceC...
go
func (r *ReferenceConstraint) Resolved() (c Constraint, err error) { if pdebug.Enabled { g := pdebug.IPrintf("START ReferenceConstraint.Resolved '%s'", r.reference) defer func() { if err == nil { g.IRelease("END ReferenceConstraint.Resolved '%s' (OK)", r.reference) } else { g.IRelease("END ReferenceC...
[ "func", "(", "r", "*", "ReferenceConstraint", ")", "Resolved", "(", ")", "(", "c", "Constraint", ",", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "IPrintf", "(", "\"", "\"", ",", "r", ".", "reference", "...
// Resolved returns the Constraint obtained by resolving // the reference.
[ "Resolved", "returns", "the", "Constraint", "obtained", "by", "resolving", "the", "reference", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L75-L102
141,527
lestrrat-go/jsval
reference.go
RefersTo
func (r *ReferenceConstraint) RefersTo(s string) *ReferenceConstraint { r.reference = s return r }
go
func (r *ReferenceConstraint) RefersTo(s string) *ReferenceConstraint { r.reference = s return r }
[ "func", "(", "r", "*", "ReferenceConstraint", ")", "RefersTo", "(", "s", "string", ")", "*", "ReferenceConstraint", "{", "r", ".", "reference", "=", "s", "\n", "return", "r", "\n", "}" ]
// RefersTo specifies the reference string that this constraint points to
[ "RefersTo", "specifies", "the", "reference", "string", "that", "this", "constraint", "points", "to" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L105-L108
141,528
lestrrat-go/jsval
reference.go
DefaultValue
func (r *ReferenceConstraint) DefaultValue() interface{} { c, err := r.Resolved() if err != nil { return nil } return c.DefaultValue() }
go
func (r *ReferenceConstraint) DefaultValue() interface{} { c, err := r.Resolved() if err != nil { return nil } return c.DefaultValue() }
[ "func", "(", "r", "*", "ReferenceConstraint", ")", "DefaultValue", "(", ")", "interface", "{", "}", "{", "c", ",", "err", ":=", "r", ".", "Resolved", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "c", ...
// DefaultValue returns the default value from the constraint pointed // by the reference
[ "DefaultValue", "returns", "the", "default", "value", "from", "the", "constraint", "pointed", "by", "the", "reference" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L116-L122
141,529
lestrrat-go/jsval
reference.go
HasDefault
func (r *ReferenceConstraint) HasDefault() bool { c, err := r.Resolved() if err != nil { return false } return c.HasDefault() }
go
func (r *ReferenceConstraint) HasDefault() bool { c, err := r.Resolved() if err != nil { return false } return c.HasDefault() }
[ "func", "(", "r", "*", "ReferenceConstraint", ")", "HasDefault", "(", ")", "bool", "{", "c", ",", "err", ":=", "r", ".", "Resolved", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "c", ".", "HasDefault"...
// HasDefault returns true if the constraint pointed by the reference // has defaults
[ "HasDefault", "returns", "true", "if", "the", "constraint", "pointed", "by", "the", "reference", "has", "defaults" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L126-L132
141,530
lestrrat-go/jsval
reference.go
Validate
func (r *ReferenceConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.IPrintf("START ReferenceConstraint.Validate") defer func() { if err == nil { g.IRelease("END ReferenceConstraint.Validate (PASS)") } else { g.IRelease("END ReferenceConstraint.Validate (FAIL): %s", err...
go
func (r *ReferenceConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.IPrintf("START ReferenceConstraint.Validate") defer func() { if err == nil { g.IRelease("END ReferenceConstraint.Validate (PASS)") } else { g.IRelease("END ReferenceConstraint.Validate (FAIL): %s", err...
[ "func", "(", "r", "*", "ReferenceConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "IPrintf", "(", "\"", "\"", ")", "\n", "defer", "func...
// Validate validates the value against the constraint pointed to // by the reference.
[ "Validate", "validates", "the", "value", "against", "the", "constraint", "pointed", "to", "by", "the", "reference", "." ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/reference.go#L136-L153
141,531
lestrrat-go/jsval
basic.go
Validate
func (nc NotConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("NotConstraint.Validate").BindError(&err) defer g.End() } if nc.child == nil { return errors.New("'not' constraint does not have a child constraint") } if err := nc.child.Validate(v); err == nil { return ...
go
func (nc NotConstraint) Validate(v interface{}) (err error) { if pdebug.Enabled { g := pdebug.Marker("NotConstraint.Validate").BindError(&err) defer g.End() } if nc.child == nil { return errors.New("'not' constraint does not have a child constraint") } if err := nc.child.Validate(v); err == nil { return ...
[ "func", "(", "nc", "NotConstraint", ")", "Validate", "(", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ")", ".", "BindError", "(", "&", "...
// Validate runs the validation, and returns an error unless // the child constraint fails
[ "Validate", "runs", "the", "validation", "and", "returns", "an", "error", "unless", "the", "child", "constraint", "fails" ]
20277e9befc0257e96a5ceb4901e068ca6e7cab4
https://github.com/lestrrat-go/jsval/blob/20277e9befc0257e96a5ceb4901e068ca6e7cab4/basic.go#L76-L90
141,532
klauspost/crc32
crc32_generic.go
simplePopulateTable
func simplePopulateTable(poly uint32, t *Table) { for i := 0; i < 256; i++ { crc := uint32(i) for j := 0; j < 8; j++ { if crc&1 == 1 { crc = (crc >> 1) ^ poly } else { crc >>= 1 } } t[i] = crc } }
go
func simplePopulateTable(poly uint32, t *Table) { for i := 0; i < 256; i++ { crc := uint32(i) for j := 0; j < 8; j++ { if crc&1 == 1 { crc = (crc >> 1) ^ poly } else { crc >>= 1 } } t[i] = crc } }
[ "func", "simplePopulateTable", "(", "poly", "uint32", ",", "t", "*", "Table", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "256", ";", "i", "++", "{", "crc", ":=", "uint32", "(", "i", ")", "\n", "for", "j", ":=", "0", ";", "j", "<", "8", ...
// simplePopulateTable constructs a Table for the specified polynomial, suitable // for use with simpleUpdate.
[ "simplePopulateTable", "constructs", "a", "Table", "for", "the", "specified", "polynomial", "suitable", "for", "use", "with", "simpleUpdate", "." ]
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32_generic.go#L26-L38
141,533
klauspost/crc32
crc32_generic.go
simpleUpdate
func simpleUpdate(crc uint32, tab *Table, p []byte) uint32 { crc = ^crc for _, v := range p { crc = tab[byte(crc)^v] ^ (crc >> 8) } return ^crc }
go
func simpleUpdate(crc uint32, tab *Table, p []byte) uint32 { crc = ^crc for _, v := range p { crc = tab[byte(crc)^v] ^ (crc >> 8) } return ^crc }
[ "func", "simpleUpdate", "(", "crc", "uint32", ",", "tab", "*", "Table", ",", "p", "[", "]", "byte", ")", "uint32", "{", "crc", "=", "^", "crc", "\n", "for", "_", ",", "v", ":=", "range", "p", "{", "crc", "=", "tab", "[", "byte", "(", "crc", "...
// simpleUpdate uses the simple algorithm to update the CRC, given a table that // was previously computed using simpleMakeTable.
[ "simpleUpdate", "uses", "the", "simple", "algorithm", "to", "update", "the", "CRC", "given", "a", "table", "that", "was", "previously", "computed", "using", "simpleMakeTable", "." ]
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32_generic.go#L42-L48
141,534
klauspost/crc32
crc32_generic.go
slicingUpdate
func slicingUpdate(crc uint32, tab *slicing8Table, p []byte) uint32 { if len(p) >= slicing8Cutoff { crc = ^crc for len(p) > 8 { crc ^= uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 crc = tab[0][p[7]] ^ tab[1][p[6]] ^ tab[2][p[5]] ^ tab[3][p[4]] ^ tab[4][crc>>24] ^ tab[5][(crc>>16)&...
go
func slicingUpdate(crc uint32, tab *slicing8Table, p []byte) uint32 { if len(p) >= slicing8Cutoff { crc = ^crc for len(p) > 8 { crc ^= uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 crc = tab[0][p[7]] ^ tab[1][p[6]] ^ tab[2][p[5]] ^ tab[3][p[4]] ^ tab[4][crc>>24] ^ tab[5][(crc>>16)&...
[ "func", "slicingUpdate", "(", "crc", "uint32", ",", "tab", "*", "slicing8Table", ",", "p", "[", "]", "byte", ")", "uint32", "{", "if", "len", "(", "p", ")", ">=", "slicing8Cutoff", "{", "crc", "=", "^", "crc", "\n", "for", "len", "(", "p", ")", "...
// slicingUpdate uses the slicing-by-8 algorithm to update the CRC, given a // table that was previously computed using slicingMakeTable.
[ "slicingUpdate", "uses", "the", "slicing", "-", "by", "-", "8", "algorithm", "to", "update", "the", "CRC", "given", "a", "table", "that", "was", "previously", "computed", "using", "slicingMakeTable", "." ]
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32_generic.go#L73-L89
141,535
klauspost/crc32
crc32_s390x.go
archUpdateCastagnoli
func archUpdateCastagnoli(crc uint32, p []byte) uint32 { if !hasVX { panic("not available") } // Use vectorized function if data length is above threshold. if len(p) >= vxMinLen { aligned := len(p) & ^vxAlignMask crc = vectorizedCastagnoli(crc, p[:aligned]) p = p[aligned:] } if len(p) == 0 { return crc ...
go
func archUpdateCastagnoli(crc uint32, p []byte) uint32 { if !hasVX { panic("not available") } // Use vectorized function if data length is above threshold. if len(p) >= vxMinLen { aligned := len(p) & ^vxAlignMask crc = vectorizedCastagnoli(crc, p[:aligned]) p = p[aligned:] } if len(p) == 0 { return crc ...
[ "func", "archUpdateCastagnoli", "(", "crc", "uint32", ",", "p", "[", "]", "byte", ")", "uint32", "{", "if", "!", "hasVX", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "// Use vectorized function if data length is above threshold.", "if", "len", "(", ...
// archUpdateCastagnoli calculates the checksum of p using // vectorizedCastagnoli.
[ "archUpdateCastagnoli", "calculates", "the", "checksum", "of", "p", "using", "vectorizedCastagnoli", "." ]
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32_s390x.go#L46-L60
141,536
klauspost/crc32
crc32_s390x.go
archUpdateIEEE
func archUpdateIEEE(crc uint32, p []byte) uint32 { if !hasVX { panic("not available") } // Use vectorized function if data length is above threshold. if len(p) >= vxMinLen { aligned := len(p) & ^vxAlignMask crc = vectorizedIEEE(crc, p[:aligned]) p = p[aligned:] } if len(p) == 0 { return crc } return s...
go
func archUpdateIEEE(crc uint32, p []byte) uint32 { if !hasVX { panic("not available") } // Use vectorized function if data length is above threshold. if len(p) >= vxMinLen { aligned := len(p) & ^vxAlignMask crc = vectorizedIEEE(crc, p[:aligned]) p = p[aligned:] } if len(p) == 0 { return crc } return s...
[ "func", "archUpdateIEEE", "(", "crc", "uint32", ",", "p", "[", "]", "byte", ")", "uint32", "{", "if", "!", "hasVX", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "// Use vectorized function if data length is above threshold.", "if", "len", "(", "p", ...
// archUpdateIEEE calculates the checksum of p using vectorizedIEEE.
[ "archUpdateIEEE", "calculates", "the", "checksum", "of", "p", "using", "vectorizedIEEE", "." ]
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32_s390x.go#L77-L91
141,537
klauspost/crc32
crc32.go
MakeTable
func MakeTable(poly uint32) *Table { switch poly { case IEEE: ieeeOnce.Do(ieeeInit) return IEEETable case Castagnoli: castagnoliOnce.Do(castagnoliInit) return castagnoliTable } return simpleMakeTable(poly) }
go
func MakeTable(poly uint32) *Table { switch poly { case IEEE: ieeeOnce.Do(ieeeInit) return IEEETable case Castagnoli: castagnoliOnce.Do(castagnoliInit) return castagnoliTable } return simpleMakeTable(poly) }
[ "func", "MakeTable", "(", "poly", "uint32", ")", "*", "Table", "{", "switch", "poly", "{", "case", "IEEE", ":", "ieeeOnce", ".", "Do", "(", "ieeeInit", ")", "\n", "return", "IEEETable", "\n", "case", "Castagnoli", ":", "castagnoliOnce", ".", "Do", "(", ...
// MakeTable returns a Table constructed from the specified polynomial. // The contents of this Table must not be modified.
[ "MakeTable", "returns", "a", "Table", "constructed", "from", "the", "specified", "polynomial", ".", "The", "contents", "of", "this", "Table", "must", "not", "be", "modified", "." ]
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32.go#L123-L133
141,538
klauspost/crc32
crc32.go
New
func New(tab *Table) hash.Hash32 { if tab == IEEETable { ieeeOnce.Do(ieeeInit) } return &digest{0, tab} }
go
func New(tab *Table) hash.Hash32 { if tab == IEEETable { ieeeOnce.Do(ieeeInit) } return &digest{0, tab} }
[ "func", "New", "(", "tab", "*", "Table", ")", "hash", ".", "Hash32", "{", "if", "tab", "==", "IEEETable", "{", "ieeeOnce", ".", "Do", "(", "ieeeInit", ")", "\n", "}", "\n", "return", "&", "digest", "{", "0", ",", "tab", "}", "\n", "}" ]
// New creates a new hash.Hash32 computing the CRC-32 checksum // using the polynomial represented by the Table. // Its Sum method will lay the value out in big-endian byte order.
[ "New", "creates", "a", "new", "hash", ".", "Hash32", "computing", "the", "CRC", "-", "32", "checksum", "using", "the", "polynomial", "represented", "by", "the", "Table", ".", "Its", "Sum", "method", "will", "lay", "the", "value", "out", "in", "big", "-",...
bab58d77464aa9cf4e84200c3276da0831fe0c03
https://github.com/klauspost/crc32/blob/bab58d77464aa9cf4e84200c3276da0831fe0c03/crc32.go#L144-L149
141,539
cppforlife/go-patch
patch/pointer.go
UnmarshalFlag
func (p *Pointer) UnmarshalFlag(data string) error { ptr, err := NewPointerFromString(data) if err != nil { return err } *p = ptr return nil }
go
func (p *Pointer) UnmarshalFlag(data string) error { ptr, err := NewPointerFromString(data) if err != nil { return err } *p = ptr return nil }
[ "func", "(", "p", "*", "Pointer", ")", "UnmarshalFlag", "(", "data", "string", ")", "error", "{", "ptr", ",", "err", ":=", "NewPointerFromString", "(", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "*", "p", ...
// UnmarshalFlag satisfies go-flags flag interface
[ "UnmarshalFlag", "satisfies", "go", "-", "flags", "flag", "interface" ]
90228d47281247384683e5fded0f15afa3e5d29a
https://github.com/cppforlife/go-patch/blob/90228d47281247384683e5fded0f15afa3e5d29a/patch/pointer.go#L205-L214
141,540
vbatts/tar-split
archive/tar/common.go
validateSparseEntries
func validateSparseEntries(sp []sparseEntry, size int64) bool { // Validate all sparse entries. These are the same checks as performed by // the BSD tar utility. if size < 0 { return false } var pre sparseEntry for _, cur := range sp { switch { case cur.Offset < 0 || cur.Length < 0: return false // Negat...
go
func validateSparseEntries(sp []sparseEntry, size int64) bool { // Validate all sparse entries. These are the same checks as performed by // the BSD tar utility. if size < 0 { return false } var pre sparseEntry for _, cur := range sp { switch { case cur.Offset < 0 || cur.Length < 0: return false // Negat...
[ "func", "validateSparseEntries", "(", "sp", "[", "]", "sparseEntry", ",", "size", "int64", ")", "bool", "{", "// Validate all sparse entries. These are the same checks as performed by", "// the BSD tar utility.", "if", "size", "<", "0", "{", "return", "false", "\n", "}"...
// validateSparseEntries reports whether sp is a valid sparse map. // It does not matter whether sp represents data fragments or hole fragments.
[ "validateSparseEntries", "reports", "whether", "sp", "is", "a", "valid", "sparse", "map", ".", "It", "does", "not", "matter", "whether", "sp", "represents", "data", "fragments", "or", "hole", "fragments", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/common.go#L246-L267
141,541
vbatts/tar-split
archive/tar/common.go
alignSparseEntries
func alignSparseEntries(src []sparseEntry, size int64) []sparseEntry { dst := src[:0] for _, s := range src { pos, end := s.Offset, s.endOffset() pos += blockPadding(+pos) // Round-up to nearest blockSize if end != size { end -= blockPadding(-end) // Round-down to nearest blockSize } if pos < end { ds...
go
func alignSparseEntries(src []sparseEntry, size int64) []sparseEntry { dst := src[:0] for _, s := range src { pos, end := s.Offset, s.endOffset() pos += blockPadding(+pos) // Round-up to nearest blockSize if end != size { end -= blockPadding(-end) // Round-down to nearest blockSize } if pos < end { ds...
[ "func", "alignSparseEntries", "(", "src", "[", "]", "sparseEntry", ",", "size", "int64", ")", "[", "]", "sparseEntry", "{", "dst", ":=", "src", "[", ":", "0", "]", "\n", "for", "_", ",", "s", ":=", "range", "src", "{", "pos", ",", "end", ":=", "s...
// alignSparseEntries mutates src and returns dst where each fragment's // starting offset is aligned up to the nearest block edge, and each // ending offset is aligned down to the nearest block edge. // // Even though the Go tar Reader and the BSD tar utility can handle entries // with arbitrary offsets and lengths, t...
[ "alignSparseEntries", "mutates", "src", "and", "returns", "dst", "where", "each", "fragment", "s", "starting", "offset", "is", "aligned", "up", "to", "the", "nearest", "block", "edge", "and", "each", "ending", "offset", "is", "aligned", "down", "to", "the", ...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/common.go#L276-L289
141,542
vbatts/tar-split
archive/tar/common.go
Name
func (fi headerFileInfo) Name() string { if fi.IsDir() { return path.Base(path.Clean(fi.h.Name)) } return path.Base(fi.h.Name) }
go
func (fi headerFileInfo) Name() string { if fi.IsDir() { return path.Base(path.Clean(fi.h.Name)) } return path.Base(fi.h.Name) }
[ "func", "(", "fi", "headerFileInfo", ")", "Name", "(", ")", "string", "{", "if", "fi", ".", "IsDir", "(", ")", "{", "return", "path", ".", "Base", "(", "path", ".", "Clean", "(", "fi", ".", "h", ".", "Name", ")", ")", "\n", "}", "\n", "return",...
// Name returns the base name of the file.
[ "Name", "returns", "the", "base", "name", "of", "the", "file", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/common.go#L544-L549
141,543
vbatts/tar-split
archive/tar/common.go
FileInfoHeader
func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) { if fi == nil { return nil, errors.New("archive/tar: FileInfo is nil") } fm := fi.Mode() h := &Header{ Name: fi.Name(), ModTime: fi.ModTime(), Mode: int64(fm.Perm()), // or'd with c_IS* constants later } switch { case fm.IsRegular()...
go
func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) { if fi == nil { return nil, errors.New("archive/tar: FileInfo is nil") } fm := fi.Mode() h := &Header{ Name: fi.Name(), ModTime: fi.ModTime(), Mode: int64(fm.Perm()), // or'd with c_IS* constants later } switch { case fm.IsRegular()...
[ "func", "FileInfoHeader", "(", "fi", "os", ".", "FileInfo", ",", "link", "string", ")", "(", "*", "Header", ",", "error", ")", "{", "if", "fi", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", ...
// FileInfoHeader creates a partially-populated Header from fi. // If fi describes a symlink, FileInfoHeader records link as the link target. // If fi describes a directory, a slash is appended to the name. // // Since os.FileInfo's Name method only returns the base name of // the file it describes, it may be necessary...
[ "FileInfoHeader", "creates", "a", "partially", "-", "populated", "Header", "from", "fi", ".", "If", "fi", "describes", "a", "symlink", "FileInfoHeader", "records", "link", "as", "the", "link", "target", ".", "If", "fi", "describes", "a", "directory", "a", "s...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/common.go#L629-L705
141,544
vbatts/tar-split
archive/tar/common.go
isHeaderOnlyType
func isHeaderOnlyType(flag byte) bool { switch flag { case TypeLink, TypeSymlink, TypeChar, TypeBlock, TypeDir, TypeFifo: return true default: return false } }
go
func isHeaderOnlyType(flag byte) bool { switch flag { case TypeLink, TypeSymlink, TypeChar, TypeBlock, TypeDir, TypeFifo: return true default: return false } }
[ "func", "isHeaderOnlyType", "(", "flag", "byte", ")", "bool", "{", "switch", "flag", "{", "case", "TypeLink", ",", "TypeSymlink", ",", "TypeChar", ",", "TypeBlock", ",", "TypeDir", ",", "TypeFifo", ":", "return", "true", "\n", "default", ":", "return", "fa...
// isHeaderOnlyType checks if the given type flag is of the type that has no // data section even if a size is specified.
[ "isHeaderOnlyType", "checks", "if", "the", "given", "type", "flag", "is", "of", "the", "type", "that", "has", "no", "data", "section", "even", "if", "a", "size", "is", "specified", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/common.go#L709-L716
141,545
vbatts/tar-split
archive/tar/strconv.go
toASCII
func toASCII(s string) string { if isASCII(s) { return s } b := make([]byte, 0, len(s)) for _, c := range s { if c < 0x80 && c != 0x00 { b = append(b, byte(c)) } } return string(b) }
go
func toASCII(s string) string { if isASCII(s) { return s } b := make([]byte, 0, len(s)) for _, c := range s { if c < 0x80 && c != 0x00 { b = append(b, byte(c)) } } return string(b) }
[ "func", "toASCII", "(", "s", "string", ")", "string", "{", "if", "isASCII", "(", "s", ")", "{", "return", "s", "\n", "}", "\n", "b", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "len", "(", "s", ")", ")", "\n", "for", "_", ",", "c", ...
// toASCII converts the input to an ASCII C-style string. // This a best effort conversion, so invalid characters are dropped.
[ "toASCII", "converts", "the", "input", "to", "an", "ASCII", "C", "-", "style", "string", ".", "This", "a", "best", "effort", "conversion", "so", "invalid", "characters", "are", "dropped", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L32-L43
141,546
vbatts/tar-split
archive/tar/strconv.go
formatString
func (f *formatter) formatString(b []byte, s string) { if len(s) > len(b) { f.err = ErrFieldTooLong } copy(b, s) if len(s) < len(b) { b[len(s)] = 0 } // Some buggy readers treat regular files with a trailing slash // in the V7 path field as a directory even though the full path // recorded elsewhere (e.g.,...
go
func (f *formatter) formatString(b []byte, s string) { if len(s) > len(b) { f.err = ErrFieldTooLong } copy(b, s) if len(s) < len(b) { b[len(s)] = 0 } // Some buggy readers treat regular files with a trailing slash // in the V7 path field as a directory even though the full path // recorded elsewhere (e.g.,...
[ "func", "(", "f", "*", "formatter", ")", "formatString", "(", "b", "[", "]", "byte", ",", "s", "string", ")", "{", "if", "len", "(", "s", ")", ">", "len", "(", "b", ")", "{", "f", ".", "err", "=", "ErrFieldTooLong", "\n", "}", "\n", "copy", "...
// formatString copies s into b, NUL-terminating if possible.
[ "formatString", "copies", "s", "into", "b", "NUL", "-", "terminating", "if", "possible", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L63-L79
141,547
vbatts/tar-split
archive/tar/strconv.go
fitsInBase256
func fitsInBase256(n int, x int64) bool { binBits := uint(n-1) * 8 return n >= 9 || (x >= -1<<binBits && x < 1<<binBits) }
go
func fitsInBase256(n int, x int64) bool { binBits := uint(n-1) * 8 return n >= 9 || (x >= -1<<binBits && x < 1<<binBits) }
[ "func", "fitsInBase256", "(", "n", "int", ",", "x", "int64", ")", "bool", "{", "binBits", ":=", "uint", "(", "n", "-", "1", ")", "*", "8", "\n", "return", "n", ">=", "9", "||", "(", "x", ">=", "-", "1", "<<", "binBits", "&&", "x", "<", "1", ...
// fitsInBase256 reports whether x can be encoded into n bytes using base-256 // encoding. Unlike octal encoding, base-256 encoding does not require that the // string ends with a NUL character. Thus, all n bytes are available for output. // // If operating in binary mode, this assumes strict GNU binary mode; which mea...
[ "fitsInBase256", "reports", "whether", "x", "can", "be", "encoded", "into", "n", "bytes", "using", "base", "-", "256", "encoding", ".", "Unlike", "octal", "encoding", "base", "-", "256", "encoding", "does", "not", "require", "that", "the", "string", "ends", ...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L88-L91
141,548
vbatts/tar-split
archive/tar/strconv.go
parseNumeric
func (p *parser) parseNumeric(b []byte) int64 { // Check for base-256 (binary) format first. // If the first bit is set, then all following bits constitute a two's // complement encoded number in big-endian byte order. if len(b) > 0 && b[0]&0x80 != 0 { // Handling negative numbers relies on the following identity...
go
func (p *parser) parseNumeric(b []byte) int64 { // Check for base-256 (binary) format first. // If the first bit is set, then all following bits constitute a two's // complement encoded number in big-endian byte order. if len(b) > 0 && b[0]&0x80 != 0 { // Handling negative numbers relies on the following identity...
[ "func", "(", "p", "*", "parser", ")", "parseNumeric", "(", "b", "[", "]", "byte", ")", "int64", "{", "// Check for base-256 (binary) format first.", "// If the first bit is set, then all following bits constitute a two's", "// complement encoded number in big-endian byte order.", ...
// parseNumeric parses the input as being encoded in either base-256 or octal. // This function may return negative numbers. // If parsing fails or an integer overflow occurs, err will be set.
[ "parseNumeric", "parses", "the", "input", "as", "being", "encoded", "in", "either", "base", "-", "256", "or", "octal", ".", "This", "function", "may", "return", "negative", "numbers", ".", "If", "parsing", "fails", "or", "an", "integer", "overflow", "occurs"...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L96-L135
141,549
vbatts/tar-split
archive/tar/strconv.go
fitsInOctal
func fitsInOctal(n int, x int64) bool { octBits := uint(n-1) * 3 return x >= 0 && (n >= 22 || x < 1<<octBits) }
go
func fitsInOctal(n int, x int64) bool { octBits := uint(n-1) * 3 return x >= 0 && (n >= 22 || x < 1<<octBits) }
[ "func", "fitsInOctal", "(", "n", "int", ",", "x", "int64", ")", "bool", "{", "octBits", ":=", "uint", "(", "n", "-", "1", ")", "*", "3", "\n", "return", "x", ">=", "0", "&&", "(", "n", ">=", "22", "||", "x", "<", "1", "<<", "octBits", ")", ...
// fitsInOctal reports whether the integer x fits in a field n-bytes long // using octal encoding with the appropriate NUL terminator.
[ "fitsInOctal", "reports", "whether", "the", "integer", "x", "fits", "in", "a", "field", "n", "-", "bytes", "long", "using", "octal", "encoding", "with", "the", "appropriate", "NUL", "terminator", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L192-L195
141,550
vbatts/tar-split
archive/tar/strconv.go
formatPAXTime
func formatPAXTime(ts time.Time) (s string) { secs, nsecs := ts.Unix(), ts.Nanosecond() if nsecs == 0 { return strconv.FormatInt(secs, 10) } // If seconds is negative, then perform correction. sign := "" if secs < 0 { sign = "-" // Remember sign secs = -(secs + 1) // Add a second to secs ...
go
func formatPAXTime(ts time.Time) (s string) { secs, nsecs := ts.Unix(), ts.Nanosecond() if nsecs == 0 { return strconv.FormatInt(secs, 10) } // If seconds is negative, then perform correction. sign := "" if secs < 0 { sign = "-" // Remember sign secs = -(secs + 1) // Add a second to secs ...
[ "func", "formatPAXTime", "(", "ts", "time", ".", "Time", ")", "(", "s", "string", ")", "{", "secs", ",", "nsecs", ":=", "ts", ".", "Unix", "(", ")", ",", "ts", ".", "Nanosecond", "(", ")", "\n", "if", "nsecs", "==", "0", "{", "return", "strconv",...
// formatPAXTime converts ts into a time of the form %d.%d as described in the // PAX specification. This function is capable of negative timestamps.
[ "formatPAXTime", "converts", "ts", "into", "a", "time", "of", "the", "form", "%d", ".", "%d", "as", "described", "in", "the", "PAX", "specification", ".", "This", "function", "is", "capable", "of", "negative", "timestamps", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L236-L250
141,551
vbatts/tar-split
archive/tar/strconv.go
parsePAXRecord
func parsePAXRecord(s string) (k, v, r string, err error) { // The size field ends at the first space. sp := strings.IndexByte(s, ' ') if sp == -1 { return "", "", s, ErrHeader } // Parse the first token as a decimal integer. n, perr := strconv.ParseInt(s[:sp], 10, 0) // Intentionally parse as native int if p...
go
func parsePAXRecord(s string) (k, v, r string, err error) { // The size field ends at the first space. sp := strings.IndexByte(s, ' ') if sp == -1 { return "", "", s, ErrHeader } // Parse the first token as a decimal integer. n, perr := strconv.ParseInt(s[:sp], 10, 0) // Intentionally parse as native int if p...
[ "func", "parsePAXRecord", "(", "s", "string", ")", "(", "k", ",", "v", ",", "r", "string", ",", "err", "error", ")", "{", "// The size field ends at the first space.", "sp", ":=", "strings", ".", "IndexByte", "(", "s", ",", "' '", ")", "\n", "if", "sp", ...
// parsePAXRecord parses the input PAX record string into a key-value pair. // If parsing is successful, it will slice off the currently read record and // return the remainder as r.
[ "parsePAXRecord", "parses", "the", "input", "PAX", "record", "string", "into", "a", "key", "-", "value", "pair", ".", "If", "parsing", "is", "successful", "it", "will", "slice", "off", "the", "currently", "read", "record", "and", "return", "the", "remainder"...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/strconv.go#L255-L285
141,552
vbatts/tar-split
tar/asm/assemble.go
NewOutputTarStream
func NewOutputTarStream(fg storage.FileGetter, up storage.Unpacker) io.ReadCloser { // ... Since these are interfaces, this is possible, so let's not have a nil pointer if fg == nil || up == nil { return nil } pr, pw := io.Pipe() go func() { err := WriteOutputTarStream(fg, up, pw) if err != nil { pw.Close...
go
func NewOutputTarStream(fg storage.FileGetter, up storage.Unpacker) io.ReadCloser { // ... Since these are interfaces, this is possible, so let's not have a nil pointer if fg == nil || up == nil { return nil } pr, pw := io.Pipe() go func() { err := WriteOutputTarStream(fg, up, pw) if err != nil { pw.Close...
[ "func", "NewOutputTarStream", "(", "fg", "storage", ".", "FileGetter", ",", "up", "storage", ".", "Unpacker", ")", "io", ".", "ReadCloser", "{", "// ... Since these are interfaces, this is possible, so let's not have a nil pointer", "if", "fg", "==", "nil", "||", "up", ...
// NewOutputTarStream returns an io.ReadCloser that is an assembled tar archive // stream. // // It takes a storage.FileGetter, for mapping the file payloads that are to be read in, // and a storage.Unpacker, which has access to the rawbytes and file order // metadata. With the combination of these two items, a precise...
[ "NewOutputTarStream", "returns", "an", "io", ".", "ReadCloser", "that", "is", "an", "assembled", "tar", "archive", "stream", ".", "It", "takes", "a", "storage", ".", "FileGetter", "for", "mapping", "the", "file", "payloads", "that", "are", "to", "be", "read"...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/tar/asm/assemble.go#L21-L36
141,553
vbatts/tar-split
tar/asm/assemble.go
WriteOutputTarStream
func WriteOutputTarStream(fg storage.FileGetter, up storage.Unpacker, w io.Writer) error { // ... Since these are interfaces, this is possible, so let's not have a nil pointer if fg == nil || up == nil { return nil } var copyBuffer []byte var crcHash hash.Hash var crcSum []byte var multiWriter io.Writer for {...
go
func WriteOutputTarStream(fg storage.FileGetter, up storage.Unpacker, w io.Writer) error { // ... Since these are interfaces, this is possible, so let's not have a nil pointer if fg == nil || up == nil { return nil } var copyBuffer []byte var crcHash hash.Hash var crcSum []byte var multiWriter io.Writer for {...
[ "func", "WriteOutputTarStream", "(", "fg", "storage", ".", "FileGetter", ",", "up", "storage", ".", "Unpacker", ",", "w", "io", ".", "Writer", ")", "error", "{", "// ... Since these are interfaces, this is possible, so let's not have a nil pointer", "if", "fg", "==", ...
// WriteOutputTarStream writes assembled tar archive to a writer.
[ "WriteOutputTarStream", "writes", "assembled", "tar", "archive", "to", "a", "writer", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/tar/asm/assemble.go#L39-L94
141,554
vbatts/tar-split
tar/storage/entry.go
SetNameBytes
func (e *Entry) SetNameBytes(name []byte) { if utf8.Valid(name) { e.Name = string(name) } else { e.NameRaw = name } }
go
func (e *Entry) SetNameBytes(name []byte) { if utf8.Valid(name) { e.Name = string(name) } else { e.NameRaw = name } }
[ "func", "(", "e", "*", "Entry", ")", "SetNameBytes", "(", "name", "[", "]", "byte", ")", "{", "if", "utf8", ".", "Valid", "(", "name", ")", "{", "e", ".", "Name", "=", "string", "(", "name", ")", "\n", "}", "else", "{", "e", ".", "NameRaw", "...
// SetNameBytes will check name for valid UTF-8 string, and set the appropriate // field
[ "SetNameBytes", "will", "check", "name", "for", "valid", "UTF", "-", "8", "string", "and", "set", "the", "appropriate", "field" ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/tar/storage/entry.go#L56-L62
141,555
vbatts/tar-split
tar/storage/entry.go
GetName
func (e *Entry) GetName() string { if len(e.NameRaw) > 0 { return string(e.NameRaw) } return e.Name }
go
func (e *Entry) GetName() string { if len(e.NameRaw) > 0 { return string(e.NameRaw) } return e.Name }
[ "func", "(", "e", "*", "Entry", ")", "GetName", "(", ")", "string", "{", "if", "len", "(", "e", ".", "NameRaw", ")", ">", "0", "{", "return", "string", "(", "e", ".", "NameRaw", ")", "\n", "}", "\n", "return", "e", ".", "Name", "\n", "}" ]
// GetName returns the string for the entry's name, regardless of the field stored in
[ "GetName", "returns", "the", "string", "for", "the", "entry", "s", "name", "regardless", "of", "the", "field", "stored", "in" ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/tar/storage/entry.go#L65-L70
141,556
vbatts/tar-split
tar/storage/entry.go
GetNameBytes
func (e *Entry) GetNameBytes() []byte { if len(e.NameRaw) > 0 { return e.NameRaw } return []byte(e.Name) }
go
func (e *Entry) GetNameBytes() []byte { if len(e.NameRaw) > 0 { return e.NameRaw } return []byte(e.Name) }
[ "func", "(", "e", "*", "Entry", ")", "GetNameBytes", "(", ")", "[", "]", "byte", "{", "if", "len", "(", "e", ".", "NameRaw", ")", ">", "0", "{", "return", "e", ".", "NameRaw", "\n", "}", "\n", "return", "[", "]", "byte", "(", "e", ".", "Name"...
// GetNameBytes returns the bytes for the entry's name, regardless of the field stored in
[ "GetNameBytes", "returns", "the", "bytes", "for", "the", "entry", "s", "name", "regardless", "of", "the", "field", "stored", "in" ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/tar/storage/entry.go#L73-L78
141,557
vbatts/tar-split
archive/tar/format.go
GetFormat
func (b *block) GetFormat() Format { // Verify checksum. var p parser value := p.parseOctal(b.V7().Chksum()) chksum1, chksum2 := b.ComputeChecksum() if p.err != nil || (value != chksum1 && value != chksum2) { return FormatUnknown } // Guess the magic values. magic := string(b.USTAR().Magic()) version := str...
go
func (b *block) GetFormat() Format { // Verify checksum. var p parser value := p.parseOctal(b.V7().Chksum()) chksum1, chksum2 := b.ComputeChecksum() if p.err != nil || (value != chksum1 && value != chksum2) { return FormatUnknown } // Guess the magic values. magic := string(b.USTAR().Magic()) version := str...
[ "func", "(", "b", "*", "block", ")", "GetFormat", "(", ")", "Format", "{", "// Verify checksum.", "var", "p", "parser", "\n", "value", ":=", "p", ".", "parseOctal", "(", "b", ".", "V7", "(", ")", ".", "Chksum", "(", ")", ")", "\n", "chksum1", ",", ...
// GetFormat checks that the block is a valid tar header based on the checksum. // It then attempts to guess the specific format based on magic values. // If the checksum fails, then FormatUnknown is returned.
[ "GetFormat", "checks", "that", "the", "block", "is", "a", "valid", "tar", "header", "based", "on", "the", "checksum", ".", "It", "then", "attempts", "to", "guess", "the", "specific", "format", "based", "on", "magic", "values", ".", "If", "the", "checksum",...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/format.go#L168-L191
141,558
vbatts/tar-split
archive/tar/format.go
ComputeChecksum
func (b *block) ComputeChecksum() (unsigned, signed int64) { for i, c := range b { if 148 <= i && i < 156 { c = ' ' // Treat the checksum field itself as all spaces. } unsigned += int64(c) signed += int64(int8(c)) } return unsigned, signed }
go
func (b *block) ComputeChecksum() (unsigned, signed int64) { for i, c := range b { if 148 <= i && i < 156 { c = ' ' // Treat the checksum field itself as all spaces. } unsigned += int64(c) signed += int64(int8(c)) } return unsigned, signed }
[ "func", "(", "b", "*", "block", ")", "ComputeChecksum", "(", ")", "(", "unsigned", ",", "signed", "int64", ")", "{", "for", "i", ",", "c", ":=", "range", "b", "{", "if", "148", "<=", "i", "&&", "i", "<", "156", "{", "c", "=", "' '", "// Treat t...
// ComputeChecksum computes the checksum for the header block. // POSIX specifies a sum of the unsigned byte values, but the Sun tar used // signed byte values. // We compute and return both.
[ "ComputeChecksum", "computes", "the", "checksum", "for", "the", "header", "block", ".", "POSIX", "specifies", "a", "sum", "of", "the", "unsigned", "byte", "values", "but", "the", "Sun", "tar", "used", "signed", "byte", "values", ".", "We", "compute", "and", ...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/format.go#L227-L236
141,559
vbatts/tar-split
archive/tar/writer.go
NewWriter
func NewWriter(w io.Writer) *Writer { return &Writer{w: w, curr: &regFileWriter{w, 0}} }
go
func NewWriter(w io.Writer) *Writer { return &Writer{w: w, curr: &regFileWriter{w, 0}} }
[ "func", "NewWriter", "(", "w", "io", ".", "Writer", ")", "*", "Writer", "{", "return", "&", "Writer", "{", "w", ":", "w", ",", "curr", ":", "&", "regFileWriter", "{", "w", ",", "0", "}", "}", "\n", "}" ]
// NewWriter creates a new Writer writing to w.
[ "NewWriter", "creates", "a", "new", "Writer", "writing", "to", "w", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/writer.go#L33-L35
141,560
vbatts/tar-split
archive/tar/writer.go
Flush
func (tw *Writer) Flush() error { if tw.err != nil { return tw.err } if nb := tw.curr.LogicalRemaining(); nb > 0 { return fmt.Errorf("archive/tar: missed writing %d bytes", nb) } if _, tw.err = tw.w.Write(zeroBlock[:tw.pad]); tw.err != nil { return tw.err } tw.pad = 0 return nil }
go
func (tw *Writer) Flush() error { if tw.err != nil { return tw.err } if nb := tw.curr.LogicalRemaining(); nb > 0 { return fmt.Errorf("archive/tar: missed writing %d bytes", nb) } if _, tw.err = tw.w.Write(zeroBlock[:tw.pad]); tw.err != nil { return tw.err } tw.pad = 0 return nil }
[ "func", "(", "tw", "*", "Writer", ")", "Flush", "(", ")", "error", "{", "if", "tw", ".", "err", "!=", "nil", "{", "return", "tw", ".", "err", "\n", "}", "\n", "if", "nb", ":=", "tw", ".", "curr", ".", "LogicalRemaining", "(", ")", ";", "nb", ...
// Flush finishes writing the current file's block padding. // The current file must be fully written before Flush can be called. // // This is unnecessary as the next call to WriteHeader or Close // will implicitly flush out the file's padding.
[ "Flush", "finishes", "writing", "the", "current", "file", "s", "block", "padding", ".", "The", "current", "file", "must", "be", "fully", "written", "before", "Flush", "can", "be", "called", ".", "This", "is", "unnecessary", "as", "the", "next", "call", "to...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/writer.go#L49-L61
141,561
vbatts/tar-split
archive/tar/writer.go
WriteHeader
func (tw *Writer) WriteHeader(hdr *Header) error { if err := tw.Flush(); err != nil { return err } tw.hdr = *hdr // Shallow copy of Header // Avoid usage of the legacy TypeRegA flag, and automatically promote // it to use TypeReg or TypeDir. if tw.hdr.Typeflag == TypeRegA { if strings.HasSuffix(tw.hdr.Name, ...
go
func (tw *Writer) WriteHeader(hdr *Header) error { if err := tw.Flush(); err != nil { return err } tw.hdr = *hdr // Shallow copy of Header // Avoid usage of the legacy TypeRegA flag, and automatically promote // it to use TypeReg or TypeDir. if tw.hdr.Typeflag == TypeRegA { if strings.HasSuffix(tw.hdr.Name, ...
[ "func", "(", "tw", "*", "Writer", ")", "WriteHeader", "(", "hdr", "*", "Header", ")", "error", "{", "if", "err", ":=", "tw", ".", "Flush", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "tw", ".", "hdr", "=", "*", "...
// WriteHeader writes hdr and prepares to accept the file's contents. // The Header.Size determines how many bytes can be written for the next file. // If the current file is not fully written, then this returns an error. // This implicitly flushes any padding necessary before writing the header.
[ "WriteHeader", "writes", "hdr", "and", "prepares", "to", "accept", "the", "file", "s", "contents", ".", "The", "Header", ".", "Size", "determines", "how", "many", "bytes", "can", "be", "written", "for", "the", "next", "file", ".", "If", "the", "current", ...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/writer.go#L67-L108
141,562
vbatts/tar-split
archive/tar/writer.go
writeRawHeader
func (tw *Writer) writeRawHeader(blk *block, size int64, flag byte) error { if err := tw.Flush(); err != nil { return err } if _, err := tw.w.Write(blk[:]); err != nil { return err } if isHeaderOnlyType(flag) { size = 0 } tw.curr = &regFileWriter{tw.w, size} tw.pad = blockPadding(size) return nil }
go
func (tw *Writer) writeRawHeader(blk *block, size int64, flag byte) error { if err := tw.Flush(); err != nil { return err } if _, err := tw.w.Write(blk[:]); err != nil { return err } if isHeaderOnlyType(flag) { size = 0 } tw.curr = &regFileWriter{tw.w, size} tw.pad = blockPadding(size) return nil }
[ "func", "(", "tw", "*", "Writer", ")", "writeRawHeader", "(", "blk", "*", "block", ",", "size", "int64", ",", "flag", "byte", ")", "error", "{", "if", "err", ":=", "tw", ".", "Flush", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n",...
// writeRawHeader writes the value of blk, regardless of its value. // It sets up the Writer such that it can accept a file of the given size. // If the flag is a special header-only flag, then the size is treated as zero.
[ "writeRawHeader", "writes", "the", "value", "of", "blk", "regardless", "of", "its", "value", ".", "It", "sets", "up", "the", "Writer", "such", "that", "it", "can", "accept", "a", "file", "of", "the", "given", "size", ".", "If", "the", "flag", "is", "a"...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/writer.go#L388-L401
141,563
vbatts/tar-split
archive/tar/writer.go
ensureEOF
func ensureEOF(r io.Reader) error { n, err := tryReadFull(r, []byte{0}) switch { case n > 0: return ErrWriteTooLong case err == io.EOF: return nil default: return err } }
go
func ensureEOF(r io.Reader) error { n, err := tryReadFull(r, []byte{0}) switch { case n > 0: return ErrWriteTooLong case err == io.EOF: return nil default: return err } }
[ "func", "ensureEOF", "(", "r", "io", ".", "Reader", ")", "error", "{", "n", ",", "err", ":=", "tryReadFull", "(", "r", ",", "[", "]", "byte", "{", "0", "}", ")", "\n", "switch", "{", "case", "n", ">", "0", ":", "return", "ErrWriteTooLong", "\n", ...
// ensureEOF checks whether r is at EOF, reporting ErrWriteTooLong if not so.
[ "ensureEOF", "checks", "whether", "r", "is", "at", "EOF", "reporting", "ErrWriteTooLong", "if", "not", "so", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/writer.go#L643-L653
141,564
vbatts/tar-split
archive/tar/reader.go
RawBytes
func (tr *Reader) RawBytes() []byte { if !tr.RawAccounting { return nil } if tr.rawBytes == nil { tr.rawBytes = bytes.NewBuffer(nil) } defer tr.rawBytes.Reset() // if we've read them, then flush them. return tr.rawBytes.Bytes() }
go
func (tr *Reader) RawBytes() []byte { if !tr.RawAccounting { return nil } if tr.rawBytes == nil { tr.rawBytes = bytes.NewBuffer(nil) } defer tr.rawBytes.Reset() // if we've read them, then flush them. return tr.rawBytes.Bytes() }
[ "func", "(", "tr", "*", "Reader", ")", "RawBytes", "(", ")", "[", "]", "byte", "{", "if", "!", "tr", ".", "RawAccounting", "{", "return", "nil", "\n", "}", "\n", "if", "tr", ".", "rawBytes", "==", "nil", "{", "tr", ".", "rawBytes", "=", "bytes", ...
// RawBytes accesses the raw bytes of the archive, apart from the file payload itself. // This includes the header and padding. // // This call resets the current rawbytes buffer // // Only when RawAccounting is enabled, otherwise this returns nil
[ "RawBytes", "accesses", "the", "raw", "bytes", "of", "the", "archive", "apart", "from", "the", "file", "payload", "itself", ".", "This", "includes", "the", "header", "and", "padding", ".", "This", "call", "resets", "the", "current", "rawbytes", "buffer", "On...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L47-L58
141,565
vbatts/tar-split
archive/tar/reader.go
NewReader
func NewReader(r io.Reader) *Reader { return &Reader{r: r, curr: &regFileReader{r, 0}} }
go
func NewReader(r io.Reader) *Reader { return &Reader{r: r, curr: &regFileReader{r, 0}} }
[ "func", "NewReader", "(", "r", "io", ".", "Reader", ")", "*", "Reader", "{", "return", "&", "Reader", "{", "r", ":", "r", ",", "curr", ":", "&", "regFileReader", "{", "r", ",", "0", "}", "}", "\n", "}" ]
// NewReader creates a new Reader reading from r.
[ "NewReader", "creates", "a", "new", "Reader", "reading", "from", "r", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L61-L63
141,566
vbatts/tar-split
archive/tar/reader.go
Next
func (tr *Reader) Next() (*Header, error) { if tr.err != nil { return nil, tr.err } hdr, err := tr.next() tr.err = err return hdr, err }
go
func (tr *Reader) Next() (*Header, error) { if tr.err != nil { return nil, tr.err } hdr, err := tr.next() tr.err = err return hdr, err }
[ "func", "(", "tr", "*", "Reader", ")", "Next", "(", ")", "(", "*", "Header", ",", "error", ")", "{", "if", "tr", ".", "err", "!=", "nil", "{", "return", "nil", ",", "tr", ".", "err", "\n", "}", "\n", "hdr", ",", "err", ":=", "tr", ".", "nex...
// Next advances to the next entry in the tar archive. // The Header.Size determines how many bytes can be read for the next file. // Any remaining data in the current file is automatically discarded. // // io.EOF is returned at the end of the input.
[ "Next", "advances", "to", "the", "next", "entry", "in", "the", "tar", "archive", ".", "The", "Header", ".", "Size", "determines", "how", "many", "bytes", "can", "be", "read", "for", "the", "next", "file", ".", "Any", "remaining", "data", "in", "the", "...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L70-L77
141,567
vbatts/tar-split
archive/tar/reader.go
handleRegularFile
func (tr *Reader) handleRegularFile(hdr *Header) error { nb := hdr.Size if isHeaderOnlyType(hdr.Typeflag) { nb = 0 } if nb < 0 { return ErrHeader } tr.pad = blockPadding(nb) tr.curr = &regFileReader{r: tr.r, nb: nb} return nil }
go
func (tr *Reader) handleRegularFile(hdr *Header) error { nb := hdr.Size if isHeaderOnlyType(hdr.Typeflag) { nb = 0 } if nb < 0 { return ErrHeader } tr.pad = blockPadding(nb) tr.curr = &regFileReader{r: tr.r, nb: nb} return nil }
[ "func", "(", "tr", "*", "Reader", ")", "handleRegularFile", "(", "hdr", "*", "Header", ")", "error", "{", "nb", ":=", "hdr", ".", "Size", "\n", "if", "isHeaderOnlyType", "(", "hdr", ".", "Typeflag", ")", "{", "nb", "=", "0", "\n", "}", "\n", "if", ...
// handleRegularFile sets up the current file reader and padding such that it // can only read the following logical data section. It will properly handle // special headers that contain no data section.
[ "handleRegularFile", "sets", "up", "the", "current", "file", "reader", "and", "padding", "such", "that", "it", "can", "only", "read", "the", "following", "logical", "data", "section", ".", "It", "will", "properly", "handle", "special", "headers", "that", "cont...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L204-L216
141,568
vbatts/tar-split
archive/tar/reader.go
readGNUSparsePAXHeaders
func (tr *Reader) readGNUSparsePAXHeaders(hdr *Header) (sparseDatas, error) { // Identify the version of GNU headers. var is1x0 bool major, minor := hdr.PAXRecords[paxGNUSparseMajor], hdr.PAXRecords[paxGNUSparseMinor] switch { case major == "0" && (minor == "0" || minor == "1"): is1x0 = false case major == "1" ...
go
func (tr *Reader) readGNUSparsePAXHeaders(hdr *Header) (sparseDatas, error) { // Identify the version of GNU headers. var is1x0 bool major, minor := hdr.PAXRecords[paxGNUSparseMajor], hdr.PAXRecords[paxGNUSparseMinor] switch { case major == "0" && (minor == "0" || minor == "1"): is1x0 = false case major == "1" ...
[ "func", "(", "tr", "*", "Reader", ")", "readGNUSparsePAXHeaders", "(", "hdr", "*", "Header", ")", "(", "sparseDatas", ",", "error", ")", "{", "// Identify the version of GNU headers.", "var", "is1x0", "bool", "\n", "major", ",", "minor", ":=", "hdr", ".", "P...
// readGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers. // If they are found, then this function reads the sparse map and returns it. // This assumes that 0.0 headers have already been converted to 0.1 headers // by the PAX header parsing logic.
[ "readGNUSparsePAXHeaders", "checks", "the", "PAX", "headers", "for", "GNU", "sparse", "headers", ".", "If", "they", "are", "found", "then", "this", "function", "reads", "the", "sparse", "map", "and", "returns", "it", ".", "This", "assumes", "that", "0", ".",...
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L245-L284
141,569
vbatts/tar-split
archive/tar/reader.go
mergePAX
func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) { for k, v := range paxHdrs { if v == "" { continue // Keep the original USTAR value } var id64 int64 switch k { case paxPath: hdr.Name = v case paxLinkpath: hdr.Linkname = v case paxUname: hdr.Uname = v case paxGname: hdr...
go
func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) { for k, v := range paxHdrs { if v == "" { continue // Keep the original USTAR value } var id64 int64 switch k { case paxPath: hdr.Name = v case paxLinkpath: hdr.Linkname = v case paxUname: hdr.Uname = v case paxGname: hdr...
[ "func", "mergePAX", "(", "hdr", "*", "Header", ",", "paxHdrs", "map", "[", "string", "]", "string", ")", "(", "err", "error", ")", "{", "for", "k", ",", "v", ":=", "range", "paxHdrs", "{", "if", "v", "==", "\"", "\"", "{", "continue", "// Keep the ...
// mergePAX merges paxHdrs into hdr for all relevant fields of Header.
[ "mergePAX", "merges", "paxHdrs", "into", "hdr", "for", "all", "relevant", "fields", "of", "Header", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L287-L330
141,570
vbatts/tar-split
archive/tar/reader.go
discard
func discard(tr *Reader, n int64) error { var seekSkipped, copySkipped int64 var err error r := tr.r if tr.RawAccounting { copySkipped, err = io.CopyN(tr.rawBytes, tr.r, n) goto out } // If possible, Seek to the last byte before the end of the data section. // Do this because Seek is often lazy about repor...
go
func discard(tr *Reader, n int64) error { var seekSkipped, copySkipped int64 var err error r := tr.r if tr.RawAccounting { copySkipped, err = io.CopyN(tr.rawBytes, tr.r, n) goto out } // If possible, Seek to the last byte before the end of the data section. // Do this because Seek is often lazy about repor...
[ "func", "discard", "(", "tr", "*", "Reader", ",", "n", "int64", ")", "error", "{", "var", "seekSkipped", ",", "copySkipped", "int64", "\n", "var", "err", "error", "\n", "r", ":=", "tr", ".", "r", "\n", "if", "tr", ".", "RawAccounting", "{", "copySkip...
// discard skips n bytes in r, reporting an error if unable to do so.
[ "discard", "skips", "n", "bytes", "in", "r", "reporting", "an", "error", "if", "unable", "to", "do", "so", "." ]
620714a4c508c880ac1bdda9c8370a2b19af1a55
https://github.com/vbatts/tar-split/blob/620714a4c508c880ac1bdda9c8370a2b19af1a55/archive/tar/reader.go#L887-L923
141,571
fastly/go-utils
vlog/log.go
VLogfQuiet
func VLogfQuiet(id, format string, v ...interface{}) { if Verbose { logfQuietN(3, id, format, v...) } }
go
func VLogfQuiet(id, format string, v ...interface{}) { if Verbose { logfQuietN(3, id, format, v...) } }
[ "func", "VLogfQuiet", "(", "id", ",", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "Verbose", "{", "logfQuietN", "(", "3", ",", "id", ",", "format", ",", "v", "...", ")", "\n", "}", "\n", "}" ]
// VlogFQuiet calls LogfQuiet if Verbose is true.
[ "VlogFQuiet", "calls", "LogfQuiet", "if", "Verbose", "is", "true", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/vlog/log.go#L38-L42
141,572
fastly/go-utils
ganglia/ganglia.go
Gmetric
func Gmetric() *Reporter { globalReporter.Do(func() { globalReporter.Reporter = NewGangliaReporter(Interval) globalReporter.AddCallback(CommonGmetrics) }) return globalReporter.Reporter }
go
func Gmetric() *Reporter { globalReporter.Do(func() { globalReporter.Reporter = NewGangliaReporter(Interval) globalReporter.AddCallback(CommonGmetrics) }) return globalReporter.Reporter }
[ "func", "Gmetric", "(", ")", "*", "Reporter", "{", "globalReporter", ".", "Do", "(", "func", "(", ")", "{", "globalReporter", ".", "Reporter", "=", "NewGangliaReporter", "(", "Interval", ")", "\n", "globalReporter", ".", "AddCallback", "(", "CommonGmetrics", ...
// Gmetric returns a global Reporter that clients may hook into by // calling AddCallback.
[ "Gmetric", "returns", "a", "global", "Reporter", "that", "clients", "may", "hook", "into", "by", "calling", "AddCallback", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/ganglia/ganglia.go#L82-L88
141,573
fastly/go-utils
ganglia/ganglia.go
Configure
func (gr *Reporter) Configure(groupName, prefix string) *Reporter { if gr == nil { return nil } gr.prefix = html.EscapeString(prefix) gr.groupName = html.EscapeString(groupName) return gr }
go
func (gr *Reporter) Configure(groupName, prefix string) *Reporter { if gr == nil { return nil } gr.prefix = html.EscapeString(prefix) gr.groupName = html.EscapeString(groupName) return gr }
[ "func", "(", "gr", "*", "Reporter", ")", "Configure", "(", "groupName", ",", "prefix", "string", ")", "*", "Reporter", "{", "if", "gr", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "gr", ".", "prefix", "=", "html", ".", "EscapeString", "(", ...
// Configure sets group name and prefix of a reporter and returns the reporter.
[ "Configure", "sets", "group", "name", "and", "prefix", "of", "a", "reporter", "and", "returns", "the", "reporter", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/ganglia/ganglia.go#L91-L98
141,574
fastly/go-utils
ganglia/ganglia.go
SetDmax
func (gr *Reporter) SetDmax(dmax time.Duration) *Reporter { if gr == nil { return nil } gr.dmax = uint32(dmax.Seconds()) return gr }
go
func (gr *Reporter) SetDmax(dmax time.Duration) *Reporter { if gr == nil { return nil } gr.dmax = uint32(dmax.Seconds()) return gr }
[ "func", "(", "gr", "*", "Reporter", ")", "SetDmax", "(", "dmax", "time", ".", "Duration", ")", "*", "Reporter", "{", "if", "gr", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "gr", ".", "dmax", "=", "uint32", "(", "dmax", ".", "Seconds", "(...
// SetDmax configures the amount of time that metrics are valid for in the // tsdb. The default of 0 means forever. Time resolution is only respected to // the second.
[ "SetDmax", "configures", "the", "amount", "of", "time", "that", "metrics", "are", "valid", "for", "in", "the", "tsdb", ".", "The", "default", "of", "0", "means", "forever", ".", "Time", "resolution", "is", "only", "respected", "to", "the", "second", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/ganglia/ganglia.go#L103-L109
141,575
fastly/go-utils
tls/tls.go
callerPkgDir
func callerPkgDir() (dir string, ok bool) { _, thisFile, _, cok := runtime.Caller(0) // /home/me/workspace/src/fastly/go-utils/tls/tls.go if !cok { return } thisDir := filepath.Dir(thisFile) // /home/me/workspace/src/fastly/go-utils/tls sep := fmt.Sprintf("%csrc%c", os.PathSepara...
go
func callerPkgDir() (dir string, ok bool) { _, thisFile, _, cok := runtime.Caller(0) // /home/me/workspace/src/fastly/go-utils/tls/tls.go if !cok { return } thisDir := filepath.Dir(thisFile) // /home/me/workspace/src/fastly/go-utils/tls sep := fmt.Sprintf("%csrc%c", os.PathSepara...
[ "func", "callerPkgDir", "(", ")", "(", "dir", "string", ",", "ok", "bool", ")", "{", "_", ",", "thisFile", ",", "_", ",", "cok", ":=", "runtime", ".", "Caller", "(", "0", ")", "// /home/me/workspace/src/fastly/go-utils/tls/tls.go", "\n", "if", "!", "cok", ...
// callerPkgDir returns a pathname containing the build-time location of the // deepest calling function that is not within this package. If that cannot be // found, ok will be false and dir will be empty.
[ "callerPkgDir", "returns", "a", "pathname", "containing", "the", "build", "-", "time", "location", "of", "the", "deepest", "calling", "function", "that", "is", "not", "within", "this", "package", ".", "If", "that", "cannot", "be", "found", "ok", "will", "be"...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L106-L137
141,576
fastly/go-utils
tls/tls.go
searchUpwards
func searchUpwards(start, dir string) (path string, ok bool) { cur := start for { test := filepath.Join(cur, dir) fi, err := os.Stat(test) if err == nil && fi != nil && fi.IsDir() { return test, true } next := filepath.Dir(cur) if next == cur { return } cur = next } }
go
func searchUpwards(start, dir string) (path string, ok bool) { cur := start for { test := filepath.Join(cur, dir) fi, err := os.Stat(test) if err == nil && fi != nil && fi.IsDir() { return test, true } next := filepath.Dir(cur) if next == cur { return } cur = next } }
[ "func", "searchUpwards", "(", "start", ",", "dir", "string", ")", "(", "path", "string", ",", "ok", "bool", ")", "{", "cur", ":=", "start", "\n", "for", "{", "test", ":=", "filepath", ".", "Join", "(", "cur", ",", "dir", ")", "\n", "fi", ",", "er...
// searchUpwards finds the deepest directory that is `start` or one of its // parents which contains a directory named `dir`. The returned path is to the // search target, not its parent. If none could be found, ok will be false and // path will be empty.
[ "searchUpwards", "finds", "the", "deepest", "directory", "that", "is", "start", "or", "one", "of", "its", "parents", "which", "contains", "a", "directory", "named", "dir", ".", "The", "returned", "path", "is", "to", "the", "search", "target", "not", "its", ...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L143-L157
141,577
fastly/go-utils
tls/tls.go
ConfigureServer
func ConfigureServer(serverKeyPairName string, clientCertNames ...string) (config *tls.Config, err error) { config, err = GenerateConfig(false, serverKeyPairName, clientCertNames) if config != nil { config.CipherSuites = PreferredCipherSuites() } return }
go
func ConfigureServer(serverKeyPairName string, clientCertNames ...string) (config *tls.Config, err error) { config, err = GenerateConfig(false, serverKeyPairName, clientCertNames) if config != nil { config.CipherSuites = PreferredCipherSuites() } return }
[ "func", "ConfigureServer", "(", "serverKeyPairName", "string", ",", "clientCertNames", "...", "string", ")", "(", "config", "*", "tls", ".", "Config", ",", "err", "error", ")", "{", "config", ",", "err", "=", "GenerateConfig", "(", "false", ",", "serverKeyPa...
// ConfigureServer returns a TLS server configuration that presents serverKeyPairName to // clients. if clientCertNames is non-empty the server will request a client // certificate and require that it be provided and signed by one of the named // certs.
[ "ConfigureServer", "returns", "a", "TLS", "server", "configuration", "that", "presents", "serverKeyPairName", "to", "clients", ".", "if", "clientCertNames", "is", "non", "-", "empty", "the", "server", "will", "request", "a", "client", "certificate", "and", "requir...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L263-L269
141,578
fastly/go-utils
tls/tls.go
ConfigureClient
func ConfigureClient(clientKeyPairName string, serverCertNames ...string) (config *tls.Config, err error) { return GenerateConfig(true, clientKeyPairName, serverCertNames) }
go
func ConfigureClient(clientKeyPairName string, serverCertNames ...string) (config *tls.Config, err error) { return GenerateConfig(true, clientKeyPairName, serverCertNames) }
[ "func", "ConfigureClient", "(", "clientKeyPairName", "string", ",", "serverCertNames", "...", "string", ")", "(", "config", "*", "tls", ".", "Config", ",", "err", "error", ")", "{", "return", "GenerateConfig", "(", "true", ",", "clientKeyPairName", ",", "serve...
// ConfigureClient returns a TLS client configuration that presents clientKeyPair // to the remote server. if serverCertNames is non-empty, server certificates must // be signed by one of the named certs; otherwise the default system CA list will be // used.
[ "ConfigureClient", "returns", "a", "TLS", "client", "configuration", "that", "presents", "clientKeyPair", "to", "the", "remote", "server", ".", "if", "serverCertNames", "is", "non", "-", "empty", "server", "certificates", "must", "be", "signed", "by", "one", "of...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L275-L277
141,579
fastly/go-utils
tls/tls.go
PreferredCipherSuites
func PreferredCipherSuites() []uint16 { return []uint16{ tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA...
go
func PreferredCipherSuites() []uint16 { return []uint16{ tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA...
[ "func", "PreferredCipherSuites", "(", ")", "[", "]", "uint16", "{", "return", "[", "]", "uint16", "{", "tls", ".", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", ",", "tls", ".", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", ",", "tls", ".", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA...
// PreferredCipherSuites returns the set of default cipher suites, minus RC4 // and 3DES suites, with ECDSA preferred over RSA.
[ "PreferredCipherSuites", "returns", "the", "set", "of", "default", "cipher", "suites", "minus", "RC4", "and", "3DES", "suites", "with", "ECDSA", "preferred", "over", "RSA", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L281-L292
141,580
fastly/go-utils
tls/tls.go
SetWrapCreds
func SetWrapCreds(adminuser, adminpass, authrealm string) { _adminuser = adminuser _adminpass = adminpass _authrealm = authrealm }
go
func SetWrapCreds(adminuser, adminpass, authrealm string) { _adminuser = adminuser _adminpass = adminpass _authrealm = authrealm }
[ "func", "SetWrapCreds", "(", "adminuser", ",", "adminpass", ",", "authrealm", "string", ")", "{", "_adminuser", "=", "adminuser", "\n", "_adminpass", "=", "adminpass", "\n", "_authrealm", "=", "authrealm", "\n", "}" ]
// SetWrapCreds stores the adminuser, adminpass, and authrealm. These parameters // will be used as the credentials and realm in calls to WrapHandleForAuth // and WrapHandlerFuncForAuth.
[ "SetWrapCreds", "stores", "the", "adminuser", "adminpass", "and", "authrealm", ".", "These", "parameters", "will", "be", "used", "as", "the", "credentials", "and", "realm", "in", "calls", "to", "WrapHandleForAuth", "and", "WrapHandlerFuncForAuth", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L297-L301
141,581
fastly/go-utils
tls/tls.go
WrapHandlerForAuth
func WrapHandlerForAuth(h http.Handler) http.Handler { return WrapHandlerForAuthCreds(h, _adminuser, _adminpass, _authrealm) }
go
func WrapHandlerForAuth(h http.Handler) http.Handler { return WrapHandlerForAuthCreds(h, _adminuser, _adminpass, _authrealm) }
[ "func", "WrapHandlerForAuth", "(", "h", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "WrapHandlerForAuthCreds", "(", "h", ",", "_adminuser", ",", "_adminpass", ",", "_authrealm", ")", "\n", "}" ]
// WrapHandlerForAuth calls WrapHandlerForAuthCreds with the currently stored // adminuser, adminpass, and authrealm. SetWrapCreds should be called before this function // or else the HAndler will not be wrapped with basic authentication.
[ "WrapHandlerForAuth", "calls", "WrapHandlerForAuthCreds", "with", "the", "currently", "stored", "adminuser", "adminpass", "and", "authrealm", ".", "SetWrapCreds", "should", "be", "called", "before", "this", "function", "or", "else", "the", "HAndler", "will", "not", ...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L306-L308
141,582
fastly/go-utils
tls/tls.go
WrapHandlerFuncForAuth
func WrapHandlerFuncForAuth(h http.HandlerFunc) http.HandlerFunc { return WrapHandlerFuncForAuthCreds(h, _adminuser, _adminpass, _authrealm) }
go
func WrapHandlerFuncForAuth(h http.HandlerFunc) http.HandlerFunc { return WrapHandlerFuncForAuthCreds(h, _adminuser, _adminpass, _authrealm) }
[ "func", "WrapHandlerFuncForAuth", "(", "h", "http", ".", "HandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "WrapHandlerFuncForAuthCreds", "(", "h", ",", "_adminuser", ",", "_adminpass", ",", "_authrealm", ")", "\n", "}" ]
// WrapHandlerFuncForAuth calls WrapHandlerFuncForAuthCreds with the currently stored // adminuser, adminpass, and authrealm. SetWrapCreds should be called before this function // or else the HandlerFunc will not be wrapped with basic authentication.
[ "WrapHandlerFuncForAuth", "calls", "WrapHandlerFuncForAuthCreds", "with", "the", "currently", "stored", "adminuser", "adminpass", "and", "authrealm", ".", "SetWrapCreds", "should", "be", "called", "before", "this", "function", "or", "else", "the", "HandlerFunc", "will",...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L313-L315
141,583
fastly/go-utils
tls/tls.go
WrapHandlerForAuthCreds
func WrapHandlerForAuthCreds(h http.Handler, adminuser, adminpass, authrealm string) http.Handler { if adminuser == "" && adminpass == "" { return h } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if isAuthenticated(r, adminuser, adminpass) { if AuthRequest != nil { AuthRequest(r,...
go
func WrapHandlerForAuthCreds(h http.Handler, adminuser, adminpass, authrealm string) http.Handler { if adminuser == "" && adminpass == "" { return h } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if isAuthenticated(r, adminuser, adminpass) { if AuthRequest != nil { AuthRequest(r,...
[ "func", "WrapHandlerForAuthCreds", "(", "h", "http", ".", "Handler", ",", "adminuser", ",", "adminpass", ",", "authrealm", "string", ")", "http", ".", "Handler", "{", "if", "adminuser", "==", "\"", "\"", "&&", "adminpass", "==", "\"", "\"", "{", "return", ...
// WrapHandlerForAuthCreds returns the Handler wrapped with basic authentication // requiring credentials adminuser and adminpass. The authrealm will be used // for the WWW-Authenticate header's basic realm.
[ "WrapHandlerForAuthCreds", "returns", "the", "Handler", "wrapped", "with", "basic", "authentication", "requiring", "credentials", "adminuser", "and", "adminpass", ".", "The", "authrealm", "will", "be", "used", "for", "the", "WWW", "-", "Authenticate", "header", "s",...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/tls.go#L320-L339
141,584
fastly/go-utils
instrumentation/instrumentation.go
GetStackTraces
func GetStackTraces() map[string][]string { stack := GetStackTrace(true) info := make(map[string][]string, 0) goroutine := "" for _, line := range strings.Split(stack, "\n") { line = strings.TrimSpace(line) line = strings.Trim(line, "\u0000") if strings.HasPrefix(line, "goroutine ") { goroutine = line ...
go
func GetStackTraces() map[string][]string { stack := GetStackTrace(true) info := make(map[string][]string, 0) goroutine := "" for _, line := range strings.Split(stack, "\n") { line = strings.TrimSpace(line) line = strings.Trim(line, "\u0000") if strings.HasPrefix(line, "goroutine ") { goroutine = line ...
[ "func", "GetStackTraces", "(", ")", "map", "[", "string", "]", "[", "]", "string", "{", "stack", ":=", "GetStackTrace", "(", "true", ")", "\n\n", "info", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "string", ",", "0", ")", "\n", "gorout...
// GetStackTraces returns a map of goroutines to string // Slice of their respective stack trace.
[ "GetStackTraces", "returns", "a", "map", "of", "goroutines", "to", "string", "Slice", "of", "their", "respective", "stack", "trace", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/instrumentation/instrumentation.go#L74-L91
141,585
fastly/go-utils
privsep/privsep.go
MaybeBecomeChild
func MaybeBecomeChild() (isChild bool, r io.Reader, w io.Writer, files []*os.File, err error) { return maybeBecomeChild() }
go
func MaybeBecomeChild() (isChild bool, r io.Reader, w io.Writer, files []*os.File, err error) { return maybeBecomeChild() }
[ "func", "MaybeBecomeChild", "(", ")", "(", "isChild", "bool", ",", "r", "io", ".", "Reader", ",", "w", "io", ".", "Writer", ",", "files", "[", "]", "*", "os", ".", "File", ",", "err", "error", ")", "{", "return", "maybeBecomeChild", "(", ")", "\n",...
// MaybeBecomeChild examines its environment to see if it was started by // CreateChild in another process. If so, it attempts to drop privileges, // re-execing if necessary. It should be called as early as possible in the // life of a program that is intended to be started by CreateChild. // // If the process is inten...
[ "MaybeBecomeChild", "examines", "its", "environment", "to", "see", "if", "it", "was", "started", "by", "CreateChild", "in", "another", "process", ".", "If", "so", "it", "attempts", "to", "drop", "privileges", "re", "-", "execing", "if", "necessary", ".", "It...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/privsep/privsep.go#L39-L41
141,586
fastly/go-utils
lifecycle/lifecycle.go
New
func New(singleProcess bool) *Lifecycle { l := Lifecycle{ interrupt: make(chan os.Signal, 1), fatalQuit: make(chan struct{}, 1), } // make sigint trigger a clean shutdown signal.Notify(l.interrupt, os.Interrupt) signal.Notify(l.interrupt, syscall.SIGTERM) signal.Notify(l.interrupt, syscall.SIGHUP) if singl...
go
func New(singleProcess bool) *Lifecycle { l := Lifecycle{ interrupt: make(chan os.Signal, 1), fatalQuit: make(chan struct{}, 1), } // make sigint trigger a clean shutdown signal.Notify(l.interrupt, os.Interrupt) signal.Notify(l.interrupt, syscall.SIGTERM) signal.Notify(l.interrupt, syscall.SIGHUP) if singl...
[ "func", "New", "(", "singleProcess", "bool", ")", "*", "Lifecycle", "{", "l", ":=", "Lifecycle", "{", "interrupt", ":", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", ",", "fatalQuit", ":", "make", "(", "chan", "struct", "{", "}", ",", "1...
// New creates a new Lifecycle. This should be called after validating // parameters but before starting work or allocating external resources. A // startup message is displayed and shutdown handlers for SIGINT and SIGTERM // are registered. // // If New is passed 'true' for singleProcess, it will wait for existing dup...
[ "New", "creates", "a", "new", "Lifecycle", ".", "This", "should", "be", "called", "after", "validating", "parameters", "but", "before", "starting", "work", "or", "allocating", "external", "resources", ".", "A", "startup", "message", "is", "displayed", "and", "...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/lifecycle/lifecycle.go#L34-L57
141,587
fastly/go-utils
lifecycle/lifecycle.go
RunWhenKilled
func (l *Lifecycle) RunWhenKilled(finalizer func(), timeout time.Duration) { vlog.VLogf("%s started", os.Args[0]) select { case sig := <-l.interrupt: vlog.VLogf("Caught signal %q, shutting down", sig) case <-l.fatalQuit: vlog.VLogf("Caught fatal quit, shutting down") } // wait for either confirmation that we...
go
func (l *Lifecycle) RunWhenKilled(finalizer func(), timeout time.Duration) { vlog.VLogf("%s started", os.Args[0]) select { case sig := <-l.interrupt: vlog.VLogf("Caught signal %q, shutting down", sig) case <-l.fatalQuit: vlog.VLogf("Caught fatal quit, shutting down") } // wait for either confirmation that we...
[ "func", "(", "l", "*", "Lifecycle", ")", "RunWhenKilled", "(", "finalizer", "func", "(", ")", ",", "timeout", "time", ".", "Duration", ")", "{", "vlog", ".", "VLogf", "(", "\"", "\"", ",", "os", ".", "Args", "[", "0", "]", ")", "\n", "select", "{...
// RunWhenKilled blocks until a shutdown signal is received, then executes // finalizer and only returns either after it has finished or another // shutdown signal is received. If timeout is non-zero, RunWhenKilled will // force shutdown if the finalizer cannot complete within the timeout duration. // // RunWhenKilled ...
[ "RunWhenKilled", "blocks", "until", "a", "shutdown", "signal", "is", "received", "then", "executes", "finalizer", "and", "only", "returns", "either", "after", "it", "has", "finished", "or", "another", "shutdown", "signal", "is", "received", ".", "If", "timeout",...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/lifecycle/lifecycle.go#L70-L105
141,588
fastly/go-utils
lifecycle/lifecycle.go
AddKillFunc
func (l *Lifecycle) AddKillFunc(f func()) { l.m.Lock() defer l.m.Unlock() l.killFuncs = append(l.killFuncs, f) }
go
func (l *Lifecycle) AddKillFunc(f func()) { l.m.Lock() defer l.m.Unlock() l.killFuncs = append(l.killFuncs, f) }
[ "func", "(", "l", "*", "Lifecycle", ")", "AddKillFunc", "(", "f", "func", "(", ")", ")", "{", "l", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "m", ".", "Unlock", "(", ")", "\n", "l", ".", "killFuncs", "=", "append", "(", "l", ...
// AddKillFunc will add f to the list of functions to be ran // when the lifecycle is killed. Functions passed to AddKillFunc // are ran in reverse order, much like defer. If the lifecycle // is being killed ad the same time AddKillFunc is called, the // passed function will not be called.
[ "AddKillFunc", "will", "add", "f", "to", "the", "list", "of", "functions", "to", "be", "ran", "when", "the", "lifecycle", "is", "killed", ".", "Functions", "passed", "to", "AddKillFunc", "are", "ran", "in", "reverse", "order", "much", "like", "defer", ".",...
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/lifecycle/lifecycle.go#L112-L116
141,589
fastly/go-utils
lifecycle/lifecycle.go
InstallStackTracer
func InstallStackTracer() stopper.Stopper { signals := make(chan os.Signal, 1) signal.Notify(signals, traceSignal) stopper := stopper.NewChanStopper() go func() { defer func() { signal.Stop(signals) close(signals) }() for { select { case <-signals: log.Print(instrumentation.GetStackTrace(true)...
go
func InstallStackTracer() stopper.Stopper { signals := make(chan os.Signal, 1) signal.Notify(signals, traceSignal) stopper := stopper.NewChanStopper() go func() { defer func() { signal.Stop(signals) close(signals) }() for { select { case <-signals: log.Print(instrumentation.GetStackTrace(true)...
[ "func", "InstallStackTracer", "(", ")", "stopper", ".", "Stopper", "{", "signals", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "signals", ",", "traceSignal", ")", "\n", "stopper", ":=", "stopper", ...
// for debugging, show goroutine trace on receipt of USR1. uninstall by calling // Stop on the returned object
[ "for", "debugging", "show", "goroutine", "trace", "on", "receipt", "of", "USR1", ".", "uninstall", "by", "calling", "Stop", "on", "the", "returned", "object" ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/lifecycle/lifecycle.go#L125-L144
141,590
fastly/go-utils
executable/executable.go
NowRunning
func NowRunning() bool { binary, err := Path() if err != nil { log.Fatalf("Couldn't find own process: %s", err) return false } proc, _, err := FindDuplicateProcess(binary) if err != nil { vlog.VLogf("Couldn't look for running processes: %s", err) return false } if proc == nil { return false } if proc...
go
func NowRunning() bool { binary, err := Path() if err != nil { log.Fatalf("Couldn't find own process: %s", err) return false } proc, _, err := FindDuplicateProcess(binary) if err != nil { vlog.VLogf("Couldn't look for running processes: %s", err) return false } if proc == nil { return false } if proc...
[ "func", "NowRunning", "(", ")", "bool", "{", "binary", ",", "err", ":=", "Path", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "false", "\n", "}", "\n", "proc", ",", "_", ...
// NowRunning returns true if there is a running process whose // binary has the same name as this one.
[ "NowRunning", "returns", "true", "if", "there", "is", "a", "running", "process", "whose", "binary", "has", "the", "same", "name", "as", "this", "one", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/executable/executable.go#L17-L35
141,591
fastly/go-utils
executable/executable.go
Dir
func Dir() (dir string, err error) { path, err := Path() if err != nil { return } dir, _ = filepath.Split(path) return }
go
func Dir() (dir string, err error) { path, err := Path() if err != nil { return } dir, _ = filepath.Split(path) return }
[ "func", "Dir", "(", ")", "(", "dir", "string", ",", "err", "error", ")", "{", "path", ",", "err", ":=", "Path", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "dir", ",", "_", "=", "filepath", ".", "Split", "(", "pa...
// Dir returns the running executable process's directory.
[ "Dir", "returns", "the", "running", "executable", "process", "s", "directory", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/executable/executable.go#L38-L45
141,592
fastly/go-utils
executable/executable.go
FindDuplicateProcess
func FindDuplicateProcess(binary string) (*os.Process, int, error) { all, err := BinaryDuplicateProcessIDs(binary) if err != nil { return nil, 0, err } if len(all) > 0 { p, err := os.FindProcess(all[0]) if err != nil { return nil, 0, err } return p, all[0], nil } return nil, 0, nil }
go
func FindDuplicateProcess(binary string) (*os.Process, int, error) { all, err := BinaryDuplicateProcessIDs(binary) if err != nil { return nil, 0, err } if len(all) > 0 { p, err := os.FindProcess(all[0]) if err != nil { return nil, 0, err } return p, all[0], nil } return nil, 0, nil }
[ "func", "FindDuplicateProcess", "(", "binary", "string", ")", "(", "*", "os", ".", "Process", ",", "int", ",", "error", ")", "{", "all", ",", "err", ":=", "BinaryDuplicateProcessIDs", "(", "binary", ")", "\n", "if", "err", "!=", "nil", "{", "return", "...
// FindDuplicateProcess looks for any other processes with the same // binary name as passed in and returns the first one found.
[ "FindDuplicateProcess", "looks", "for", "any", "other", "processes", "with", "the", "same", "binary", "name", "as", "passed", "in", "and", "returns", "the", "first", "one", "found", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/executable/executable.go#L49-L62
141,593
fastly/go-utils
executable/executable.go
DuplicateProcessIDs
func DuplicateProcessIDs() (pids []int, err error) { binary, err := Path() if err != nil { return nil, fmt.Errorf("Can't get path: %v", err) } return BinaryDuplicateProcessIDs(binary) }
go
func DuplicateProcessIDs() (pids []int, err error) { binary, err := Path() if err != nil { return nil, fmt.Errorf("Can't get path: %v", err) } return BinaryDuplicateProcessIDs(binary) }
[ "func", "DuplicateProcessIDs", "(", ")", "(", "pids", "[", "]", "int", ",", "err", "error", ")", "{", "binary", ",", "err", ":=", "Path", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// DuplicateProcessIDs returns all pids belonging to processes with the // same binary name as the running program.
[ "DuplicateProcessIDs", "returns", "all", "pids", "belonging", "to", "processes", "with", "the", "same", "binary", "name", "as", "the", "running", "program", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/executable/executable.go#L66-L72
141,594
fastly/go-utils
tls/cert_creator.go
NewCertCreator
func NewCertCreator() *CertCreator { return &CertCreator{ Serial: 1, NotBefore: time.Now(), NotAfter: time.Date(2049, 12, 31, 23, 59, 59, 0, time.UTC), // end of ASN.1 time KeySize: 4096, } }
go
func NewCertCreator() *CertCreator { return &CertCreator{ Serial: 1, NotBefore: time.Now(), NotAfter: time.Date(2049, 12, 31, 23, 59, 59, 0, time.UTC), // end of ASN.1 time KeySize: 4096, } }
[ "func", "NewCertCreator", "(", ")", "*", "CertCreator", "{", "return", "&", "CertCreator", "{", "Serial", ":", "1", ",", "NotBefore", ":", "time", ".", "Now", "(", ")", ",", "NotAfter", ":", "time", ".", "Date", "(", "2049", ",", "12", ",", "31", "...
// NewCertCreator returns a CertCreator with default values.
[ "NewCertCreator", "returns", "a", "CertCreator", "with", "default", "values", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/cert_creator.go#L57-L64
141,595
fastly/go-utils
tls/cert_creator.go
GenerateRootKeyPair
func (cc *CertCreator) GenerateRootKeyPair(name string, commonName string, hosts ...string) (*KeyPair, error) { return cc.GenerateKeyPair(CA, nil, name, commonName, hosts...) }
go
func (cc *CertCreator) GenerateRootKeyPair(name string, commonName string, hosts ...string) (*KeyPair, error) { return cc.GenerateKeyPair(CA, nil, name, commonName, hosts...) }
[ "func", "(", "cc", "*", "CertCreator", ")", "GenerateRootKeyPair", "(", "name", "string", ",", "commonName", "string", ",", "hosts", "...", "string", ")", "(", "*", "KeyPair", ",", "error", ")", "{", "return", "cc", ".", "GenerateKeyPair", "(", "CA", ","...
// GenerateRootKeyPair creates or reloads a self-signed CA cert.
[ "GenerateRootKeyPair", "creates", "or", "reloads", "a", "self", "-", "signed", "CA", "cert", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/cert_creator.go#L83-L85
141,596
fastly/go-utils
tls/cert_creator.go
LoadKeyPairFromDisk
func LoadKeyPairFromDisk(name string) (*KeyPair, error) { // cert certFile := name + "-cert.pem" b, err := ioutil.ReadFile(certFile) if err != nil { return nil, err } block, _ := pem.Decode(b) if block == nil { return nil, fmt.Errorf("No PEM data found in %q", certFile) } cert, err := x509.ParseCertifica...
go
func LoadKeyPairFromDisk(name string) (*KeyPair, error) { // cert certFile := name + "-cert.pem" b, err := ioutil.ReadFile(certFile) if err != nil { return nil, err } block, _ := pem.Decode(b) if block == nil { return nil, fmt.Errorf("No PEM data found in %q", certFile) } cert, err := x509.ParseCertifica...
[ "func", "LoadKeyPairFromDisk", "(", "name", "string", ")", "(", "*", "KeyPair", ",", "error", ")", "{", "// cert", "certFile", ":=", "name", "+", "\"", "\"", "\n", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "certFile", ")", "\n", "if", "e...
// LoadKeyPairFromDisk returns a KeyPair from disk files based on the given // name.
[ "LoadKeyPairFromDisk", "returns", "a", "KeyPair", "from", "disk", "files", "based", "on", "the", "given", "name", "." ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/tls/cert_creator.go#L232-L272
141,597
fastly/go-utils
strftime/strftime_pure.go
twoD
func twoD(p []byte, n int) []byte { if n < 10 { return append(p, ' ', '0'+byte(n)) } return strconv.AppendInt(p, int64(n), 10) }
go
func twoD(p []byte, n int) []byte { if n < 10 { return append(p, ' ', '0'+byte(n)) } return strconv.AppendInt(p, int64(n), 10) }
[ "func", "twoD", "(", "p", "[", "]", "byte", ",", "n", "int", ")", "[", "]", "byte", "{", "if", "n", "<", "10", "{", "return", "append", "(", "p", ",", "' '", ",", "'0'", "+", "byte", "(", "n", ")", ")", "\n", "}", "\n", "return", "strconv",...
// helper function to append %2d ints
[ "helper", "function", "to", "append", "%2d", "ints" ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/strftime/strftime_pure.go#L220-L225
141,598
fastly/go-utils
strftime/strftime_pure.go
zero3d
func zero3d(p []byte, n int) []byte { switch { case n < 10: p = append(p, "00"...) case n < 100: p = append(p, '0') } return strconv.AppendInt(p, int64(n), 10) }
go
func zero3d(p []byte, n int) []byte { switch { case n < 10: p = append(p, "00"...) case n < 100: p = append(p, '0') } return strconv.AppendInt(p, int64(n), 10) }
[ "func", "zero3d", "(", "p", "[", "]", "byte", ",", "n", "int", ")", "[", "]", "byte", "{", "switch", "{", "case", "n", "<", "10", ":", "p", "=", "append", "(", "p", ",", "\"", "\"", "...", ")", "\n", "case", "n", "<", "100", ":", "p", "="...
// helper function to append %03d ints
[ "helper", "function", "to", "append", "%03d", "ints" ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/strftime/strftime_pure.go#L237-L245
141,599
fastly/go-utils
suppress/suppress.go
For
func For(duration time.Duration, id string, f func(int, string)) { // WrapFor is depth 1, WrapFor(2, duration, id, f) }
go
func For(duration time.Duration, id string, f func(int, string)) { // WrapFor is depth 1, WrapFor(2, duration, id, f) }
[ "func", "For", "(", "duration", "time", ".", "Duration", ",", "id", "string", ",", "f", "func", "(", "int", ",", "string", ")", ")", "{", "// WrapFor is depth 1,", "WrapFor", "(", "2", ",", "duration", ",", "id", ",", "f", ")", "\n", "}" ]
// For aggregates repeated calls to itself and calls f once every duration // with the number of aggregated calls and the tag coalesced with the calling // file and line number
[ "For", "aggregates", "repeated", "calls", "to", "itself", "and", "calls", "f", "once", "every", "duration", "with", "the", "number", "of", "aggregated", "calls", "and", "the", "tag", "coalesced", "with", "the", "calling", "file", "and", "line", "number" ]
d95a45783239f69a867fec572fb7675bcee07d88
https://github.com/fastly/go-utils/blob/d95a45783239f69a867fec572fb7675bcee07d88/suppress/suppress.go#L33-L36