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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
124,700 | codahale/metrics | metrics.go | Snapshot | func Snapshot() (c map[string]uint64, g map[string]int64) {
hm.Lock()
defer hm.Unlock()
gm.Lock()
defer gm.Unlock()
cm.Lock()
defer cm.Unlock()
for _, init := range inits {
init()
}
c = make(map[string]uint64, len(counters)+len(counterFuncs))
for n, v := range counters {
c[n] = v
}
for n, f := rang... | go | func Snapshot() (c map[string]uint64, g map[string]int64) {
hm.Lock()
defer hm.Unlock()
gm.Lock()
defer gm.Unlock()
cm.Lock()
defer cm.Unlock()
for _, init := range inits {
init()
}
c = make(map[string]uint64, len(counters)+len(counterFuncs))
for n, v := range counters {
c[n] = v
}
for n, f := rang... | [
"func",
"Snapshot",
"(",
")",
"(",
"c",
"map",
"[",
"string",
"]",
"uint64",
",",
"g",
"map",
"[",
"string",
"]",
"int64",
")",
"{",
"hm",
".",
"Lock",
"(",
")",
"\n",
"defer",
"hm",
".",
"Unlock",
"(",
")",
"\n\n",
"gm",
".",
"Lock",
"(",
")... | // Snapshot returns a copy of the values of all registered counters and gauges. | [
"Snapshot",
"returns",
"a",
"copy",
"of",
"the",
"values",
"of",
"all",
"registered",
"counters",
"and",
"gauges",
"."
] | bc2005d86c7922adc3dd228f42f16015d8132ac8 | https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L162-L191 |
124,701 | codahale/metrics | metrics.go | Remove | func (h *Histogram) Remove() {
hm.Lock()
defer hm.Unlock()
Gauge(h.name + ".P50").Remove()
Gauge(h.name + ".P75").Remove()
Gauge(h.name + ".P90").Remove()
Gauge(h.name + ".P95").Remove()
Gauge(h.name + ".P99").Remove()
Gauge(h.name + ".P999").Remove()
delete(histograms, h.name)
} | go | func (h *Histogram) Remove() {
hm.Lock()
defer hm.Unlock()
Gauge(h.name + ".P50").Remove()
Gauge(h.name + ".P75").Remove()
Gauge(h.name + ".P90").Remove()
Gauge(h.name + ".P95").Remove()
Gauge(h.name + ".P99").Remove()
Gauge(h.name + ".P999").Remove()
delete(histograms, h.name)
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Remove",
"(",
")",
"{",
"hm",
".",
"Lock",
"(",
")",
"\n",
"defer",
"hm",
".",
"Unlock",
"(",
")",
"\n\n",
"Gauge",
"(",
"h",
".",
"name",
"+",
"\"",
"\"",
")",
".",
"Remove",
"(",
")",
"\n",
"Gauge",... | // Remove removes the given histogram. | [
"Remove",
"removes",
"the",
"given",
"histogram",
"."
] | bc2005d86c7922adc3dd228f42f16015d8132ac8 | https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L223-L236 |
124,702 | codahale/metrics | metrics.go | RecordValue | func (h *Histogram) RecordValue(v int64) error {
h.rw.Lock()
defer h.rw.Unlock()
err := h.hist.Current.RecordValue(v)
if err != nil {
return Error{h.name, err}
}
return nil
} | go | func (h *Histogram) RecordValue(v int64) error {
h.rw.Lock()
defer h.rw.Unlock()
err := h.hist.Current.RecordValue(v)
if err != nil {
return Error{h.name, err}
}
return nil
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"RecordValue",
"(",
"v",
"int64",
")",
"error",
"{",
"h",
".",
"rw",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"rw",
".",
"Unlock",
"(",
")",
"\n\n",
"err",
":=",
"h",
".",
"hist",
".",
"Current",
... | // RecordValue records the given value, or returns an error if the value is out
// of range.
// Returned error values are of type Error. | [
"RecordValue",
"records",
"the",
"given",
"value",
"or",
"returns",
"an",
"error",
"if",
"the",
"value",
"is",
"out",
"of",
"range",
".",
"Returned",
"error",
"values",
"are",
"of",
"type",
"Error",
"."
] | bc2005d86c7922adc3dd228f42f16015d8132ac8 | https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L256-L265 |
124,703 | ipfs/go-ipld-cbor | encoding/cloner.go | NewPooledCloner | func NewPooledCloner(atl atlas.Atlas) PooledCloner {
return PooledCloner{
pool: sync.Pool{
New: func() interface{} {
return refmt.NewCloner(atl)
},
},
}
} | go | func NewPooledCloner(atl atlas.Atlas) PooledCloner {
return PooledCloner{
pool: sync.Pool{
New: func() interface{} {
return refmt.NewCloner(atl)
},
},
}
} | [
"func",
"NewPooledCloner",
"(",
"atl",
"atlas",
".",
"Atlas",
")",
"PooledCloner",
"{",
"return",
"PooledCloner",
"{",
"pool",
":",
"sync",
".",
"Pool",
"{",
"New",
":",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"refmt",
".",
"NewCloner",
... | // NewPooledCloner returns a PooledCloner with the given atlas. Do not copy
// after use. | [
"NewPooledCloner",
"returns",
"a",
"PooledCloner",
"with",
"the",
"given",
"atlas",
".",
"Do",
"not",
"copy",
"after",
"use",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/cloner.go#L17-L25 |
124,704 | ipfs/go-ipld-cbor | encoding/cloner.go | Clone | func (p *PooledCloner) Clone(a, b interface{}) error {
c := p.pool.Get().(refmt.Cloner)
err := c.Clone(a, b)
p.pool.Put(c)
return err
} | go | func (p *PooledCloner) Clone(a, b interface{}) error {
c := p.pool.Get().(refmt.Cloner)
err := c.Clone(a, b)
p.pool.Put(c)
return err
} | [
"func",
"(",
"p",
"*",
"PooledCloner",
")",
"Clone",
"(",
"a",
",",
"b",
"interface",
"{",
"}",
")",
"error",
"{",
"c",
":=",
"p",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"refmt",
".",
"Cloner",
")",
"\n",
"err",
":=",
"c",
".",
"Clone",... | // Clone clones a into b using a cloner from the pool. | [
"Clone",
"clones",
"a",
"into",
"b",
"using",
"a",
"cloner",
"from",
"the",
"pool",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/cloner.go#L28-L33 |
124,705 | ipfs/go-ipld-cbor | refmt.go | RegisterCborType | func RegisterCborType(i interface{}) {
var entry *atlas.AtlasEntry
if ae, ok := i.(*atlas.AtlasEntry); ok {
entry = ae
} else {
entry = atlas.BuildEntry(i).StructMap().AutogenerateWithSortingScheme(atlas.KeySortMode_RFC7049).Complete()
}
atlasEntries = append(atlasEntries, entry)
rebuildAtlas()
} | go | func RegisterCborType(i interface{}) {
var entry *atlas.AtlasEntry
if ae, ok := i.(*atlas.AtlasEntry); ok {
entry = ae
} else {
entry = atlas.BuildEntry(i).StructMap().AutogenerateWithSortingScheme(atlas.KeySortMode_RFC7049).Complete()
}
atlasEntries = append(atlasEntries, entry)
rebuildAtlas()
} | [
"func",
"RegisterCborType",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"var",
"entry",
"*",
"atlas",
".",
"AtlasEntry",
"\n",
"if",
"ae",
",",
"ok",
":=",
"i",
".",
"(",
"*",
"atlas",
".",
"AtlasEntry",
")",
";",
"ok",
"{",
"entry",
"=",
"ae",
"\... | // RegisterCborType allows to register a custom cbor type | [
"RegisterCborType",
"allows",
"to",
"register",
"a",
"custom",
"cbor",
"type"
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/refmt.go#L63-L72 |
124,706 | ipfs/go-ipld-cbor | readable.go | HumanReadable | func HumanReadable(blob []byte) (string, error) {
reader := bytes.NewReader(blob)
var buf bytes.Buffer
writer := bufio.NewWriter(&buf)
err := shared.TokenPump{
TokenSource: cbor.NewDecoder(cbor.DecodeOptions{}, reader),
TokenSink: pretty.NewEncoder(writer),
}.Run()
if err != nil {
return "", err
}
i... | go | func HumanReadable(blob []byte) (string, error) {
reader := bytes.NewReader(blob)
var buf bytes.Buffer
writer := bufio.NewWriter(&buf)
err := shared.TokenPump{
TokenSource: cbor.NewDecoder(cbor.DecodeOptions{}, reader),
TokenSink: pretty.NewEncoder(writer),
}.Run()
if err != nil {
return "", err
}
i... | [
"func",
"HumanReadable",
"(",
"blob",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"reader",
":=",
"bytes",
".",
"NewReader",
"(",
"blob",
")",
"\n\n",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"writer",
":=",
"bufio",
".",
"NewWri... | //HumanReadable returns a string representation of a CBOR blob | [
"HumanReadable",
"returns",
"a",
"string",
"representation",
"of",
"a",
"CBOR",
"blob"
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/readable.go#L13-L33 |
124,707 | ipfs/go-ipld-cbor | node.go | WrapObject | func WrapObject(m interface{}, mhType uint64, mhLen int) (*Node, error) {
data, err := marshaller.Marshal(m)
if err != nil {
return nil, err
}
var obj interface{}
err = cloner.Clone(m, &obj)
if err != nil {
return nil, err
}
if mhType == math.MaxUint64 {
mhType = mh.SHA2_256
}
hash, err := mh.Sum(dat... | go | func WrapObject(m interface{}, mhType uint64, mhLen int) (*Node, error) {
data, err := marshaller.Marshal(m)
if err != nil {
return nil, err
}
var obj interface{}
err = cloner.Clone(m, &obj)
if err != nil {
return nil, err
}
if mhType == math.MaxUint64 {
mhType = mh.SHA2_256
}
hash, err := mh.Sum(dat... | [
"func",
"WrapObject",
"(",
"m",
"interface",
"{",
"}",
",",
"mhType",
"uint64",
",",
"mhLen",
"int",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"marshaller",
".",
"Marshal",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"n... | // WrapObject converts an arbitrary object into a Node. | [
"WrapObject",
"converts",
"an",
"arbitrary",
"object",
"into",
"a",
"Node",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L112-L141 |
124,708 | ipfs/go-ipld-cbor | node.go | Resolve | func (n *Node) Resolve(path []string) (interface{}, []string, error) {
var cur interface{} = n.obj
for i, val := range path {
switch curv := cur.(type) {
case map[string]interface{}:
next, ok := curv[val]
if !ok {
return nil, nil, ErrNoSuchLink
}
cur = next
case map[interface{}]interface{}:
... | go | func (n *Node) Resolve(path []string) (interface{}, []string, error) {
var cur interface{} = n.obj
for i, val := range path {
switch curv := cur.(type) {
case map[string]interface{}:
next, ok := curv[val]
if !ok {
return nil, nil, ErrNoSuchLink
}
cur = next
case map[interface{}]interface{}:
... | [
"func",
"(",
"n",
"*",
"Node",
")",
"Resolve",
"(",
"path",
"[",
"]",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"cur",
"interface",
"{",
"}",
"=",
"n",
".",
"obj",
"\n",
"for",
"i",
","... | // Resolve resolves a given path, and returns the object found at the end, as well
// as the possible tail of the path that was not resolved. | [
"Resolve",
"resolves",
"a",
"given",
"path",
"and",
"returns",
"the",
"object",
"found",
"at",
"the",
"end",
"as",
"well",
"as",
"the",
"possible",
"tail",
"of",
"the",
"path",
"that",
"was",
"not",
"resolved",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L145-L192 |
124,709 | ipfs/go-ipld-cbor | node.go | Copy | func (n *Node) Copy() node.Node {
links := make([]*node.Link, len(n.links))
copy(links, n.links)
raw := make([]byte, len(n.raw))
copy(raw, n.raw)
tree := make([]string, len(n.tree))
copy(tree, n.tree)
return &Node{
obj: copyObj(n.obj),
links: links,
raw: raw,
tree: tree,
cid: n.cid,
}
} | go | func (n *Node) Copy() node.Node {
links := make([]*node.Link, len(n.links))
copy(links, n.links)
raw := make([]byte, len(n.raw))
copy(raw, n.raw)
tree := make([]string, len(n.tree))
copy(tree, n.tree)
return &Node{
obj: copyObj(n.obj),
links: links,
raw: raw,
tree: tree,
cid: n.cid,
}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Copy",
"(",
")",
"node",
".",
"Node",
"{",
"links",
":=",
"make",
"(",
"[",
"]",
"*",
"node",
".",
"Link",
",",
"len",
"(",
"n",
".",
"links",
")",
")",
"\n",
"copy",
"(",
"links",
",",
"n",
".",
"links"... | // Copy creates a copy of the Node. | [
"Copy",
"creates",
"a",
"copy",
"of",
"the",
"Node",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L195-L212 |
124,710 | ipfs/go-ipld-cbor | node.go | ResolveLink | func (n *Node) ResolveLink(path []string) (*node.Link, []string, error) {
obj, rest, err := n.Resolve(path)
if err != nil {
return nil, nil, err
}
lnk, ok := obj.(*node.Link)
if !ok {
return nil, rest, ErrNonLink
}
return lnk, rest, nil
} | go | func (n *Node) ResolveLink(path []string) (*node.Link, []string, error) {
obj, rest, err := n.Resolve(path)
if err != nil {
return nil, nil, err
}
lnk, ok := obj.(*node.Link)
if !ok {
return nil, rest, ErrNonLink
}
return lnk, rest, nil
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"ResolveLink",
"(",
"path",
"[",
"]",
"string",
")",
"(",
"*",
"node",
".",
"Link",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"obj",
",",
"rest",
",",
"err",
":=",
"n",
".",
"Resolve",
"(",
"path",
"... | // ResolveLink resolves a path and returns the raw Link at the end, as well as
// the possible tail of the path that was not resolved. | [
"ResolveLink",
"resolves",
"a",
"path",
"and",
"returns",
"the",
"raw",
"Link",
"at",
"the",
"end",
"as",
"well",
"as",
"the",
"possible",
"tail",
"of",
"the",
"path",
"that",
"was",
"not",
"resolved",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L244-L256 |
124,711 | ipfs/go-ipld-cbor | node.go | Tree | func (n *Node) Tree(path string, depth int) []string {
if path == "" && depth == -1 {
return n.tree
}
var out []string
for _, t := range n.tree {
if !strings.HasPrefix(t, path) {
continue
}
sub := strings.TrimLeft(t[len(path):], "/")
if sub == "" {
continue
}
if depth < 0 {
out = append(ou... | go | func (n *Node) Tree(path string, depth int) []string {
if path == "" && depth == -1 {
return n.tree
}
var out []string
for _, t := range n.tree {
if !strings.HasPrefix(t, path) {
continue
}
sub := strings.TrimLeft(t[len(path):], "/")
if sub == "" {
continue
}
if depth < 0 {
out = append(ou... | [
"func",
"(",
"n",
"*",
"Node",
")",
"Tree",
"(",
"path",
"string",
",",
"depth",
"int",
")",
"[",
"]",
"string",
"{",
"if",
"path",
"==",
"\"",
"\"",
"&&",
"depth",
"==",
"-",
"1",
"{",
"return",
"n",
".",
"tree",
"\n",
"}",
"\n\n",
"var",
"o... | // Tree returns a flattend array of paths at the given path for the given depth. | [
"Tree",
"returns",
"a",
"flattend",
"array",
"of",
"paths",
"at",
"the",
"given",
"path",
"for",
"the",
"given",
"depth",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L259-L286 |
124,712 | ipfs/go-ipld-cbor | node.go | Size | func (n *Node) Size() (uint64, error) {
return uint64(len(n.RawData())), nil
} | go | func (n *Node) Size() (uint64, error) {
return uint64(len(n.RawData())), nil
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Size",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"uint64",
"(",
"len",
"(",
"n",
".",
"RawData",
"(",
")",
")",
")",
",",
"nil",
"\n",
"}"
] | // Size returns the size of the binary representation of the Node. | [
"Size",
"returns",
"the",
"size",
"of",
"the",
"binary",
"representation",
"of",
"the",
"Node",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L368-L370 |
124,713 | ipfs/go-ipld-cbor | node.go | MarshalJSON | func (n *Node) MarshalJSON() ([]byte, error) {
out, err := convertToJSONIsh(n.obj)
if err != nil {
return nil, err
}
return json.Marshal(out)
} | go | func (n *Node) MarshalJSON() ([]byte, error) {
out, err := convertToJSONIsh(n.obj)
if err != nil {
return nil, err
}
return json.Marshal(out)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"convertToJSONIsh",
"(",
"n",
".",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err"... | // MarshalJSON converts the Node into its JSON representation. | [
"MarshalJSON",
"converts",
"the",
"Node",
"into",
"its",
"JSON",
"representation",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L384-L391 |
124,714 | ipfs/go-ipld-cbor | node.go | FromJSON | func FromJSON(r io.Reader, mhType uint64, mhLen int) (*Node, error) {
var m interface{}
err := json.NewDecoder(r).Decode(&m)
if err != nil {
return nil, err
}
obj, err := convertToCborIshObj(m)
if err != nil {
return nil, err
}
return WrapObject(obj, mhType, mhLen)
} | go | func FromJSON(r io.Reader, mhType uint64, mhLen int) (*Node, error) {
var m interface{}
err := json.NewDecoder(r).Decode(&m)
if err != nil {
return nil, err
}
obj, err := convertToCborIshObj(m)
if err != nil {
return nil, err
}
return WrapObject(obj, mhType, mhLen)
} | [
"func",
"FromJSON",
"(",
"r",
"io",
".",
"Reader",
",",
"mhType",
"uint64",
",",
"mhLen",
"int",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"var",
"m",
"interface",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
")",
".",
... | // FromJSON converts incoming JSON into a Node. | [
"FromJSON",
"converts",
"incoming",
"JSON",
"into",
"a",
"Node",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/node.go#L455-L468 |
124,715 | ipfs/go-ipld-cbor | encoding/marshaller.go | NewMarshallerAtlased | func NewMarshallerAtlased(atl atlas.Atlas) *Marshaller {
m := new(Marshaller)
m.marshal = cbor.NewMarshallerAtlased(&m.writer, atl)
return m
} | go | func NewMarshallerAtlased(atl atlas.Atlas) *Marshaller {
m := new(Marshaller)
m.marshal = cbor.NewMarshallerAtlased(&m.writer, atl)
return m
} | [
"func",
"NewMarshallerAtlased",
"(",
"atl",
"atlas",
".",
"Atlas",
")",
"*",
"Marshaller",
"{",
"m",
":=",
"new",
"(",
"Marshaller",
")",
"\n",
"m",
".",
"marshal",
"=",
"cbor",
".",
"NewMarshallerAtlased",
"(",
"&",
"m",
".",
"writer",
",",
"atl",
")"... | // NewMarshallerAtlased constructs a new cbor Marshaller using the given atlas. | [
"NewMarshallerAtlased",
"constructs",
"a",
"new",
"cbor",
"Marshaller",
"using",
"the",
"given",
"atlas",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/marshaller.go#L27-L31 |
124,716 | ipfs/go-ipld-cbor | encoding/marshaller.go | Encode | func (m *Marshaller) Encode(obj interface{}, w io.Writer) error {
m.writer.w = w
err := m.marshal.Marshal(obj)
m.writer.w = nil
return err
} | go | func (m *Marshaller) Encode(obj interface{}, w io.Writer) error {
m.writer.w = w
err := m.marshal.Marshal(obj)
m.writer.w = nil
return err
} | [
"func",
"(",
"m",
"*",
"Marshaller",
")",
"Encode",
"(",
"obj",
"interface",
"{",
"}",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"m",
".",
"writer",
".",
"w",
"=",
"w",
"\n",
"err",
":=",
"m",
".",
"marshal",
".",
"Marshal",
"(",
"obj",... | // Encode encodes the given object to the given writer. | [
"Encode",
"encodes",
"the",
"given",
"object",
"to",
"the",
"given",
"writer",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/marshaller.go#L34-L39 |
124,717 | ipfs/go-ipld-cbor | encoding/marshaller.go | Marshal | func (m *Marshaller) Marshal(obj interface{}) ([]byte, error) {
var buf bytes.Buffer
if err := m.Encode(obj, &buf); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | go | func (m *Marshaller) Marshal(obj interface{}) ([]byte, error) {
var buf bytes.Buffer
if err := m.Encode(obj, &buf); err != nil {
return nil, err
}
return buf.Bytes(), nil
} | [
"func",
"(",
"m",
"*",
"Marshaller",
")",
"Marshal",
"(",
"obj",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"m",
".",
"Encode",
"(",
"obj",
",",
"&",... | // Marshal marshels the given object to a byte slice. | [
"Marshal",
"marshels",
"the",
"given",
"object",
"to",
"a",
"byte",
"slice",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/marshaller.go#L42-L48 |
124,718 | ipfs/go-ipld-cbor | encoding/marshaller.go | NewPooledMarshaller | func NewPooledMarshaller(atl atlas.Atlas) PooledMarshaller {
return PooledMarshaller{
pool: sync.Pool{
New: func() interface{} {
return NewMarshallerAtlased(atl)
},
},
}
} | go | func NewPooledMarshaller(atl atlas.Atlas) PooledMarshaller {
return PooledMarshaller{
pool: sync.Pool{
New: func() interface{} {
return NewMarshallerAtlased(atl)
},
},
}
} | [
"func",
"NewPooledMarshaller",
"(",
"atl",
"atlas",
".",
"Atlas",
")",
"PooledMarshaller",
"{",
"return",
"PooledMarshaller",
"{",
"pool",
":",
"sync",
".",
"Pool",
"{",
"New",
":",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"NewMarshallerAtlase... | // NewPooledMarshaller returns a PooledMarshaller with the given atlas. Do not
// copy after use. | [
"NewPooledMarshaller",
"returns",
"a",
"PooledMarshaller",
"with",
"the",
"given",
"atlas",
".",
"Do",
"not",
"copy",
"after",
"use",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/marshaller.go#L57-L65 |
124,719 | ipfs/go-ipld-cbor | encoding/marshaller.go | Marshal | func (p *PooledMarshaller) Marshal(obj interface{}) ([]byte, error) {
m := p.pool.Get().(*Marshaller)
bts, err := m.Marshal(obj)
p.pool.Put(m)
return bts, err
} | go | func (p *PooledMarshaller) Marshal(obj interface{}) ([]byte, error) {
m := p.pool.Get().(*Marshaller)
bts, err := m.Marshal(obj)
p.pool.Put(m)
return bts, err
} | [
"func",
"(",
"p",
"*",
"PooledMarshaller",
")",
"Marshal",
"(",
"obj",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"m",
":=",
"p",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Marshaller",
")",
"\n",
"bts",
... | // Marshal marshals the passed object using the pool of marshallers. | [
"Marshal",
"marshals",
"the",
"passed",
"object",
"using",
"the",
"pool",
"of",
"marshallers",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/marshaller.go#L68-L73 |
124,720 | ipfs/go-ipld-cbor | encoding/marshaller.go | Encode | func (p *PooledMarshaller) Encode(obj interface{}, w io.Writer) error {
m := p.pool.Get().(*Marshaller)
err := m.Encode(obj, w)
p.pool.Put(m)
return err
} | go | func (p *PooledMarshaller) Encode(obj interface{}, w io.Writer) error {
m := p.pool.Get().(*Marshaller)
err := m.Encode(obj, w)
p.pool.Put(m)
return err
} | [
"func",
"(",
"p",
"*",
"PooledMarshaller",
")",
"Encode",
"(",
"obj",
"interface",
"{",
"}",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"m",
":=",
"p",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Marshaller",
")",
"\n",
"err",
":=... | // Encode encodes the passed object to the given writer using the pool of
// marshallers. | [
"Encode",
"encodes",
"the",
"passed",
"object",
"to",
"the",
"given",
"writer",
"using",
"the",
"pool",
"of",
"marshallers",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/marshaller.go#L77-L82 |
124,721 | ipfs/go-ipld-cbor | encoding/unmarshaller.go | NewUnmarshallerAtlased | func NewUnmarshallerAtlased(atl atlas.Atlas) *Unmarshaller {
m := new(Unmarshaller)
m.unmarshal = cbor.NewUnmarshallerAtlased(cbor.DecodeOptions{CoerceUndefToNull: true}, &m.reader, atl)
return m
} | go | func NewUnmarshallerAtlased(atl atlas.Atlas) *Unmarshaller {
m := new(Unmarshaller)
m.unmarshal = cbor.NewUnmarshallerAtlased(cbor.DecodeOptions{CoerceUndefToNull: true}, &m.reader, atl)
return m
} | [
"func",
"NewUnmarshallerAtlased",
"(",
"atl",
"atlas",
".",
"Atlas",
")",
"*",
"Unmarshaller",
"{",
"m",
":=",
"new",
"(",
"Unmarshaller",
")",
"\n",
"m",
".",
"unmarshal",
"=",
"cbor",
".",
"NewUnmarshallerAtlased",
"(",
"cbor",
".",
"DecodeOptions",
"{",
... | // NewUnmarshallerAtlased creates a new reusable unmarshaller. | [
"NewUnmarshallerAtlased",
"creates",
"a",
"new",
"reusable",
"unmarshaller",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/unmarshaller.go#L27-L31 |
124,722 | ipfs/go-ipld-cbor | encoding/unmarshaller.go | Decode | func (m *Unmarshaller) Decode(r io.Reader, obj interface{}) error {
m.reader.r = r
err := m.unmarshal.Unmarshal(obj)
m.reader.r = nil
return err
} | go | func (m *Unmarshaller) Decode(r io.Reader, obj interface{}) error {
m.reader.r = r
err := m.unmarshal.Unmarshal(obj)
m.reader.r = nil
return err
} | [
"func",
"(",
"m",
"*",
"Unmarshaller",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"m",
".",
"reader",
".",
"r",
"=",
"r",
"\n",
"err",
":=",
"m",
".",
"unmarshal",
".",
"Unmarshal",
"(",
... | // Decode reads a CBOR object from the given reader and decodes it into the
// given object. | [
"Decode",
"reads",
"a",
"CBOR",
"object",
"from",
"the",
"given",
"reader",
"and",
"decodes",
"it",
"into",
"the",
"given",
"object",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/unmarshaller.go#L35-L40 |
124,723 | ipfs/go-ipld-cbor | encoding/unmarshaller.go | Unmarshal | func (m *Unmarshaller) Unmarshal(b []byte, obj interface{}) error {
return m.Decode(bytes.NewReader(b), obj)
} | go | func (m *Unmarshaller) Unmarshal(b []byte, obj interface{}) error {
return m.Decode(bytes.NewReader(b), obj)
} | [
"func",
"(",
"m",
"*",
"Unmarshaller",
")",
"Unmarshal",
"(",
"b",
"[",
"]",
"byte",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"m",
".",
"Decode",
"(",
"bytes",
".",
"NewReader",
"(",
"b",
")",
",",
"obj",
")",
"\n",
"}"
] | // Unmarshal unmarshals the given CBOR byte slice into the given object. | [
"Unmarshal",
"unmarshals",
"the",
"given",
"CBOR",
"byte",
"slice",
"into",
"the",
"given",
"object",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/unmarshaller.go#L43-L45 |
124,724 | ipfs/go-ipld-cbor | encoding/unmarshaller.go | NewPooledUnmarshaller | func NewPooledUnmarshaller(atl atlas.Atlas) PooledUnmarshaller {
return PooledUnmarshaller{
pool: sync.Pool{
New: func() interface{} {
return NewUnmarshallerAtlased(atl)
},
},
}
} | go | func NewPooledUnmarshaller(atl atlas.Atlas) PooledUnmarshaller {
return PooledUnmarshaller{
pool: sync.Pool{
New: func() interface{} {
return NewUnmarshallerAtlased(atl)
},
},
}
} | [
"func",
"NewPooledUnmarshaller",
"(",
"atl",
"atlas",
".",
"Atlas",
")",
"PooledUnmarshaller",
"{",
"return",
"PooledUnmarshaller",
"{",
"pool",
":",
"sync",
".",
"Pool",
"{",
"New",
":",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"NewUnmarshall... | // NewPooledUnmarshaller returns a PooledUnmarshaller with the given atlas. Do
// not copy after use. | [
"NewPooledUnmarshaller",
"returns",
"a",
"PooledUnmarshaller",
"with",
"the",
"given",
"atlas",
".",
"Do",
"not",
"copy",
"after",
"use",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/unmarshaller.go#L54-L62 |
124,725 | ipfs/go-ipld-cbor | encoding/unmarshaller.go | Decode | func (p *PooledUnmarshaller) Decode(r io.Reader, obj interface{}) error {
u := p.pool.Get().(*Unmarshaller)
err := u.Decode(r, obj)
p.pool.Put(u)
return err
} | go | func (p *PooledUnmarshaller) Decode(r io.Reader, obj interface{}) error {
u := p.pool.Get().(*Unmarshaller)
err := u.Decode(r, obj)
p.pool.Put(u)
return err
} | [
"func",
"(",
"p",
"*",
"PooledUnmarshaller",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"u",
":=",
"p",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Unmarshaller",
")",
"\n",
"err",
... | // Decode decodes an object from the passed reader into the given object using
// the pool of unmarshallers. | [
"Decode",
"decodes",
"an",
"object",
"from",
"the",
"passed",
"reader",
"into",
"the",
"given",
"object",
"using",
"the",
"pool",
"of",
"unmarshallers",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/unmarshaller.go#L66-L71 |
124,726 | ipfs/go-ipld-cbor | encoding/unmarshaller.go | Unmarshal | func (p *PooledUnmarshaller) Unmarshal(b []byte, obj interface{}) error {
u := p.pool.Get().(*Unmarshaller)
err := u.Unmarshal(b, obj)
p.pool.Put(u)
return err
} | go | func (p *PooledUnmarshaller) Unmarshal(b []byte, obj interface{}) error {
u := p.pool.Get().(*Unmarshaller)
err := u.Unmarshal(b, obj)
p.pool.Put(u)
return err
} | [
"func",
"(",
"p",
"*",
"PooledUnmarshaller",
")",
"Unmarshal",
"(",
"b",
"[",
"]",
"byte",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"u",
":=",
"p",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Unmarshaller",
")",
"\n",
"err",
... | // Unmarshal unmarshals the passed object using the pool of unmarshallers. | [
"Unmarshal",
"unmarshals",
"the",
"passed",
"object",
"using",
"the",
"pool",
"of",
"unmarshallers",
"."
] | 59d81622555073ee8fdb6eed13c728a1fedeb724 | https://github.com/ipfs/go-ipld-cbor/blob/59d81622555073ee8fdb6eed13c728a1fedeb724/encoding/unmarshaller.go#L74-L79 |
124,727 | fluent/fluent-logger-golang | fluent/fluent.go | Close | func (f *Fluent) Close() (err error) {
if f.Config.Async {
close(f.pending)
f.wg.Wait()
}
f.close()
return
} | go | func (f *Fluent) Close() (err error) {
if f.Config.Async {
close(f.pending)
f.wg.Wait()
}
f.close()
return
} | [
"func",
"(",
"f",
"*",
"Fluent",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"f",
".",
"Config",
".",
"Async",
"{",
"close",
"(",
"f",
".",
"pending",
")",
"\n",
"f",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}",
"\n",
"f",
... | // Close closes the connection, waiting for pending logs to be sent | [
"Close",
"closes",
"the",
"connection",
"waiting",
"for",
"pending",
"logs",
"to",
"be",
"sent"
] | 7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b | https://github.com/fluent/fluent-logger-golang/blob/7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b/fluent/fluent.go#L294-L301 |
124,728 | fluent/fluent-logger-golang | fluent/fluent.go | appendBuffer | func (f *Fluent) appendBuffer(msg *msgToSend) error {
select {
case f.pending <- msg:
default:
return fmt.Errorf("fluent#appendBuffer: Buffer full, limit %v", f.Config.BufferLimit)
}
return nil
} | go | func (f *Fluent) appendBuffer(msg *msgToSend) error {
select {
case f.pending <- msg:
default:
return fmt.Errorf("fluent#appendBuffer: Buffer full, limit %v", f.Config.BufferLimit)
}
return nil
} | [
"func",
"(",
"f",
"*",
"Fluent",
")",
"appendBuffer",
"(",
"msg",
"*",
"msgToSend",
")",
"error",
"{",
"select",
"{",
"case",
"f",
".",
"pending",
"<-",
"msg",
":",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"f",
".",
"... | // appendBuffer appends data to buffer with lock. | [
"appendBuffer",
"appends",
"data",
"to",
"buffer",
"with",
"lock",
"."
] | 7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b | https://github.com/fluent/fluent-logger-golang/blob/7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b/fluent/fluent.go#L304-L311 |
124,729 | fluent/fluent-logger-golang | fluent/fluent.go | close | func (f *Fluent) close() {
f.muconn.Lock()
if f.conn != nil {
f.conn.Close()
f.conn = nil
}
f.muconn.Unlock()
} | go | func (f *Fluent) close() {
f.muconn.Lock()
if f.conn != nil {
f.conn.Close()
f.conn = nil
}
f.muconn.Unlock()
} | [
"func",
"(",
"f",
"*",
"Fluent",
")",
"close",
"(",
")",
"{",
"f",
".",
"muconn",
".",
"Lock",
"(",
")",
"\n",
"if",
"f",
".",
"conn",
"!=",
"nil",
"{",
"f",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"f",
".",
"conn",
"=",
"nil",
"\n",
"... | // close closes the connection. | [
"close",
"closes",
"the",
"connection",
"."
] | 7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b | https://github.com/fluent/fluent-logger-golang/blob/7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b/fluent/fluent.go#L314-L321 |
124,730 | fluent/fluent-logger-golang | fluent/fluent.go | connect | func (f *Fluent) connect() (err error) {
switch f.Config.FluentNetwork {
case "tcp":
f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentHost+":"+strconv.Itoa(f.Config.FluentPort), f.Config.Timeout)
case "unix":
f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentSocketPath, f.... | go | func (f *Fluent) connect() (err error) {
switch f.Config.FluentNetwork {
case "tcp":
f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentHost+":"+strconv.Itoa(f.Config.FluentPort), f.Config.Timeout)
case "unix":
f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentSocketPath, f.... | [
"func",
"(",
"f",
"*",
"Fluent",
")",
"connect",
"(",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"f",
".",
"Config",
".",
"FluentNetwork",
"{",
"case",
"\"",
"\"",
":",
"f",
".",
"conn",
",",
"err",
"=",
"net",
".",
"DialTimeout",
"(",
"f",
... | // connect establishes a new connection using the specified transport. | [
"connect",
"establishes",
"a",
"new",
"connection",
"using",
"the",
"specified",
"transport",
"."
] | 7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b | https://github.com/fluent/fluent-logger-golang/blob/7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b/fluent/fluent.go#L324-L335 |
124,731 | VividCortex/gohistogram | numerichistogram.go | NewHistogram | func NewHistogram(n int) *NumericHistogram {
return &NumericHistogram{
bins: make([]bin, 0),
maxbins: n,
total: 0,
}
} | go | func NewHistogram(n int) *NumericHistogram {
return &NumericHistogram{
bins: make([]bin, 0),
maxbins: n,
total: 0,
}
} | [
"func",
"NewHistogram",
"(",
"n",
"int",
")",
"*",
"NumericHistogram",
"{",
"return",
"&",
"NumericHistogram",
"{",
"bins",
":",
"make",
"(",
"[",
"]",
"bin",
",",
"0",
")",
",",
"maxbins",
":",
"n",
",",
"total",
":",
"0",
",",
"}",
"\n",
"}"
] | // NewHistogram returns a new NumericHistogram with a maximum of n bins.
//
// There is no "optimal" bin count, but somewhere between 20 and 80 bins
// should be sufficient. | [
"NewHistogram",
"returns",
"a",
"new",
"NumericHistogram",
"with",
"a",
"maximum",
"of",
"n",
"bins",
".",
"There",
"is",
"no",
"optimal",
"bin",
"count",
"but",
"somewhere",
"between",
"20",
"and",
"80",
"bins",
"should",
"be",
"sufficient",
"."
] | 51564d9861991fb0ad0f531c99ef602d0f9866e6 | https://github.com/VividCortex/gohistogram/blob/51564d9861991fb0ad0f531c99ef602d0f9866e6/numerichistogram.go#L20-L26 |
124,732 | VividCortex/gohistogram | numerichistogram.go | Mean | func (h *NumericHistogram) Mean() float64 {
if h.total == 0 {
return 0
}
sum := 0.0
for i := range h.bins {
sum += h.bins[i].value * h.bins[i].count
}
return sum / float64(h.total)
} | go | func (h *NumericHistogram) Mean() float64 {
if h.total == 0 {
return 0
}
sum := 0.0
for i := range h.bins {
sum += h.bins[i].value * h.bins[i].count
}
return sum / float64(h.total)
} | [
"func",
"(",
"h",
"*",
"NumericHistogram",
")",
"Mean",
"(",
")",
"float64",
"{",
"if",
"h",
".",
"total",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"sum",
":=",
"0.0",
"\n\n",
"for",
"i",
":=",
"range",
"h",
".",
"bins",
"{",
"sum",
"+... | // Mean returns the sample mean of the distribution | [
"Mean",
"returns",
"the",
"sample",
"mean",
"of",
"the",
"distribution"
] | 51564d9861991fb0ad0f531c99ef602d0f9866e6 | https://github.com/VividCortex/gohistogram/blob/51564d9861991fb0ad0f531c99ef602d0f9866e6/numerichistogram.go#L79-L91 |
124,733 | VividCortex/gohistogram | numerichistogram.go | trim | func (h *NumericHistogram) trim() {
for len(h.bins) > h.maxbins {
// Find closest bins in terms of value
minDelta := 1e99
minDeltaIndex := 0
for i := range h.bins {
if i == 0 {
continue
}
if delta := h.bins[i].value - h.bins[i-1].value; delta < minDelta {
minDelta = delta
minDeltaIndex = ... | go | func (h *NumericHistogram) trim() {
for len(h.bins) > h.maxbins {
// Find closest bins in terms of value
minDelta := 1e99
minDeltaIndex := 0
for i := range h.bins {
if i == 0 {
continue
}
if delta := h.bins[i].value - h.bins[i-1].value; delta < minDelta {
minDelta = delta
minDeltaIndex = ... | [
"func",
"(",
"h",
"*",
"NumericHistogram",
")",
"trim",
"(",
")",
"{",
"for",
"len",
"(",
"h",
".",
"bins",
")",
">",
"h",
".",
"maxbins",
"{",
"// Find closest bins in terms of value",
"minDelta",
":=",
"1e99",
"\n",
"minDeltaIndex",
":=",
"0",
"\n",
"f... | // trim merges adjacent bins to decrease the bin count to the maximum value | [
"trim",
"merges",
"adjacent",
"bins",
"to",
"decrease",
"the",
"bin",
"count",
"to",
"the",
"maximum",
"value"
] | 51564d9861991fb0ad0f531c99ef602d0f9866e6 | https://github.com/VividCortex/gohistogram/blob/51564d9861991fb0ad0f531c99ef602d0f9866e6/numerichistogram.go#L114-L144 |
124,734 | VividCortex/gohistogram | numerichistogram.go | String | func (h *NumericHistogram) String() (str string) {
str += fmt.Sprintln("Total:", h.total)
for i := range h.bins {
var bar string
for j := 0; j < int(float64(h.bins[i].count)/float64(h.total)*200); j++ {
bar += "."
}
str += fmt.Sprintln(h.bins[i].value, "\t", bar)
}
return
} | go | func (h *NumericHistogram) String() (str string) {
str += fmt.Sprintln("Total:", h.total)
for i := range h.bins {
var bar string
for j := 0; j < int(float64(h.bins[i].count)/float64(h.total)*200); j++ {
bar += "."
}
str += fmt.Sprintln(h.bins[i].value, "\t", bar)
}
return
} | [
"func",
"(",
"h",
"*",
"NumericHistogram",
")",
"String",
"(",
")",
"(",
"str",
"string",
")",
"{",
"str",
"+=",
"fmt",
".",
"Sprintln",
"(",
"\"",
"\"",
",",
"h",
".",
"total",
")",
"\n\n",
"for",
"i",
":=",
"range",
"h",
".",
"bins",
"{",
"va... | // String returns a string reprentation of the histogram,
// which is useful for printing to a terminal. | [
"String",
"returns",
"a",
"string",
"reprentation",
"of",
"the",
"histogram",
"which",
"is",
"useful",
"for",
"printing",
"to",
"a",
"terminal",
"."
] | 51564d9861991fb0ad0f531c99ef602d0f9866e6 | https://github.com/VividCortex/gohistogram/blob/51564d9861991fb0ad0f531c99ef602d0f9866e6/numerichistogram.go#L148-L160 |
124,735 | VividCortex/gohistogram | weightedhistogram.go | CDF | func (h *WeightedHistogram) CDF(x float64) float64 {
count := 0.0
for i := range h.bins {
if h.bins[i].value <= x {
count += float64(h.bins[i].count)
}
}
return count / h.total
} | go | func (h *WeightedHistogram) CDF(x float64) float64 {
count := 0.0
for i := range h.bins {
if h.bins[i].value <= x {
count += float64(h.bins[i].count)
}
}
return count / h.total
} | [
"func",
"(",
"h",
"*",
"WeightedHistogram",
")",
"CDF",
"(",
"x",
"float64",
")",
"float64",
"{",
"count",
":=",
"0.0",
"\n",
"for",
"i",
":=",
"range",
"h",
".",
"bins",
"{",
"if",
"h",
".",
"bins",
"[",
"i",
"]",
".",
"value",
"<=",
"x",
"{",... | // CDF returns the value of the cumulative distribution function
// at x | [
"CDF",
"returns",
"the",
"value",
"of",
"the",
"cumulative",
"distribution",
"function",
"at",
"x"
] | 51564d9861991fb0ad0f531c99ef602d0f9866e6 | https://github.com/VividCortex/gohistogram/blob/51564d9861991fb0ad0f531c99ef602d0f9866e6/weightedhistogram.go#L92-L101 |
124,736 | wvanbergen/kafka | consumergroup/utils.go | dividePartitionsBetweenConsumers | func dividePartitionsBetweenConsumers(consumers kazoo.ConsumergroupInstanceList, partitions partitionLeaders) map[string][]*kazoo.Partition {
result := make(map[string][]*kazoo.Partition)
plen := len(partitions)
clen := len(consumers)
if clen == 0 {
return result
}
sort.Sort(partitions)
sort.Sort(consumers)
... | go | func dividePartitionsBetweenConsumers(consumers kazoo.ConsumergroupInstanceList, partitions partitionLeaders) map[string][]*kazoo.Partition {
result := make(map[string][]*kazoo.Partition)
plen := len(partitions)
clen := len(consumers)
if clen == 0 {
return result
}
sort.Sort(partitions)
sort.Sort(consumers)
... | [
"func",
"dividePartitionsBetweenConsumers",
"(",
"consumers",
"kazoo",
".",
"ConsumergroupInstanceList",
",",
"partitions",
"partitionLeaders",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"kazoo",
".",
"Partition",
"{",
"result",
":=",
"make",
"(",
"map",
"["... | // Divides a set of partitions between a set of consumers. | [
"Divides",
"a",
"set",
"of",
"partitions",
"between",
"a",
"set",
"of",
"consumers",
"."
] | e2edea948ddfee841ea9a263b32ccca15f7d6c2f | https://github.com/wvanbergen/kafka/blob/e2edea948ddfee841ea9a263b32ccca15f7d6c2f/consumergroup/utils.go#L30-L62 |
124,737 | wvanbergen/kafka | consumergroup/offset_manager.go | NewZookeeperOffsetManager | func NewZookeeperOffsetManager(cg *ConsumerGroup, config *OffsetManagerConfig) OffsetManager {
if config == nil {
config = NewOffsetManagerConfig()
}
zom := &zookeeperOffsetManager{
config: config,
cg: cg,
offsets: make(offsetsMap),
closing: make(chan struct{}),
closed: make(chan struct{}),
... | go | func NewZookeeperOffsetManager(cg *ConsumerGroup, config *OffsetManagerConfig) OffsetManager {
if config == nil {
config = NewOffsetManagerConfig()
}
zom := &zookeeperOffsetManager{
config: config,
cg: cg,
offsets: make(offsetsMap),
closing: make(chan struct{}),
closed: make(chan struct{}),
... | [
"func",
"NewZookeeperOffsetManager",
"(",
"cg",
"*",
"ConsumerGroup",
",",
"config",
"*",
"OffsetManagerConfig",
")",
"OffsetManager",
"{",
"if",
"config",
"==",
"nil",
"{",
"config",
"=",
"NewOffsetManagerConfig",
"(",
")",
"\n",
"}",
"\n\n",
"zom",
":=",
"&"... | // NewZookeeperOffsetManager returns an offset manager that uses Zookeeper
// to store offsets. | [
"NewZookeeperOffsetManager",
"returns",
"an",
"offset",
"manager",
"that",
"uses",
"Zookeeper",
"to",
"store",
"offsets",
"."
] | e2edea948ddfee841ea9a263b32ccca15f7d6c2f | https://github.com/wvanbergen/kafka/blob/e2edea948ddfee841ea9a263b32ccca15f7d6c2f/consumergroup/offset_manager.go#L91-L109 |
124,738 | wvanbergen/kafka | consumergroup/offset_manager.go | markAsProcessed | func (pot *partitionOffsetTracker) markAsProcessed(offset int64) bool {
pot.l.Lock()
defer pot.l.Unlock()
if offset > pot.highestProcessedOffset {
pot.highestProcessedOffset = offset
if pot.waitingForOffset == pot.highestProcessedOffset {
close(pot.done)
}
return true
} else {
return false
}
} | go | func (pot *partitionOffsetTracker) markAsProcessed(offset int64) bool {
pot.l.Lock()
defer pot.l.Unlock()
if offset > pot.highestProcessedOffset {
pot.highestProcessedOffset = offset
if pot.waitingForOffset == pot.highestProcessedOffset {
close(pot.done)
}
return true
} else {
return false
}
} | [
"func",
"(",
"pot",
"*",
"partitionOffsetTracker",
")",
"markAsProcessed",
"(",
"offset",
"int64",
")",
"bool",
"{",
"pot",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pot",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"if",
"offset",
">",
"pot",
... | // MarkAsProcessed marks the provided offset as highest processed offset if
// it's higher than any previous offset it has received. | [
"MarkAsProcessed",
"marks",
"the",
"provided",
"offset",
"as",
"highest",
"processed",
"offset",
"if",
"it",
"s",
"higher",
"than",
"any",
"previous",
"offset",
"it",
"has",
"received",
"."
] | e2edea948ddfee841ea9a263b32ccca15f7d6c2f | https://github.com/wvanbergen/kafka/blob/e2edea948ddfee841ea9a263b32ccca15f7d6c2f/consumergroup/offset_manager.go#L252-L264 |
124,739 | wvanbergen/kafka | consumergroup/offset_manager.go | commit | func (pot *partitionOffsetTracker) commit(committer offsetCommitter) error {
pot.l.Lock()
defer pot.l.Unlock()
if pot.highestProcessedOffset > pot.lastCommittedOffset {
if err := committer(pot.highestProcessedOffset); err != nil {
return err
}
pot.lastCommittedOffset = pot.highestProcessedOffset
return n... | go | func (pot *partitionOffsetTracker) commit(committer offsetCommitter) error {
pot.l.Lock()
defer pot.l.Unlock()
if pot.highestProcessedOffset > pot.lastCommittedOffset {
if err := committer(pot.highestProcessedOffset); err != nil {
return err
}
pot.lastCommittedOffset = pot.highestProcessedOffset
return n... | [
"func",
"(",
"pot",
"*",
"partitionOffsetTracker",
")",
"commit",
"(",
"committer",
"offsetCommitter",
")",
"error",
"{",
"pot",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pot",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"pot",
".",
"high... | // Commit calls a committer function if the highest processed offset is out
// of sync with the last committed offset. | [
"Commit",
"calls",
"a",
"committer",
"function",
"if",
"the",
"highest",
"processed",
"offset",
"is",
"out",
"of",
"sync",
"with",
"the",
"last",
"committed",
"offset",
"."
] | e2edea948ddfee841ea9a263b32ccca15f7d6c2f | https://github.com/wvanbergen/kafka/blob/e2edea948ddfee841ea9a263b32ccca15f7d6c2f/consumergroup/offset_manager.go#L268-L281 |
124,740 | wvanbergen/kafka | consumergroup/consumer_group.go | JoinConsumerGroup | func JoinConsumerGroup(name string, topics []string, zookeeper []string, config *Config) (cg *ConsumerGroup, err error) {
if name == "" {
return nil, sarama.ConfigurationError("Empty consumergroup name")
}
if len(topics) == 0 {
return nil, sarama.ConfigurationError("No topics provided")
}
if len(zookeeper) ... | go | func JoinConsumerGroup(name string, topics []string, zookeeper []string, config *Config) (cg *ConsumerGroup, err error) {
if name == "" {
return nil, sarama.ConfigurationError("Empty consumergroup name")
}
if len(topics) == 0 {
return nil, sarama.ConfigurationError("No topics provided")
}
if len(zookeeper) ... | [
"func",
"JoinConsumerGroup",
"(",
"name",
"string",
",",
"topics",
"[",
"]",
"string",
",",
"zookeeper",
"[",
"]",
"string",
",",
"config",
"*",
"Config",
")",
"(",
"cg",
"*",
"ConsumerGroup",
",",
"err",
"error",
")",
"{",
"if",
"name",
"==",
"\"",
... | // Connects to a consumer group, using Zookeeper for auto-discovery | [
"Connects",
"to",
"a",
"consumer",
"group",
"using",
"Zookeeper",
"for",
"auto",
"-",
"discovery"
] | e2edea948ddfee841ea9a263b32ccca15f7d6c2f | https://github.com/wvanbergen/kafka/blob/e2edea948ddfee841ea9a263b32ccca15f7d6c2f/consumergroup/consumer_group.go#L86-L182 |
124,741 | wvanbergen/kafka | consumergroup/consumer_group.go | partitionConsumer | func (cg *ConsumerGroup) partitionConsumer(topic string, partition int32, messages chan<- *sarama.ConsumerMessage, errors chan<- error, wg *sync.WaitGroup, stopper <-chan struct{}) {
defer wg.Done()
// Since ProcessingTimeout is the amount of time we'll wait for the final batch
// of messages to be processed before... | go | func (cg *ConsumerGroup) partitionConsumer(topic string, partition int32, messages chan<- *sarama.ConsumerMessage, errors chan<- error, wg *sync.WaitGroup, stopper <-chan struct{}) {
defer wg.Done()
// Since ProcessingTimeout is the amount of time we'll wait for the final batch
// of messages to be processed before... | [
"func",
"(",
"cg",
"*",
"ConsumerGroup",
")",
"partitionConsumer",
"(",
"topic",
"string",
",",
"partition",
"int32",
",",
"messages",
"chan",
"<-",
"*",
"sarama",
".",
"ConsumerMessage",
",",
"errors",
"chan",
"<-",
"error",
",",
"wg",
"*",
"sync",
".",
... | // Consumes a partition | [
"Consumes",
"a",
"partition"
] | e2edea948ddfee841ea9a263b32ccca15f7d6c2f | https://github.com/wvanbergen/kafka/blob/e2edea948ddfee841ea9a263b32ccca15f7d6c2f/consumergroup/consumer_group.go#L377-L512 |
124,742 | ulule/deepcopier | deepcopier.go | WithContext | func (dc *DeepCopier) WithContext(ctx map[string]interface{}) *DeepCopier {
dc.ctx = ctx
return dc
} | go | func (dc *DeepCopier) WithContext(ctx map[string]interface{}) *DeepCopier {
dc.ctx = ctx
return dc
} | [
"func",
"(",
"dc",
"*",
"DeepCopier",
")",
"WithContext",
"(",
"ctx",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"DeepCopier",
"{",
"dc",
".",
"ctx",
"=",
"ctx",
"\n",
"return",
"dc",
"\n",
"}"
] | // WithContext injects the given context into the builder instance. | [
"WithContext",
"injects",
"the",
"given",
"context",
"into",
"the",
"builder",
"instance",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L49-L52 |
124,743 | ulule/deepcopier | deepcopier.go | To | func (dc *DeepCopier) To(dst interface{}) error {
dc.dst = dst
return process(dc.dst, dc.src, Options{Context: dc.ctx})
} | go | func (dc *DeepCopier) To(dst interface{}) error {
dc.dst = dst
return process(dc.dst, dc.src, Options{Context: dc.ctx})
} | [
"func",
"(",
"dc",
"*",
"DeepCopier",
")",
"To",
"(",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"dc",
".",
"dst",
"=",
"dst",
"\n",
"return",
"process",
"(",
"dc",
".",
"dst",
",",
"dc",
".",
"src",
",",
"Options",
"{",
"Context",
":",
"... | // To sets the destination. | [
"To",
"sets",
"the",
"destination",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L55-L58 |
124,744 | ulule/deepcopier | deepcopier.go | From | func (dc *DeepCopier) From(src interface{}) error {
dc.dst = dc.src
dc.src = src
return process(dc.dst, dc.src, Options{Context: dc.ctx, Reversed: true})
} | go | func (dc *DeepCopier) From(src interface{}) error {
dc.dst = dc.src
dc.src = src
return process(dc.dst, dc.src, Options{Context: dc.ctx, Reversed: true})
} | [
"func",
"(",
"dc",
"*",
"DeepCopier",
")",
"From",
"(",
"src",
"interface",
"{",
"}",
")",
"error",
"{",
"dc",
".",
"dst",
"=",
"dc",
".",
"src",
"\n",
"dc",
".",
"src",
"=",
"src",
"\n",
"return",
"process",
"(",
"dc",
".",
"dst",
",",
"dc",
... | // From sets the given the source as destination and destination as source. | [
"From",
"sets",
"the",
"given",
"the",
"source",
"as",
"destination",
"and",
"destination",
"as",
"source",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L61-L65 |
124,745 | ulule/deepcopier | deepcopier.go | getTagOptions | func getTagOptions(value string) TagOptions {
options := TagOptions{}
for _, opt := range strings.Split(value, ";") {
o := strings.Split(opt, ":")
// deepcopier:"keyword; without; value;"
if len(o) == 1 {
options[o[0]] = ""
}
// deepcopier:"key:value; anotherkey:anothervalue"
if len(o) == 2 {
opt... | go | func getTagOptions(value string) TagOptions {
options := TagOptions{}
for _, opt := range strings.Split(value, ";") {
o := strings.Split(opt, ":")
// deepcopier:"keyword; without; value;"
if len(o) == 1 {
options[o[0]] = ""
}
// deepcopier:"key:value; anotherkey:anothervalue"
if len(o) == 2 {
opt... | [
"func",
"getTagOptions",
"(",
"value",
"string",
")",
"TagOptions",
"{",
"options",
":=",
"TagOptions",
"{",
"}",
"\n\n",
"for",
"_",
",",
"opt",
":=",
"range",
"strings",
".",
"Split",
"(",
"value",
",",
"\"",
"\"",
")",
"{",
"o",
":=",
"strings",
"... | // getTagOptions parses deepcopier tag field and returns options. | [
"getTagOptions",
"parses",
"deepcopier",
"tag",
"field",
"and",
"returns",
"options",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L260-L278 |
124,746 | ulule/deepcopier | deepcopier.go | getRelatedField | func getRelatedField(instance interface{}, name string) (string, TagOptions) {
var (
value = reflect.Indirect(reflect.ValueOf(instance))
fieldName string
tagOptions TagOptions
)
for i := 0; i < value.NumField(); i++ {
var (
vField = value.Field(i)
tField = value.Type().Field(i)
tagOpt... | go | func getRelatedField(instance interface{}, name string) (string, TagOptions) {
var (
value = reflect.Indirect(reflect.ValueOf(instance))
fieldName string
tagOptions TagOptions
)
for i := 0; i < value.NumField(); i++ {
var (
vField = value.Field(i)
tField = value.Type().Field(i)
tagOpt... | [
"func",
"getRelatedField",
"(",
"instance",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"(",
"string",
",",
"TagOptions",
")",
"{",
"var",
"(",
"value",
"=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"instance",
")",
")",
... | // getRelatedField returns first matching field. | [
"getRelatedField",
"returns",
"first",
"matching",
"field",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L281-L311 |
124,747 | ulule/deepcopier | deepcopier.go | getMethodNames | func getMethodNames(instance interface{}) []string {
var methods []string
t := reflect.TypeOf(instance)
for i := 0; i < t.NumMethod(); i++ {
methods = append(methods, t.Method(i).Name)
}
return methods
} | go | func getMethodNames(instance interface{}) []string {
var methods []string
t := reflect.TypeOf(instance)
for i := 0; i < t.NumMethod(); i++ {
methods = append(methods, t.Method(i).Name)
}
return methods
} | [
"func",
"getMethodNames",
"(",
"instance",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"var",
"methods",
"[",
"]",
"string",
"\n\n",
"t",
":=",
"reflect",
".",
"TypeOf",
"(",
"instance",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"t"... | // getMethodNames returns instance's method names. | [
"getMethodNames",
"returns",
"instance",
"s",
"method",
"names",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L314-L323 |
124,748 | ulule/deepcopier | deepcopier.go | getFieldNames | func getFieldNames(instance interface{}) []string {
var (
fields []string
v = reflect.Indirect(reflect.ValueOf(instance))
t = v.Type()
)
if t.Kind() != reflect.Struct {
return nil
}
for i := 0; i < v.NumField(); i++ {
var (
vField = v.Field(i)
tField = v.Type().Field(i)
)
// Is exp... | go | func getFieldNames(instance interface{}) []string {
var (
fields []string
v = reflect.Indirect(reflect.ValueOf(instance))
t = v.Type()
)
if t.Kind() != reflect.Struct {
return nil
}
for i := 0; i < v.NumField(); i++ {
var (
vField = v.Field(i)
tField = v.Type().Field(i)
)
// Is exp... | [
"func",
"getFieldNames",
"(",
"instance",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"var",
"(",
"fields",
"[",
"]",
"string",
"\n",
"v",
"=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"instance",
")",
")",
"\n",
"t",... | // getFieldNames returns instance's field names. | [
"getFieldNames",
"returns",
"instance",
"s",
"field",
"names",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L326-L357 |
124,749 | ulule/deepcopier | deepcopier.go | isNullableType | func isNullableType(t reflect.Type) bool {
return t.ConvertibleTo(reflect.TypeOf((*driver.Valuer)(nil)).Elem())
} | go | func isNullableType(t reflect.Type) bool {
return t.ConvertibleTo(reflect.TypeOf((*driver.Valuer)(nil)).Elem())
} | [
"func",
"isNullableType",
"(",
"t",
"reflect",
".",
"Type",
")",
"bool",
"{",
"return",
"t",
".",
"ConvertibleTo",
"(",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"driver",
".",
"Valuer",
")",
"(",
"nil",
")",
")",
".",
"Elem",
"(",
")",
")",
"\n",
... | // isNullableType returns true if the given type is a nullable one. | [
"isNullableType",
"returns",
"true",
"if",
"the",
"given",
"type",
"is",
"a",
"nullable",
"one",
"."
] | ca99b135e50f526fde9cd88705f0ff2f3f95b77c | https://github.com/ulule/deepcopier/blob/ca99b135e50f526fde9cd88705f0ff2f3f95b77c/deepcopier.go#L360-L362 |
124,750 | goji/httpauth | basic_auth.go | ServeHTTP | func (b basicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Check if we have a user-provided error handler, else set a default
if b.opts.UnauthorizedHandler == nil {
b.opts.UnauthorizedHandler = http.HandlerFunc(defaultUnauthorizedHandler)
}
// Check that the provided details match
if b.authentica... | go | func (b basicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Check if we have a user-provided error handler, else set a default
if b.opts.UnauthorizedHandler == nil {
b.opts.UnauthorizedHandler = http.HandlerFunc(defaultUnauthorizedHandler)
}
// Check that the provided details match
if b.authentica... | [
"func",
"(",
"b",
"basicAuth",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Check if we have a user-provided error handler, else set a default",
"if",
"b",
".",
"opts",
".",
"UnauthorizedHandler",
... | // Satisfies the http.Handler interface for basicAuth. | [
"Satisfies",
"the",
"http",
".",
"Handler",
"interface",
"for",
"basicAuth",
"."
] | 2da839ab0f4df05a6db5eb277995589dadbd4fb9 | https://github.com/goji/httpauth/blob/2da839ab0f4df05a6db5eb277995589dadbd4fb9/basic_auth.go#L31-L45 |
124,751 | goji/httpauth | basic_auth.go | simpleBasicAuthFunc | func (b *basicAuth) simpleBasicAuthFunc(user, pass string, r *http.Request) bool {
// Equalize lengths of supplied and required credentials
// by hashing them
givenUser := sha256.Sum256([]byte(user))
givenPass := sha256.Sum256([]byte(pass))
requiredUser := sha256.Sum256([]byte(b.opts.User))
requiredPass := sha256... | go | func (b *basicAuth) simpleBasicAuthFunc(user, pass string, r *http.Request) bool {
// Equalize lengths of supplied and required credentials
// by hashing them
givenUser := sha256.Sum256([]byte(user))
givenPass := sha256.Sum256([]byte(pass))
requiredUser := sha256.Sum256([]byte(b.opts.User))
requiredPass := sha256... | [
"func",
"(",
"b",
"*",
"basicAuth",
")",
"simpleBasicAuthFunc",
"(",
"user",
",",
"pass",
"string",
",",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"// Equalize lengths of supplied and required credentials",
"// by hashing them",
"givenUser",
":=",
"sha256"... | // simpleBasicAuthFunc authenticates the supplied username and password against
// the User and Password set in the Options struct. | [
"simpleBasicAuthFunc",
"authenticates",
"the",
"supplied",
"username",
"and",
"password",
"against",
"the",
"User",
"and",
"Password",
"set",
"in",
"the",
"Options",
"struct",
"."
] | 2da839ab0f4df05a6db5eb277995589dadbd4fb9 | https://github.com/goji/httpauth/blob/2da839ab0f4df05a6db5eb277995589dadbd4fb9/basic_auth.go#L97-L112 |
124,752 | goji/httpauth | basic_auth.go | requestAuth | func (b *basicAuth) requestAuth(w http.ResponseWriter, r *http.Request) {
w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm=%q`, b.opts.Realm))
b.opts.UnauthorizedHandler.ServeHTTP(w, r)
} | go | func (b *basicAuth) requestAuth(w http.ResponseWriter, r *http.Request) {
w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm=%q`, b.opts.Realm))
b.opts.UnauthorizedHandler.ServeHTTP(w, r)
} | [
"func",
"(",
"b",
"*",
"basicAuth",
")",
"requestAuth",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"`Basic ... | // Require authentication, and serve our error handler otherwise. | [
"Require",
"authentication",
"and",
"serve",
"our",
"error",
"handler",
"otherwise",
"."
] | 2da839ab0f4df05a6db5eb277995589dadbd4fb9 | https://github.com/goji/httpauth/blob/2da839ab0f4df05a6db5eb277995589dadbd4fb9/basic_auth.go#L115-L118 |
124,753 | goji/httpauth | basic_auth.go | defaultUnauthorizedHandler | func defaultUnauthorizedHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
} | go | func defaultUnauthorizedHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
} | [
"func",
"defaultUnauthorizedHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"http",
".",
"Error",
"(",
"w",
",",
"http",
".",
"StatusText",
"(",
"http",
".",
"StatusUnauthorized",
")",
",",
"http",
".",... | // defaultUnauthorizedHandler provides a default HTTP 401 Unauthorized response. | [
"defaultUnauthorizedHandler",
"provides",
"a",
"default",
"HTTP",
"401",
"Unauthorized",
"response",
"."
] | 2da839ab0f4df05a6db5eb277995589dadbd4fb9 | https://github.com/goji/httpauth/blob/2da839ab0f4df05a6db5eb277995589dadbd4fb9/basic_auth.go#L121-L123 |
124,754 | yalp/jsonpath | jsonpath.go | Prepare | func Prepare(path string) (FilterFunc, error) {
p := newScanner(path)
if err := p.parse(); err != nil {
return nil, err
}
return p.prepareFilterFunc(), nil
} | go | func Prepare(path string) (FilterFunc, error) {
p := newScanner(path)
if err := p.parse(); err != nil {
return nil, err
}
return p.prepareFilterFunc(), nil
} | [
"func",
"Prepare",
"(",
"path",
"string",
")",
"(",
"FilterFunc",
",",
"error",
")",
"{",
"p",
":=",
"newScanner",
"(",
"path",
")",
"\n",
"if",
"err",
":=",
"p",
".",
"parse",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // Prepare will parse the path and return a filter function that can then be applied to decoded JSON values. | [
"Prepare",
"will",
"parse",
"the",
"path",
"and",
"return",
"a",
"filter",
"function",
"that",
"can",
"then",
"be",
"applied",
"to",
"decoded",
"JSON",
"values",
"."
] | 5cc68e5049a040829faef3a44c00ec4332f6dec7 | https://github.com/yalp/jsonpath/blob/5cc68e5049a040829faef3a44c00ec4332f6dec7/jsonpath.go#L51-L57 |
124,755 | yalp/jsonpath | jsonpath.go | next | func (a actions) next(r, c interface{}) (interface{}, error) {
return a[0](r, c, a[1:])
} | go | func (a actions) next(r, c interface{}) (interface{}, error) {
return a[0](r, c, a[1:])
} | [
"func",
"(",
"a",
"actions",
")",
"next",
"(",
"r",
",",
"c",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"a",
"[",
"0",
"]",
"(",
"r",
",",
"c",
",",
"a",
"[",
"1",
":",
"]",
")",
"\n",
"}"
] | // next applies the next action function | [
"next",
"applies",
"the",
"next",
"action",
"function"
] | 5cc68e5049a040829faef3a44c00ec4332f6dec7 | https://github.com/yalp/jsonpath/blob/5cc68e5049a040829faef3a44c00ec4332f6dec7/jsonpath.go#L77-L79 |
124,756 | yalp/jsonpath | jsonpath.go | call | func (a actions) call(r, c interface{}) (interface{}, error) {
return a[0](r, c, a)
} | go | func (a actions) call(r, c interface{}) (interface{}, error) {
return a[0](r, c, a)
} | [
"func",
"(",
"a",
"actions",
")",
"call",
"(",
"r",
",",
"c",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"a",
"[",
"0",
"]",
"(",
"r",
",",
"c",
",",
"a",
")",
"\n",
"}"
] | // call applies the next action function without taking it out | [
"call",
"applies",
"the",
"next",
"action",
"function",
"without",
"taking",
"it",
"out"
] | 5cc68e5049a040829faef3a44c00ec4332f6dec7 | https://github.com/yalp/jsonpath/blob/5cc68e5049a040829faef3a44c00ec4332f6dec7/jsonpath.go#L82-L84 |
124,757 | yalp/jsonpath | jsonpath.go | parseBracket | func (p *parser) parseBracket() error {
if p.peek() == '?' {
return p.parseFilter()
} else if p.peek() == '*' {
p.scan() // eat *
if p.scan() != ']' {
return fmt.Errorf("expected closing bracket after [* at %d", p.column())
}
return p.prepareWildcard()
}
return p.parseArray()
} | go | func (p *parser) parseBracket() error {
if p.peek() == '?' {
return p.parseFilter()
} else if p.peek() == '*' {
p.scan() // eat *
if p.scan() != ']' {
return fmt.Errorf("expected closing bracket after [* at %d", p.column())
}
return p.prepareWildcard()
}
return p.parseArray()
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"parseBracket",
"(",
")",
"error",
"{",
"if",
"p",
".",
"peek",
"(",
")",
"==",
"'?'",
"{",
"return",
"p",
".",
"parseFilter",
"(",
")",
"\n",
"}",
"else",
"if",
"p",
".",
"peek",
"(",
")",
"==",
"'*'",
"... | // bracket contains filter, wildcard or array access | [
"bracket",
"contains",
"filter",
"wildcard",
"or",
"array",
"access"
] | 5cc68e5049a040829faef3a44c00ec4332f6dec7 | https://github.com/yalp/jsonpath/blob/5cc68e5049a040829faef3a44c00ec4332f6dec7/jsonpath.go#L247-L258 |
124,758 | jmoiron/modl | transaction.go | Rollback | func (t *Transaction) Rollback() error {
t.dbmap.trace("rollback;")
return t.Tx.Rollback()
} | go | func (t *Transaction) Rollback() error {
t.dbmap.trace("rollback;")
return t.Tx.Rollback()
} | [
"func",
"(",
"t",
"*",
"Transaction",
")",
"Rollback",
"(",
")",
"error",
"{",
"t",
".",
"dbmap",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"return",
"t",
".",
"Tx",
".",
"Rollback",
"(",
")",
"\n",
"}"
] | // Rollback rolls back the underlying database transaction. | [
"Rollback",
"rolls",
"back",
"the",
"underlying",
"database",
"transaction",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/transaction.go#L60-L63 |
124,759 | jmoiron/modl | dbmap.go | NewDbMap | func NewDbMap(db *sql.DB, dialect Dialect) *DbMap {
return &DbMap{
Db: db,
Dialect: dialect,
Dbx: sqlx.NewDb(db, dialect.DriverName()),
mapper: reflectx.NewMapperFunc("db", sqlx.NameMapper),
}
} | go | func NewDbMap(db *sql.DB, dialect Dialect) *DbMap {
return &DbMap{
Db: db,
Dialect: dialect,
Dbx: sqlx.NewDb(db, dialect.DriverName()),
mapper: reflectx.NewMapperFunc("db", sqlx.NameMapper),
}
} | [
"func",
"NewDbMap",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"dialect",
"Dialect",
")",
"*",
"DbMap",
"{",
"return",
"&",
"DbMap",
"{",
"Db",
":",
"db",
",",
"Dialect",
":",
"dialect",
",",
"Dbx",
":",
"sqlx",
".",
"NewDb",
"(",
"db",
",",
"dialect... | // NewDbMap returns a new DbMap using the db connection and dialect. | [
"NewDbMap",
"returns",
"a",
"new",
"DbMap",
"using",
"the",
"db",
"connection",
"and",
"dialect",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L53-L60 |
124,760 | jmoiron/modl | dbmap.go | TraceOn | func (m *DbMap) TraceOn(prefix string, logger *log.Logger) {
m.logger = logger
if len(prefix) == 0 {
m.logPrefix = prefix
} else {
m.logPrefix = prefix + " "
}
} | go | func (m *DbMap) TraceOn(prefix string, logger *log.Logger) {
m.logger = logger
if len(prefix) == 0 {
m.logPrefix = prefix
} else {
m.logPrefix = prefix + " "
}
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"TraceOn",
"(",
"prefix",
"string",
",",
"logger",
"*",
"log",
".",
"Logger",
")",
"{",
"m",
".",
"logger",
"=",
"logger",
"\n",
"if",
"len",
"(",
"prefix",
")",
"==",
"0",
"{",
"m",
".",
"logPrefix",
"=",
"... | // TraceOn turns on SQL statement logging for this DbMap. After this is
// called, all SQL statements will be sent to the logger. If prefix is
// a non-empty string, it will be written to the front of all logged
// strings, which can aid in filtering log lines.
//
// Use TraceOn if you want to spy on the SQL statemen... | [
"TraceOn",
"turns",
"on",
"SQL",
"statement",
"logging",
"for",
"this",
"DbMap",
".",
"After",
"this",
"is",
"called",
"all",
"SQL",
"statements",
"will",
"be",
"sent",
"to",
"the",
"logger",
".",
"If",
"prefix",
"is",
"a",
"non",
"-",
"empty",
"string",... | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L69-L76 |
124,761 | jmoiron/modl | dbmap.go | AddTableWithName | func (m *DbMap) AddTableWithName(i interface{}, name string) *TableMap {
return m.AddTable(i, name)
} | go | func (m *DbMap) AddTableWithName(i interface{}, name string) *TableMap {
return m.AddTable(i, name)
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"AddTableWithName",
"(",
"i",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"*",
"TableMap",
"{",
"return",
"m",
".",
"AddTable",
"(",
"i",
",",
"name",
")",
"\n",
"}"
] | // AddTableWithName adds a new mapping of the interface to a table name. | [
"AddTableWithName",
"adds",
"a",
"new",
"mapping",
"of",
"the",
"interface",
"to",
"a",
"table",
"name",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L142-L144 |
124,762 | jmoiron/modl | dbmap.go | CreateTablesSql | func (m *DbMap) CreateTablesSql() (map[string]string, error) {
return m.createTables(false, false)
} | go | func (m *DbMap) CreateTablesSql() (map[string]string, error) {
return m.createTables(false, false)
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"CreateTablesSql",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"m",
".",
"createTables",
"(",
"false",
",",
"false",
")",
"\n",
"}"
] | // CreateTablesSql returns create table SQL as a map of table names to
// their associated CREATE TABLE statements. | [
"CreateTablesSql",
"returns",
"create",
"table",
"SQL",
"as",
"a",
"map",
"of",
"table",
"names",
"to",
"their",
"associated",
"CREATE",
"TABLE",
"statements",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L148-L150 |
124,763 | jmoiron/modl | dbmap.go | CreateTablesIfNotExistsSql | func (m *DbMap) CreateTablesIfNotExistsSql() (map[string]string, error) {
return m.createTables(true, false)
} | go | func (m *DbMap) CreateTablesIfNotExistsSql() (map[string]string, error) {
return m.createTables(true, false)
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"CreateTablesIfNotExistsSql",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"m",
".",
"createTables",
"(",
"true",
",",
"false",
")",
"\n",
"}"
] | // CreateTablesIfNotExistsSql returns create table SQL as a map of table names to
// their associated CREATE TABLE IF NOT EXISTS statements. | [
"CreateTablesIfNotExistsSql",
"returns",
"create",
"table",
"SQL",
"as",
"a",
"map",
"of",
"table",
"names",
"to",
"their",
"associated",
"CREATE",
"TABLE",
"IF",
"NOT",
"EXISTS",
"statements",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L154-L156 |
124,764 | jmoiron/modl | dbmap.go | CreateTables | func (m *DbMap) CreateTables() error {
_, err := m.createTables(false, true)
return err
} | go | func (m *DbMap) CreateTables() error {
_, err := m.createTables(false, true)
return err
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"CreateTables",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"createTables",
"(",
"false",
",",
"true",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // CreateTables iterates through TableMaps registered to this DbMap and
// executes "create table" statements against the database for each.
//
// This is particularly useful in unit tests where you want to create
// and destroy the schema automatically. | [
"CreateTables",
"iterates",
"through",
"TableMaps",
"registered",
"to",
"this",
"DbMap",
"and",
"executes",
"create",
"table",
"statements",
"against",
"the",
"database",
"for",
"each",
".",
"This",
"is",
"particularly",
"useful",
"in",
"unit",
"tests",
"where",
... | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L163-L166 |
124,765 | jmoiron/modl | dbmap.go | CreateTablesIfNotExists | func (m *DbMap) CreateTablesIfNotExists() error {
_, err := m.createTables(true, true)
return err
} | go | func (m *DbMap) CreateTablesIfNotExists() error {
_, err := m.createTables(true, true)
return err
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"CreateTablesIfNotExists",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"createTables",
"(",
"true",
",",
"true",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // CreateTablesIfNotExists is similar to CreateTables, but starts
// each statement with "create table if not exists" so that existing
// tables do not raise errors. | [
"CreateTablesIfNotExists",
"is",
"similar",
"to",
"CreateTables",
"but",
"starts",
"each",
"statement",
"with",
"create",
"table",
"if",
"not",
"exists",
"so",
"that",
"existing",
"tables",
"do",
"not",
"raise",
"errors",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L171-L174 |
124,766 | jmoiron/modl | dbmap.go | DropTables | func (m *DbMap) DropTables() error {
var err error
for i := range m.tables {
table := m.tables[i]
_, e := m.Exec(fmt.Sprintf("drop table %s;", m.Dialect.QuoteField(table.TableName)))
if e != nil {
err = e
}
}
return err
} | go | func (m *DbMap) DropTables() error {
var err error
for i := range m.tables {
table := m.tables[i]
_, e := m.Exec(fmt.Sprintf("drop table %s;", m.Dialect.QuoteField(table.TableName)))
if e != nil {
err = e
}
}
return err
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"DropTables",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"for",
"i",
":=",
"range",
"m",
".",
"tables",
"{",
"table",
":=",
"m",
".",
"tables",
"[",
"i",
"]",
"\n",
"_",
",",
"e",
":=",
"m",
".",... | // DropTables iterates through TableMaps registered to this DbMap and
// executes "drop table" statements against the database for each. | [
"DropTables",
"iterates",
"through",
"TableMaps",
"registered",
"to",
"this",
"DbMap",
"and",
"executes",
"drop",
"table",
"statements",
"against",
"the",
"database",
"for",
"each",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L260-L270 |
124,767 | jmoiron/modl | dbmap.go | SelectOne | func (m *DbMap) SelectOne(dest interface{}, query string, args ...interface{}) error {
return hookedget(m, m, dest, query, args...)
} | go | func (m *DbMap) SelectOne(dest interface{}, query string, args ...interface{}) error {
return hookedget(m, m, dest, query, args...)
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"SelectOne",
"(",
"dest",
"interface",
"{",
"}",
",",
"query",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"hookedget",
"(",
"m",
",",
"m",
",",
"dest",
",",
"query",
",",
... | // SelectOne runs an arbitrary SQL Query, binding the columns in the result to
// fields on the struct specified by dest. | [
"SelectOne",
"runs",
"an",
"arbitrary",
"SQL",
"Query",
"binding",
"the",
"columns",
"in",
"the",
"result",
"to",
"fields",
"on",
"the",
"struct",
"specified",
"by",
"dest",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L356-L358 |
124,768 | jmoiron/modl | dbmap.go | Begin | func (m *DbMap) Begin() (*Transaction, error) {
m.trace("begin;")
tx, err := m.Dbx.Beginx()
if err != nil {
return nil, err
}
return &Transaction{m, tx}, nil
} | go | func (m *DbMap) Begin() (*Transaction, error) {
m.trace("begin;")
tx, err := m.Dbx.Beginx()
if err != nil {
return nil, err
}
return &Transaction{m, tx}, nil
} | [
"func",
"(",
"m",
"*",
"DbMap",
")",
"Begin",
"(",
")",
"(",
"*",
"Transaction",
",",
"error",
")",
"{",
"m",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"tx",
",",
"err",
":=",
"m",
".",
"Dbx",
".",
"Beginx",
"(",
")",
"\n",
"if",
"err",
"!=... | // Begin starts a modl Transaction. | [
"Begin",
"starts",
"a",
"modl",
"Transaction",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dbmap.go#L373-L380 |
124,769 | jmoiron/modl | hooks.go | setupHooks | func (t *TableMap) setupHooks(i interface{}) {
// These hooks must be implemented on a pointer, so if a value is passed in
// we have to get a pointer for a new value of that type in order for the
// type assertions to pass.
ptr := i
if reflect.ValueOf(i).Kind() == reflect.Struct {
ptr = reflect.New(reflect.Valu... | go | func (t *TableMap) setupHooks(i interface{}) {
// These hooks must be implemented on a pointer, so if a value is passed in
// we have to get a pointer for a new value of that type in order for the
// type assertions to pass.
ptr := i
if reflect.ValueOf(i).Kind() == reflect.Struct {
ptr = reflect.New(reflect.Valu... | [
"func",
"(",
"t",
"*",
"TableMap",
")",
"setupHooks",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"// These hooks must be implemented on a pointer, so if a value is passed in",
"// we have to get a pointer for a new value of that type in order for the",
"// type assertions to pass.",
... | // Determine which hooks are supported by the mapper struct i | [
"Determine",
"which",
"hooks",
"are",
"supported",
"by",
"the",
"mapper",
"struct",
"i"
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/hooks.go#L50-L66 |
124,770 | jmoiron/modl | dialect.go | InsertAutoIncr | func (d PostgresDialect) InsertAutoIncr(e SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
rows, err := e.handle().Queryx(insertSql, params...)
if err != nil {
return 0, err
}
defer rows.Close()
if rows.Next() {
var id int64
err := rows.Scan(&id)
return id, err
}
return 0, errors.... | go | func (d PostgresDialect) InsertAutoIncr(e SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
rows, err := e.handle().Queryx(insertSql, params...)
if err != nil {
return 0, err
}
defer rows.Close()
if rows.Next() {
var id int64
err := rows.Scan(&id)
return id, err
}
return 0, errors.... | [
"func",
"(",
"d",
"PostgresDialect",
")",
"InsertAutoIncr",
"(",
"e",
"SqlExecutor",
",",
"insertSql",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"(",
"int64",
",",
"error",
")",
"{",
"rows",
",",
"err",
":=",
"e",
".",
"handle",
"(",
... | // InsertAutoIncr inserts via a query and reads the resultant rows for the new
// auto increment ID, as it's not returned with the result in PostgreSQL. | [
"InsertAutoIncr",
"inserts",
"via",
"a",
"query",
"and",
"reads",
"the",
"resultant",
"rows",
"for",
"the",
"new",
"auto",
"increment",
"ID",
"as",
"it",
"s",
"not",
"returned",
"with",
"the",
"result",
"in",
"PostgreSQL",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dialect.go#L263-L277 |
124,771 | jmoiron/modl | dialect.go | ToSqlType | func (d MySQLDialect) ToSqlType(col *ColumnMap) string {
switch col.gotype.Kind() {
case reflect.Bool:
return "boolean"
case reflect.Int, reflect.Int16, reflect.Int32, reflect.Uint16, reflect.Uint32:
return "int"
case reflect.Int64, reflect.Uint64:
return "bigint"
case reflect.Float64, reflect.Float32:
ret... | go | func (d MySQLDialect) ToSqlType(col *ColumnMap) string {
switch col.gotype.Kind() {
case reflect.Bool:
return "boolean"
case reflect.Int, reflect.Int16, reflect.Int32, reflect.Uint16, reflect.Uint32:
return "int"
case reflect.Int64, reflect.Uint64:
return "bigint"
case reflect.Float64, reflect.Float32:
ret... | [
"func",
"(",
"d",
"MySQLDialect",
")",
"ToSqlType",
"(",
"col",
"*",
"ColumnMap",
")",
"string",
"{",
"switch",
"col",
".",
"gotype",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Bool",
":",
"return",
"\"",
"\"",
"\n",
"case",
"reflect",
".",... | // ToSqlType maps go types to MySQL types. | [
"ToSqlType",
"maps",
"go",
"types",
"to",
"MySQL",
"types",
"."
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dialect.go#L318-L352 |
124,772 | jmoiron/modl | dialect.go | CreateTableSuffix | func (d MySQLDialect) CreateTableSuffix() string {
return fmt.Sprintf(" engine=%s charset=%s", d.Engine, d.Encoding)
} | go | func (d MySQLDialect) CreateTableSuffix() string {
return fmt.Sprintf(" engine=%s charset=%s", d.Engine, d.Encoding)
} | [
"func",
"(",
"d",
"MySQLDialect",
")",
"CreateTableSuffix",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"Engine",
",",
"d",
".",
"Encoding",
")",
"\n",
"}"
] | // CreateTableSuffix returns engine=%s charset=%s based on values stored on struct | [
"CreateTableSuffix",
"returns",
"engine",
"=",
"%s",
"charset",
"=",
"%s",
"based",
"on",
"values",
"stored",
"on",
"struct"
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/dialect.go#L370-L372 |
124,773 | jmoiron/modl | tablemap.go | tableForPointer | func tableForPointer(m *DbMap, i interface{}, checkPk bool) (*TableMap, reflect.Value, error) {
v := reflect.ValueOf(i)
if v.Kind() != reflect.Ptr {
return nil, v, fmt.Errorf("value %v not a pointer", v)
}
v = v.Elem()
t := m.TableForType(v.Type())
if t == nil {
return nil, v, fmt.Errorf("could not find table... | go | func tableForPointer(m *DbMap, i interface{}, checkPk bool) (*TableMap, reflect.Value, error) {
v := reflect.ValueOf(i)
if v.Kind() != reflect.Ptr {
return nil, v, fmt.Errorf("value %v not a pointer", v)
}
v = v.Elem()
t := m.TableForType(v.Type())
if t == nil {
return nil, v, fmt.Errorf("could not find table... | [
"func",
"tableForPointer",
"(",
"m",
"*",
"DbMap",
",",
"i",
"interface",
"{",
"}",
",",
"checkPk",
"bool",
")",
"(",
"*",
"TableMap",
",",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"i",
")",
"\n",
... | // Return a table for a pointer; error if i is not a pointer or if the
// table is not found | [
"Return",
"a",
"table",
"for",
"a",
"pointer",
";",
"error",
"if",
"i",
"is",
"not",
"a",
"pointer",
"or",
"if",
"the",
"table",
"is",
"not",
"found"
] | 99654d091ece9b281eec23c9e6fe9ff960e1baa1 | https://github.com/jmoiron/modl/blob/99654d091ece9b281eec23c9e6fe9ff960e1baa1/tablemap.go#L361-L375 |
124,774 | stretchr/gomniauth | providers/soundcloud/soundcloud.go | TripperFactory | func (provider *SoundcloudProvider) TripperFactory() common.TripperFactory {
if provider.tripperFactory == nil {
provider.tripperFactory = new(oauth2.OAuth2TripperFactory)
}
return provider.tripperFactory
} | go | func (provider *SoundcloudProvider) TripperFactory() common.TripperFactory {
if provider.tripperFactory == nil {
provider.tripperFactory = new(oauth2.OAuth2TripperFactory)
}
return provider.tripperFactory
} | [
"func",
"(",
"provider",
"*",
"SoundcloudProvider",
")",
"TripperFactory",
"(",
")",
"common",
".",
"TripperFactory",
"{",
"if",
"provider",
".",
"tripperFactory",
"==",
"nil",
"{",
"provider",
".",
"tripperFactory",
"=",
"new",
"(",
"oauth2",
".",
"OAuth2Trip... | // TipperFactory gets an OAuth2TripperFactory | [
"TipperFactory",
"gets",
"an",
"OAuth2TripperFactory"
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/providers/soundcloud/soundcloud.go#L42-L49 |
124,775 | stretchr/gomniauth | providers/soundcloud/soundcloud.go | Get | func (provider *SoundcloudProvider) Get(creds *common.Credentials, endpoint string) (objx.Map, error) {
return oauth2.Get(provider, creds, endpoint)
} | go | func (provider *SoundcloudProvider) Get(creds *common.Credentials, endpoint string) (objx.Map, error) {
return oauth2.Get(provider, creds, endpoint)
} | [
"func",
"(",
"provider",
"*",
"SoundcloudProvider",
")",
"Get",
"(",
"creds",
"*",
"common",
".",
"Credentials",
",",
"endpoint",
"string",
")",
"(",
"objx",
".",
"Map",
",",
"error",
")",
"{",
"return",
"oauth2",
".",
"Get",
"(",
"provider",
",",
"cre... | // Get makes an authenticated request and returns the data in the
// response as a data map. | [
"Get",
"makes",
"an",
"authenticated",
"request",
"and",
"returns",
"the",
"data",
"in",
"the",
"response",
"as",
"a",
"data",
"map",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/providers/soundcloud/soundcloud.go#L85-L87 |
124,776 | stretchr/gomniauth | provider_list.go | WithProviders | func WithProviders(providers ...common.Provider) *ProviderList {
GetSecurityKey()
list := &ProviderList{providers}
SharedProviderList = list
return list
} | go | func WithProviders(providers ...common.Provider) *ProviderList {
GetSecurityKey()
list := &ProviderList{providers}
SharedProviderList = list
return list
} | [
"func",
"WithProviders",
"(",
"providers",
"...",
"common",
".",
"Provider",
")",
"*",
"ProviderList",
"{",
"GetSecurityKey",
"(",
")",
"\n",
"list",
":=",
"&",
"ProviderList",
"{",
"providers",
"}",
"\n",
"SharedProviderList",
"=",
"list",
"\n",
"return",
"... | // WithProviders generates a new ProviderList which should be
// used to interact with Gomniauth services. | [
"WithProviders",
"generates",
"a",
"new",
"ProviderList",
"which",
"should",
"be",
"used",
"to",
"interact",
"with",
"Gomniauth",
"services",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/provider_list.go#L20-L25 |
124,777 | stretchr/gomniauth | provider_list.go | Add | func (l *ProviderList) Add(provider common.Provider) *ProviderList {
l.providers = append(l.providers, provider)
return l
} | go | func (l *ProviderList) Add(provider common.Provider) *ProviderList {
l.providers = append(l.providers, provider)
return l
} | [
"func",
"(",
"l",
"*",
"ProviderList",
")",
"Add",
"(",
"provider",
"common",
".",
"Provider",
")",
"*",
"ProviderList",
"{",
"l",
".",
"providers",
"=",
"append",
"(",
"l",
".",
"providers",
",",
"provider",
")",
"\n",
"return",
"l",
"\n",
"}"
] | // Add adds a provider to this list. | [
"Add",
"adds",
"a",
"provider",
"to",
"this",
"list",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/provider_list.go#L28-L31 |
124,778 | stretchr/gomniauth | provider_list.go | Provider | func (l *ProviderList) Provider(name string) (common.Provider, error) {
// panic on nil
if l == nil {
panic(common.PrefixForErrors + "No providers have been initialised. Make sure you have called gomniauth.WithProviders(...).")
}
for _, provider := range l.providers {
if provider.Name() == name {
return p... | go | func (l *ProviderList) Provider(name string) (common.Provider, error) {
// panic on nil
if l == nil {
panic(common.PrefixForErrors + "No providers have been initialised. Make sure you have called gomniauth.WithProviders(...).")
}
for _, provider := range l.providers {
if provider.Name() == name {
return p... | [
"func",
"(",
"l",
"*",
"ProviderList",
")",
"Provider",
"(",
"name",
"string",
")",
"(",
"common",
".",
"Provider",
",",
"error",
")",
"{",
"// panic on nil",
"if",
"l",
"==",
"nil",
"{",
"panic",
"(",
"common",
".",
"PrefixForErrors",
"+",
"\"",
"\"",... | // Provider gets a provider by name, or returns a common.MissingProviderError
// if no provider with that name is registered. | [
"Provider",
"gets",
"a",
"provider",
"by",
"name",
"or",
"returns",
"a",
"common",
".",
"MissingProviderError",
"if",
"no",
"provider",
"with",
"that",
"name",
"is",
"registered",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/provider_list.go#L35-L49 |
124,779 | stretchr/gomniauth | oauth2/oauth2_tripper_factory.go | NewTripper | func (f *OAuth2TripperFactory) NewTripper(creds *common.Credentials, provider common.Provider) (common.Tripper, error) {
return NewOAuth2Tripper(creds, provider), nil
} | go | func (f *OAuth2TripperFactory) NewTripper(creds *common.Credentials, provider common.Provider) (common.Tripper, error) {
return NewOAuth2Tripper(creds, provider), nil
} | [
"func",
"(",
"f",
"*",
"OAuth2TripperFactory",
")",
"NewTripper",
"(",
"creds",
"*",
"common",
".",
"Credentials",
",",
"provider",
"common",
".",
"Provider",
")",
"(",
"common",
".",
"Tripper",
",",
"error",
")",
"{",
"return",
"NewOAuth2Tripper",
"(",
"c... | // NewTripper creates a Tripper object for the OAuth2 authentication protocol. | [
"NewTripper",
"creates",
"a",
"Tripper",
"object",
"for",
"the",
"OAuth2",
"authentication",
"protocol",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/oauth2_tripper_factory.go#L12-L14 |
124,780 | stretchr/gomniauth | common/credentials.go | PublicData | func (c *Credentials) PublicData(options map[string]interface{}) (publicData interface{}, err error) {
// ensure the ID is a string
idValue := c.Map.Get(CredentialsKeyID).Data()
var idStringValue string
switch idValue.(type) {
case float64:
idStringValue = strconv.FormatFloat(idValue.(float64), 'g', -1, 64)
ca... | go | func (c *Credentials) PublicData(options map[string]interface{}) (publicData interface{}, err error) {
// ensure the ID is a string
idValue := c.Map.Get(CredentialsKeyID).Data()
var idStringValue string
switch idValue.(type) {
case float64:
idStringValue = strconv.FormatFloat(idValue.(float64), 'g', -1, 64)
ca... | [
"func",
"(",
"c",
"*",
"Credentials",
")",
"PublicData",
"(",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"publicData",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"// ensure the ID is a string",
"idValue",
":=",
"c",
... | // PublicData gets the storable data from this credentials object. | [
"PublicData",
"gets",
"the",
"storable",
"data",
"from",
"this",
"credentials",
"object",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/common/credentials.go#L22-L38 |
124,781 | stretchr/gomniauth | providers/heroku/heroku.go | GetClient | func (provider *HerokuProvider) GetClient(creds *common.Credentials) (*http.Client, error) {
return oauth2.GetClient(provider.TripperFactory(), creds, provider)
} | go | func (provider *HerokuProvider) GetClient(creds *common.Credentials) (*http.Client, error) {
return oauth2.GetClient(provider.TripperFactory(), creds, provider)
} | [
"func",
"(",
"provider",
"*",
"HerokuProvider",
")",
"GetClient",
"(",
"creds",
"*",
"common",
".",
"Credentials",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"return",
"oauth2",
".",
"GetClient",
"(",
"provider",
".",
"TripperFactory",
... | // GetClient returns an authenticated http.Client that can be used to make requests to
// protected heroku resources | [
"GetClient",
"returns",
"an",
"authenticated",
"http",
".",
"Client",
"that",
"can",
"be",
"used",
"to",
"make",
"requests",
"to",
"protected",
"heroku",
"resources"
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/providers/heroku/heroku.go#L115-L117 |
124,782 | stretchr/gomniauth | oauth2/get.go | Get | func Get(provider common.Provider, creds *common.Credentials, endpoint string) (objx.Map, error) {
client, clientErr := provider.GetClient(creds)
if clientErr != nil {
return nil, clientErr
}
response, responseErr := client.Get(endpoint)
if responseErr != nil {
return nil, responseErr
}
body, bodyErr :=... | go | func Get(provider common.Provider, creds *common.Credentials, endpoint string) (objx.Map, error) {
client, clientErr := provider.GetClient(creds)
if clientErr != nil {
return nil, clientErr
}
response, responseErr := client.Get(endpoint)
if responseErr != nil {
return nil, responseErr
}
body, bodyErr :=... | [
"func",
"Get",
"(",
"provider",
"common",
".",
"Provider",
",",
"creds",
"*",
"common",
".",
"Credentials",
",",
"endpoint",
"string",
")",
"(",
"objx",
".",
"Map",
",",
"error",
")",
"{",
"client",
",",
"clientErr",
":=",
"provider",
".",
"GetClient",
... | // Get executes an authenticated HTTP GET against the given provider and returns an
// objx.Map of the response.
//
// The response type is automatically detected and used to unmarshal the response. | [
"Get",
"executes",
"an",
"authenticated",
"HTTP",
"GET",
"against",
"the",
"given",
"provider",
"and",
"returns",
"an",
"objx",
".",
"Map",
"of",
"the",
"response",
".",
"The",
"response",
"type",
"is",
"automatically",
"detected",
"and",
"used",
"to",
"unma... | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/get.go#L14-L52 |
124,783 | stretchr/gomniauth | oauth2/get_client.go | GetClient | func GetClient(tripperFactory common.TripperFactory, creds *common.Credentials, provider common.Provider) (*http.Client, error) {
tripper, tripperErr := tripperFactory.NewTripper(creds, provider)
if tripperErr != nil {
return nil, tripperErr
}
return &http.Client{Transport: tripper}, nil
} | go | func GetClient(tripperFactory common.TripperFactory, creds *common.Credentials, provider common.Provider) (*http.Client, error) {
tripper, tripperErr := tripperFactory.NewTripper(creds, provider)
if tripperErr != nil {
return nil, tripperErr
}
return &http.Client{Transport: tripper}, nil
} | [
"func",
"GetClient",
"(",
"tripperFactory",
"common",
".",
"TripperFactory",
",",
"creds",
"*",
"common",
".",
"Credentials",
",",
"provider",
"common",
".",
"Provider",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"tripper",
",",
"tripper... | // GetClient gets an http.Client authenticated with the specified
// common.Credentials. | [
"GetClient",
"gets",
"an",
"http",
".",
"Client",
"authenticated",
"with",
"the",
"specified",
"common",
".",
"Credentials",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/get_client.go#L10-L19 |
124,784 | stretchr/gomniauth | providers/soundcloud/user.go | IDForProvider | func (u *User) IDForProvider(provider string) string {
id := u.ProviderCredentials()[provider].Get(common.CredentialsKeyID).Data()
switch id.(type) {
case string:
return id.(string)
case float64:
return strconv.FormatFloat(id.(float64), 'f', 0, 64)
}
return ""
} | go | func (u *User) IDForProvider(provider string) string {
id := u.ProviderCredentials()[provider].Get(common.CredentialsKeyID).Data()
switch id.(type) {
case string:
return id.(string)
case float64:
return strconv.FormatFloat(id.(float64), 'f', 0, 64)
}
return ""
} | [
"func",
"(",
"u",
"*",
"User",
")",
"IDForProvider",
"(",
"provider",
"string",
")",
"string",
"{",
"id",
":=",
"u",
".",
"ProviderCredentials",
"(",
")",
"[",
"provider",
"]",
".",
"Get",
"(",
"common",
".",
"CredentialsKeyID",
")",
".",
"Data",
"(",
... | // IDForProvider gets the ID value for the specified provider name for
// this user from the ProviderCredentials data. | [
"IDForProvider",
"gets",
"the",
"ID",
"value",
"for",
"the",
"specified",
"provider",
"name",
"for",
"this",
"user",
"from",
"the",
"ProviderCredentials",
"data",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/providers/soundcloud/user.go#L60-L69 |
124,785 | stretchr/gomniauth | oauth2/url.go | GetBeginAuthURLWithBase | func GetBeginAuthURLWithBase(base string, state *common.State, config *common.Config) (string, error) {
if config == nil {
panic("OAuth2Handler: Must have valid Config specified.")
}
// copy the config
params := objx.MSI(
OAuth2KeyClientID, config.Get(OAuth2KeyClientID).Str(),
OAuth2KeyRedirectUrl, config.G... | go | func GetBeginAuthURLWithBase(base string, state *common.State, config *common.Config) (string, error) {
if config == nil {
panic("OAuth2Handler: Must have valid Config specified.")
}
// copy the config
params := objx.MSI(
OAuth2KeyClientID, config.Get(OAuth2KeyClientID).Str(),
OAuth2KeyRedirectUrl, config.G... | [
"func",
"GetBeginAuthURLWithBase",
"(",
"base",
"string",
",",
"state",
"*",
"common",
".",
"State",
",",
"config",
"*",
"common",
".",
"Config",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
... | // GetBeginAuthURLWithBase returns the OAuth2 authorization URL from the given arguments.
//
// The state object will be encoded to base64 and signed to ensure integrity. | [
"GetBeginAuthURLWithBase",
"returns",
"the",
"OAuth2",
"authorization",
"URL",
"from",
"the",
"given",
"arguments",
".",
"The",
"state",
"object",
"will",
"be",
"encoded",
"to",
"base64",
"and",
"signed",
"to",
"ensure",
"integrity",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/url.go#L11-L48 |
124,786 | stretchr/gomniauth | oauth2/header.go | AuthorizationHeader | func AuthorizationHeader(creds *common.Credentials) (key, value string) {
return "Authorization", "Bearer " + creds.Get(OAuth2KeyAccessToken).Str("Invalid")
} | go | func AuthorizationHeader(creds *common.Credentials) (key, value string) {
return "Authorization", "Bearer " + creds.Get(OAuth2KeyAccessToken).Str("Invalid")
} | [
"func",
"AuthorizationHeader",
"(",
"creds",
"*",
"common",
".",
"Credentials",
")",
"(",
"key",
",",
"value",
"string",
")",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"creds",
".",
"Get",
"(",
"OAuth2KeyAccessToken",
")",
".",
"Str",
"(",
"\"",... | // AuthorizationHeader returns the key, value pair to insert into an authorized request. | [
"AuthorizationHeader",
"returns",
"the",
"key",
"value",
"pair",
"to",
"insert",
"into",
"an",
"authorized",
"request",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/header.go#L8-L10 |
124,787 | stretchr/gomniauth | facade.go | ProviderPublicData | func ProviderPublicData(provider common.Provider, options map[string]interface{}) (interface{}, error) {
optionsx := objx.New(options)
return map[string]interface{}{
"name": provider.Name(),
"display": provider.DisplayName(),
"loginpath": fmt.Sprintf(optionsx.Get("loginpathFormat").Str("auth/%s/login")... | go | func ProviderPublicData(provider common.Provider, options map[string]interface{}) (interface{}, error) {
optionsx := objx.New(options)
return map[string]interface{}{
"name": provider.Name(),
"display": provider.DisplayName(),
"loginpath": fmt.Sprintf(optionsx.Get("loginpathFormat").Str("auth/%s/login")... | [
"func",
"ProviderPublicData",
"(",
"provider",
"common",
".",
"Provider",
",",
"options",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"optionsx",
":=",
"objx",
".",
"New",
"(",
"options",
"... | // ProviderPublicData gets the public data for the specified provider.
//
// The options should contain the `loginpathFormat`, which will determine how the
// loginpath value is created. | [
"ProviderPublicData",
"gets",
"the",
"public",
"data",
"for",
"the",
"specified",
"provider",
".",
"The",
"options",
"should",
"contain",
"the",
"loginpathFormat",
"which",
"will",
"determine",
"how",
"the",
"loginpath",
"value",
"is",
"created",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/facade.go#L13-L23 |
124,788 | stretchr/gomniauth | shortcuts.go | StateFromParam | func StateFromParam(paramValue string) (*common.State, error) {
stateMap, err := objx.FromSignedBase64(paramValue, GetSecurityKey())
if err != nil {
return nil, err
}
return &common.State{Map: stateMap}, nil
} | go | func StateFromParam(paramValue string) (*common.State, error) {
stateMap, err := objx.FromSignedBase64(paramValue, GetSecurityKey())
if err != nil {
return nil, err
}
return &common.State{Map: stateMap}, nil
} | [
"func",
"StateFromParam",
"(",
"paramValue",
"string",
")",
"(",
"*",
"common",
".",
"State",
",",
"error",
")",
"{",
"stateMap",
",",
"err",
":=",
"objx",
".",
"FromSignedBase64",
"(",
"paramValue",
",",
"GetSecurityKey",
"(",
")",
")",
"\n\n",
"if",
"e... | // StateFromParam decodes the state parameter hash and turns it
// into a usable State object. | [
"StateFromParam",
"decodes",
"the",
"state",
"parameter",
"hash",
"and",
"turns",
"it",
"into",
"a",
"usable",
"State",
"object",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/shortcuts.go#L23-L32 |
124,789 | stretchr/gomniauth | oauth2/oauth2_tripper.go | NewOAuth2Tripper | func NewOAuth2Tripper(creds *common.Credentials, provider common.Provider) *OAuth2Tripper {
return &OAuth2Tripper{common.GetRoundTripper(), creds, provider}
} | go | func NewOAuth2Tripper(creds *common.Credentials, provider common.Provider) *OAuth2Tripper {
return &OAuth2Tripper{common.GetRoundTripper(), creds, provider}
} | [
"func",
"NewOAuth2Tripper",
"(",
"creds",
"*",
"common",
".",
"Credentials",
",",
"provider",
"common",
".",
"Provider",
")",
"*",
"OAuth2Tripper",
"{",
"return",
"&",
"OAuth2Tripper",
"{",
"common",
".",
"GetRoundTripper",
"(",
")",
",",
"creds",
",",
"prov... | // NewOAuth2Tripper creates a new OAuth2Tripper with the given arguments. | [
"NewOAuth2Tripper",
"creates",
"a",
"new",
"OAuth2Tripper",
"with",
"the",
"given",
"arguments",
"."
] | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/oauth2_tripper.go#L15-L17 |
124,790 | stretchr/gomniauth | oauth2/oauth2_tripper.go | RoundTrip | func (t *OAuth2Tripper) RoundTrip(req *http.Request) (*http.Response, error) {
//TODO: check token expiration and renew if necessary
if t.Credentials() != nil {
// copy the request
req = cloneRequest(req)
// set the header
headerK, headerV := AuthorizationHeader(t.Credentials())
req.Header.Set(headerK, ... | go | func (t *OAuth2Tripper) RoundTrip(req *http.Request) (*http.Response, error) {
//TODO: check token expiration and renew if necessary
if t.Credentials() != nil {
// copy the request
req = cloneRequest(req)
// set the header
headerK, headerV := AuthorizationHeader(t.Credentials())
req.Header.Set(headerK, ... | [
"func",
"(",
"t",
"*",
"OAuth2Tripper",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"//TODO: check token expiration and renew if necessary",
"if",
"t",
".",
"Credentials",
"(",
")... | // RoundTrip is called by the http package when making a request to a server. This
// implementation of RoundTrip inserts the appropriate authorization headers
// into the request in order to enable access of protected resources.
//
// If the auth token has expired, RoundTrip will attempt to renew it. | [
"RoundTrip",
"is",
"called",
"by",
"the",
"http",
"package",
"when",
"making",
"a",
"request",
"to",
"a",
"server",
".",
"This",
"implementation",
"of",
"RoundTrip",
"inserts",
"the",
"appropriate",
"authorization",
"headers",
"into",
"the",
"request",
"in",
"... | 4b6c822be2eb64551618722ff80cecde4d63d9be | https://github.com/stretchr/gomniauth/blob/4b6c822be2eb64551618722ff80cecde4d63d9be/oauth2/oauth2_tripper.go#L24-L43 |
124,791 | v2pro/plz | gls/goid.go | GoID | func GoID() int64 {
g := getg()
p_goid := (*int64)(unsafe.Pointer(g + goidOffset))
return *p_goid
} | go | func GoID() int64 {
g := getg()
p_goid := (*int64)(unsafe.Pointer(g + goidOffset))
return *p_goid
} | [
"func",
"GoID",
"(",
")",
"int64",
"{",
"g",
":=",
"getg",
"(",
")",
"\n",
"p_goid",
":=",
"(",
"*",
"int64",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"g",
"+",
"goidOffset",
")",
")",
"\n",
"return",
"*",
"p_goid",
"\n",
"}"
] | // GoID returns the goroutine id of current goroutine | [
"GoID",
"returns",
"the",
"goroutine",
"id",
"of",
"current",
"goroutine"
] | 2d49b86ea38230256fa4bf998fad76b8878c7be3 | https://github.com/v2pro/plz/blob/2d49b86ea38230256fa4bf998fad76b8878c7be3/gls/goid.go#L21-L25 |
124,792 | v2pro/plz | msgfmt/jsonfmt/encoder_float.go | WriteFloat32 | func WriteFloat32(space []byte, val float32) []byte {
abs := math.Abs(float64(val))
fmt := byte('f')
// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
if abs != 0 {
if float32(abs) < 1e-6 || float32(abs) >= 1e21 {
fmt = 'e'
}
}
return append(space, strconv.For... | go | func WriteFloat32(space []byte, val float32) []byte {
abs := math.Abs(float64(val))
fmt := byte('f')
// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
if abs != 0 {
if float32(abs) < 1e-6 || float32(abs) >= 1e21 {
fmt = 'e'
}
}
return append(space, strconv.For... | [
"func",
"WriteFloat32",
"(",
"space",
"[",
"]",
"byte",
",",
"val",
"float32",
")",
"[",
"]",
"byte",
"{",
"abs",
":=",
"math",
".",
"Abs",
"(",
"float64",
"(",
"val",
")",
")",
"\n",
"fmt",
":=",
"byte",
"(",
"'f'",
")",
"\n",
"// Note: Must use f... | // WriteFloat32 write float32 to stream | [
"WriteFloat32",
"write",
"float32",
"to",
"stream"
] | 2d49b86ea38230256fa4bf998fad76b8878c7be3 | https://github.com/v2pro/plz/blob/2d49b86ea38230256fa4bf998fad76b8878c7be3/msgfmt/jsonfmt/encoder_float.go#L71-L81 |
124,793 | tyler-smith/go-bip32 | bip32.go | NewMasterKey | func NewMasterKey(seed []byte) (*Key, error) {
// Generate key and chaincode
hmac := hmac.New(sha512.New, []byte("Bitcoin seed"))
_, err := hmac.Write(seed)
if err != nil {
return nil, err
}
intermediary := hmac.Sum(nil)
// Split it into our key and chain code
keyBytes := intermediary[:32]
chainCode := inte... | go | func NewMasterKey(seed []byte) (*Key, error) {
// Generate key and chaincode
hmac := hmac.New(sha512.New, []byte("Bitcoin seed"))
_, err := hmac.Write(seed)
if err != nil {
return nil, err
}
intermediary := hmac.Sum(nil)
// Split it into our key and chain code
keyBytes := intermediary[:32]
chainCode := inte... | [
"func",
"NewMasterKey",
"(",
"seed",
"[",
"]",
"byte",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"// Generate key and chaincode",
"hmac",
":=",
"hmac",
".",
"New",
"(",
"sha512",
".",
"New",
",",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n... | // NewMasterKey creates a new master extended key from a seed | [
"NewMasterKey",
"creates",
"a",
"new",
"master",
"extended",
"key",
"from",
"a",
"seed"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L59-L90 |
124,794 | tyler-smith/go-bip32 | bip32.go | NewChildKey | func (key *Key) NewChildKey(childIdx uint32) (*Key, error) {
// Fail early if trying to create hardned child from public key
if !key.IsPrivate && childIdx >= FirstHardenedChild {
return nil, ErrHardnedChildPublicKey
}
intermediary, err := key.getIntermediary(childIdx)
if err != nil {
return nil, err
}
// C... | go | func (key *Key) NewChildKey(childIdx uint32) (*Key, error) {
// Fail early if trying to create hardned child from public key
if !key.IsPrivate && childIdx >= FirstHardenedChild {
return nil, ErrHardnedChildPublicKey
}
intermediary, err := key.getIntermediary(childIdx)
if err != nil {
return nil, err
}
// C... | [
"func",
"(",
"key",
"*",
"Key",
")",
"NewChildKey",
"(",
"childIdx",
"uint32",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"// Fail early if trying to create hardned child from public key",
"if",
"!",
"key",
".",
"IsPrivate",
"&&",
"childIdx",
">=",
"FirstHard... | // NewChildKey derives a child key from a given parent as outlined by bip32 | [
"NewChildKey",
"derives",
"a",
"child",
"key",
"from",
"a",
"given",
"parent",
"as",
"outlined",
"by",
"bip32"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L93-L147 |
124,795 | tyler-smith/go-bip32 | bip32.go | PublicKey | func (key *Key) PublicKey() *Key {
keyBytes := key.Key
if key.IsPrivate {
keyBytes = publicKeyForPrivateKey(keyBytes)
}
return &Key{
Version: PublicWalletVersion,
Key: keyBytes,
Depth: key.Depth,
ChildNumber: key.ChildNumber,
FingerPrint: key.FingerPrint,
ChainCode: key.ChainCode... | go | func (key *Key) PublicKey() *Key {
keyBytes := key.Key
if key.IsPrivate {
keyBytes = publicKeyForPrivateKey(keyBytes)
}
return &Key{
Version: PublicWalletVersion,
Key: keyBytes,
Depth: key.Depth,
ChildNumber: key.ChildNumber,
FingerPrint: key.FingerPrint,
ChainCode: key.ChainCode... | [
"func",
"(",
"key",
"*",
"Key",
")",
"PublicKey",
"(",
")",
"*",
"Key",
"{",
"keyBytes",
":=",
"key",
".",
"Key",
"\n\n",
"if",
"key",
".",
"IsPrivate",
"{",
"keyBytes",
"=",
"publicKeyForPrivateKey",
"(",
"keyBytes",
")",
"\n",
"}",
"\n\n",
"return",
... | // PublicKey returns the public version of key or return a copy
// The 'Neuter' function from the bip32 spec | [
"PublicKey",
"returns",
"the",
"public",
"version",
"of",
"key",
"or",
"return",
"a",
"copy",
"The",
"Neuter",
"function",
"from",
"the",
"bip32",
"spec"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L177-L193 |
124,796 | tyler-smith/go-bip32 | bip32.go | Serialize | func (key *Key) Serialize() ([]byte, error) {
// Private keys should be prepended with a single null byte
keyBytes := key.Key
if key.IsPrivate {
keyBytes = append([]byte{0x0}, keyBytes...)
}
// Write fields to buffer in order
buffer := new(bytes.Buffer)
buffer.Write(key.Version)
buffer.WriteByte(key.Depth)
... | go | func (key *Key) Serialize() ([]byte, error) {
// Private keys should be prepended with a single null byte
keyBytes := key.Key
if key.IsPrivate {
keyBytes = append([]byte{0x0}, keyBytes...)
}
// Write fields to buffer in order
buffer := new(bytes.Buffer)
buffer.Write(key.Version)
buffer.WriteByte(key.Depth)
... | [
"func",
"(",
"key",
"*",
"Key",
")",
"Serialize",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Private keys should be prepended with a single null byte",
"keyBytes",
":=",
"key",
".",
"Key",
"\n",
"if",
"key",
".",
"IsPrivate",
"{",
"keyBytes... | // Serialize a Key to a 78 byte byte slice | [
"Serialize",
"a",
"Key",
"to",
"a",
"78",
"byte",
"byte",
"slice"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L196-L219 |
124,797 | tyler-smith/go-bip32 | bip32.go | B58Serialize | func (key *Key) B58Serialize() string {
serializedKey, err := key.Serialize()
if err != nil {
return ""
}
return base58Encode(serializedKey)
} | go | func (key *Key) B58Serialize() string {
serializedKey, err := key.Serialize()
if err != nil {
return ""
}
return base58Encode(serializedKey)
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"B58Serialize",
"(",
")",
"string",
"{",
"serializedKey",
",",
"err",
":=",
"key",
".",
"Serialize",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"base58Encode"... | // B58Serialize encodes the Key in the standard Bitcoin base58 encoding | [
"B58Serialize",
"encodes",
"the",
"Key",
"in",
"the",
"standard",
"Bitcoin",
"base58",
"encoding"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L222-L229 |
124,798 | tyler-smith/go-bip32 | bip32.go | Deserialize | func Deserialize(data []byte) (*Key, error) {
if len(data) != 82 {
return nil, ErrSerializedKeyWrongSize
}
var key = &Key{}
key.Version = data[0:4]
key.Depth = data[4]
key.FingerPrint = data[5:9]
key.ChildNumber = data[9:13]
key.ChainCode = data[13:45]
if data[45] == byte(0) {
key.IsPrivate = true
key.K... | go | func Deserialize(data []byte) (*Key, error) {
if len(data) != 82 {
return nil, ErrSerializedKeyWrongSize
}
var key = &Key{}
key.Version = data[0:4]
key.Depth = data[4]
key.FingerPrint = data[5:9]
key.ChildNumber = data[9:13]
key.ChainCode = data[13:45]
if data[45] == byte(0) {
key.IsPrivate = true
key.K... | [
"func",
"Deserialize",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"if",
"len",
"(",
"data",
")",
"!=",
"82",
"{",
"return",
"nil",
",",
"ErrSerializedKeyWrongSize",
"\n",
"}",
"\n",
"var",
"key",
"=",
"&",
"Key",
... | // Deserialize a byte slice into a Key | [
"Deserialize",
"a",
"byte",
"slice",
"into",
"a",
"Key"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L237-L269 |
124,799 | tyler-smith/go-bip32 | bip32.go | B58Deserialize | func B58Deserialize(data string) (*Key, error) {
b, err := base58Decode(data)
if err != nil {
return nil, err
}
return Deserialize(b)
} | go | func B58Deserialize(data string) (*Key, error) {
b, err := base58Decode(data)
if err != nil {
return nil, err
}
return Deserialize(b)
} | [
"func",
"B58Deserialize",
"(",
"data",
"string",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"base58Decode",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"... | // B58Deserialize deserializes a Key encoded in base58 encoding | [
"B58Deserialize",
"deserializes",
"a",
"Key",
"encoded",
"in",
"base58",
"encoding"
] | 2c9cfd17756470a0b7c3e4b7954bae7d11035504 | https://github.com/tyler-smith/go-bip32/blob/2c9cfd17756470a0b7c3e4b7954bae7d11035504/bip32.go#L272-L278 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.