id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
148,000 | aybabtme/uniplot | histogram/histogram.go | Hist | func Hist(bins int, input []float64) Histogram {
if len(input) == 0 || bins == 0 {
return Histogram{}
}
min, max := input[0], input[0]
for _, val := range input {
min = math.Min(min, val)
max = math.Max(max, val)
}
if min == max {
return Histogram{
Min: len(input),
Max: len(input),
Coun... | go | func Hist(bins int, input []float64) Histogram {
if len(input) == 0 || bins == 0 {
return Histogram{}
}
min, max := input[0], input[0]
for _, val := range input {
min = math.Min(min, val)
max = math.Max(max, val)
}
if min == max {
return Histogram{
Min: len(input),
Max: len(input),
Coun... | [
"func",
"Hist",
"(",
"bins",
"int",
",",
"input",
"[",
"]",
"float64",
")",
"Histogram",
"{",
"if",
"len",
"(",
"input",
")",
"==",
"0",
"||",
"bins",
"==",
"0",
"{",
"return",
"Histogram",
"{",
"}",
"\n",
"}",
"\n\n",
"min",
",",
"max",
":=",
... | // Hist creates an histogram partionning input over `bins` buckets. | [
"Hist",
"creates",
"an",
"histogram",
"partionning",
"input",
"over",
"bins",
"buckets",
"."
] | 039c559e5e7e0512b313109b11266bf6fe2db223 | https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/histogram/histogram.go#L33-L79 |
148,001 | aybabtme/uniplot | histogram/histogram.go | PowerHist | func PowerHist(power float64, input []float64) Histogram {
if len(input) == 0 || power <= 0 {
return Histogram{}
}
minx, maxx := input[0], input[0]
for _, val := range input {
minx = math.Min(minx, val)
maxx = math.Max(maxx, val)
}
fromPower := math.Floor(logbase(minx, power))
toPower := math.Floor(logba... | go | func PowerHist(power float64, input []float64) Histogram {
if len(input) == 0 || power <= 0 {
return Histogram{}
}
minx, maxx := input[0], input[0]
for _, val := range input {
minx = math.Min(minx, val)
maxx = math.Max(maxx, val)
}
fromPower := math.Floor(logbase(minx, power))
toPower := math.Floor(logba... | [
"func",
"PowerHist",
"(",
"power",
"float64",
",",
"input",
"[",
"]",
"float64",
")",
"Histogram",
"{",
"if",
"len",
"(",
"input",
")",
"==",
"0",
"||",
"power",
"<=",
"0",
"{",
"return",
"Histogram",
"{",
"}",
"\n",
"}",
"\n\n",
"minx",
",",
"maxx... | // PowerHist creates an histogram partionning input over buckets of power
// `pow`. | [
"PowerHist",
"creates",
"an",
"histogram",
"partionning",
"input",
"over",
"buckets",
"of",
"power",
"pow",
"."
] | 039c559e5e7e0512b313109b11266bf6fe2db223 | https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/histogram/histogram.go#L83-L120 |
148,002 | aybabtme/uniplot | histogram/histogram.go | Scale | func (h Histogram) Scale(s ScaleFunc, idx int) float64 {
bkt := h.Buckets[idx]
scale := s(h.Min, h.Max, bkt.Count)
return scale
} | go | func (h Histogram) Scale(s ScaleFunc, idx int) float64 {
bkt := h.Buckets[idx]
scale := s(h.Min, h.Max, bkt.Count)
return scale
} | [
"func",
"(",
"h",
"Histogram",
")",
"Scale",
"(",
"s",
"ScaleFunc",
",",
"idx",
"int",
")",
"float64",
"{",
"bkt",
":=",
"h",
".",
"Buckets",
"[",
"idx",
"]",
"\n",
"scale",
":=",
"s",
"(",
"h",
".",
"Min",
",",
"h",
".",
"Max",
",",
"bkt",
"... | // Scale gives the scaled count of the bucket at idx, using the
// provided scale func. | [
"Scale",
"gives",
"the",
"scaled",
"count",
"of",
"the",
"bucket",
"at",
"idx",
"using",
"the",
"provided",
"scale",
"func",
"."
] | 039c559e5e7e0512b313109b11266bf6fe2db223 | https://github.com/aybabtme/uniplot/blob/039c559e5e7e0512b313109b11266bf6fe2db223/histogram/histogram.go#L124-L128 |
148,003 | APTrust/bagins | payload.go | NewPayload | func NewPayload(location string) (*Payload, error) {
if _, err := os.Stat(filepath.Clean(location)); os.IsNotExist(err) {
return nil, fmt.Errorf("Payload directory does not exist! Returned: %v", err)
}
p := new(Payload)
p.dir = filepath.Clean(location)
return p, nil
} | go | func NewPayload(location string) (*Payload, error) {
if _, err := os.Stat(filepath.Clean(location)); os.IsNotExist(err) {
return nil, fmt.Errorf("Payload directory does not exist! Returned: %v", err)
}
p := new(Payload)
p.dir = filepath.Clean(location)
return p, nil
} | [
"func",
"NewPayload",
"(",
"location",
"string",
")",
"(",
"*",
"Payload",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filepath",
".",
"Clean",
"(",
"location",
")",
")",
";",
"os",
".",
"IsNotExist",
"(",
"err",
... | // Returns a new Payload struct managing the path provied. | [
"Returns",
"a",
"new",
"Payload",
"struct",
"managing",
"the",
"path",
"provied",
"."
] | 5bc94534149810750faf248f6ac948b48cbb2fc5 | https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/payload.go#L27-L34 |
148,004 | APTrust/bagins | payload.go | OctetStreamSum | func (p *Payload) OctetStreamSum() (int64, int) {
var sum int64
var count int
visit := func(pth string, info os.FileInfo, err error) error {
if !info.IsDir() {
sum = sum + info.Size()
count = count + 1
}
return err
}
filepath.Walk(p.dir, visit)
return sum, count
} | go | func (p *Payload) OctetStreamSum() (int64, int) {
var sum int64
var count int
visit := func(pth string, info os.FileInfo, err error) error {
if !info.IsDir() {
sum = sum + info.Size()
count = count + 1
}
return err
}
filepath.Walk(p.dir, visit)
return sum, count
} | [
"func",
"(",
"p",
"*",
"Payload",
")",
"OctetStreamSum",
"(",
")",
"(",
"int64",
",",
"int",
")",
"{",
"var",
"sum",
"int64",
"\n",
"var",
"count",
"int",
"\n\n",
"visit",
":=",
"func",
"(",
"pth",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",... | // Returns the octetstream sum and number of files of all the files in the
// payload directory. See the BagIt specification "Oxsum" field of the
// bag-info.txt file for more information. | [
"Returns",
"the",
"octetstream",
"sum",
"and",
"number",
"of",
"files",
"of",
"all",
"the",
"files",
"in",
"the",
"payload",
"directory",
".",
"See",
"the",
"BagIt",
"specification",
"Oxsum",
"field",
"of",
"the",
"bag",
"-",
"info",
".",
"txt",
"file",
... | 5bc94534149810750faf248f6ac948b48cbb2fc5 | https://github.com/APTrust/bagins/blob/5bc94534149810750faf248f6ac948b48cbb2fc5/payload.go#L184-L199 |
148,005 | Clever/ARCHIVED-oplog-replay | bson/reader.go | New | func New(r io.Reader) *Scanner {
scanner := NewScanner(r)
scanner.Split(func(data []byte, atEOF bool) (int, []byte, error) {
if len(data) < 4 {
return needMoreData()
}
var size int32
if err := binary.Read(bytes.NewBuffer(data[0:4]), binary.LittleEndian, &size); err != nil {
return 0, nil, err
}
if... | go | func New(r io.Reader) *Scanner {
scanner := NewScanner(r)
scanner.Split(func(data []byte, atEOF bool) (int, []byte, error) {
if len(data) < 4 {
return needMoreData()
}
var size int32
if err := binary.Read(bytes.NewBuffer(data[0:4]), binary.LittleEndian, &size); err != nil {
return 0, nil, err
}
if... | [
"func",
"New",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Scanner",
"{",
"scanner",
":=",
"NewScanner",
"(",
"r",
")",
"\n",
"scanner",
".",
"Split",
"(",
"func",
"(",
"data",
"[",
"]",
"byte",
",",
"atEOF",
"bool",
")",
"(",
"int",
",",
"[",
"]... | // mongodump outputs collections as binary files with all the documents appended together.
// The first four bytes are the size of the full document, including the size bytes. | [
"mongodump",
"outputs",
"collections",
"as",
"binary",
"files",
"with",
"all",
"the",
"documents",
"appended",
"together",
".",
"The",
"first",
"four",
"bytes",
"are",
"the",
"size",
"of",
"the",
"full",
"document",
"including",
"the",
"size",
"bytes",
"."
] | 486adac430d066719165dc1b164da60356497b40 | https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/bson/reader.go#L13-L32 |
148,006 | akutz/gournal | stdlib/gournal_stdlib.go | New | func New() gournal.Appender {
return &appender{
log.New(os.Stdout, "",
log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile),
}
} | go | func New() gournal.Appender {
return &appender{
log.New(os.Stdout, "",
log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile),
}
} | [
"func",
"New",
"(",
")",
"gournal",
".",
"Appender",
"{",
"return",
"&",
"appender",
"{",
"log",
".",
"New",
"(",
"os",
".",
"Stdout",
",",
"\"",
"\"",
",",
"log",
".",
"Ldate",
"|",
"log",
".",
"Ltime",
"|",
"log",
".",
"Lmicroseconds",
"|",
"lo... | // New returns a stdlib logger that implements the Gournal Appender interface. | [
"New",
"returns",
"a",
"stdlib",
"logger",
"that",
"implements",
"the",
"Gournal",
"Appender",
"interface",
"."
] | f6e56fa29076290418175a5105fd0223c66ad1bc | https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/stdlib/gournal_stdlib.go#L15-L20 |
148,007 | akutz/gournal | stdlib/gournal_stdlib.go | NewWithOptions | func NewWithOptions(out io.Writer, prefix string, flags int) gournal.Appender {
return &appender{log.New(out, prefix, flags)}
} | go | func NewWithOptions(out io.Writer, prefix string, flags int) gournal.Appender {
return &appender{log.New(out, prefix, flags)}
} | [
"func",
"NewWithOptions",
"(",
"out",
"io",
".",
"Writer",
",",
"prefix",
"string",
",",
"flags",
"int",
")",
"gournal",
".",
"Appender",
"{",
"return",
"&",
"appender",
"{",
"log",
".",
"New",
"(",
"out",
",",
"prefix",
",",
"flags",
")",
"}",
"\n",... | // NewWithOptions returns a stdlib logger that implements the Gournal Appender
// interface. | [
"NewWithOptions",
"returns",
"a",
"stdlib",
"logger",
"that",
"implements",
"the",
"Gournal",
"Appender",
"interface",
"."
] | f6e56fa29076290418175a5105fd0223c66ad1bc | https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/stdlib/gournal_stdlib.go#L24-L26 |
148,008 | golang-plus/uuid | internal/timebased/timebased.go | NewUUID | func NewUUID() ([]byte, error) {
// Get and release a global lock
locker.Lock()
defer locker.Unlock()
uuid := make([]byte, 16)
// get timestamp
now := time.Now().UTC()
timestamp := uint64(now.UnixNano()/100) + intervals // get timestamp
if !now.After(lastGenerated) {
clockSequence++ // last generated time k... | go | func NewUUID() ([]byte, error) {
// Get and release a global lock
locker.Lock()
defer locker.Unlock()
uuid := make([]byte, 16)
// get timestamp
now := time.Now().UTC()
timestamp := uint64(now.UnixNano()/100) + intervals // get timestamp
if !now.After(lastGenerated) {
clockSequence++ // last generated time k... | [
"func",
"NewUUID",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Get and release a global lock",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"locker",
".",
"Unlock",
"(",
")",
"\n\n",
"uuid",
":=",
"make",
"(",
"[",
"]",
"byte",
",... | // NewUUID returns a new time-based uuid. | [
"NewUUID",
"returns",
"a",
"new",
"time",
"-",
"based",
"uuid",
"."
] | abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe | https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/timebased/timebased.go#L28-L93 |
148,009 | golang-plus/uuid | internal/layout.go | SetLayout | func SetLayout(uuid []byte, layout Layout) {
switch layout {
case LayoutNCS:
uuid[8] = (uuid[8] | 0x00) & 0x0f // Msb0=0
case LayoutRFC4122:
uuid[8] = (uuid[8] | 0x80) & 0x8f // Msb0=1, Msb1=0
case LayoutMicrosoft:
uuid[8] = (uuid[8] | 0xc0) & 0xcf // Msb0=1, Msb1=1, Msb2=0
case LayoutFuture:
uuid[8] = (uu... | go | func SetLayout(uuid []byte, layout Layout) {
switch layout {
case LayoutNCS:
uuid[8] = (uuid[8] | 0x00) & 0x0f // Msb0=0
case LayoutRFC4122:
uuid[8] = (uuid[8] | 0x80) & 0x8f // Msb0=1, Msb1=0
case LayoutMicrosoft:
uuid[8] = (uuid[8] | 0xc0) & 0xcf // Msb0=1, Msb1=1, Msb2=0
case LayoutFuture:
uuid[8] = (uu... | [
"func",
"SetLayout",
"(",
"uuid",
"[",
"]",
"byte",
",",
"layout",
"Layout",
")",
"{",
"switch",
"layout",
"{",
"case",
"LayoutNCS",
":",
"uuid",
"[",
"8",
"]",
"=",
"(",
"uuid",
"[",
"8",
"]",
"|",
"0x00",
")",
"&",
"0x0f",
"// Msb0=0",
"\n",
"c... | // SetLayout sets the layout for uuid.
// This is intended to be called from the New function in packages that implement uuid generating functions. | [
"SetLayout",
"sets",
"the",
"layout",
"for",
"uuid",
".",
"This",
"is",
"intended",
"to",
"be",
"called",
"from",
"the",
"New",
"function",
"in",
"packages",
"that",
"implement",
"uuid",
"generating",
"functions",
"."
] | abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe | https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/layout.go#L21-L34 |
148,010 | golang-plus/uuid | internal/layout.go | GetLayout | func GetLayout(uuid []byte) Layout {
switch {
case (uuid[8] & 0x80) == 0x00:
return LayoutNCS
case (uuid[8] & 0xc0) == 0x80:
return LayoutRFC4122
case (uuid[8] & 0xe0) == 0xc0:
return LayoutMicrosoft
case (uuid[8] & 0xe0) == 0xe0:
return LayoutFuture
}
return LayoutInvalid
} | go | func GetLayout(uuid []byte) Layout {
switch {
case (uuid[8] & 0x80) == 0x00:
return LayoutNCS
case (uuid[8] & 0xc0) == 0x80:
return LayoutRFC4122
case (uuid[8] & 0xe0) == 0xc0:
return LayoutMicrosoft
case (uuid[8] & 0xe0) == 0xe0:
return LayoutFuture
}
return LayoutInvalid
} | [
"func",
"GetLayout",
"(",
"uuid",
"[",
"]",
"byte",
")",
"Layout",
"{",
"switch",
"{",
"case",
"(",
"uuid",
"[",
"8",
"]",
"&",
"0x80",
")",
"==",
"0x00",
":",
"return",
"LayoutNCS",
"\n",
"case",
"(",
"uuid",
"[",
"8",
"]",
"&",
"0xc0",
")",
"... | // GetLayout returns layout of uuid. | [
"GetLayout",
"returns",
"layout",
"of",
"uuid",
"."
] | abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe | https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/layout.go#L37-L50 |
148,011 | akutz/gournal | zap/gournal_zap.go | NewWithOptions | func NewWithOptions(enc zap.Encoder, opts ...zap.Option) gournal.Appender {
return &appender{zap.New(enc, opts...)}
} | go | func NewWithOptions(enc zap.Encoder, opts ...zap.Option) gournal.Appender {
return &appender{zap.New(enc, opts...)}
} | [
"func",
"NewWithOptions",
"(",
"enc",
"zap",
".",
"Encoder",
",",
"opts",
"...",
"zap",
".",
"Option",
")",
"gournal",
".",
"Appender",
"{",
"return",
"&",
"appender",
"{",
"zap",
".",
"New",
"(",
"enc",
",",
"opts",
"...",
")",
"}",
"\n",
"}"
] | // NewWithOptions returns a zap logger that implements the Gournal Appender
// interface. | [
"NewWithOptions",
"returns",
"a",
"zap",
"logger",
"that",
"implements",
"the",
"Gournal",
"Appender",
"interface",
"."
] | f6e56fa29076290418175a5105fd0223c66ad1bc | https://github.com/akutz/gournal/blob/f6e56fa29076290418175a5105fd0223c66ad1bc/zap/gournal_zap.go#L26-L28 |
148,012 | golang-plus/uuid | internal/random/random.go | NewUUID | func NewUUID() ([]byte, error) {
uuid := make([]byte, 16)
n, err := rand.Read(uuid[:])
if err != nil {
return nil, errors.Wrap(err, "could not generate random bytes")
}
if n != len(uuid) {
return nil, errors.New("could not generate random bytes with 16 length")
}
// set version(v4)
internal.SetVersion(uuid... | go | func NewUUID() ([]byte, error) {
uuid := make([]byte, 16)
n, err := rand.Read(uuid[:])
if err != nil {
return nil, errors.Wrap(err, "could not generate random bytes")
}
if n != len(uuid) {
return nil, errors.New("could not generate random bytes with 16 length")
}
// set version(v4)
internal.SetVersion(uuid... | [
"func",
"NewUUID",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"uuid",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
")",
"\n",
"n",
",",
"err",
":=",
"rand",
".",
"Read",
"(",
"uuid",
"[",
":",
"]",
")",
"\n",
"if",
"err",
... | // NewUUID returns a new randomly uuid. | [
"NewUUID",
"returns",
"a",
"new",
"randomly",
"uuid",
"."
] | abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe | https://github.com/golang-plus/uuid/blob/abc8f6f4d9f8ee48848030dba1eb233bc8b4c4fe/internal/random/random.go#L12-L28 |
148,013 | Clever/ARCHIVED-oplog-replay | ratecontroller/fixed/fixed.go | New | func New(operationsPerSecond float64) ratecontroller.Controller {
return &fixedRateController{opsPerSecond: operationsPerSecond, replayStartTime: time.Now()}
} | go | func New(operationsPerSecond float64) ratecontroller.Controller {
return &fixedRateController{opsPerSecond: operationsPerSecond, replayStartTime: time.Now()}
} | [
"func",
"New",
"(",
"operationsPerSecond",
"float64",
")",
"ratecontroller",
".",
"Controller",
"{",
"return",
"&",
"fixedRateController",
"{",
"opsPerSecond",
":",
"operationsPerSecond",
",",
"replayStartTime",
":",
"time",
".",
"Now",
"(",
")",
"}",
"\n",
"}"
... | // New returns a rate controller that controls oplog entries at a rate of
// X per second | [
"New",
"returns",
"a",
"rate",
"controller",
"that",
"controls",
"oplog",
"entries",
"at",
"a",
"rate",
"of",
"X",
"per",
"second"
] | 486adac430d066719165dc1b164da60356497b40 | https://github.com/Clever/ARCHIVED-oplog-replay/blob/486adac430d066719165dc1b164da60356497b40/ratecontroller/fixed/fixed.go#L29-L31 |
148,014 | mb0/glob | glob.go | metaRegexp | func (c Config) metaRegexp() (*regexp.Regexp, error) {
meta := regexp.QuoteMeta(string([]byte{c.Star, c.Quest, c.Range}))
return regexp.Compile(`(^|[^\\])[` + meta + `]`)
} | go | func (c Config) metaRegexp() (*regexp.Regexp, error) {
meta := regexp.QuoteMeta(string([]byte{c.Star, c.Quest, c.Range}))
return regexp.Compile(`(^|[^\\])[` + meta + `]`)
} | [
"func",
"(",
"c",
"Config",
")",
"metaRegexp",
"(",
")",
"(",
"*",
"regexp",
".",
"Regexp",
",",
"error",
")",
"{",
"meta",
":=",
"regexp",
".",
"QuoteMeta",
"(",
"string",
"(",
"[",
"]",
"byte",
"{",
"c",
".",
"Star",
",",
"c",
".",
"Quest",
"... | // mataRegexp returns a regexp matcher to detect pattern control characters. | [
"mataRegexp",
"returns",
"a",
"regexp",
"matcher",
"to",
"detect",
"pattern",
"control",
"characters",
"."
] | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L60-L63 |
148,015 | mb0/glob | glob.go | New | func New(c Config) (*Globber, error) {
hasmeta, err := c.metaRegexp()
if err != nil {
return nil, err
}
return &Globber{c, hasmeta}, nil
} | go | func New(c Config) (*Globber, error) {
hasmeta, err := c.metaRegexp()
if err != nil {
return nil, err
}
return &Globber{c, hasmeta}, nil
} | [
"func",
"New",
"(",
"c",
"Config",
")",
"(",
"*",
"Globber",
",",
"error",
")",
"{",
"hasmeta",
",",
"err",
":=",
"c",
".",
"metaRegexp",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&"... | // New returns a new Globber with the given Config c. | [
"New",
"returns",
"a",
"new",
"Globber",
"with",
"the",
"given",
"Config",
"c",
"."
] | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L86-L92 |
148,016 | mb0/glob | glob.go | GlobStrings | func (g *Globber) GlobStrings(list []string, pattern string) (matches []string, err error) {
if len(list) == 0 {
return
}
// check if pattern is a simple path
if !g.hasmeta.MatchString(pattern) {
i := sort.SearchStrings(list, pattern)
if i < len(list) && list[i] == pattern {
matches = []string{pattern}
}... | go | func (g *Globber) GlobStrings(list []string, pattern string) (matches []string, err error) {
if len(list) == 0 {
return
}
// check if pattern is a simple path
if !g.hasmeta.MatchString(pattern) {
i := sort.SearchStrings(list, pattern)
if i < len(list) && list[i] == pattern {
matches = []string{pattern}
}... | [
"func",
"(",
"g",
"*",
"Globber",
")",
"GlobStrings",
"(",
"list",
"[",
"]",
"string",
",",
"pattern",
"string",
")",
"(",
"matches",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"list",
")",
"==",
"0",
"{",
"return",
"\n"... | // GlobStrings returns all expanded paths from list matching pattern or nil if there are no matches.
// The syntax of pattern is the same as in Match. The control characters of the pattern and
// GlobStar matching behaviour can be configured in Config.
// The given list must be sorted in ascending order. New matches ar... | [
"GlobStrings",
"returns",
"all",
"expanded",
"paths",
"from",
"list",
"matching",
"pattern",
"or",
"nil",
"if",
"there",
"are",
"no",
"matches",
".",
"The",
"syntax",
"of",
"pattern",
"is",
"the",
"same",
"as",
"in",
"Match",
".",
"The",
"control",
"charac... | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L98-L129 |
148,017 | mb0/glob | glob.go | split | func (g *Globber) split(path string) (dir, file string) {
i := len(path) - 1
for i >= 0 && path[i] != g.config.Separator {
i--
}
return path[:i+1], path[i+1:]
} | go | func (g *Globber) split(path string) (dir, file string) {
i := len(path) - 1
for i >= 0 && path[i] != g.config.Separator {
i--
}
return path[:i+1], path[i+1:]
} | [
"func",
"(",
"g",
"*",
"Globber",
")",
"split",
"(",
"path",
"string",
")",
"(",
"dir",
",",
"file",
"string",
")",
"{",
"i",
":=",
"len",
"(",
"path",
")",
"-",
"1",
"\n",
"for",
"i",
">=",
"0",
"&&",
"path",
"[",
"i",
"]",
"!=",
"g",
".",... | // split splits path immediately following the final Separator, separating it into
// a directory and file component. If there is no Separator in path, split returns an empty
// dir and file set to path. The returned values have the property that path = dir+file. | [
"split",
"splits",
"path",
"immediately",
"following",
"the",
"final",
"Separator",
"separating",
"it",
"into",
"a",
"directory",
"and",
"file",
"component",
".",
"If",
"there",
"is",
"no",
"Separator",
"in",
"path",
"split",
"returns",
"an",
"empty",
"dir",
... | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L134-L140 |
148,018 | mb0/glob | glob.go | globStrings | func (g *Globber) globStrings(list []string, dir, pattern string, matches []string) ([]string, error) {
m := matches
matchtree := g.config.GlobStar && g.hasGlobStar(pattern)
paths := g.filepaths(list, dir, matchtree)
dirlen := len(dir)
if dir != "" {
dirlen++
}
for _, path := range paths {
matched, err := g.... | go | func (g *Globber) globStrings(list []string, dir, pattern string, matches []string) ([]string, error) {
m := matches
matchtree := g.config.GlobStar && g.hasGlobStar(pattern)
paths := g.filepaths(list, dir, matchtree)
dirlen := len(dir)
if dir != "" {
dirlen++
}
for _, path := range paths {
matched, err := g.... | [
"func",
"(",
"g",
"*",
"Globber",
")",
"globStrings",
"(",
"list",
"[",
"]",
"string",
",",
"dir",
",",
"pattern",
"string",
",",
"matches",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"m",
":=",
"matches",
"\n",
"ma... | // globStrings searches for strings matching pattern in list and appends them to matches.
// The given list must be sorted in ascending order. New matches are added in lexicographical order. | [
"globStrings",
"searches",
"for",
"strings",
"matching",
"pattern",
"in",
"list",
"and",
"appends",
"them",
"to",
"matches",
".",
"The",
"given",
"list",
"must",
"be",
"sorted",
"in",
"ascending",
"order",
".",
"New",
"matches",
"are",
"added",
"in",
"lexico... | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L144-L162 |
148,019 | mb0/glob | glob.go | hasGlobStar | func (g *Globber) hasGlobStar(pattern string) bool {
for i := 0; i < len(pattern); i++ {
switch pattern[i] {
case g.config.Separator:
return false
case g.config.Star:
if i+1 < len(pattern) && pattern[i+1] == g.config.Star {
return true
}
case '\\':
i++
}
}
return false
} | go | func (g *Globber) hasGlobStar(pattern string) bool {
for i := 0; i < len(pattern); i++ {
switch pattern[i] {
case g.config.Separator:
return false
case g.config.Star:
if i+1 < len(pattern) && pattern[i+1] == g.config.Star {
return true
}
case '\\':
i++
}
}
return false
} | [
"func",
"(",
"g",
"*",
"Globber",
")",
"hasGlobStar",
"(",
"pattern",
"string",
")",
"bool",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"pattern",
")",
";",
"i",
"++",
"{",
"switch",
"pattern",
"[",
"i",
"]",
"{",
"case",
"g",
".",
... | // hasGlobStar returns true if the pattern contains multiple Star wildcards in the first path segment. | [
"hasGlobStar",
"returns",
"true",
"if",
"the",
"pattern",
"contains",
"multiple",
"Star",
"wildcards",
"in",
"the",
"first",
"path",
"segment",
"."
] | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L165-L179 |
148,020 | mb0/glob | glob.go | filepaths | func (g *Globber) filepaths(list []string, dir string, tree bool) (r []string) {
var dirsep string
if dir != "" {
dirsep = dir + string(g.config.Separator)
i := sort.SearchStrings(list, dirsep)
if i >= len(list) {
return
}
list = list[i:]
}
found := map[string]struct{}{}
for _, path := range list {
... | go | func (g *Globber) filepaths(list []string, dir string, tree bool) (r []string) {
var dirsep string
if dir != "" {
dirsep = dir + string(g.config.Separator)
i := sort.SearchStrings(list, dirsep)
if i >= len(list) {
return
}
list = list[i:]
}
found := map[string]struct{}{}
for _, path := range list {
... | [
"func",
"(",
"g",
"*",
"Globber",
")",
"filepaths",
"(",
"list",
"[",
"]",
"string",
",",
"dir",
"string",
",",
"tree",
"bool",
")",
"(",
"r",
"[",
"]",
"string",
")",
"{",
"var",
"dirsep",
"string",
"\n",
"if",
"dir",
"!=",
"\"",
"\"",
"{",
"d... | // filepaths returns child paths of dir expanded from the given list.
// If tree is true it returns all ancestor paths of dir. | [
"filepaths",
"returns",
"child",
"paths",
"of",
"dir",
"expanded",
"from",
"the",
"given",
"list",
".",
"If",
"tree",
"is",
"true",
"it",
"returns",
"all",
"ancestor",
"paths",
"of",
"dir",
"."
] | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L183-L213 |
148,021 | mb0/glob | glob.go | scanChunk | func (g *Globber) scanChunk(pattern string) (star int, chunk, rest string) {
for len(pattern) > 0 && pattern[0] == g.config.Star {
pattern = pattern[1:]
star++
}
inrange := false
var i int
Scan:
for i = 0; i < len(pattern); i++ {
switch pattern[i] {
case '\\':
// error check handled in matchChunk: bad p... | go | func (g *Globber) scanChunk(pattern string) (star int, chunk, rest string) {
for len(pattern) > 0 && pattern[0] == g.config.Star {
pattern = pattern[1:]
star++
}
inrange := false
var i int
Scan:
for i = 0; i < len(pattern); i++ {
switch pattern[i] {
case '\\':
// error check handled in matchChunk: bad p... | [
"func",
"(",
"g",
"*",
"Globber",
")",
"scanChunk",
"(",
"pattern",
"string",
")",
"(",
"star",
"int",
",",
"chunk",
",",
"rest",
"string",
")",
"{",
"for",
"len",
"(",
"pattern",
")",
">",
"0",
"&&",
"pattern",
"[",
"0",
"]",
"==",
"g",
".",
"... | // scanChunk gets the next segment of pattern, which is a non-star string
// possibly preceded by stars. | [
"scanChunk",
"gets",
"the",
"next",
"segment",
"of",
"pattern",
"which",
"is",
"a",
"non",
"-",
"star",
"string",
"possibly",
"preceded",
"by",
"stars",
"."
] | 1eb79d2de6c448664e7272f8b9fe1938239e3aaa | https://github.com/mb0/glob/blob/1eb79d2de6c448664e7272f8b9fe1938239e3aaa/glob.go#L320-L346 |
148,022 | mastahyeti/certstore | certstore_windows.go | openStore | func openStore() (*winStore, error) {
storeName := unsafe.Pointer(stringToUTF16("MY"))
defer C.free(storeName)
store := C.CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, C.CERT_SYSTEM_STORE_CURRENT_USER, storeName)
if store == nil {
return nil, lastError("failed to open system cert store")
}
return &winStore{st... | go | func openStore() (*winStore, error) {
storeName := unsafe.Pointer(stringToUTF16("MY"))
defer C.free(storeName)
store := C.CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, C.CERT_SYSTEM_STORE_CURRENT_USER, storeName)
if store == nil {
return nil, lastError("failed to open system cert store")
}
return &winStore{st... | [
"func",
"openStore",
"(",
")",
"(",
"*",
"winStore",
",",
"error",
")",
"{",
"storeName",
":=",
"unsafe",
".",
"Pointer",
"(",
"stringToUTF16",
"(",
"\"",
"\"",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"storeName",
")",
"\n\n",
"store",
":=",
... | // openStore opens the current user's personal cert store. | [
"openStore",
"opens",
"the",
"current",
"user",
"s",
"personal",
"cert",
"store",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L79-L89 |
148,023 | mastahyeti/certstore | certstore_windows.go | Close | func (s *winStore) Close() {
C.CertCloseStore(s.store, 0)
s.store = nil
} | go | func (s *winStore) Close() {
C.CertCloseStore(s.store, 0)
s.store = nil
} | [
"func",
"(",
"s",
"*",
"winStore",
")",
"Close",
"(",
")",
"{",
"C",
".",
"CertCloseStore",
"(",
"s",
".",
"store",
",",
"0",
")",
"\n",
"s",
".",
"store",
"=",
"nil",
"\n",
"}"
] | // Close implements the Store interface. | [
"Close",
"implements",
"the",
"Store",
"interface",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L204-L207 |
148,024 | mastahyeti/certstore | certstore_windows.go | Sign | func (wpk *winPrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
if wpk.capiProv != 0 {
return wpk.capiSignHash(opts.HashFunc(), digest)
} else if wpk.cngHandle != 0 {
return wpk.cngSignHash(opts.HashFunc(), digest)
} else {
return nil, errors.New("bad private key")
}
} | go | func (wpk *winPrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
if wpk.capiProv != 0 {
return wpk.capiSignHash(opts.HashFunc(), digest)
} else if wpk.cngHandle != 0 {
return wpk.cngSignHash(opts.HashFunc(), digest)
} else {
return nil, errors.New("bad private key")
}
} | [
"func",
"(",
"wpk",
"*",
"winPrivateKey",
")",
"Sign",
"(",
"rand",
"io",
".",
"Reader",
",",
"digest",
"[",
"]",
"byte",
",",
"opts",
"crypto",
".",
"SignerOpts",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"wpk",
".",
"capiProv",
... | // Sign implements the crypto.Signer interface. | [
"Sign",
"implements",
"the",
"crypto",
".",
"Signer",
"interface",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L360-L368 |
148,025 | mastahyeti/certstore | certstore_windows.go | cngSignHash | func (wpk *winPrivateKey) cngSignHash(hash crypto.Hash, digest []byte) ([]byte, error) {
if len(digest) != hash.Size() {
return nil, errors.New("bad digest for hash")
}
var (
// input
padPtr = unsafe.Pointer(nil)
digestPtr = (*C.BYTE)(&digest[0])
digestLen = C.DWORD(len(digest))
flags = C.DWORD(0... | go | func (wpk *winPrivateKey) cngSignHash(hash crypto.Hash, digest []byte) ([]byte, error) {
if len(digest) != hash.Size() {
return nil, errors.New("bad digest for hash")
}
var (
// input
padPtr = unsafe.Pointer(nil)
digestPtr = (*C.BYTE)(&digest[0])
digestLen = C.DWORD(len(digest))
flags = C.DWORD(0... | [
"func",
"(",
"wpk",
"*",
"winPrivateKey",
")",
"cngSignHash",
"(",
"hash",
"crypto",
".",
"Hash",
",",
"digest",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"digest",
")",
"!=",
"hash",
".",
"Size",
"("... | // cngSignHash signs a digest using the CNG APIs. | [
"cngSignHash",
"signs",
"a",
"digest",
"using",
"the",
"CNG",
"APIs",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L371-L441 |
148,026 | mastahyeti/certstore | certstore_windows.go | getProviderParam | func (wpk *winPrivateKey) getProviderParam(param C.DWORD) (unsafe.Pointer, error) {
var dataLen C.DWORD
if ok := C.CryptGetProvParam(wpk.capiProv, param, nil, &dataLen, 0); ok == winFalse {
return nil, lastError("failed to get provider parameter size")
}
data := make([]byte, dataLen)
dataPtr := (*C.BYTE)(unsafe... | go | func (wpk *winPrivateKey) getProviderParam(param C.DWORD) (unsafe.Pointer, error) {
var dataLen C.DWORD
if ok := C.CryptGetProvParam(wpk.capiProv, param, nil, &dataLen, 0); ok == winFalse {
return nil, lastError("failed to get provider parameter size")
}
data := make([]byte, dataLen)
dataPtr := (*C.BYTE)(unsafe... | [
"func",
"(",
"wpk",
"*",
"winPrivateKey",
")",
"getProviderParam",
"(",
"param",
"C",
".",
"DWORD",
")",
"(",
"unsafe",
".",
"Pointer",
",",
"error",
")",
"{",
"var",
"dataLen",
"C",
".",
"DWORD",
"\n",
"if",
"ok",
":=",
"C",
".",
"CryptGetProvParam",
... | // getProviderParam gets a parameter about a provider. | [
"getProviderParam",
"gets",
"a",
"parameter",
"about",
"a",
"provider",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L572-L586 |
148,027 | mastahyeti/certstore | certstore_windows.go | Close | func (wpk *winPrivateKey) Close() {
if wpk.cngHandle != 0 {
C.NCryptFreeObject(C.NCRYPT_HANDLE(wpk.cngHandle))
wpk.cngHandle = 0
}
if wpk.capiProv != 0 {
C.CryptReleaseContext(wpk.capiProv, 0)
wpk.capiProv = 0
}
} | go | func (wpk *winPrivateKey) Close() {
if wpk.cngHandle != 0 {
C.NCryptFreeObject(C.NCRYPT_HANDLE(wpk.cngHandle))
wpk.cngHandle = 0
}
if wpk.capiProv != 0 {
C.CryptReleaseContext(wpk.capiProv, 0)
wpk.capiProv = 0
}
} | [
"func",
"(",
"wpk",
"*",
"winPrivateKey",
")",
"Close",
"(",
")",
"{",
"if",
"wpk",
".",
"cngHandle",
"!=",
"0",
"{",
"C",
".",
"NCryptFreeObject",
"(",
"C",
".",
"NCRYPT_HANDLE",
"(",
"wpk",
".",
"cngHandle",
")",
")",
"\n",
"wpk",
".",
"cngHandle",... | // Close closes this winPrivateKey. | [
"Close",
"closes",
"this",
"winPrivateKey",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L589-L599 |
148,028 | mastahyeti/certstore | certstore_windows.go | lastError | func lastError(msg string) error {
if err := checkError(msg); err != nil {
return err
}
return errors.New(msg)
} | go | func lastError(msg string) error {
if err := checkError(msg); err != nil {
return err
}
return errors.New(msg)
} | [
"func",
"lastError",
"(",
"msg",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"checkError",
"(",
"msg",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"errors",
".",
"New",
"(",
"msg",
")",
"\n",
"}"
] | // lastError gets the last error from the current thread. If there isn't one, it
// returns a new error. | [
"lastError",
"gets",
"the",
"last",
"error",
"from",
"the",
"current",
"thread",
".",
"If",
"there",
"isn",
"t",
"one",
"it",
"returns",
"a",
"new",
"error",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L617-L623 |
148,029 | mastahyeti/certstore | certstore_windows.go | checkError | func checkError(msg string) error {
if code := errCode(C.GetLastError()); code != 0 {
return errors.Wrap(code, msg)
}
return nil
} | go | func checkError(msg string) error {
if code := errCode(C.GetLastError()); code != 0 {
return errors.Wrap(code, msg)
}
return nil
} | [
"func",
"checkError",
"(",
"msg",
"string",
")",
"error",
"{",
"if",
"code",
":=",
"errCode",
"(",
"C",
".",
"GetLastError",
"(",
")",
")",
";",
"code",
"!=",
"0",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"code",
",",
"msg",
")",
"\n",
"}",
"\n... | // checkError tries to get the last error from the current thread. If there
// isn't one, it returns nil. | [
"checkError",
"tries",
"to",
"get",
"the",
"last",
"error",
"from",
"the",
"current",
"thread",
".",
"If",
"there",
"isn",
"t",
"one",
"it",
"returns",
"nil",
"."
] | 04bdce6d3f6d509bf404d6a2e5b016db14eff232 | https://github.com/mastahyeti/certstore/blob/04bdce6d3f6d509bf404d6a2e5b016db14eff232/certstore_windows.go#L627-L633 |
148,030 | spiegel-im-spiegel/gocli | file/glob.go | NewGlobOption | func NewGlobOption(opts ...GlogOptFunc) *GlobOption {
o := &GlobOption{flags: GlobStdFlags}
for _, opt := range opts {
opt(o)
}
return o
} | go | func NewGlobOption(opts ...GlogOptFunc) *GlobOption {
o := &GlobOption{flags: GlobStdFlags}
for _, opt := range opts {
opt(o)
}
return o
} | [
"func",
"NewGlobOption",
"(",
"opts",
"...",
"GlogOptFunc",
")",
"*",
"GlobOption",
"{",
"o",
":=",
"&",
"GlobOption",
"{",
"flags",
":",
"GlobStdFlags",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"o",
")",
"\n",
"}",
... | //NewGlobOption returns GlobOption instance | [
"NewGlobOption",
"returns",
"GlobOption",
"instance"
] | 3e939b56b665677023383e8a22a9f15079c80a43 | https://github.com/spiegel-im-spiegel/gocli/blob/3e939b56b665677023383e8a22a9f15079c80a43/file/glob.go#L55-L61 |
148,031 | mynameisfiber/gohll | gob.go | MarshalBinary | func (h *HLL) MarshalBinary() ([]byte, error) {
var buf bytes.Buffer
ts := h.tempSet
if ts == nil {
ts = &tempSet{}
}
sl := h.sparseList
if sl == nil {
sl = &sparseList{}
}
err := gob.NewEncoder(&buf).Encode(
serializable{
P: h.P,
M1: h.m1,
M2: h.m2,
Alpha: h.alph... | go | func (h *HLL) MarshalBinary() ([]byte, error) {
var buf bytes.Buffer
ts := h.tempSet
if ts == nil {
ts = &tempSet{}
}
sl := h.sparseList
if sl == nil {
sl = &sparseList{}
}
err := gob.NewEncoder(&buf).Encode(
serializable{
P: h.P,
M1: h.m1,
M2: h.m2,
Alpha: h.alph... | [
"func",
"(",
"h",
"*",
"HLL",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"ts",
":=",
"h",
".",
"tempSet",
"\n",
"if",
"ts",
"==",
"nil",
"{",
"ts",
"=",
"&",
"tem... | // MarshalBinary implements encoding.BinaryMarshaler.
// Does not serialize hasher! | [
"MarshalBinary",
"implements",
"encoding",
".",
"BinaryMarshaler",
".",
"Does",
"not",
"serialize",
"hasher!"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gob.go#L25-L50 |
148,032 | mynameisfiber/gohll | gob.go | UnmarshalBinary | func (h *HLL) UnmarshalBinary(data []byte) error {
var s serializable
err := gob.NewDecoder(bytes.NewReader(data)).Decode(&s)
if err != nil {
return err
}
h.P = s.P
h.m1 = s.M1
h.m2 = s.M2
h.alpha = s.Alpha
h.format = s.Format
h.tempSet = &s.TempSet
h.sparseList = &s.SparseList
h.registers = s.Registers
... | go | func (h *HLL) UnmarshalBinary(data []byte) error {
var s serializable
err := gob.NewDecoder(bytes.NewReader(data)).Decode(&s)
if err != nil {
return err
}
h.P = s.P
h.m1 = s.M1
h.m2 = s.M2
h.alpha = s.Alpha
h.format = s.Format
h.tempSet = &s.TempSet
h.sparseList = &s.SparseList
h.registers = s.Registers
... | [
"func",
"(",
"h",
"*",
"HLL",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"s",
"serializable",
"\n",
"err",
":=",
"gob",
".",
"NewDecoder",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
")",
".",
"Decode",
"... | // UnmarshalBinary implements encoding.BinaryUnmarshaler.
// Preserves the hasher. | [
"UnmarshalBinary",
"implements",
"encoding",
".",
"BinaryUnmarshaler",
".",
"Preserves",
"the",
"hasher",
"."
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gob.go#L54-L73 |
148,033 | mynameisfiber/gohll | auxillary.go | encodeHash | func encodeHash(x uint64, p uint8) uint32 {
if sliceUint64(x, 63-p, 39) == 0 {
var result uint32
result = uint32((x >> 32) &^ 0x7f)
w := sliceUint64(x, 63-p, 0) << p
result |= (uint32(bits.LeadingZeros64(w)) << 1)
result |= 1
return result
}
return uint32(x>>32) &^ 0x1
} | go | func encodeHash(x uint64, p uint8) uint32 {
if sliceUint64(x, 63-p, 39) == 0 {
var result uint32
result = uint32((x >> 32) &^ 0x7f)
w := sliceUint64(x, 63-p, 0) << p
result |= (uint32(bits.LeadingZeros64(w)) << 1)
result |= 1
return result
}
return uint32(x>>32) &^ 0x1
} | [
"func",
"encodeHash",
"(",
"x",
"uint64",
",",
"p",
"uint8",
")",
"uint32",
"{",
"if",
"sliceUint64",
"(",
"x",
",",
"63",
"-",
"p",
",",
"39",
")",
"==",
"0",
"{",
"var",
"result",
"uint32",
"\n",
"result",
"=",
"uint32",
"(",
"(",
"x",
">>",
... | // encodeHash takes in a 64bit hash and the set precision and outputs a 32bit
// encoded hash for use with the sparseList | [
"encodeHash",
"takes",
"in",
"a",
"64bit",
"hash",
"and",
"the",
"set",
"precision",
"and",
"outputs",
"a",
"32bit",
"encoded",
"hash",
"for",
"use",
"with",
"the",
"sparseList"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/auxillary.go#L10-L20 |
148,034 | mynameisfiber/gohll | auxillary.go | estimateBias | func estimateBias(E float64, p uint8) float64 {
if p > 18 {
return 0.0
}
estimateVector := rawEstimateData[p-4]
N := len(estimateVector)
if E < estimateVector[0] || E > estimateVector[N-1] {
return 0.0
}
biasVector := biasData[p-4]
if estimateVector[0] == E {
return biasVector[0]
}
for i := 1; i < le... | go | func estimateBias(E float64, p uint8) float64 {
if p > 18 {
return 0.0
}
estimateVector := rawEstimateData[p-4]
N := len(estimateVector)
if E < estimateVector[0] || E > estimateVector[N-1] {
return 0.0
}
biasVector := biasData[p-4]
if estimateVector[0] == E {
return biasVector[0]
}
for i := 1; i < le... | [
"func",
"estimateBias",
"(",
"E",
"float64",
",",
"p",
"uint8",
")",
"float64",
"{",
"if",
"p",
">",
"18",
"{",
"return",
"0.0",
"\n",
"}",
"\n",
"estimateVector",
":=",
"rawEstimateData",
"[",
"p",
"-",
"4",
"]",
"\n",
"N",
":=",
"len",
"(",
"esti... | // estimateBias estimates the amount of bias in a normal mode cardinality query
// with an estimator value of E and a normal mode precision of p | [
"estimateBias",
"estimates",
"the",
"amount",
"of",
"bias",
"in",
"a",
"normal",
"mode",
"cardinality",
"query",
"with",
"an",
"estimator",
"value",
"of",
"E",
"and",
"a",
"normal",
"mode",
"precision",
"of",
"p"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/auxillary.go#L54-L80 |
148,035 | mynameisfiber/gohll | gohll.go | NewHLLByError | func NewHLLByError(errorRate float64) (*HLL, error) {
if errorRate < 0.00025390625 || errorRate > 0.26 {
return nil, ErrErrorRateOutOfBounds
}
p := uint8(math.Ceil(math.Log2(math.Pow(1.04/errorRate, 2))))
return NewHLL(p)
} | go | func NewHLLByError(errorRate float64) (*HLL, error) {
if errorRate < 0.00025390625 || errorRate > 0.26 {
return nil, ErrErrorRateOutOfBounds
}
p := uint8(math.Ceil(math.Log2(math.Pow(1.04/errorRate, 2))))
return NewHLL(p)
} | [
"func",
"NewHLLByError",
"(",
"errorRate",
"float64",
")",
"(",
"*",
"HLL",
",",
"error",
")",
"{",
"if",
"errorRate",
"<",
"0.00025390625",
"||",
"errorRate",
">",
"0.26",
"{",
"return",
"nil",
",",
"ErrErrorRateOutOfBounds",
"\n",
"}",
"\n",
"p",
":=",
... | // NewHLLByError creates a new HLL object with error rate given by `errorRate`.
// The error must be between 26% and 0.0253% | [
"NewHLLByError",
"creates",
"a",
"new",
"HLL",
"object",
"with",
"error",
"rate",
"given",
"by",
"errorRate",
".",
"The",
"error",
"must",
"be",
"between",
"26%",
"and",
"0",
".",
"0253%"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L76-L82 |
148,036 | mynameisfiber/gohll | gohll.go | NewHLL | func NewHLL(p uint8) (*HLL, error) {
if p < 4 || p > 25 {
return nil, ErrInvalidP
}
m1 := uint(1 << p)
m2 := uint(1 << 25)
var alpha float64
switch m1 {
case 16:
alpha = 0.673
case 32:
alpha = 0.697
case 64:
alpha = 0.709
default:
alpha = 0.7213 / (1 + 1.079/float64(m1))
}
format := SPARSE
//... | go | func NewHLL(p uint8) (*HLL, error) {
if p < 4 || p > 25 {
return nil, ErrInvalidP
}
m1 := uint(1 << p)
m2 := uint(1 << 25)
var alpha float64
switch m1 {
case 16:
alpha = 0.673
case 32:
alpha = 0.697
case 64:
alpha = 0.709
default:
alpha = 0.7213 / (1 + 1.079/float64(m1))
}
format := SPARSE
//... | [
"func",
"NewHLL",
"(",
"p",
"uint8",
")",
"(",
"*",
"HLL",
",",
"error",
")",
"{",
"if",
"p",
"<",
"4",
"||",
"p",
">",
"25",
"{",
"return",
"nil",
",",
"ErrInvalidP",
"\n",
"}",
"\n\n",
"m1",
":=",
"uint",
"(",
"1",
"<<",
"p",
")",
"\n",
"... | // NewHLL creates a new HLL object given a normal mode precision between 4 and
// 25 | [
"NewHLL",
"creates",
"a",
"new",
"HLL",
"object",
"given",
"a",
"normal",
"mode",
"precision",
"between",
"4",
"and",
"25"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L86-L124 |
148,037 | mynameisfiber/gohll | gohll.go | Add | func (h *HLL) Add(value string) {
hash := h.Hasher(value)
h.AddHash(hash)
} | go | func (h *HLL) Add(value string) {
hash := h.Hasher(value)
h.AddHash(hash)
} | [
"func",
"(",
"h",
"*",
"HLL",
")",
"Add",
"(",
"value",
"string",
")",
"{",
"hash",
":=",
"h",
".",
"Hasher",
"(",
"value",
")",
"\n",
"h",
".",
"AddHash",
"(",
"hash",
")",
"\n",
"}"
] | // Add will add the given string value to the HLL using the currently set
// Hasher function | [
"Add",
"will",
"add",
"the",
"given",
"string",
"value",
"to",
"the",
"HLL",
"using",
"the",
"currently",
"set",
"Hasher",
"function"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L128-L131 |
148,038 | mynameisfiber/gohll | gohll.go | AddWithHasher | func (h *HLL) AddWithHasher(value string, hasher func(string) uint64) {
hash := hasher(value)
h.AddHash(hash)
} | go | func (h *HLL) AddWithHasher(value string, hasher func(string) uint64) {
hash := hasher(value)
h.AddHash(hash)
} | [
"func",
"(",
"h",
"*",
"HLL",
")",
"AddWithHasher",
"(",
"value",
"string",
",",
"hasher",
"func",
"(",
"string",
")",
"uint64",
")",
"{",
"hash",
":=",
"hasher",
"(",
"value",
")",
"\n",
"h",
".",
"AddHash",
"(",
"hash",
")",
"\n",
"}"
] | // AddWithHasher will add the given string value to the HLL using the specified
// hasher function. | [
"AddWithHasher",
"will",
"add",
"the",
"given",
"string",
"value",
"to",
"the",
"HLL",
"using",
"the",
"specified",
"hasher",
"function",
"."
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L135-L138 |
148,039 | mynameisfiber/gohll | gohll.go | AddHash | func (h *HLL) AddHash(hash uint64) {
switch h.format {
case NORMAL:
h.addNormal(hash)
case SPARSE:
h.addSparse(hash)
}
} | go | func (h *HLL) AddHash(hash uint64) {
switch h.format {
case NORMAL:
h.addNormal(hash)
case SPARSE:
h.addSparse(hash)
}
} | [
"func",
"(",
"h",
"*",
"HLL",
")",
"AddHash",
"(",
"hash",
"uint64",
")",
"{",
"switch",
"h",
".",
"format",
"{",
"case",
"NORMAL",
":",
"h",
".",
"addNormal",
"(",
"hash",
")",
"\n",
"case",
"SPARSE",
":",
"h",
".",
"addSparse",
"(",
"hash",
")"... | // AddHash will add the given uint64 hash to the HLL | [
"AddHash",
"will",
"add",
"the",
"given",
"uint64",
"hash",
"to",
"the",
"HLL"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L141-L148 |
148,040 | mynameisfiber/gohll | gohll.go | ToNormal | func (h *HLL) ToNormal() {
if h.format != SPARSE {
return
}
h.format = NORMAL
h.registers = make([]uint8, h.m1)
for _, value := range h.sparseList.Data {
index, rho := decodeHash(value, h.P)
if h.registers[index] < rho {
h.registers[index] = rho
}
}
for _, value := range *(h.tempSet) {
index, rho :=... | go | func (h *HLL) ToNormal() {
if h.format != SPARSE {
return
}
h.format = NORMAL
h.registers = make([]uint8, h.m1)
for _, value := range h.sparseList.Data {
index, rho := decodeHash(value, h.P)
if h.registers[index] < rho {
h.registers[index] = rho
}
}
for _, value := range *(h.tempSet) {
index, rho :=... | [
"func",
"(",
"h",
"*",
"HLL",
")",
"ToNormal",
"(",
")",
"{",
"if",
"h",
".",
"format",
"!=",
"SPARSE",
"{",
"return",
"\n",
"}",
"\n",
"h",
".",
"format",
"=",
"NORMAL",
"\n",
"h",
".",
"registers",
"=",
"make",
"(",
"[",
"]",
"uint8",
",",
... | // ToNormal will convert the current HLL to normal mode, maintaining any data
// already inserted into the structure, if it is in sparse mode | [
"ToNormal",
"will",
"convert",
"the",
"current",
"HLL",
"to",
"normal",
"mode",
"maintaining",
"any",
"data",
"already",
"inserted",
"into",
"the",
"structure",
"if",
"it",
"is",
"in",
"sparse",
"mode"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L181-L201 |
148,041 | mynameisfiber/gohll | gohll.go | Cardinality | func (h *HLL) Cardinality() float64 {
var cardinality float64
switch h.format {
case NORMAL:
cardinality = h.cardinalityNormal()
case SPARSE:
cardinality = h.cardinalitySparse()
}
return cardinality
} | go | func (h *HLL) Cardinality() float64 {
var cardinality float64
switch h.format {
case NORMAL:
cardinality = h.cardinalityNormal()
case SPARSE:
cardinality = h.cardinalitySparse()
}
return cardinality
} | [
"func",
"(",
"h",
"*",
"HLL",
")",
"Cardinality",
"(",
")",
"float64",
"{",
"var",
"cardinality",
"float64",
"\n",
"switch",
"h",
".",
"format",
"{",
"case",
"NORMAL",
":",
"cardinality",
"=",
"h",
".",
"cardinalityNormal",
"(",
")",
"\n",
"case",
"SPA... | // Cardinality returns the estimated cardinality of the current HLL object | [
"Cardinality",
"returns",
"the",
"estimated",
"cardinality",
"of",
"the",
"current",
"HLL",
"object"
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L204-L213 |
148,042 | mynameisfiber/gohll | gohll.go | Union | func (h *HLL) Union(other *HLL) error {
if h.P != other.P {
return ErrSameP
}
if other.format == NORMAL {
if h.format == SPARSE {
h.ToNormal()
}
for i := uint(0); i < h.m1; i++ {
if other.registers[i] > h.registers[i] {
h.registers[i] = other.registers[i]
}
}
} else if h.format == NORMAL && o... | go | func (h *HLL) Union(other *HLL) error {
if h.P != other.P {
return ErrSameP
}
if other.format == NORMAL {
if h.format == SPARSE {
h.ToNormal()
}
for i := uint(0); i < h.m1; i++ {
if other.registers[i] > h.registers[i] {
h.registers[i] = other.registers[i]
}
}
} else if h.format == NORMAL && o... | [
"func",
"(",
"h",
"*",
"HLL",
")",
"Union",
"(",
"other",
"*",
"HLL",
")",
"error",
"{",
"if",
"h",
".",
"P",
"!=",
"other",
".",
"P",
"{",
"return",
"ErrSameP",
"\n",
"}",
"\n",
"if",
"other",
".",
"format",
"==",
"NORMAL",
"{",
"if",
"h",
"... | // Union will merge all data in another HLL object into this one. | [
"Union",
"will",
"merge",
"all",
"data",
"in",
"another",
"HLL",
"object",
"into",
"this",
"one",
"."
] | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L256-L284 |
148,043 | mynameisfiber/gohll | gohll.go | CardinalityUnion | func (h *HLL) CardinalityUnion(other *HLL) (float64, error) {
if h.P != other.P {
return 0.0, ErrSameP
}
cardinality := 0.0
if h.format == NORMAL && other.format == NORMAL {
cardinality = h.cardinalityUnionNN(other)
} else if h.format == NORMAL && other.format == SPARSE {
cardinality = h.cardinalityUnionNS(o... | go | func (h *HLL) CardinalityUnion(other *HLL) (float64, error) {
if h.P != other.P {
return 0.0, ErrSameP
}
cardinality := 0.0
if h.format == NORMAL && other.format == NORMAL {
cardinality = h.cardinalityUnionNN(other)
} else if h.format == NORMAL && other.format == SPARSE {
cardinality = h.cardinalityUnionNS(o... | [
"func",
"(",
"h",
"*",
"HLL",
")",
"CardinalityUnion",
"(",
"other",
"*",
"HLL",
")",
"(",
"float64",
",",
"error",
")",
"{",
"if",
"h",
".",
"P",
"!=",
"other",
".",
"P",
"{",
"return",
"0.0",
",",
"ErrSameP",
"\n",
"}",
"\n",
"cardinality",
":=... | // CardinalityUnion returns the estimated cardinality of the union between this
// and another HLL object. This result would be the same as first taking the
// union between this and the other object and then calling Cardinality.
// However, by calling this function we are not making any changes to the HLL
// object. | [
"CardinalityUnion",
"returns",
"the",
"estimated",
"cardinality",
"of",
"the",
"union",
"between",
"this",
"and",
"another",
"HLL",
"object",
".",
"This",
"result",
"would",
"be",
"the",
"same",
"as",
"first",
"taking",
"the",
"union",
"between",
"this",
"and"... | f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8 | https://github.com/mynameisfiber/gohll/blob/f1936e87f4dd37ebb8e0dc7bbf8c696c0276bcd8/gohll.go#L306-L321 |
148,044 | vcaesar/imgo | img.go | IsBlack | func IsBlack(c color.Color) bool {
r, g, b, a := c.RGBA()
return r == br && g == bg && b == bb && a == ba
} | go | func IsBlack(c color.Color) bool {
r, g, b, a := c.RGBA()
return r == br && g == bg && b == bb && a == ba
} | [
"func",
"IsBlack",
"(",
"c",
"color",
".",
"Color",
")",
"bool",
"{",
"r",
",",
"g",
",",
"b",
",",
"a",
":=",
"c",
".",
"RGBA",
"(",
")",
"\n\n",
"return",
"r",
"==",
"br",
"&&",
"g",
"==",
"bg",
"&&",
"b",
"==",
"bb",
"&&",
"a",
"==",
"... | // IsBlack color is black | [
"IsBlack",
"color",
"is",
"black"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L44-L48 |
148,045 | vcaesar/imgo | img.go | DecodeFile | func DecodeFile(fileName string) (image.Image, string, error) {
file, err := os.Open(fileName)
if err != nil {
return nil, "", fmt.Errorf("%s: %s", fileName, err)
}
img, fm, err := image.Decode(file)
if err != nil {
return nil, fm, fmt.Errorf("%s: %s", fileName, err)
}
return img, fm, nil
} | go | func DecodeFile(fileName string) (image.Image, string, error) {
file, err := os.Open(fileName)
if err != nil {
return nil, "", fmt.Errorf("%s: %s", fileName, err)
}
img, fm, err := image.Decode(file)
if err != nil {
return nil, fm, fmt.Errorf("%s: %s", fileName, err)
}
return img, fm, nil
} | [
"func",
"DecodeFile",
"(",
"fileName",
"string",
")",
"(",
"image",
".",
"Image",
",",
"string",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fileName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // DecodeFile decodes image file | [
"DecodeFile",
"decodes",
"image",
"file"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L51-L63 |
148,046 | vcaesar/imgo | img.go | GetSize | func GetSize(imagePath string) (int, int) {
file, err := os.Open(imagePath)
defer file.Close()
if err != nil {
log.Println(err)
}
img, _, err := image.DecodeConfig(file)
if err != nil {
log.Println(imagePath, err)
}
w := img.Width / 2
h := img.Height / 2
return w, h
} | go | func GetSize(imagePath string) (int, int) {
file, err := os.Open(imagePath)
defer file.Close()
if err != nil {
log.Println(err)
}
img, _, err := image.DecodeConfig(file)
if err != nil {
log.Println(imagePath, err)
}
w := img.Width / 2
h := img.Height / 2
return w, h
} | [
"func",
"GetSize",
"(",
"imagePath",
"string",
")",
"(",
"int",
",",
"int",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"imagePath",
")",
"\n",
"defer",
"file",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
... | // GetSize get the image's size | [
"GetSize",
"get",
"the",
"image",
"s",
"size"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L66-L82 |
148,047 | vcaesar/imgo | img.go | SaveToPNG | func SaveToPNG(path string, img image.Image) {
f, err := os.Create(path)
if err != nil {
log.Println(err)
}
defer f.Close()
png.Encode(f, img)
} | go | func SaveToPNG(path string, img image.Image) {
f, err := os.Create(path)
if err != nil {
log.Println(err)
}
defer f.Close()
png.Encode(f, img)
} | [
"func",
"SaveToPNG",
"(",
"path",
"string",
",",
"img",
"image",
".",
"Image",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"}",
"\n",... | // SaveToPNG create a png file with the image.Image | [
"SaveToPNG",
"create",
"a",
"png",
"file",
"with",
"the",
"image",
".",
"Image"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L85-L93 |
148,048 | vcaesar/imgo | img.go | ReadPNG | func ReadPNG(path string) image.Image {
f, err := os.Open(path)
if err != nil {
log.Println(err)
}
defer f.Close()
img, derr := png.Decode(f)
if derr != nil {
log.Println(derr)
}
return img
} | go | func ReadPNG(path string) image.Image {
f, err := os.Open(path)
if err != nil {
log.Println(err)
}
defer f.Close()
img, derr := png.Decode(f)
if derr != nil {
log.Println(derr)
}
return img
} | [
"func",
"ReadPNG",
"(",
"path",
"string",
")",
"image",
".",
"Image",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"defer",
"f",... | // ReadPNG read png return image.Image | [
"ReadPNG",
"read",
"png",
"return",
"image",
".",
"Image"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L96-L110 |
148,049 | vcaesar/imgo | img.go | ModTime | func ModTime(filePath string) (int64, error) {
f, e := os.Stat(filePath)
if e != nil {
return 0, e
}
return f.ModTime().Unix(), nil
} | go | func ModTime(filePath string) (int64, error) {
f, e := os.Stat(filePath)
if e != nil {
return 0, e
}
return f.ModTime().Unix(), nil
} | [
"func",
"ModTime",
"(",
"filePath",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"f",
",",
"e",
":=",
"os",
".",
"Stat",
"(",
"filePath",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"return",
"0",
",",
"e",
"\n",
"}",
"\n\n",
"return",
"f",... | // ModTime file modified time | [
"ModTime",
"file",
"modified",
"time"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L113-L120 |
148,050 | vcaesar/imgo | img.go | Encode | func Encode(out io.Writer, subImg image.Image, fm string) error {
switch fm {
case "jpeg":
return jpeg.Encode(out, subImg, nil)
case "png":
return png.Encode(out, subImg)
case "gif":
return gif.Encode(out, subImg, &gif.Options{})
case "bmp":
return bmp.Encode(out, subImg)
default:
return errors.New("ERR... | go | func Encode(out io.Writer, subImg image.Image, fm string) error {
switch fm {
case "jpeg":
return jpeg.Encode(out, subImg, nil)
case "png":
return png.Encode(out, subImg)
case "gif":
return gif.Encode(out, subImg, &gif.Options{})
case "bmp":
return bmp.Encode(out, subImg)
default:
return errors.New("ERR... | [
"func",
"Encode",
"(",
"out",
"io",
".",
"Writer",
",",
"subImg",
"image",
".",
"Image",
",",
"fm",
"string",
")",
"error",
"{",
"switch",
"fm",
"{",
"case",
"\"",
"\"",
":",
"return",
"jpeg",
".",
"Encode",
"(",
"out",
",",
"subImg",
",",
"nil",
... | // Encode encode image to buf | [
"Encode",
"encode",
"image",
"to",
"buf"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L133-L146 |
148,051 | vcaesar/imgo | img.go | ToString | func ToString(img image.Image) (result string) {
for row := img.Bounds().Min.Y; row < img.Bounds().Max.Y; row++ {
for col := img.Bounds().Min.X; col < img.Bounds().Max.X; col++ {
if IsBlack(img.At(col, row)) {
result += "."
} else {
result += "O"
}
}
result += "\n"
}
return
} | go | func ToString(img image.Image) (result string) {
for row := img.Bounds().Min.Y; row < img.Bounds().Max.Y; row++ {
for col := img.Bounds().Min.X; col < img.Bounds().Max.X; col++ {
if IsBlack(img.At(col, row)) {
result += "."
} else {
result += "O"
}
}
result += "\n"
}
return
} | [
"func",
"ToString",
"(",
"img",
"image",
".",
"Image",
")",
"(",
"result",
"string",
")",
"{",
"for",
"row",
":=",
"img",
".",
"Bounds",
"(",
")",
".",
"Min",
".",
"Y",
";",
"row",
"<",
"img",
".",
"Bounds",
"(",
")",
".",
"Max",
".",
"Y",
";... | // ToString tostring image.Image | [
"ToString",
"tostring",
"image",
".",
"Image"
] | 13af122cf2fa6117048933e141c0b52f19116ca6 | https://github.com/vcaesar/imgo/blob/13af122cf2fa6117048933e141c0b52f19116ca6/img.go#L149-L163 |
148,052 | uber-archive/stacked | tls.go | TLSServer | func TLSServer(config *tls.Config, srv ListenServer) Detector {
// TODO: isTLSClientHello can really benefit from more bytes
return Detector{
Needed: minBytes,
Test: isTLSClientHello,
Handler: newTLSShim(config, srv),
}
} | go | func TLSServer(config *tls.Config, srv ListenServer) Detector {
// TODO: isTLSClientHello can really benefit from more bytes
return Detector{
Needed: minBytes,
Test: isTLSClientHello,
Handler: newTLSShim(config, srv),
}
} | [
"func",
"TLSServer",
"(",
"config",
"*",
"tls",
".",
"Config",
",",
"srv",
"ListenServer",
")",
"Detector",
"{",
"// TODO: isTLSClientHello can really benefit from more bytes",
"return",
"Detector",
"{",
"Needed",
":",
"minBytes",
",",
"Test",
":",
"isTLSClientHello",... | // TLSServer returns a detector that detects a client TLS handshake before
// wrapping each connection in tls.Server to pass to the ListenServer. | [
"TLSServer",
"returns",
"a",
"detector",
"that",
"detects",
"a",
"client",
"TLS",
"handshake",
"before",
"wrapping",
"each",
"connection",
"in",
"tls",
".",
"Server",
"to",
"pass",
"to",
"the",
"ListenServer",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/tls.go#L204-L211 |
148,053 | uber-archive/stacked | handler.go | ServeConnection | func (bchf HandlerFunc) ServeConnection(conn net.Conn, bufr *bufio.Reader) {
bchf(conn, bufr)
} | go | func (bchf HandlerFunc) ServeConnection(conn net.Conn, bufr *bufio.Reader) {
bchf(conn, bufr)
} | [
"func",
"(",
"bchf",
"HandlerFunc",
")",
"ServeConnection",
"(",
"conn",
"net",
".",
"Conn",
",",
"bufr",
"*",
"bufio",
".",
"Reader",
")",
"{",
"bchf",
"(",
"conn",
",",
"bufr",
")",
"\n",
"}"
] | // ServeConnection simply calls the function | [
"ServeConnection",
"simply",
"calls",
"the",
"function"
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/handler.go#L39-L41 |
148,054 | uber-archive/stacked | detector.go | DefaultHTTPHandler | func DefaultHTTPHandler(hndl http.Handler) Detector {
if hndl == nil {
hndl = http.DefaultServeMux
}
handler := ListenServerHandler(&http.Server{
Handler: hndl,
})
return FallthroughDetector(handler)
} | go | func DefaultHTTPHandler(hndl http.Handler) Detector {
if hndl == nil {
hndl = http.DefaultServeMux
}
handler := ListenServerHandler(&http.Server{
Handler: hndl,
})
return FallthroughDetector(handler)
} | [
"func",
"DefaultHTTPHandler",
"(",
"hndl",
"http",
".",
"Handler",
")",
"Detector",
"{",
"if",
"hndl",
"==",
"nil",
"{",
"hndl",
"=",
"http",
".",
"DefaultServeMux",
"\n",
"}",
"\n",
"handler",
":=",
"ListenServerHandler",
"(",
"&",
"http",
".",
"Server",
... | // DefaultHTTPHandler creates a FallthroughDetector around an http.Handler. | [
"DefaultHTTPHandler",
"creates",
"a",
"FallthroughDetector",
"around",
"an",
"http",
".",
"Handler",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/detector.go#L41-L49 |
148,055 | uber-archive/stacked | detector.go | FallthroughDetector | func FallthroughDetector(hndl Handler) Detector {
return Detector{
Needed: 0,
Test: func([]byte) bool { return true },
Handler: hndl,
}
} | go | func FallthroughDetector(hndl Handler) Detector {
return Detector{
Needed: 0,
Test: func([]byte) bool { return true },
Handler: hndl,
}
} | [
"func",
"FallthroughDetector",
"(",
"hndl",
"Handler",
")",
"Detector",
"{",
"return",
"Detector",
"{",
"Needed",
":",
"0",
",",
"Test",
":",
"func",
"(",
"[",
"]",
"byte",
")",
"bool",
"{",
"return",
"true",
"}",
",",
"Handler",
":",
"hndl",
",",
"}... | // FallthroughDetector returns a Detector whose Test function always returns
// true. No bytes are needed for tautology. | [
"FallthroughDetector",
"returns",
"a",
"Detector",
"whose",
"Test",
"function",
"always",
"returns",
"true",
".",
"No",
"bytes",
"are",
"needed",
"for",
"tautology",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/detector.go#L53-L59 |
148,056 | uber-archive/stacked | detector.go | PrefixDetector | func PrefixDetector(prefix string, handler Handler) Detector {
return Detector{
Needed: len([]byte(prefix)),
Test: func(b []byte) bool { return string(b) == prefix },
Handler: handler,
}
} | go | func PrefixDetector(prefix string, handler Handler) Detector {
return Detector{
Needed: len([]byte(prefix)),
Test: func(b []byte) bool { return string(b) == prefix },
Handler: handler,
}
} | [
"func",
"PrefixDetector",
"(",
"prefix",
"string",
",",
"handler",
"Handler",
")",
"Detector",
"{",
"return",
"Detector",
"{",
"Needed",
":",
"len",
"(",
"[",
"]",
"byte",
"(",
"prefix",
")",
")",
",",
"Test",
":",
"func",
"(",
"b",
"[",
"]",
"byte",... | // PrefixDetector detects a static string prefix. | [
"PrefixDetector",
"detects",
"a",
"static",
"string",
"prefix",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/detector.go#L62-L68 |
148,057 | uber-archive/stacked | detector.go | PrefixBytesDetector | func PrefixBytesDetector(prefix []byte, handler Handler) Detector {
return Detector{
Needed: len(prefix),
Test: func(b []byte) bool {
for i, v := range prefix {
if b[i] != v {
return false
}
}
return true
},
Handler: handler,
}
} | go | func PrefixBytesDetector(prefix []byte, handler Handler) Detector {
return Detector{
Needed: len(prefix),
Test: func(b []byte) bool {
for i, v := range prefix {
if b[i] != v {
return false
}
}
return true
},
Handler: handler,
}
} | [
"func",
"PrefixBytesDetector",
"(",
"prefix",
"[",
"]",
"byte",
",",
"handler",
"Handler",
")",
"Detector",
"{",
"return",
"Detector",
"{",
"Needed",
":",
"len",
"(",
"prefix",
")",
",",
"Test",
":",
"func",
"(",
"b",
"[",
"]",
"byte",
")",
"bool",
"... | // PrefixBytesDetector detects a static string prefix. | [
"PrefixBytesDetector",
"detects",
"a",
"static",
"string",
"prefix",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/detector.go#L71-L84 |
148,058 | uber-archive/stacked | server.go | ListenAndServe | func ListenAndServe(hostPort string, detectors ...Detector) error {
return NewServer(detectors...).ListenAndServe(hostPort)
} | go | func ListenAndServe(hostPort string, detectors ...Detector) error {
return NewServer(detectors...).ListenAndServe(hostPort)
} | [
"func",
"ListenAndServe",
"(",
"hostPort",
"string",
",",
"detectors",
"...",
"Detector",
")",
"error",
"{",
"return",
"NewServer",
"(",
"detectors",
"...",
")",
".",
"ListenAndServe",
"(",
"hostPort",
")",
"\n",
"}"
] | // ListenAndServe creates a server for the passed detectors, and has it listend
// and serve. | [
"ListenAndServe",
"creates",
"a",
"server",
"for",
"the",
"passed",
"detectors",
"and",
"has",
"it",
"listend",
"and",
"serve",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/server.go#L37-L39 |
148,059 | uber-archive/stacked | server.go | ListenAndServe | func (srv Server) ListenAndServe(hostPort string) error {
ln, err := net.Listen("tcp", hostPort)
if err != nil {
return err
}
return srv.Serve(ln)
} | go | func (srv Server) ListenAndServe(hostPort string) error {
ln, err := net.Listen("tcp", hostPort)
if err != nil {
return err
}
return srv.Serve(ln)
} | [
"func",
"(",
"srv",
"Server",
")",
"ListenAndServe",
"(",
"hostPort",
"string",
")",
"error",
"{",
"ln",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"hostPort",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // ListenAndServe opens a listening TCP socket, and calls Serve on it. | [
"ListenAndServe",
"opens",
"a",
"listening",
"TCP",
"socket",
"and",
"calls",
"Serve",
"on",
"it",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/server.go#L47-L53 |
148,060 | uber-archive/stacked | server.go | Serve | func (srv Server) Serve(ln net.Listener) error {
// TODO: afford start-able handlers? Currently the requirement is that any
// such need is met lazily/on-demand as connBufShim does.
defer srv.closeDetectors()
var tempDelay time.Duration // how long to sleep on accept failure
for {
conn, err := ln.Accept()
i... | go | func (srv Server) Serve(ln net.Listener) error {
// TODO: afford start-able handlers? Currently the requirement is that any
// such need is met lazily/on-demand as connBufShim does.
defer srv.closeDetectors()
var tempDelay time.Duration // how long to sleep on accept failure
for {
conn, err := ln.Accept()
i... | [
"func",
"(",
"srv",
"Server",
")",
"Serve",
"(",
"ln",
"net",
".",
"Listener",
")",
"error",
"{",
"// TODO: afford start-able handlers? Currently the requirement is that any",
"// such need is met lazily/on-demand as connBufShim does.",
"defer",
"srv",
".",
"closeDetectors",
... | // Serve runs a handling loop on a listening socket. | [
"Serve",
"runs",
"a",
"handling",
"loop",
"on",
"a",
"listening",
"socket",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/server.go#L56-L85 |
148,061 | uber-archive/stacked | listen_server.go | ServeConnection | func (cbs *connBufShim) ServeConnection(conn net.Conn, bufr *bufio.Reader) {
cbs.lnFor(conn).conns <- &bufConn{conn, bufr}
} | go | func (cbs *connBufShim) ServeConnection(conn net.Conn, bufr *bufio.Reader) {
cbs.lnFor(conn).conns <- &bufConn{conn, bufr}
} | [
"func",
"(",
"cbs",
"*",
"connBufShim",
")",
"ServeConnection",
"(",
"conn",
"net",
".",
"Conn",
",",
"bufr",
"*",
"bufio",
".",
"Reader",
")",
"{",
"cbs",
".",
"lnFor",
"(",
"conn",
")",
".",
"conns",
"<-",
"&",
"bufConn",
"{",
"conn",
",",
"bufr"... | // ServeConnection simply puts a new bufConn onto bufConns for distribution by
// bufLn.Accept. | [
"ServeConnection",
"simply",
"puts",
"a",
"new",
"bufConn",
"onto",
"bufConns",
"for",
"distribution",
"by",
"bufLn",
".",
"Accept",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/listen_server.go#L47-L49 |
148,062 | uber-archive/stacked | listen_server.go | Close | func (cbs *connBufShim) Close() error {
if cbs.listeners == nil {
for _, ln := range cbs.listeners {
ln.Close() // TODO: care about error? use a MultiError?
}
cbs.listeners = nil
}
return nil
} | go | func (cbs *connBufShim) Close() error {
if cbs.listeners == nil {
for _, ln := range cbs.listeners {
ln.Close() // TODO: care about error? use a MultiError?
}
cbs.listeners = nil
}
return nil
} | [
"func",
"(",
"cbs",
"*",
"connBufShim",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"cbs",
".",
"listeners",
"==",
"nil",
"{",
"for",
"_",
",",
"ln",
":=",
"range",
"cbs",
".",
"listeners",
"{",
"ln",
".",
"Close",
"(",
")",
"// TODO: care about erro... | // Close closes any bufListeners | [
"Close",
"closes",
"any",
"bufListeners"
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/listen_server.go#L72-L80 |
148,063 | uber-archive/stacked | buf_conn.go | Read | func (bufc *bufConn) Read(b []byte) (int, error) {
if bufc.bufr == nil {
return bufc.conn.Read(b)
}
n := len(b)
if m := bufc.bufr.Buffered(); m < n {
n = m
}
p, err := bufc.bufr.Peek(n)
n = copy(b, p)
bufc.bufr.Discard(n)
if err == bufio.ErrBufferFull {
err = nil
}
if bufc.bufr.Buffered() == 0 {
// ... | go | func (bufc *bufConn) Read(b []byte) (int, error) {
if bufc.bufr == nil {
return bufc.conn.Read(b)
}
n := len(b)
if m := bufc.bufr.Buffered(); m < n {
n = m
}
p, err := bufc.bufr.Peek(n)
n = copy(b, p)
bufc.bufr.Discard(n)
if err == bufio.ErrBufferFull {
err = nil
}
if bufc.bufr.Buffered() == 0 {
// ... | [
"func",
"(",
"bufc",
"*",
"bufConn",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"bufc",
".",
"bufr",
"==",
"nil",
"{",
"return",
"bufc",
".",
"conn",
".",
"Read",
"(",
"b",
")",
"\n",
"}",
"\n\n",
... | // Read reads data by first draining the buffered reader, and then passes
// through to the underlying connection. | [
"Read",
"reads",
"data",
"by",
"first",
"draining",
"the",
"buffered",
"reader",
"and",
"then",
"passes",
"through",
"to",
"the",
"underlying",
"connection",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/buf_conn.go#L20-L40 |
148,064 | uber-archive/stacked | buf_conn.go | SetWriteDeadline | func (bufc *bufConn) SetWriteDeadline(t time.Time) error {
return bufc.conn.SetWriteDeadline(t)
} | go | func (bufc *bufConn) SetWriteDeadline(t time.Time) error {
return bufc.conn.SetWriteDeadline(t)
} | [
"func",
"(",
"bufc",
"*",
"bufConn",
")",
"SetWriteDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"return",
"bufc",
".",
"conn",
".",
"SetWriteDeadline",
"(",
"t",
")",
"\n",
"}"
] | // SetWriteDeadline sets the deadline for future Write calls. | [
"SetWriteDeadline",
"sets",
"the",
"deadline",
"for",
"future",
"Write",
"calls",
"."
] | f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb | https://github.com/uber-archive/stacked/blob/f68dcbe9559e6669e6f73c4dcdb8bfdbf13712bb/buf_conn.go#L74-L76 |
148,065 | cloud-ca/go-cloudca | services/cloudca/ssh_key.go | Get | func (sshKeyApi *SSHKeyApi) Get(name string) (*SSHKey, error) {
data, err := sshKeyApi.entityService.Get(name, map[string]string{})
if err != nil {
return nil, err
}
return parseSSHKey(data), nil
} | go | func (sshKeyApi *SSHKeyApi) Get(name string) (*SSHKey, error) {
data, err := sshKeyApi.entityService.Get(name, map[string]string{})
if err != nil {
return nil, err
}
return parseSSHKey(data), nil
} | [
"func",
"(",
"sshKeyApi",
"*",
"SSHKeyApi",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"*",
"SSHKey",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"sshKeyApi",
".",
"entityService",
".",
"Get",
"(",
"name",
",",
"map",
"[",
"string",
"]",
"s... | //Get SSH key with the specified id for the current environment | [
"Get",
"SSH",
"key",
"with",
"the",
"specified",
"id",
"for",
"the",
"current",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/ssh_key.go#L48-L54 |
148,066 | cloud-ca/go-cloudca | services/cloudca/ssh_key.go | ListWithOptions | func (sshKeyApi *SSHKeyApi) ListWithOptions(options map[string]string) ([]SSHKey, error) {
data, err := sshKeyApi.entityService.List(options)
if err != nil {
return nil, err
}
return parseSSHKeyList(data), nil
} | go | func (sshKeyApi *SSHKeyApi) ListWithOptions(options map[string]string) ([]SSHKey, error) {
data, err := sshKeyApi.entityService.List(options)
if err != nil {
return nil, err
}
return parseSSHKeyList(data), nil
} | [
"func",
"(",
"sshKeyApi",
"*",
"SSHKeyApi",
")",
"ListWithOptions",
"(",
"options",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"SSHKey",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"sshKeyApi",
".",
"entityService",
".",
"List",
"("... | //List all SSH keys for the current environment. Can use options to do sorting and paging. | [
"List",
"all",
"SSH",
"keys",
"for",
"the",
"current",
"environment",
".",
"Can",
"use",
"options",
"to",
"do",
"sorting",
"and",
"paging",
"."
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/ssh_key.go#L62-L68 |
148,067 | cloud-ca/go-cloudca | services/cloudca/ssh_key.go | Create | func (sshKeyApi *SSHKeyApi) Create(key SSHKey) (*SSHKey, error) {
send, merr := json.Marshal(key)
if merr != nil {
return nil, merr
}
body, err := sshKeyApi.entityService.Create(send, map[string]string{})
if err != nil {
return nil, err
}
return parseSSHKey(body), nil
} | go | func (sshKeyApi *SSHKeyApi) Create(key SSHKey) (*SSHKey, error) {
send, merr := json.Marshal(key)
if merr != nil {
return nil, merr
}
body, err := sshKeyApi.entityService.Create(send, map[string]string{})
if err != nil {
return nil, err
}
return parseSSHKey(body), nil
} | [
"func",
"(",
"sshKeyApi",
"*",
"SSHKeyApi",
")",
"Create",
"(",
"key",
"SSHKey",
")",
"(",
"*",
"SSHKey",
",",
"error",
")",
"{",
"send",
",",
"merr",
":=",
"json",
".",
"Marshal",
"(",
"key",
")",
"\n",
"if",
"merr",
"!=",
"nil",
"{",
"return",
... | //Create an SSH key in the current environment | [
"Create",
"an",
"SSH",
"key",
"in",
"the",
"current",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/ssh_key.go#L71-L81 |
148,068 | cloud-ca/go-cloudca | services/cloudca/ssh_key.go | Delete | func (sshKeyApi *SSHKeyApi) Delete(id string) (bool, error) {
_, err := sshKeyApi.entityService.Delete(id, []byte{}, map[string]string{})
return err == nil, err
} | go | func (sshKeyApi *SSHKeyApi) Delete(id string) (bool, error) {
_, err := sshKeyApi.entityService.Delete(id, []byte{}, map[string]string{})
return err == nil, err
} | [
"func",
"(",
"sshKeyApi",
"*",
"SSHKeyApi",
")",
"Delete",
"(",
"id",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"sshKeyApi",
".",
"entityService",
".",
"Delete",
"(",
"id",
",",
"[",
"]",
"byte",
"{",
"}",
",",
"m... | //Delete an SSH Key with specified id in the current environment | [
"Delete",
"an",
"SSH",
"Key",
"with",
"specified",
"id",
"in",
"the",
"current",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/ssh_key.go#L84-L87 |
148,069 | mb0/diff | diff.go | ByteStrings | func ByteStrings(a, b string) []Change {
return Diff(len(a), len(b), &strings{a, b})
} | go | func ByteStrings(a, b string) []Change {
return Diff(len(a), len(b), &strings{a, b})
} | [
"func",
"ByteStrings",
"(",
"a",
",",
"b",
"string",
")",
"[",
"]",
"Change",
"{",
"return",
"Diff",
"(",
"len",
"(",
"a",
")",
",",
"len",
"(",
"b",
")",
",",
"&",
"strings",
"{",
"a",
",",
"b",
"}",
")",
"\n",
"}"
] | // ByteStrings returns the differences of two strings in bytes. | [
"ByteStrings",
"returns",
"the",
"differences",
"of",
"two",
"strings",
"in",
"bytes",
"."
] | d8d9a906c24d7b0ee77287e0463e5ca7f026032e | https://github.com/mb0/diff/blob/d8d9a906c24d7b0ee77287e0463e5ca7f026032e/diff.go#L17-L19 |
148,070 | mb0/diff | diff.go | Bytes | func Bytes(a, b []byte) []Change {
return Diff(len(a), len(b), &bytes{a, b})
} | go | func Bytes(a, b []byte) []Change {
return Diff(len(a), len(b), &bytes{a, b})
} | [
"func",
"Bytes",
"(",
"a",
",",
"b",
"[",
"]",
"byte",
")",
"[",
"]",
"Change",
"{",
"return",
"Diff",
"(",
"len",
"(",
"a",
")",
",",
"len",
"(",
"b",
")",
",",
"&",
"bytes",
"{",
"a",
",",
"b",
"}",
")",
"\n",
"}"
] | // Bytes returns the difference of two byte slices | [
"Bytes",
"returns",
"the",
"difference",
"of",
"two",
"byte",
"slices"
] | d8d9a906c24d7b0ee77287e0463e5ca7f026032e | https://github.com/mb0/diff/blob/d8d9a906c24d7b0ee77287e0463e5ca7f026032e/diff.go#L26-L28 |
148,071 | mb0/diff | diff.go | Ints | func Ints(a, b []int) []Change {
return Diff(len(a), len(b), &ints{a, b})
} | go | func Ints(a, b []int) []Change {
return Diff(len(a), len(b), &ints{a, b})
} | [
"func",
"Ints",
"(",
"a",
",",
"b",
"[",
"]",
"int",
")",
"[",
"]",
"Change",
"{",
"return",
"Diff",
"(",
"len",
"(",
"a",
")",
",",
"len",
"(",
"b",
")",
",",
"&",
"ints",
"{",
"a",
",",
"b",
"}",
")",
"\n",
"}"
] | // Ints returns the difference of two int slices | [
"Ints",
"returns",
"the",
"difference",
"of",
"two",
"int",
"slices"
] | d8d9a906c24d7b0ee77287e0463e5ca7f026032e | https://github.com/mb0/diff/blob/d8d9a906c24d7b0ee77287e0463e5ca7f026032e/diff.go#L35-L37 |
148,072 | mb0/diff | diff.go | Runes | func Runes(a, b []rune) []Change {
return Diff(len(a), len(b), &runes{a, b})
} | go | func Runes(a, b []rune) []Change {
return Diff(len(a), len(b), &runes{a, b})
} | [
"func",
"Runes",
"(",
"a",
",",
"b",
"[",
"]",
"rune",
")",
"[",
"]",
"Change",
"{",
"return",
"Diff",
"(",
"len",
"(",
"a",
")",
",",
"len",
"(",
"b",
")",
",",
"&",
"runes",
"{",
"a",
",",
"b",
"}",
")",
"\n",
"}"
] | // Runes returns the difference of two rune slices | [
"Runes",
"returns",
"the",
"difference",
"of",
"two",
"rune",
"slices"
] | d8d9a906c24d7b0ee77287e0463e5ca7f026032e | https://github.com/mb0/diff/blob/d8d9a906c24d7b0ee77287e0463e5ca7f026032e/diff.go#L44-L46 |
148,073 | mb0/diff | diff.go | Granular | func Granular(granularity int, changes []Change) []Change {
if len(changes) == 0 {
return changes
}
gap := 0
for i := 1; i < len(changes); i++ {
curr := changes[i]
prev := changes[i-gap-1]
// same as curr.B-(prev.B+prev.Ins); consistency is key
if curr.A-(prev.A+prev.Del) <= granularity {
// merge chan... | go | func Granular(granularity int, changes []Change) []Change {
if len(changes) == 0 {
return changes
}
gap := 0
for i := 1; i < len(changes); i++ {
curr := changes[i]
prev := changes[i-gap-1]
// same as curr.B-(prev.B+prev.Ins); consistency is key
if curr.A-(prev.A+prev.Del) <= granularity {
// merge chan... | [
"func",
"Granular",
"(",
"granularity",
"int",
",",
"changes",
"[",
"]",
"Change",
")",
"[",
"]",
"Change",
"{",
"if",
"len",
"(",
"changes",
")",
"==",
"0",
"{",
"return",
"changes",
"\n",
"}",
"\n",
"gap",
":=",
"0",
"\n",
"for",
"i",
":=",
"1"... | // Granular merges neighboring changes smaller than the specified granularity.
// The changes must be ordered by ascending positions as returned by this package. | [
"Granular",
"merges",
"neighboring",
"changes",
"smaller",
"than",
"the",
"specified",
"granularity",
".",
"The",
"changes",
"must",
"be",
"ordered",
"by",
"ascending",
"positions",
"as",
"returned",
"by",
"this",
"package",
"."
] | d8d9a906c24d7b0ee77287e0463e5ca7f026032e | https://github.com/mb0/diff/blob/d8d9a906c24d7b0ee77287e0463e5ca7f026032e/diff.go#L54-L75 |
148,074 | mb0/diff | diff.go | Diff | func Diff(n, m int, data Data) []Change {
c := &context{data: data}
if n > m {
c.flags = make([]byte, n)
} else {
c.flags = make([]byte, m)
}
c.max = n + m + 1
c.compare(0, 0, n, m)
return c.result(n, m)
} | go | func Diff(n, m int, data Data) []Change {
c := &context{data: data}
if n > m {
c.flags = make([]byte, n)
} else {
c.flags = make([]byte, m)
}
c.max = n + m + 1
c.compare(0, 0, n, m)
return c.result(n, m)
} | [
"func",
"Diff",
"(",
"n",
",",
"m",
"int",
",",
"data",
"Data",
")",
"[",
"]",
"Change",
"{",
"c",
":=",
"&",
"context",
"{",
"data",
":",
"data",
"}",
"\n",
"if",
"n",
">",
"m",
"{",
"c",
".",
"flags",
"=",
"make",
"(",
"[",
"]",
"byte",
... | // Diff returns the differences of data.
// data.Equal is called repeatedly with 0<=i<n and 0<=j<m | [
"Diff",
"returns",
"the",
"differences",
"of",
"data",
".",
"data",
".",
"Equal",
"is",
"called",
"repeatedly",
"with",
"0<",
"=",
"i<n",
"and",
"0<",
"=",
"j<m"
] | d8d9a906c24d7b0ee77287e0463e5ca7f026032e | https://github.com/mb0/diff/blob/d8d9a906c24d7b0ee77287e0463e5ca7f026032e/diff.go#L79-L89 |
148,075 | venicegeo/geojson-go | geojson/feature.go | FeatureFromBytes | func FeatureFromBytes(bytes []byte) (*Feature, error) {
var result Feature
if err := json.Unmarshal(bytes, &result); err != nil {
return nil, err
}
result.ResolveGeometry()
return &result, nil
} | go | func FeatureFromBytes(bytes []byte) (*Feature, error) {
var result Feature
if err := json.Unmarshal(bytes, &result); err != nil {
return nil, err
}
result.ResolveGeometry()
return &result, nil
} | [
"func",
"FeatureFromBytes",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"*",
"Feature",
",",
"error",
")",
"{",
"var",
"result",
"Feature",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"result",
")",
";",
"err",
"!=",
"n... | // FeatureFromBytes constructs a Feature from a GeoJSON byte array
// and returns its pointer | [
"FeatureFromBytes",
"constructs",
"a",
"Feature",
"from",
"a",
"GeoJSON",
"byte",
"array",
"and",
"returns",
"its",
"pointer"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L46-L53 |
148,076 | venicegeo/geojson-go | geojson/feature.go | IDStr | func (feature *Feature) IDStr() string {
if feature.ID == nil {
return ""
}
return fmt.Sprintf("%v", feature.ID)
} | go | func (feature *Feature) IDStr() string {
if feature.ID == nil {
return ""
}
return fmt.Sprintf("%v", feature.ID)
} | [
"func",
"(",
"feature",
"*",
"Feature",
")",
"IDStr",
"(",
")",
"string",
"{",
"if",
"feature",
".",
"ID",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"feature",
".",
"ID",
")",
... | // IDStr returns the ID as a string | [
"IDStr",
"returns",
"the",
"ID",
"as",
"a",
"string"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L80-L85 |
148,077 | venicegeo/geojson-go | geojson/feature.go | Map | func (feature *Feature) Map() map[string]interface{} {
result := make(map[string]interface{})
switch ft := feature.Geometry.(type) {
case Mapper:
result[GEOMETRY] = ft.Map()
case map[string]interface{}:
result[GEOMETRY] = ft
default:
result[GEOMETRY] = nil
}
result[PROPERTIES] = feature.Properties
result[... | go | func (feature *Feature) Map() map[string]interface{} {
result := make(map[string]interface{})
switch ft := feature.Geometry.(type) {
case Mapper:
result[GEOMETRY] = ft.Map()
case map[string]interface{}:
result[GEOMETRY] = ft
default:
result[GEOMETRY] = nil
}
result[PROPERTIES] = feature.Properties
result[... | [
"func",
"(",
"feature",
"*",
"Feature",
")",
"Map",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"switch",
"ft",
":=",
"feature",
".",
"... | // Map returns a map of the Feature's members
// This may be useful in wrapping a Feature with foreign members | [
"Map",
"returns",
"a",
"map",
"of",
"the",
"Feature",
"s",
"members",
"This",
"may",
"be",
"useful",
"in",
"wrapping",
"a",
"Feature",
"with",
"foreign",
"members"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L89-L103 |
148,078 | venicegeo/geojson-go | geojson/feature.go | NewFeature | func NewFeature(geometry interface{}, id interface{}, properties map[string]interface{}) *Feature {
if properties == nil {
properties = make(map[string]interface{})
}
return &Feature{Type: FEATURE, Geometry: geometry, Properties: properties, ID: id}
} | go | func NewFeature(geometry interface{}, id interface{}, properties map[string]interface{}) *Feature {
if properties == nil {
properties = make(map[string]interface{})
}
return &Feature{Type: FEATURE, Geometry: geometry, Properties: properties, ID: id}
} | [
"func",
"NewFeature",
"(",
"geometry",
"interface",
"{",
"}",
",",
"id",
"interface",
"{",
"}",
",",
"properties",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"Feature",
"{",
"if",
"properties",
"==",
"nil",
"{",
"properties",
"=",
"mak... | // NewFeature is the normal factory method for a feature
// Note that id is expected to be a string or number | [
"NewFeature",
"is",
"the",
"normal",
"factory",
"method",
"for",
"a",
"feature",
"Note",
"that",
"id",
"is",
"expected",
"to",
"be",
"a",
"string",
"or",
"number"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L107-L112 |
148,079 | venicegeo/geojson-go | geojson/feature.go | PropertyString | func (feature *Feature) PropertyString(propertyName string) string {
var result string
if property, ok := feature.Properties[propertyName]; ok {
return stringify(property)
}
return result
} | go | func (feature *Feature) PropertyString(propertyName string) string {
var result string
if property, ok := feature.Properties[propertyName]; ok {
return stringify(property)
}
return result
} | [
"func",
"(",
"feature",
"*",
"Feature",
")",
"PropertyString",
"(",
"propertyName",
"string",
")",
"string",
"{",
"var",
"result",
"string",
"\n",
"if",
"property",
",",
"ok",
":=",
"feature",
".",
"Properties",
"[",
"propertyName",
"]",
";",
"ok",
"{",
... | // PropertyString returns the string value of the property if it exists
// and is a string, or the empty string otherwise | [
"PropertyString",
"returns",
"the",
"string",
"value",
"of",
"the",
"property",
"if",
"it",
"exists",
"and",
"is",
"a",
"string",
"or",
"the",
"empty",
"string",
"otherwise"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L141-L147 |
148,080 | venicegeo/geojson-go | geojson/feature.go | PropertyInt | func (feature *Feature) PropertyInt(propertyName string) int {
var result int
if property, ok := feature.Properties[propertyName]; ok {
result = intify(property)
}
return result
} | go | func (feature *Feature) PropertyInt(propertyName string) int {
var result int
if property, ok := feature.Properties[propertyName]; ok {
result = intify(property)
}
return result
} | [
"func",
"(",
"feature",
"*",
"Feature",
")",
"PropertyInt",
"(",
"propertyName",
"string",
")",
"int",
"{",
"var",
"result",
"int",
"\n",
"if",
"property",
",",
"ok",
":=",
"feature",
".",
"Properties",
"[",
"propertyName",
"]",
";",
"ok",
"{",
"result",... | // PropertyInt returns the integer value of the property if it exists
// or 0 otherwise | [
"PropertyInt",
"returns",
"the",
"integer",
"value",
"of",
"the",
"property",
"if",
"it",
"exists",
"or",
"0",
"otherwise"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L172-L178 |
148,081 | venicegeo/geojson-go | geojson/feature.go | PropertyStringSlice | func (feature *Feature) PropertyStringSlice(propertyName string) []string {
var result []string
if property, ok := feature.Properties[propertyName]; ok {
switch ptype := property.(type) {
case []string:
result = ptype
case []interface{}:
for _, curr := range ptype {
if currString, ok := curr.(string);... | go | func (feature *Feature) PropertyStringSlice(propertyName string) []string {
var result []string
if property, ok := feature.Properties[propertyName]; ok {
switch ptype := property.(type) {
case []string:
result = ptype
case []interface{}:
for _, curr := range ptype {
if currString, ok := curr.(string);... | [
"func",
"(",
"feature",
"*",
"Feature",
")",
"PropertyStringSlice",
"(",
"propertyName",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"result",
"[",
"]",
"string",
"\n",
"if",
"property",
",",
"ok",
":=",
"feature",
".",
"Properties",
"[",
"propertyName"... | // PropertyStringSlice returns the string slice value of the property if it exists
// or an empty slice otherwise | [
"PropertyStringSlice",
"returns",
"the",
"string",
"slice",
"value",
"of",
"the",
"property",
"if",
"it",
"exists",
"or",
"an",
"empty",
"slice",
"otherwise"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L182-L197 |
148,082 | venicegeo/geojson-go | geojson/feature.go | FeatureFromMap | func FeatureFromMap(input map[string]interface{}) *Feature {
var (
result Feature
ok bool
)
if result.Type, ok = input[TYPE].(string); ok {
if _, ok = input[PROPERTIES].(map[string]interface{}); ok {
result.Properties = input[PROPERTIES].(map[string]interface{})
}
result.Geometry = input[GEOMETRY]
... | go | func FeatureFromMap(input map[string]interface{}) *Feature {
var (
result Feature
ok bool
)
if result.Type, ok = input[TYPE].(string); ok {
if _, ok = input[PROPERTIES].(map[string]interface{}); ok {
result.Properties = input[PROPERTIES].(map[string]interface{})
}
result.Geometry = input[GEOMETRY]
... | [
"func",
"FeatureFromMap",
"(",
"input",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"Feature",
"{",
"var",
"(",
"result",
"Feature",
"\n",
"ok",
"bool",
"\n",
")",
"\n",
"if",
"result",
".",
"Type",
",",
"ok",
"=",
"input",
"[",
"TY... | // FeatureFromMap constructs a Feature from a map
// and returns its pointer | [
"FeatureFromMap",
"constructs",
"a",
"Feature",
"from",
"a",
"map",
"and",
"returns",
"its",
"pointer"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature.go#L233-L259 |
148,083 | venicegeo/geojson-go | geojson/feature_collection.go | FeatureCollectionFromBytes | func FeatureCollectionFromBytes(bytes []byte) (*FeatureCollection, error) {
var result FeatureCollection
if err := json.Unmarshal(bytes, &result); err != nil {
return nil, err
}
for _, feature := range result.Features {
feature.ResolveGeometry()
}
return &result, nil
} | go | func FeatureCollectionFromBytes(bytes []byte) (*FeatureCollection, error) {
var result FeatureCollection
if err := json.Unmarshal(bytes, &result); err != nil {
return nil, err
}
for _, feature := range result.Features {
feature.ResolveGeometry()
}
return &result, nil
} | [
"func",
"FeatureCollectionFromBytes",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"*",
"FeatureCollection",
",",
"error",
")",
"{",
"var",
"result",
"FeatureCollection",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"&",
"result",
")"... | // FeatureCollectionFromBytes constructs a FeatureCollection from a GeoJSON byte array
// and returns its pointer | [
"FeatureCollectionFromBytes",
"constructs",
"a",
"FeatureCollection",
"from",
"a",
"GeoJSON",
"byte",
"array",
"and",
"returns",
"its",
"pointer"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature_collection.go#L36-L45 |
148,084 | venicegeo/geojson-go | geojson/feature_collection.go | NewFeatureCollection | func NewFeatureCollection(features []*Feature) *FeatureCollection {
if features == nil {
features = make([]*Feature, 0)
}
return &FeatureCollection{Type: FEATURECOLLECTION, Features: features}
} | go | func NewFeatureCollection(features []*Feature) *FeatureCollection {
if features == nil {
features = make([]*Feature, 0)
}
return &FeatureCollection{Type: FEATURECOLLECTION, Features: features}
} | [
"func",
"NewFeatureCollection",
"(",
"features",
"[",
"]",
"*",
"Feature",
")",
"*",
"FeatureCollection",
"{",
"if",
"features",
"==",
"nil",
"{",
"features",
"=",
"make",
"(",
"[",
"]",
"*",
"Feature",
",",
"0",
")",
"\n",
"}",
"\n",
"return",
"&",
... | // NewFeatureCollection is the normal factory method for a FeatureCollection | [
"NewFeatureCollection",
"is",
"the",
"normal",
"factory",
"method",
"for",
"a",
"FeatureCollection"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature_collection.go#L60-L65 |
148,085 | venicegeo/geojson-go | geojson/feature_collection.go | Map | func (fc *FeatureCollection) Map() map[string]interface{} {
result := make(map[string]interface{})
result["type"] = fc.Type
features := make([]interface{}, len(fc.Features))
for inx, feature := range fc.Features {
features[inx] = feature.Map()
}
result[FEATURES] = features
result[BBOX] = fc.Bbox
return resul... | go | func (fc *FeatureCollection) Map() map[string]interface{} {
result := make(map[string]interface{})
result["type"] = fc.Type
features := make([]interface{}, len(fc.Features))
for inx, feature := range fc.Features {
features[inx] = feature.Map()
}
result[FEATURES] = features
result[BBOX] = fc.Bbox
return resul... | [
"func",
"(",
"fc",
"*",
"FeatureCollection",
")",
"Map",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"result",
"[",
"\"",
"\"",
"]",
"=... | // Map returns a map of the FeatureCollection's members
// This may be useful in wrapping a Feature Collection with foreign members | [
"Map",
"returns",
"a",
"map",
"of",
"the",
"FeatureCollection",
"s",
"members",
"This",
"may",
"be",
"useful",
"in",
"wrapping",
"a",
"Feature",
"Collection",
"with",
"foreign",
"members"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature_collection.go#L80-L91 |
148,086 | venicegeo/geojson-go | geojson/feature_collection.go | FeatureCollectionFromMap | func FeatureCollectionFromMap(input map[string]interface{}) *FeatureCollection {
result := NewFeatureCollection(nil)
featuresIfc := input[FEATURES]
switch it := featuresIfc.(type) {
case []interface{}:
for _, featureIfc := range it {
if featureMap, ok := featureIfc.(map[string]interface{}); ok {
feature :=... | go | func FeatureCollectionFromMap(input map[string]interface{}) *FeatureCollection {
result := NewFeatureCollection(nil)
featuresIfc := input[FEATURES]
switch it := featuresIfc.(type) {
case []interface{}:
for _, featureIfc := range it {
if featureMap, ok := featureIfc.(map[string]interface{}); ok {
feature :=... | [
"func",
"FeatureCollectionFromMap",
"(",
"input",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"FeatureCollection",
"{",
"result",
":=",
"NewFeatureCollection",
"(",
"nil",
")",
"\n",
"featuresIfc",
":=",
"input",
"[",
"FEATURES",
"]",
"\n",
"... | // FeatureCollectionFromMap constructs a FeatureCollection from a map
// and returns its pointer | [
"FeatureCollectionFromMap",
"constructs",
"a",
"FeatureCollection",
"from",
"a",
"map",
"and",
"returns",
"its",
"pointer"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature_collection.go#L95-L112 |
148,087 | venicegeo/geojson-go | geojson/feature_collection.go | FillProperties | func (fc *FeatureCollection) FillProperties() {
properties := make(map[string]bool)
// Loop 1: construct a set (actually a map)
for _, feature := range fc.Features {
for key := range feature.Properties {
if _, ok := properties[key]; !ok {
properties[key] = true
}
}
}
// Loop 2: make sure each featu... | go | func (fc *FeatureCollection) FillProperties() {
properties := make(map[string]bool)
// Loop 1: construct a set (actually a map)
for _, feature := range fc.Features {
for key := range feature.Properties {
if _, ok := properties[key]; !ok {
properties[key] = true
}
}
}
// Loop 2: make sure each featu... | [
"func",
"(",
"fc",
"*",
"FeatureCollection",
")",
"FillProperties",
"(",
")",
"{",
"properties",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n\n",
"// Loop 1: construct a set (actually a map)",
"for",
"_",
",",
"feature",
":=",
"range",
"fc",
... | // FillProperties iterates through all features to ensure that all properties
// are present on all features to meet the needs of some relational databases | [
"FillProperties",
"iterates",
"through",
"all",
"features",
"to",
"ensure",
"that",
"all",
"properties",
"are",
"present",
"on",
"all",
"features",
"to",
"meet",
"the",
"needs",
"of",
"some",
"relational",
"databases"
] | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/feature_collection.go#L116-L136 |
148,088 | venicegeo/geojson-go | geojson/wfs.go | FromWFS | func FromWFS(wfsURL, featureType string) (*FeatureCollection, error) {
var (
result *FeatureCollection
err error
request *http.Request
response *http.Response
b []byte
ok bool
)
v := url.Values{}
v.Set("service", "wfs")
v.Set("count", "9999")
v.Set("outputFormat", "application/js... | go | func FromWFS(wfsURL, featureType string) (*FeatureCollection, error) {
var (
result *FeatureCollection
err error
request *http.Request
response *http.Response
b []byte
ok bool
)
v := url.Values{}
v.Set("service", "wfs")
v.Set("count", "9999")
v.Set("outputFormat", "application/js... | [
"func",
"FromWFS",
"(",
"wfsURL",
",",
"featureType",
"string",
")",
"(",
"*",
"FeatureCollection",
",",
"error",
")",
"{",
"var",
"(",
"result",
"*",
"FeatureCollection",
"\n",
"err",
"error",
"\n",
"request",
"*",
"http",
".",
"Request",
"\n",
"response"... | // FromWFS returns a Feature Collection from the WFS provided.
// This is a convenience method only and not intended for serious processing.
// This function does not currently support WFS layers with large numbers of features. | [
"FromWFS",
"returns",
"a",
"Feature",
"Collection",
"from",
"the",
"WFS",
"provided",
".",
"This",
"is",
"a",
"convenience",
"method",
"only",
"and",
"not",
"intended",
"for",
"serious",
"processing",
".",
"This",
"function",
"does",
"not",
"currently",
"suppo... | d1ea2453c82c1124c6d4233f92ba5424f15d8bc3 | https://github.com/venicegeo/geojson-go/blob/d1ea2453c82c1124c6d4233f92ba5424f15d8bc3/geojson/wfs.go#L30-L75 |
148,089 | cloud-ca/go-cloudca | services/cloudca/template.go | Get | func (templateApi *TemplateApi) Get(id string) (*Template, error) {
data, err := templateApi.entityService.Get(id, map[string]string{})
if err != nil {
return nil, err
}
return parseTemplate(data), nil
} | go | func (templateApi *TemplateApi) Get(id string) (*Template, error) {
data, err := templateApi.entityService.Get(id, map[string]string{})
if err != nil {
return nil, err
}
return parseTemplate(data), nil
} | [
"func",
"(",
"templateApi",
"*",
"TemplateApi",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"*",
"Template",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"templateApi",
".",
"entityService",
".",
"Get",
"(",
"id",
",",
"map",
"[",
"string",
"]",
... | //Get template with the specified id for the current environment | [
"Get",
"template",
"with",
"the",
"specified",
"id",
"for",
"the",
"current",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/template.go#L62-L68 |
148,090 | cloud-ca/go-cloudca | services/cloudca/template.go | ListWithOptions | func (templateApi *TemplateApi) ListWithOptions(options map[string]string) ([]Template, error) {
data, err := templateApi.entityService.List(options)
if err != nil {
return nil, err
}
return parseTemplateList(data), nil
} | go | func (templateApi *TemplateApi) ListWithOptions(options map[string]string) ([]Template, error) {
data, err := templateApi.entityService.List(options)
if err != nil {
return nil, err
}
return parseTemplateList(data), nil
} | [
"func",
"(",
"templateApi",
"*",
"TemplateApi",
")",
"ListWithOptions",
"(",
"options",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"Template",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"templateApi",
".",
"entityService",
".",
"List... | //List all templates for the current environment. Can use options to do sorting and paging. | [
"List",
"all",
"templates",
"for",
"the",
"current",
"environment",
".",
"Can",
"use",
"options",
"to",
"do",
"sorting",
"and",
"paging",
"."
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/template.go#L76-L82 |
148,091 | cloud-ca/go-cloudca | api/api.go | buildUrl | func (ccaClient CcaApiClient) buildUrl(endpoint string, options map[string]string) string {
query := url.Values{}
if options != nil {
for k, v := range options {
query.Add(k, v)
}
}
u, _ := url.Parse(ccaClient.apiURL + "/" + strings.Trim(endpoint, "/") + "?" + query.Encode())
return u.String()
} | go | func (ccaClient CcaApiClient) buildUrl(endpoint string, options map[string]string) string {
query := url.Values{}
if options != nil {
for k, v := range options {
query.Add(k, v)
}
}
u, _ := url.Parse(ccaClient.apiURL + "/" + strings.Trim(endpoint, "/") + "?" + query.Encode())
return u.String()
} | [
"func",
"(",
"ccaClient",
"CcaApiClient",
")",
"buildUrl",
"(",
"endpoint",
"string",
",",
"options",
"map",
"[",
"string",
"]",
"string",
")",
"string",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"if",
"options",
"!=",
"nil",
"{",
"for"... | //Build a URL by using endpoint and options. Options will be set as query parameters. | [
"Build",
"a",
"URL",
"by",
"using",
"endpoint",
"and",
"options",
".",
"Options",
"will",
"be",
"set",
"as",
"query",
"parameters",
"."
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/api/api.go#L46-L55 |
148,092 | cloud-ca/go-cloudca | api/api.go | Do | func (ccaClient CcaApiClient) Do(request CcaRequest) (*CcaResponse, error) {
var bodyBuffer io.Reader
if request.Body != nil {
bodyBuffer = bytes.NewBuffer(request.Body)
}
method := request.Method
if method == "" {
method = "GET"
}
req, err := http.NewRequest(request.Method, ccaClient.buildUrl(request.Endpoi... | go | func (ccaClient CcaApiClient) Do(request CcaRequest) (*CcaResponse, error) {
var bodyBuffer io.Reader
if request.Body != nil {
bodyBuffer = bytes.NewBuffer(request.Body)
}
method := request.Method
if method == "" {
method = "GET"
}
req, err := http.NewRequest(request.Method, ccaClient.buildUrl(request.Endpoi... | [
"func",
"(",
"ccaClient",
"CcaApiClient",
")",
"Do",
"(",
"request",
"CcaRequest",
")",
"(",
"*",
"CcaResponse",
",",
"error",
")",
"{",
"var",
"bodyBuffer",
"io",
".",
"Reader",
"\n",
"if",
"request",
".",
"Body",
"!=",
"nil",
"{",
"bodyBuffer",
"=",
... | //Does the API call to server and returns a CCAResponse. Cloud.ca errors will be returned in the
//CCAResponse body, not in the error return value. The error return value is reserved for unexpected errors. | [
"Does",
"the",
"API",
"call",
"to",
"server",
"and",
"returns",
"a",
"CCAResponse",
".",
"Cloud",
".",
"ca",
"errors",
"will",
"be",
"returned",
"in",
"the",
"CCAResponse",
"body",
"not",
"in",
"the",
"error",
"return",
"value",
".",
"The",
"error",
"ret... | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/api/api.go#L59-L80 |
148,093 | cloud-ca/go-cloudca | configuration/environment.go | Get | func (environmentApi *EnvironmentApi) Get(id string) (*Environment, error) {
data, err := environmentApi.configurationService.Get(id, map[string]string{})
if err != nil {
return nil, err
}
return parseEnvironment(data), nil
} | go | func (environmentApi *EnvironmentApi) Get(id string) (*Environment, error) {
data, err := environmentApi.configurationService.Get(id, map[string]string{})
if err != nil {
return nil, err
}
return parseEnvironment(data), nil
} | [
"func",
"(",
"environmentApi",
"*",
"EnvironmentApi",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"*",
"Environment",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"environmentApi",
".",
"configurationService",
".",
"Get",
"(",
"id",
",",
"map",
"[",
... | //Get environment with the specified id | [
"Get",
"environment",
"with",
"the",
"specified",
"id"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/configuration/environment.go#L55-L61 |
148,094 | cloud-ca/go-cloudca | services/cloudca/remote_access_vpn_user.go | NewRemoteAccessVpnUserService | func NewRemoteAccessVpnUserService(apiClient api.ApiClient, serviceCode string, environmentName string) RemoteAccessVpnUserService {
return &RemoteAccessVpnUserApi{
entityService: services.NewEntityService(apiClient, serviceCode, environmentName, REMOTE_ACCESS_VPN_USER_ENTITY_TYPE),
}
} | go | func NewRemoteAccessVpnUserService(apiClient api.ApiClient, serviceCode string, environmentName string) RemoteAccessVpnUserService {
return &RemoteAccessVpnUserApi{
entityService: services.NewEntityService(apiClient, serviceCode, environmentName, REMOTE_ACCESS_VPN_USER_ENTITY_TYPE),
}
} | [
"func",
"NewRemoteAccessVpnUserService",
"(",
"apiClient",
"api",
".",
"ApiClient",
",",
"serviceCode",
"string",
",",
"environmentName",
"string",
")",
"RemoteAccessVpnUserService",
"{",
"return",
"&",
"RemoteAccessVpnUserApi",
"{",
"entityService",
":",
"services",
".... | // NewRemoteAccessVpnUserService creates a new VPN User Service for this specific service and environment | [
"NewRemoteAccessVpnUserService",
"creates",
"a",
"new",
"VPN",
"User",
"Service",
"for",
"this",
"specific",
"service",
"and",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/remote_access_vpn_user.go#L31-L35 |
148,095 | cloud-ca/go-cloudca | services/cloudca/remote_access_vpn_user.go | Get | func (remoteAccessVpnUserApi *RemoteAccessVpnUserApi) Get(id string) (*RemoteAccessVpnUser, error) {
data, err := remoteAccessVpnUserApi.entityService.Get(id, map[string]string{})
if err != nil {
return nil, err
}
return parseRemoteAccessVpnUser(data), nil
} | go | func (remoteAccessVpnUserApi *RemoteAccessVpnUserApi) Get(id string) (*RemoteAccessVpnUser, error) {
data, err := remoteAccessVpnUserApi.entityService.Get(id, map[string]string{})
if err != nil {
return nil, err
}
return parseRemoteAccessVpnUser(data), nil
} | [
"func",
"(",
"remoteAccessVpnUserApi",
"*",
"RemoteAccessVpnUserApi",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"*",
"RemoteAccessVpnUser",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"remoteAccessVpnUserApi",
".",
"entityService",
".",
"Get",
"(",
"id"... | // Get a specific VPN User in the current environment by their ID | [
"Get",
"a",
"specific",
"VPN",
"User",
"in",
"the",
"current",
"environment",
"by",
"their",
"ID"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/remote_access_vpn_user.go#L50-L56 |
148,096 | cloud-ca/go-cloudca | services/cloudca/remote_access_vpn_user.go | List | func (remoteAccessVpnUserApi *RemoteAccessVpnUserApi) List() ([]RemoteAccessVpnUser, error) {
data, err := remoteAccessVpnUserApi.entityService.List(map[string]string{})
if err != nil {
return nil, err
}
return parseRemoteAccessVpnUserList(data), nil
} | go | func (remoteAccessVpnUserApi *RemoteAccessVpnUserApi) List() ([]RemoteAccessVpnUser, error) {
data, err := remoteAccessVpnUserApi.entityService.List(map[string]string{})
if err != nil {
return nil, err
}
return parseRemoteAccessVpnUserList(data), nil
} | [
"func",
"(",
"remoteAccessVpnUserApi",
"*",
"RemoteAccessVpnUserApi",
")",
"List",
"(",
")",
"(",
"[",
"]",
"RemoteAccessVpnUser",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"remoteAccessVpnUserApi",
".",
"entityService",
".",
"List",
"(",
"map",
"[",
... | // List VPN Users for this environment | [
"List",
"VPN",
"Users",
"for",
"this",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/remote_access_vpn_user.go#L59-L65 |
148,097 | cloud-ca/go-cloudca | services/cloudca/remote_access_vpn_user.go | Create | func (remoteAccessVpnUserApi *RemoteAccessVpnUserApi) Create(remoteAccessVpnUser RemoteAccessVpnUser) (bool, error) {
send, merr := json.Marshal(remoteAccessVpnUser)
if merr != nil {
return false, merr
}
_, err := remoteAccessVpnUserApi.entityService.Create(send, map[string]string{})
return err == nil, err
} | go | func (remoteAccessVpnUserApi *RemoteAccessVpnUserApi) Create(remoteAccessVpnUser RemoteAccessVpnUser) (bool, error) {
send, merr := json.Marshal(remoteAccessVpnUser)
if merr != nil {
return false, merr
}
_, err := remoteAccessVpnUserApi.entityService.Create(send, map[string]string{})
return err == nil, err
} | [
"func",
"(",
"remoteAccessVpnUserApi",
"*",
"RemoteAccessVpnUserApi",
")",
"Create",
"(",
"remoteAccessVpnUser",
"RemoteAccessVpnUser",
")",
"(",
"bool",
",",
"error",
")",
"{",
"send",
",",
"merr",
":=",
"json",
".",
"Marshal",
"(",
"remoteAccessVpnUser",
")",
... | // Create a VPN User in the current environment | [
"Create",
"a",
"VPN",
"User",
"in",
"the",
"current",
"environment"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/services/cloudca/remote_access_vpn_user.go#L68-L75 |
148,098 | cloud-ca/go-cloudca | client.go | NewCcaClientWithURL | func NewCcaClientWithURL(apiURL string, apiKey string) *CcaClient {
apiClient := api.NewApiClient(apiURL, apiKey)
return NewCcaClientWithApiClient(apiClient)
} | go | func NewCcaClientWithURL(apiURL string, apiKey string) *CcaClient {
apiClient := api.NewApiClient(apiURL, apiKey)
return NewCcaClientWithApiClient(apiClient)
} | [
"func",
"NewCcaClientWithURL",
"(",
"apiURL",
"string",
",",
"apiKey",
"string",
")",
"*",
"CcaClient",
"{",
"apiClient",
":=",
"api",
".",
"NewApiClient",
"(",
"apiURL",
",",
"apiKey",
")",
"\n",
"return",
"NewCcaClientWithApiClient",
"(",
"apiClient",
")",
"... | //Create a CcaClient with a custom URL | [
"Create",
"a",
"CcaClient",
"with",
"a",
"custom",
"URL"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/client.go#L29-L32 |
148,099 | cloud-ca/go-cloudca | client.go | NewInsecureCcaClientWithURL | func NewInsecureCcaClientWithURL(apiURL string, apiKey string) *CcaClient {
apiClient := api.NewInsecureApiClient(apiURL, apiKey)
return NewCcaClientWithApiClient(apiClient)
} | go | func NewInsecureCcaClientWithURL(apiURL string, apiKey string) *CcaClient {
apiClient := api.NewInsecureApiClient(apiURL, apiKey)
return NewCcaClientWithApiClient(apiClient)
} | [
"func",
"NewInsecureCcaClientWithURL",
"(",
"apiURL",
"string",
",",
"apiKey",
"string",
")",
"*",
"CcaClient",
"{",
"apiClient",
":=",
"api",
".",
"NewInsecureApiClient",
"(",
"apiURL",
",",
"apiKey",
")",
"\n",
"return",
"NewCcaClientWithApiClient",
"(",
"apiCli... | //Create a CcaClient with a custom URL that accepts insecure connections | [
"Create",
"a",
"CcaClient",
"with",
"a",
"custom",
"URL",
"that",
"accepts",
"insecure",
"connections"
] | fb928a1e9d26293010e4d829bbcbfc22eb31f013 | https://github.com/cloud-ca/go-cloudca/blob/fb928a1e9d26293010e4d829bbcbfc22eb31f013/client.go#L35-L38 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.