repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
nwaples/rardecode | archive15.go | readBlockHeader | func (a *archive15) readBlockHeader() (*blockHeader15, error) {
var err error
b := a.buf[:7]
r := io.Reader(a.v)
if a.encrypted {
salt := a.buf[:saltSize]
_, err = io.ReadFull(r, salt)
if err != nil {
return nil, err
}
key, iv := a.getKeys(salt)
r = newAesDecryptReader(r, key, iv)
err = readFull(r,... | go | func (a *archive15) readBlockHeader() (*blockHeader15, error) {
var err error
b := a.buf[:7]
r := io.Reader(a.v)
if a.encrypted {
salt := a.buf[:saltSize]
_, err = io.ReadFull(r, salt)
if err != nil {
return nil, err
}
key, iv := a.getKeys(salt)
r = newAesDecryptReader(r, key, iv)
err = readFull(r,... | [
"func",
"(",
"a",
"*",
"archive15",
")",
"readBlockHeader",
"(",
")",
"(",
"*",
"blockHeader15",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"b",
":=",
"a",
".",
"buf",
"[",
":",
"7",
"]",
"\n",
"r",
":=",
"io",
".",
"Reader",
"(",
"a"... | // readBlockHeader returns the next block header in the archive.
// It will return io.EOF if there were no bytes read. | [
"readBlockHeader",
"returns",
"the",
"next",
"block",
"header",
"in",
"the",
"archive",
".",
"It",
"will",
"return",
"io",
".",
"EOF",
"if",
"there",
"were",
"no",
"bytes",
"read",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/archive15.go#L360-L416 | test |
nwaples/rardecode | archive15.go | newArchive15 | func newArchive15(r *bufio.Reader, password string) fileBlockReader {
a := new(archive15)
a.v = r
a.pass = utf16.Encode([]rune(password)) // convert to UTF-16
a.checksum.Hash32 = crc32.NewIEEE()
a.buf = readBuf(make([]byte, 100))
return a
} | go | func newArchive15(r *bufio.Reader, password string) fileBlockReader {
a := new(archive15)
a.v = r
a.pass = utf16.Encode([]rune(password)) // convert to UTF-16
a.checksum.Hash32 = crc32.NewIEEE()
a.buf = readBuf(make([]byte, 100))
return a
} | [
"func",
"newArchive15",
"(",
"r",
"*",
"bufio",
".",
"Reader",
",",
"password",
"string",
")",
"fileBlockReader",
"{",
"a",
":=",
"new",
"(",
"archive15",
")",
"\n",
"a",
".",
"v",
"=",
"r",
"\n",
"a",
".",
"pass",
"=",
"utf16",
".",
"Encode",
"(",... | // newArchive15 creates a new fileBlockReader for a Version 1.5 archive | [
"newArchive15",
"creates",
"a",
"new",
"fileBlockReader",
"for",
"a",
"Version",
"1",
".",
"5",
"archive"
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/archive15.go#L461-L468 | test |
nwaples/rardecode | decode50.go | readFilter5Data | func readFilter5Data(br bitReader) (int, error) {
// TODO: should data really be uint? (for 32bit ints).
// It will be masked later anyway by decode window mask.
bytes, err := br.readBits(2)
if err != nil {
return 0, err
}
bytes++
var data int
for i := 0; i < bytes; i++ {
n, err := br.readBits(8)
if err ... | go | func readFilter5Data(br bitReader) (int, error) {
// TODO: should data really be uint? (for 32bit ints).
// It will be masked later anyway by decode window mask.
bytes, err := br.readBits(2)
if err != nil {
return 0, err
}
bytes++
var data int
for i := 0; i < bytes; i++ {
n, err := br.readBits(8)
if err ... | [
"func",
"readFilter5Data",
"(",
"br",
"bitReader",
")",
"(",
"int",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"br",
".",
"readBits",
"(",
"2",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"bytes",... | // readFilter5Data reads an encoded integer used in V5 filters. | [
"readFilter5Data",
"reads",
"an",
"encoded",
"integer",
"used",
"in",
"V5",
"filters",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode50.go#L132-L150 | test |
nwaples/rardecode | decode_reader.go | writeByte | func (w *window) writeByte(c byte) {
w.buf[w.w] = c
w.w = (w.w + 1) & w.mask
} | go | func (w *window) writeByte(c byte) {
w.buf[w.w] = c
w.w = (w.w + 1) & w.mask
} | [
"func",
"(",
"w",
"*",
"window",
")",
"writeByte",
"(",
"c",
"byte",
")",
"{",
"w",
".",
"buf",
"[",
"w",
".",
"w",
"]",
"=",
"c",
"\n",
"w",
".",
"w",
"=",
"(",
"w",
".",
"w",
"+",
"1",
")",
"&",
"w",
".",
"mask",
"\n",
"}"
] | // writeByte writes c to the end of the window | [
"writeByte",
"writes",
"c",
"to",
"the",
"end",
"of",
"the",
"window"
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L78-L81 | test |
nwaples/rardecode | decode_reader.go | copyBytes | func (w *window) copyBytes(len, off int) {
len &= w.mask
n := w.available()
if len > n {
// if there is not enough space availaible we copy
// as much as we can and save the offset and length
// of the remaining data to be copied later.
w.l = len - n
w.o = off
len = n
}
i := (w.w - off) & w.mask
for... | go | func (w *window) copyBytes(len, off int) {
len &= w.mask
n := w.available()
if len > n {
// if there is not enough space availaible we copy
// as much as we can and save the offset and length
// of the remaining data to be copied later.
w.l = len - n
w.o = off
len = n
}
i := (w.w - off) & w.mask
for... | [
"func",
"(",
"w",
"*",
"window",
")",
"copyBytes",
"(",
"len",
",",
"off",
"int",
")",
"{",
"len",
"&=",
"w",
".",
"mask",
"\n",
"n",
":=",
"w",
".",
"available",
"(",
")",
"\n",
"if",
"len",
">",
"n",
"{",
"w",
".",
"l",
"=",
"len",
"-",
... | // copyBytes copies len bytes at off distance from the end
// to the end of the window. | [
"copyBytes",
"copies",
"len",
"bytes",
"at",
"off",
"distance",
"from",
"the",
"end",
"to",
"the",
"end",
"of",
"the",
"window",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L85-L104 | test |
nwaples/rardecode | decode_reader.go | read | func (w *window) read(p []byte) (n int) {
if w.r > w.w {
n = copy(p, w.buf[w.r:])
w.r = (w.r + n) & w.mask
p = p[n:]
}
if w.r < w.w {
l := copy(p, w.buf[w.r:w.w])
w.r += l
n += l
}
if w.l > 0 && n > 0 {
// if we have successfully read data, copy any
// leftover data from a previous copyBytes.
l :... | go | func (w *window) read(p []byte) (n int) {
if w.r > w.w {
n = copy(p, w.buf[w.r:])
w.r = (w.r + n) & w.mask
p = p[n:]
}
if w.r < w.w {
l := copy(p, w.buf[w.r:w.w])
w.r += l
n += l
}
if w.l > 0 && n > 0 {
// if we have successfully read data, copy any
// leftover data from a previous copyBytes.
l :... | [
"func",
"(",
"w",
"*",
"window",
")",
"read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
")",
"{",
"if",
"w",
".",
"r",
">",
"w",
".",
"w",
"{",
"n",
"=",
"copy",
"(",
"p",
",",
"w",
".",
"buf",
"[",
"w",
".",
"r",
":",
"]",
... | // read reads bytes from the beginning of the window into p | [
"read",
"reads",
"bytes",
"from",
"the",
"beginning",
"of",
"the",
"window",
"into",
"p"
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L107-L126 | test |
nwaples/rardecode | decode_reader.go | queueFilter | func (d *decodeReader) queueFilter(f *filterBlock) error {
if f.reset {
d.filters = nil
}
if len(d.filters) >= maxQueuedFilters {
return errTooManyFilters
}
// offset & length must be < window size
f.offset &= d.win.mask
f.length &= d.win.mask
// make offset relative to previous filter in list
for _, fb :=... | go | func (d *decodeReader) queueFilter(f *filterBlock) error {
if f.reset {
d.filters = nil
}
if len(d.filters) >= maxQueuedFilters {
return errTooManyFilters
}
// offset & length must be < window size
f.offset &= d.win.mask
f.length &= d.win.mask
// make offset relative to previous filter in list
for _, fb :=... | [
"func",
"(",
"d",
"*",
"decodeReader",
")",
"queueFilter",
"(",
"f",
"*",
"filterBlock",
")",
"error",
"{",
"if",
"f",
".",
"reset",
"{",
"d",
".",
"filters",
"=",
"nil",
"\n",
"}",
"\n",
"if",
"len",
"(",
"d",
".",
"filters",
")",
">=",
"maxQueu... | // queueFilter adds a filterBlock to the end decodeReader's filters. | [
"queueFilter",
"adds",
"a",
"filterBlock",
"to",
"the",
"end",
"decodeReader",
"s",
"filters",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L158-L178 | test |
nwaples/rardecode | decode_reader.go | processFilters | func (d *decodeReader) processFilters() (err error) {
f := d.filters[0]
if f.offset > 0 {
return nil
}
d.filters = d.filters[1:]
if d.win.buffered() < f.length {
// fill() didn't return enough bytes
err = d.readErr()
if err == nil || err == io.EOF {
return errInvalidFilter
}
return err
}
if cap(d... | go | func (d *decodeReader) processFilters() (err error) {
f := d.filters[0]
if f.offset > 0 {
return nil
}
d.filters = d.filters[1:]
if d.win.buffered() < f.length {
// fill() didn't return enough bytes
err = d.readErr()
if err == nil || err == io.EOF {
return errInvalidFilter
}
return err
}
if cap(d... | [
"func",
"(",
"d",
"*",
"decodeReader",
")",
"processFilters",
"(",
")",
"(",
"err",
"error",
")",
"{",
"f",
":=",
"d",
".",
"filters",
"[",
"0",
"]",
"\n",
"if",
"f",
".",
"offset",
">",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"d",
".",
"... | // processFilters processes any filters valid at the current read index
// and stores the output in outbuf. | [
"processFilters",
"processes",
"any",
"filters",
"valid",
"at",
"the",
"current",
"read",
"index",
"and",
"stores",
"the",
"output",
"in",
"outbuf",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L182-L233 | test |
nwaples/rardecode | decode_reader.go | fill | func (d *decodeReader) fill() {
if d.err != nil {
return
}
var fl []*filterBlock
fl, d.err = d.dec.fill(&d.win) // fill window using decoder
for _, f := range fl {
err := d.queueFilter(f)
if err != nil {
d.err = err
return
}
}
} | go | func (d *decodeReader) fill() {
if d.err != nil {
return
}
var fl []*filterBlock
fl, d.err = d.dec.fill(&d.win) // fill window using decoder
for _, f := range fl {
err := d.queueFilter(f)
if err != nil {
d.err = err
return
}
}
} | [
"func",
"(",
"d",
"*",
"decodeReader",
")",
"fill",
"(",
")",
"{",
"if",
"d",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"var",
"fl",
"[",
"]",
"*",
"filterBlock",
"\n",
"fl",
",",
"d",
".",
"err",
"=",
"d",
".",
"dec",
".",
"... | // fill fills the decodeReader's window | [
"fill",
"fills",
"the",
"decodeReader",
"s",
"window"
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L236-L249 | test |
nwaples/rardecode | decode_reader.go | Read | func (d *decodeReader) Read(p []byte) (n int, err error) {
if len(d.outbuf) == 0 {
// no filter output, see if we need to create more
if d.win.buffered() == 0 {
// fill empty window
d.fill()
if d.win.buffered() == 0 {
return 0, d.readErr()
}
} else if len(d.filters) > 0 {
f := d.filters[0]
... | go | func (d *decodeReader) Read(p []byte) (n int, err error) {
if len(d.outbuf) == 0 {
// no filter output, see if we need to create more
if d.win.buffered() == 0 {
// fill empty window
d.fill()
if d.win.buffered() == 0 {
return 0, d.readErr()
}
} else if len(d.filters) > 0 {
f := d.filters[0]
... | [
"func",
"(",
"d",
"*",
"decodeReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"d",
".",
"outbuf",
")",
"==",
"0",
"{",
"if",
"d",
".",
"win",
".",
"buffered",
"(",
")"... | // Read decodes data and stores it in p. | [
"Read",
"decodes",
"data",
"and",
"stores",
"it",
"in",
"p",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/decode_reader.go#L252-L290 | test |
nwaples/rardecode | archive.go | readFull | func readFull(r io.Reader, buf []byte) error {
_, err := io.ReadFull(r, buf)
if err == io.EOF {
return io.ErrUnexpectedEOF
}
return err
} | go | func readFull(r io.Reader, buf []byte) error {
_, err := io.ReadFull(r, buf)
if err == io.EOF {
return io.ErrUnexpectedEOF
}
return err
} | [
"func",
"readFull",
"(",
"r",
"io",
".",
"Reader",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"r",
",",
"buf",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"return",
"io",
".",
... | // readFull wraps io.ReadFull to return io.ErrUnexpectedEOF instead
// of io.EOF when 0 bytes are read. | [
"readFull",
"wraps",
"io",
".",
"ReadFull",
"to",
"return",
"io",
".",
"ErrUnexpectedEOF",
"instead",
"of",
"io",
".",
"EOF",
"when",
"0",
"bytes",
"are",
"read",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/archive.go#L85-L91 | test |
nwaples/rardecode | archive.go | findSig | func findSig(br *bufio.Reader) (int, error) {
for n := 0; n <= maxSfxSize; {
b, err := br.ReadSlice(sigPrefix[0])
n += len(b)
if err == bufio.ErrBufferFull {
continue
} else if err != nil {
if err == io.EOF {
err = errNoSig
}
return 0, err
}
b, err = br.Peek(len(sigPrefix[1:]) + 2)
if er... | go | func findSig(br *bufio.Reader) (int, error) {
for n := 0; n <= maxSfxSize; {
b, err := br.ReadSlice(sigPrefix[0])
n += len(b)
if err == bufio.ErrBufferFull {
continue
} else if err != nil {
if err == io.EOF {
err = errNoSig
}
return 0, err
}
b, err = br.Peek(len(sigPrefix[1:]) + 2)
if er... | [
"func",
"findSig",
"(",
"br",
"*",
"bufio",
".",
"Reader",
")",
"(",
"int",
",",
"error",
")",
"{",
"for",
"n",
":=",
"0",
";",
"n",
"<=",
"maxSfxSize",
";",
"{",
"b",
",",
"err",
":=",
"br",
".",
"ReadSlice",
"(",
"sigPrefix",
"[",
"0",
"]",
... | // findSig searches for the RAR signature and version at the beginning of a file.
// It searches no more than maxSfxSize bytes. | [
"findSig",
"searches",
"for",
"the",
"RAR",
"signature",
"and",
"version",
"at",
"the",
"beginning",
"of",
"a",
"file",
".",
"It",
"searches",
"no",
"more",
"than",
"maxSfxSize",
"bytes",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/archive.go#L95-L134 | test |
nwaples/rardecode | vm.go | execute | func (v *vm) execute(cmd []command) {
v.ip = 0 // reset instruction pointer
for n := 0; n < maxCommands; n++ {
ip := v.ip
if ip >= uint32(len(cmd)) {
return
}
ins := cmd[ip]
ins.f(v, ins.bm, ins.op) // run cpu instruction
if v.ipMod {
// command modified ip, don't increment
v.ipMod = false
} el... | go | func (v *vm) execute(cmd []command) {
v.ip = 0 // reset instruction pointer
for n := 0; n < maxCommands; n++ {
ip := v.ip
if ip >= uint32(len(cmd)) {
return
}
ins := cmd[ip]
ins.f(v, ins.bm, ins.op) // run cpu instruction
if v.ipMod {
// command modified ip, don't increment
v.ipMod = false
} el... | [
"func",
"(",
"v",
"*",
"vm",
")",
"execute",
"(",
"cmd",
"[",
"]",
"command",
")",
"{",
"v",
".",
"ip",
"=",
"0",
"\n",
"for",
"n",
":=",
"0",
";",
"n",
"<",
"maxCommands",
";",
"n",
"++",
"{",
"ip",
":=",
"v",
".",
"ip",
"\n",
"if",
"ip"... | // execute runs a list of commands on the vm. | [
"execute",
"runs",
"a",
"list",
"of",
"commands",
"on",
"the",
"vm",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/vm.go#L39-L55 | test |
nwaples/rardecode | vm.go | newVM | func newVM(mem []byte) *vm {
v := new(vm)
if cap(mem) < vmSize+4 {
v.m = make([]byte, vmSize+4)
copy(v.m, mem)
} else {
v.m = mem[:vmSize+4]
for i := len(mem); i < len(v.m); i++ {
v.m[i] = 0
}
}
v.r[7] = vmSize
return v
} | go | func newVM(mem []byte) *vm {
v := new(vm)
if cap(mem) < vmSize+4 {
v.m = make([]byte, vmSize+4)
copy(v.m, mem)
} else {
v.m = mem[:vmSize+4]
for i := len(mem); i < len(v.m); i++ {
v.m[i] = 0
}
}
v.r[7] = vmSize
return v
} | [
"func",
"newVM",
"(",
"mem",
"[",
"]",
"byte",
")",
"*",
"vm",
"{",
"v",
":=",
"new",
"(",
"vm",
")",
"\n",
"if",
"cap",
"(",
"mem",
")",
"<",
"vmSize",
"+",
"4",
"{",
"v",
".",
"m",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"vmSize",
"+",... | // newVM creates a new RAR virtual machine using the byte slice as memory. | [
"newVM",
"creates",
"a",
"new",
"RAR",
"virtual",
"machine",
"using",
"the",
"byte",
"slice",
"as",
"memory",
"."
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/vm.go#L58-L72 | test |
nwaples/rardecode | bit_reader.go | limitBitReader | func limitBitReader(br bitReader, n int, err error) bitReader {
return &limitedBitReader{br, n, err}
} | go | func limitBitReader(br bitReader, n int, err error) bitReader {
return &limitedBitReader{br, n, err}
} | [
"func",
"limitBitReader",
"(",
"br",
"bitReader",
",",
"n",
"int",
",",
"err",
"error",
")",
"bitReader",
"{",
"return",
"&",
"limitedBitReader",
"{",
"br",
",",
"n",
",",
"err",
"}",
"\n",
"}"
] | // limitBitReader returns a bitReader that reads from br and stops with io.EOF after n bits.
// If br returns an io.EOF before reading n bits, err is returned. | [
"limitBitReader",
"returns",
"a",
"bitReader",
"that",
"reads",
"from",
"br",
"and",
"stops",
"with",
"io",
".",
"EOF",
"after",
"n",
"bits",
".",
"If",
"br",
"returns",
"an",
"io",
".",
"EOF",
"before",
"reading",
"n",
"bits",
"err",
"is",
"returned",
... | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/bit_reader.go#L18-L20 | test |
nwaples/rardecode | bit_reader.go | readUint32 | func (r *rarBitReader) readUint32() (uint32, error) {
n, err := r.readBits(2)
if err != nil {
return 0, err
}
if n != 1 {
n, err = r.readBits(4 << uint(n))
return uint32(n), err
}
n, err = r.readBits(4)
if err != nil {
return 0, err
}
if n == 0 {
n, err = r.readBits(8)
n |= -1 << 8
return uint32(... | go | func (r *rarBitReader) readUint32() (uint32, error) {
n, err := r.readBits(2)
if err != nil {
return 0, err
}
if n != 1 {
n, err = r.readBits(4 << uint(n))
return uint32(n), err
}
n, err = r.readBits(4)
if err != nil {
return 0, err
}
if n == 0 {
n, err = r.readBits(8)
n |= -1 << 8
return uint32(... | [
"func",
"(",
"r",
"*",
"rarBitReader",
")",
"readUint32",
"(",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"r",
".",
"readBits",
"(",
"2",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
... | // readUint32 reads a RAR V3 encoded uint32 | [
"readUint32",
"reads",
"a",
"RAR",
"V3",
"encoded",
"uint32"
] | 197ef08ef68c4454ae5970a9c2692d6056ceb8d7 | https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/bit_reader.go#L77-L98 | test |
kljensen/snowball | russian/step3.go | step3 | func step3(word *snowballword.SnowballWord) bool {
// Search for a DERIVATIONAL ending in R2 (i.e. the entire
// ending must lie in R2), and if one is found, remove it.
suffix, _ := word.RemoveFirstSuffixIn(word.R2start, "ост", "ость")
if suffix != "" {
return true
}
return false
} | go | func step3(word *snowballword.SnowballWord) bool {
// Search for a DERIVATIONAL ending in R2 (i.e. the entire
// ending must lie in R2), and if one is found, remove it.
suffix, _ := word.RemoveFirstSuffixIn(word.R2start, "ост", "ость")
if suffix != "" {
return true
}
return false
} | [
"func",
"step3",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"_",
":=",
"word",
".",
"RemoveFirstSuffixIn",
"(",
"word",
".",
"R2start",
",",
"\"ост\", \"",
"о",
"ть\")",
")",
"\n",
"т",
"\n",
"if",
"suffix",
... | // Step 3 is the removal of the derivational suffix.
// | [
"Step",
"3",
"is",
"the",
"removal",
"of",
"the",
"derivational",
"suffix",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/step3.go#L9-L19 | test |
kljensen/snowball | english/stem.go | Stem | func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))
// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
return word
}
// Return special words immediately
if specialVersion := stemSpecialWord(word); specialV... | go | func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))
// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
return word
}
// Return special words immediately
if specialVersion := stemSpecialWord(word); specialV... | [
"func",
"Stem",
"(",
"word",
"string",
",",
"stemStopwWords",
"bool",
")",
"string",
"{",
"word",
"=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"TrimSpace",
"(",
"word",
")",
")",
"\n",
"if",
"len",
"(",
"word",
")",
"<=",
"2",
"||",
"(",
"s... | // Stem an English word. This is the only exported
// function in this package.
// | [
"Stem",
"an",
"English",
"word",
".",
"This",
"is",
"the",
"only",
"exported",
"function",
"in",
"this",
"package",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/stem.go#L11-L44 | test |
kljensen/snowball | french/step6.go | step6 | func step6(word *snowballword.SnowballWord) bool {
// If the words ends é or è (unicode code points 233 and 232)
// followed by at least one non-vowel, remove the accent from the e.
// Note, this step is oddly articulated on Porter's Snowball website:
// http://snowball.tartarus.org/algorithms/french/stemmer.html... | go | func step6(word *snowballword.SnowballWord) bool {
// If the words ends é or è (unicode code points 233 and 232)
// followed by at least one non-vowel, remove the accent from the e.
// Note, this step is oddly articulated on Porter's Snowball website:
// http://snowball.tartarus.org/algorithms/french/stemmer.html... | [
"func",
"step6",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"numNonVowels",
":=",
"0",
"\n",
"for",
"i",
":=",
"len",
"(",
"word",
".",
"RS",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"r",
":=",
"wor... | // Step 6 Un-accent
// | [
"Step",
"6",
"Un",
"-",
"accent"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/step6.go#L9-L42 | test |
kljensen/snowball | french/step5.go | step5 | func step5(word *snowballword.SnowballWord) bool {
suffix, _ := word.FirstSuffix("enn", "onn", "ett", "ell", "eill")
if suffix != "" {
word.RemoveLastNRunes(1)
}
return false
} | go | func step5(word *snowballword.SnowballWord) bool {
suffix, _ := word.FirstSuffix("enn", "onn", "ett", "ell", "eill")
if suffix != "" {
word.RemoveLastNRunes(1)
}
return false
} | [
"func",
"step5",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"_",
":=",
"word",
".",
"FirstSuffix",
"(",
"\"enn\"",
",",
"\"onn\"",
",",
"\"ett\"",
",",
"\"ell\"",
",",
"\"eill\"",
")",
"\n",
"if",
"suffix",
... | // Step 5 Undouble non-vowel endings
// | [
"Step",
"5",
"Undouble",
"non",
"-",
"vowel",
"endings"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/step5.go#L9-L16 | test |
kljensen/snowball | spanish/step2a.go | step2a | func step2a(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS), "ya", "ye", "yan", "yen", "yeron", "yendo", "yo", "yó", "yas", "yes", "yais", "yamos")
if suffix != "" {
idx := len(word.RS) - len(suffixRunes) - 1
if idx >= 0 && word.RS[idx] == 117 {
word... | go | func step2a(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS), "ya", "ye", "yan", "yen", "yeron", "yendo", "yo", "yó", "yas", "yes", "yais", "yamos")
if suffix != "" {
idx := len(word.RS) - len(suffixRunes) - 1
if idx >= 0 && word.RS[idx] == 117 {
word... | [
"func",
"step2a",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"word",
".",
"FirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\"ya\"",
",",
"\"ye... | // Step 2a is the removal of verb suffixes beginning y,
// Search for the longest among the following suffixes
// in RV, and if found, delete if preceded by u.
// | [
"Step",
"2a",
"is",
"the",
"removal",
"of",
"verb",
"suffixes",
"beginning",
"y",
"Search",
"for",
"the",
"longest",
"among",
"the",
"following",
"suffixes",
"in",
"RV",
"and",
"if",
"found",
"delete",
"if",
"preceded",
"by",
"u",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/spanish/step2a.go#L11-L21 | test |
kljensen/snowball | russian/step4.go | step4 | func step4(word *snowballword.SnowballWord) bool {
// (1) Undouble "н", or, 2) if the word ends with a SUPERLATIVE ending,
// (remove it and undouble н n), or 3) if the word ends ь (') (soft sign)
// remove it.
// Undouble "н"
if word.HasSuffixRunes([]rune("нн")) {
word.RemoveLastNRunes(1)
return true
}
/... | go | func step4(word *snowballword.SnowballWord) bool {
// (1) Undouble "н", or, 2) if the word ends with a SUPERLATIVE ending,
// (remove it and undouble н n), or 3) if the word ends ь (') (soft sign)
// remove it.
// Undouble "н"
if word.HasSuffixRunes([]rune("нн")) {
word.RemoveLastNRunes(1)
return true
}
/... | [
"func",
"step4",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"if",
"word",
".",
"HasSuffixRunes",
"(",
"[",
"]",
"rune",
"(",
"\"нн\"))",
")",
" ",
"{",
"\n",
"{",
"word",
".",
"RemoveLastNRunes",
"(",
"1",
")",
"\n",
"re... | // Step 4 is the undoubling of double non-vowel endings
// and removal of superlative endings.
// | [
"Step",
"4",
"is",
"the",
"undoubling",
"of",
"double",
"non",
"-",
"vowel",
"endings",
"and",
"removal",
"of",
"superlative",
"endings",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/step4.go#L10-L38 | test |
kljensen/snowball | snowball.go | Stem | func Stem(word, language string, stemStopWords bool) (stemmed string, err error) {
var f func(string, bool) string
switch language {
case "english":
f = english.Stem
case "spanish":
f = spanish.Stem
case "french":
f = french.Stem
case "russian":
f = russian.Stem
case "swedish":
f = swedish.Stem
case ... | go | func Stem(word, language string, stemStopWords bool) (stemmed string, err error) {
var f func(string, bool) string
switch language {
case "english":
f = english.Stem
case "spanish":
f = spanish.Stem
case "french":
f = french.Stem
case "russian":
f = russian.Stem
case "swedish":
f = swedish.Stem
case ... | [
"func",
"Stem",
"(",
"word",
",",
"language",
"string",
",",
"stemStopWords",
"bool",
")",
"(",
"stemmed",
"string",
",",
"err",
"error",
")",
"{",
"var",
"f",
"func",
"(",
"string",
",",
"bool",
")",
"string",
"\n",
"switch",
"language",
"{",
"case",
... | // Stem a word in the specified language.
// | [
"Stem",
"a",
"word",
"in",
"the",
"specified",
"language",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowball.go#L20-L43 | test |
kljensen/snowball | english/step1c.go | step1c | func step1c(w *snowballword.SnowballWord) bool {
rsLen := len(w.RS)
// Replace suffix y or Y by i if preceded by a non-vowel which is not
// the first letter of the word (so cry -> cri, by -> by, say -> say)
//
// Note: the unicode code points for
// y, Y, & i are 121, 89, & 105 respectively.
//
if len(w.RS) ... | go | func step1c(w *snowballword.SnowballWord) bool {
rsLen := len(w.RS)
// Replace suffix y or Y by i if preceded by a non-vowel which is not
// the first letter of the word (so cry -> cri, by -> by, say -> say)
//
// Note: the unicode code points for
// y, Y, & i are 121, 89, & 105 respectively.
//
if len(w.RS) ... | [
"func",
"step1c",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"rsLen",
":=",
"len",
"(",
"w",
".",
"RS",
")",
"\n",
"if",
"len",
"(",
"w",
".",
"RS",
")",
">",
"2",
"&&",
"(",
"w",
".",
"RS",
"[",
"rsLen",
"-",
"1",
... | // Step 1c is the normalization of various "y" endings.
// | [
"Step",
"1c",
"is",
"the",
"normalization",
"of",
"various",
"y",
"endings",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step1c.go#L9-L24 | test |
kljensen/snowball | english/step3.go | step3 | func step3(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix(
"ational", "tional", "alize", "icate", "ative",
"iciti", "ical", "ful", "ness",
)
// If it is not in R1, do nothing
if suffix == "" || len(suffixRunes) > len(w.RS)-w.R1start {
return false
}
// Handle special cases wher... | go | func step3(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix(
"ational", "tional", "alize", "icate", "ative",
"iciti", "ical", "ful", "ness",
)
// If it is not in R1, do nothing
if suffix == "" || len(suffixRunes) > len(w.RS)-w.R1start {
return false
}
// Handle special cases wher... | [
"func",
"step3",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"w",
".",
"FirstSuffix",
"(",
"\"ational\"",
",",
"\"tional\"",
",",
"\"alize\"",
",",
"\"icate\"",
",",
"\"ative\"",
",",
"\"iciti\"",... | // Step 3 is the stemming of various longer sufficies
// found in R1.
// | [
"Step",
"3",
"is",
"the",
"stemming",
"of",
"various",
"longer",
"sufficies",
"found",
"in",
"R1",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step3.go#L10-L56 | test |
kljensen/snowball | french/common.go | isStopWord | func isStopWord(word string) bool {
switch word {
case "au", "aux", "avec", "ce", "ces", "dans", "de", "des", "du",
"elle", "en", "et", "eux", "il", "je", "la", "le", "leur",
"lui", "ma", "mais", "me", "même", "mes", "moi", "mon", "ne",
"nos", "notre", "nous", "on", "ou", "par", "pas", "pour", "qu",
"que", "q... | go | func isStopWord(word string) bool {
switch word {
case "au", "aux", "avec", "ce", "ces", "dans", "de", "des", "du",
"elle", "en", "et", "eux", "il", "je", "la", "le", "leur",
"lui", "ma", "mais", "me", "même", "mes", "moi", "mon", "ne",
"nos", "notre", "nous", "on", "ou", "par", "pas", "pour", "qu",
"que", "q... | [
"func",
"isStopWord",
"(",
"word",
"string",
")",
"bool",
"{",
"switch",
"word",
"{",
"case",
"\"au\"",
",",
"\"aux\"",
",",
"\"avec\"",
",",
"\"ce\"",
",",
"\"ces\"",
",",
"\"dans\"",
",",
"\"de\"",
",",
"\"des\"",
",",
"\"du\"",
",",
"\"elle\"",
",",
... | // Return `true` if the input `word` is a French stop word.
// | [
"Return",
"true",
"if",
"the",
"input",
"word",
"is",
"a",
"French",
"stop",
"word",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/common.go#L10-L36 | test |
kljensen/snowball | french/common.go | capitalizeYUI | func capitalizeYUI(word *snowballword.SnowballWord) {
// Keep track of vowels that we see
vowelPreviously := false
// Peak ahead to see if the next rune is a vowel
vowelNext := func(j int) bool {
return (j+1 < len(word.RS) && isLowerVowel(word.RS[j+1]))
}
// Look at all runes
for i := 0; i < len(word.RS); i... | go | func capitalizeYUI(word *snowballword.SnowballWord) {
// Keep track of vowels that we see
vowelPreviously := false
// Peak ahead to see if the next rune is a vowel
vowelNext := func(j int) bool {
return (j+1 < len(word.RS) && isLowerVowel(word.RS[j+1]))
}
// Look at all runes
for i := 0; i < len(word.RS); i... | [
"func",
"capitalizeYUI",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"{",
"vowelPreviously",
":=",
"false",
"\n",
"vowelNext",
":=",
"func",
"(",
"j",
"int",
")",
"bool",
"{",
"return",
"(",
"j",
"+",
"1",
"<",
"len",
"(",
"word",
".",
... | // Capitalize Y, I, and U runes that are acting as consanants.
// Put into upper case "u" or "i" preceded and followed by a
// vowel, and "y" preceded or followed by a vowel. "u" after q is
// also put into upper case.
// | [
"Capitalize",
"Y",
"I",
"and",
"U",
"runes",
"that",
"are",
"acting",
"as",
"consanants",
".",
"Put",
"into",
"upper",
"case",
"u",
"or",
"i",
"preceded",
"and",
"followed",
"by",
"a",
"vowel",
"and",
"y",
"preceded",
"or",
"followed",
"by",
"a",
"vowe... | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/common.go#L57-L105 | test |
kljensen/snowball | english/step2.go | step2 | func step2(w *snowballword.SnowballWord) bool {
// Possible sufficies for this step, longest first.
suffix, suffixRunes := w.FirstSuffix(
"ational", "fulness", "iveness", "ization", "ousness",
"biliti", "lessli", "tional", "alism", "aliti", "ation",
"entli", "fulli", "iviti", "ousli", "anci", "abli",
"alli",... | go | func step2(w *snowballword.SnowballWord) bool {
// Possible sufficies for this step, longest first.
suffix, suffixRunes := w.FirstSuffix(
"ational", "fulness", "iveness", "ization", "ousness",
"biliti", "lessli", "tional", "alism", "aliti", "ation",
"entli", "fulli", "iviti", "ousli", "anci", "abli",
"alli",... | [
"func",
"step2",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"w",
".",
"FirstSuffix",
"(",
"\"ational\"",
",",
"\"fulness\"",
",",
"\"iveness\"",
",",
"\"ization\"",
",",
"\"ousness\"",
",",
"\"bi... | // Step 2 is the stemming of various endings found in
// R1 including "al", "ness", and "li".
// | [
"Step",
"2",
"is",
"the",
"stemming",
"of",
"various",
"endings",
"found",
"in",
"R1",
"including",
"al",
"ness",
"and",
"li",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step2.go#L10-L97 | test |
kljensen/snowball | spanish/step3.go | step3 | func step3(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIfIn(word.RVstart, len(word.RS),
"os", "a", "o", "á", "í", "ó", "e", "é",
)
// No suffix found, nothing to do.
//
if suffix == "" {
return false
}
// Remove all these suffixes
word.RemoveLastNRunes(len(suffixRunes))
... | go | func step3(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIfIn(word.RVstart, len(word.RS),
"os", "a", "o", "á", "í", "ó", "e", "é",
)
// No suffix found, nothing to do.
//
if suffix == "" {
return false
}
// Remove all these suffixes
word.RemoveLastNRunes(len(suffixRunes))
... | [
"func",
"step3",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"word",
".",
"FirstSuffixIfIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\"os\"",
",",
"\"a... | // Step 3 is the removal of residual suffixes.
// | [
"Step",
"3",
"is",
"the",
"removal",
"of",
"residual",
"suffixes",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/spanish/step3.go#L9-L33 | test |
kljensen/snowball | english/step0.go | step0 | func step0(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("'s'", "'s", "'")
if suffix == "" {
return false
}
w.RemoveLastNRunes(len(suffixRunes))
return true
} | go | func step0(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("'s'", "'s", "'")
if suffix == "" {
return false
}
w.RemoveLastNRunes(len(suffixRunes))
return true
} | [
"func",
"step0",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"w",
".",
"FirstSuffix",
"(",
"\"'s'\"",
",",
"\"'s\"",
",",
"\"'\"",
")",
"\n",
"if",
"suffix",
"==",
"\"\"",
"{",
"return",
"fa... | // Step 0 is to strip off apostrophes and "s".
// | [
"Step",
"0",
"is",
"to",
"strip",
"off",
"apostrophes",
"and",
"s",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step0.go#L9-L16 | test |
kljensen/snowball | romance/common.go | VnvSuffix | func VnvSuffix(word *snowballword.SnowballWord, f isVowelFunc, start int) int {
for i := 1; i < len(word.RS[start:]); i++ {
j := start + i
if f(word.RS[j-1]) && !f(word.RS[j]) {
return j + 1
}
}
return len(word.RS)
} | go | func VnvSuffix(word *snowballword.SnowballWord, f isVowelFunc, start int) int {
for i := 1; i < len(word.RS[start:]); i++ {
j := start + i
if f(word.RS[j-1]) && !f(word.RS[j]) {
return j + 1
}
}
return len(word.RS)
} | [
"func",
"VnvSuffix",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
",",
"f",
"isVowelFunc",
",",
"start",
"int",
")",
"int",
"{",
"for",
"i",
":=",
"1",
";",
"i",
"<",
"len",
"(",
"word",
".",
"RS",
"[",
"start",
":",
"]",
")",
";",
"i",... | // Finds the region after the first non-vowel following a vowel,
// or a the null region at the end of the word if there is no
// such non-vowel. Returns the index in the Word where the
// region starts; optionally skips the first `start` characters.
// | [
"Finds",
"the",
"region",
"after",
"the",
"first",
"non",
"-",
"vowel",
"following",
"a",
"vowel",
"or",
"a",
"the",
"null",
"region",
"at",
"the",
"end",
"of",
"the",
"word",
"if",
"there",
"is",
"no",
"such",
"non",
"-",
"vowel",
".",
"Returns",
"t... | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/romance/common.go#L17-L25 | test |
kljensen/snowball | swedish/step1.go | step1 | func step1(w *snowballword.SnowballWord) bool {
// Possible sufficies for this step, longest first.
suffixes := []string{
"heterna", "hetens", "anden", "heten", "heter", "arnas",
"ernas", "ornas", "andes", "arens", "andet", "arna", "erna",
"orna", "ande", "arne", "aste", "aren", "ades", "erns", "ade",
"are",... | go | func step1(w *snowballword.SnowballWord) bool {
// Possible sufficies for this step, longest first.
suffixes := []string{
"heterna", "hetens", "anden", "heten", "heter", "arnas",
"ernas", "ornas", "andes", "arens", "andet", "arna", "erna",
"orna", "ande", "arne", "aste", "aren", "ades", "erns", "ade",
"are",... | [
"func",
"step1",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffixes",
":=",
"[",
"]",
"string",
"{",
"\"heterna\"",
",",
"\"hetens\"",
",",
"\"anden\"",
",",
"\"heten\"",
",",
"\"heter\"",
",",
"\"arnas\"",
",",
"\"ernas\"",
",... | // Step 1 is the stemming of various endings found in
// R1 including "heterna", "ornas", and "andet".
// | [
"Step",
"1",
"is",
"the",
"stemming",
"of",
"various",
"endings",
"found",
"in",
"R1",
"including",
"heterna",
"ornas",
"and",
"andet",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/swedish/step1.go#L10-L48 | test |
kljensen/snowball | french/step2a.go | step2a | func step2a(word *snowballword.SnowballWord) bool {
// Search for the longest among the following suffixes
// in RV and if found, delete if preceded by a non-vowel.
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"issantes", "issaIent", "issions", "issants", "issante",
"iraIent", "issons"... | go | func step2a(word *snowballword.SnowballWord) bool {
// Search for the longest among the following suffixes
// in RV and if found, delete if preceded by a non-vowel.
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"issantes", "issaIent", "issions", "issants", "issante",
"iraIent", "issons"... | [
"func",
"step2a",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"word",
".",
"FirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\"issantes\"",
",",
... | // Step 2a is the removal of Verb suffixes beginning
// with "i" in the RV region.
// | [
"Step",
"2a",
"is",
"the",
"removal",
"of",
"Verb",
"suffixes",
"beginning",
"with",
"i",
"in",
"the",
"RV",
"region",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/step2a.go#L10-L31 | test |
kljensen/snowball | russian/step1.go | removePerfectiveGerundEnding | func removePerfectiveGerundEnding(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"ившись", "ывшись", "вшись", "ивши", "ывши", "вши", "ив", "ыв", "в",
)
switch suffix {
case "в", "вши", "вшись":
// These are "Group 1" perfective gerund endings.
//... | go | func removePerfectiveGerundEnding(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"ившись", "ывшись", "вшись", "ивши", "ывши", "вши", "ив", "ыв", "в",
)
switch suffix {
case "в", "вши", "вшись":
// These are "Group 1" perfective gerund endings.
//... | [
"func",
"removePerfectiveGerundEnding",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"word",
".",
"FirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\... | // Remove perfective gerund endings and return true if one was removed.
// | [
"Remove",
"perfective",
"gerund",
"endings",
"and",
"return",
"true",
"if",
"one",
"was",
"removed",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/step1.go#L60-L80 | test |
kljensen/snowball | russian/step1.go | removeAdjectivalEnding | func removeAdjectivalEnding(word *snowballword.SnowballWord) bool {
// Remove adjectival endings. Start by looking for
// an adjective ending.
//
suffix, _ := word.RemoveFirstSuffixIn(word.RVstart,
"ими", "ыми", "его", "ого", "ему", "ому", "ее", "ие",
"ые", "ое", "ей", "ий", "ый", "ой", "ем", "им", "ым",
"о... | go | func removeAdjectivalEnding(word *snowballword.SnowballWord) bool {
// Remove adjectival endings. Start by looking for
// an adjective ending.
//
suffix, _ := word.RemoveFirstSuffixIn(word.RVstart,
"ими", "ыми", "его", "ого", "ему", "ому", "ее", "ие",
"ые", "ое", "ей", "ий", "ый", "ой", "ем", "им", "ым",
"о... | [
"func",
"removeAdjectivalEnding",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"_",
":=",
"word",
".",
"RemoveFirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"\"ими\", \"",
"ы",
"и\", \"его",
"и",
"о",
"\"",
" \"о... | // Remove adjectival endings and return true if one was removed.
// | [
"Remove",
"adjectival",
"endings",
"and",
"return",
"true",
"if",
"one",
"was",
"removed",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/step1.go#L84-L118 | test |
kljensen/snowball | spanish/step2b.go | step2b | func step2b(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"iésemos", "iéramos", "iríamos", "eríamos", "aríamos", "ásemos",
"áramos", "ábamos", "isteis", "iríais", "iremos", "ieseis",
"ierais", "eríais", "eremos", "asteis", "aríais", "aremos",
"íam... | go | func step2b(word *snowballword.SnowballWord) bool {
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"iésemos", "iéramos", "iríamos", "eríamos", "aríamos", "ásemos",
"áramos", "ábamos", "isteis", "iríais", "iremos", "ieseis",
"ierais", "eríais", "eremos", "asteis", "aríais", "aremos",
"íam... | [
"func",
"step2b",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"word",
".",
"FirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\"iésemos\",",
",",
... | // Step 2b is the removal of verb suffixes beginning y,
// Search for the longest among the following suffixes
// in RV, and if found, delete if preceded by u.
// | [
"Step",
"2b",
"is",
"the",
"removal",
"of",
"verb",
"suffixes",
"beginning",
"y",
"Search",
"for",
"the",
"longest",
"among",
"the",
"following",
"suffixes",
"in",
"RV",
"and",
"if",
"found",
"delete",
"if",
"preceded",
"by",
"u",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/spanish/step2b.go#L11-L46 | test |
kljensen/snowball | french/step4.go | step4 | func step4(word *snowballword.SnowballWord) bool {
hadChange := false
if word.String() == "voudrion" {
log.Println("...", word)
}
// If the word ends s (unicode code point 115),
// not preceded by a, i, o, u, è or s, delete it.
//
if idx := len(word.RS) - 1; idx >= 1 && word.RS[idx] == 115 {
switch word.R... | go | func step4(word *snowballword.SnowballWord) bool {
hadChange := false
if word.String() == "voudrion" {
log.Println("...", word)
}
// If the word ends s (unicode code point 115),
// not preceded by a, i, o, u, è or s, delete it.
//
if idx := len(word.RS) - 1; idx >= 1 && word.RS[idx] == 115 {
switch word.R... | [
"func",
"step4",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"hadChange",
":=",
"false",
"\n",
"if",
"word",
".",
"String",
"(",
")",
"==",
"\"voudrion\"",
"{",
"log",
".",
"Println",
"(",
"\"...\"",
",",
"word",
")",
"\n",... | // Step 4 is the cleaning up of residual suffixes.
// | [
"Step",
"4",
"is",
"the",
"cleaning",
"up",
"of",
"residual",
"suffixes",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/step4.go#L10-L82 | test |
kljensen/snowball | english/step5.go | step5 | func step5(w *snowballword.SnowballWord) bool {
// Last rune index = `lri`
lri := len(w.RS) - 1
// If R1 is emtpy, R2 is also empty, and we
// need not do anything in step 5.
//
if w.R1start > lri {
return false
}
if w.RS[lri] == 101 {
// The word ends with "e", which is unicode code point 101.
// De... | go | func step5(w *snowballword.SnowballWord) bool {
// Last rune index = `lri`
lri := len(w.RS) - 1
// If R1 is emtpy, R2 is also empty, and we
// need not do anything in step 5.
//
if w.R1start > lri {
return false
}
if w.RS[lri] == 101 {
// The word ends with "e", which is unicode code point 101.
// De... | [
"func",
"step5",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"lri",
":=",
"len",
"(",
"w",
".",
"RS",
")",
"-",
"1",
"\n",
"if",
"w",
".",
"R1start",
">",
"lri",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"w",
".",... | // Step 5 is the stemming of "e" and "l" sufficies
// found in R2.
// | [
"Step",
"5",
"is",
"the",
"stemming",
"of",
"e",
"and",
"l",
"sufficies",
"found",
"in",
"R2",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step5.go#L10-L45 | test |
kljensen/snowball | spanish/stem.go | Stem | func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))
// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
return word
}
w := snowballword.New(word)
// Stem the word. Note, each of these
// steps will alter... | go | func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))
// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
return word
}
w := snowballword.New(word)
// Stem the word. Note, each of these
// steps will alter... | [
"func",
"Stem",
"(",
"word",
"string",
",",
"stemStopwWords",
"bool",
")",
"string",
"{",
"word",
"=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"TrimSpace",
"(",
"word",
")",
")",
"\n",
"if",
"len",
"(",
"word",
")",
"<=",
"2",
"||",
"(",
"s... | // Stem an Spanish word. This is the only exported
// function in this package.
// | [
"Stem",
"an",
"Spanish",
"word",
".",
"This",
"is",
"the",
"only",
"exported",
"function",
"in",
"this",
"package",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/spanish/stem.go#L18-L47 | test |
kljensen/snowball | russian/stem.go | Stem | func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))
w := snowballword.New(word)
// Return small words and stop words
if len(w.RS) <= 2 || (stemStopwWords == false && isStopWord(word)) {
return word
}
preprocess(w)
step1(w)
step2(w)
step3(w)
step4(w)
retur... | go | func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))
w := snowballword.New(word)
// Return small words and stop words
if len(w.RS) <= 2 || (stemStopwWords == false && isStopWord(word)) {
return word
}
preprocess(w)
step1(w)
step2(w)
step3(w)
step4(w)
retur... | [
"func",
"Stem",
"(",
"word",
"string",
",",
"stemStopwWords",
"bool",
")",
"string",
"{",
"word",
"=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"TrimSpace",
"(",
"word",
")",
")",
"\n",
"w",
":=",
"snowballword",
".",
"New",
"(",
"word",
")",
... | // Stem an Russian word. This is the only exported
// function in this package.
// | [
"Stem",
"an",
"Russian",
"word",
".",
"This",
"is",
"the",
"only",
"exported",
"function",
"in",
"this",
"package",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/stem.go#L11-L28 | test |
kljensen/snowball | norwegian/common.go | isStopWord | func isStopWord(word string) bool {
switch word {
case "ut", "få", "hadde", "hva", "tilbake", "vil", "han", "meget", "men", "vi", "en", "før",
"samme", "stille", "inn", "er", "kan", "makt", "ved", "forsøke", "hvis", "part", "rett",
"måte", "denne", "mer", "i", "lang", "ny", "hans", "hvilken", "tid", "vite", "her"... | go | func isStopWord(word string) bool {
switch word {
case "ut", "få", "hadde", "hva", "tilbake", "vil", "han", "meget", "men", "vi", "en", "før",
"samme", "stille", "inn", "er", "kan", "makt", "ved", "forsøke", "hvis", "part", "rett",
"måte", "denne", "mer", "i", "lang", "ny", "hans", "hvilken", "tid", "vite", "her"... | [
"func",
"isStopWord",
"(",
"word",
"string",
")",
"bool",
"{",
"switch",
"word",
"{",
"case",
"\"ut\"",
",",
"\"få\",",
",",
" ",
"hadde\",",
"h",
",",
" ",
"hva\",",
"h",
",",
" ",
"tilbake\",",
"t",
",",
" ",
"vil\",",
"v",
",",
" ",
"han\",",
"h... | // Return `true` if the input `word` is a Norwegian stop word.
// | [
"Return",
"true",
"if",
"the",
"input",
"word",
"is",
"a",
"Norwegian",
"stop",
"word",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/norwegian/common.go#L37-L52 | test |
kljensen/snowball | swedish/common.go | isStopWord | func isStopWord(word string) bool {
switch word {
case "och", "det", "att", "i", "en", "jag", "hon", "som", "han",
"på", "den", "med", "var", "sig", "för", "så", "till", "är", "men",
"ett", "om", "hade", "de", "av", "icke", "mig", "du", "henne", "då",
"sin", "nu", "har", "inte", "hans", "honom", "skulle", "henn... | go | func isStopWord(word string) bool {
switch word {
case "och", "det", "att", "i", "en", "jag", "hon", "som", "han",
"på", "den", "med", "var", "sig", "för", "så", "till", "är", "men",
"ett", "om", "hade", "de", "av", "icke", "mig", "du", "henne", "då",
"sin", "nu", "har", "inte", "hans", "honom", "skulle", "henn... | [
"func",
"isStopWord",
"(",
"word",
"string",
")",
"bool",
"{",
"switch",
"word",
"{",
"case",
"\"och\"",
",",
"\"det\"",
",",
"\"att\"",
",",
"\"i\"",
",",
"\"en\"",
",",
"\"jag\"",
",",
"\"hon\"",
",",
"\"som\"",
",",
"\"han\"",
",",
"\"på\",",
",",
"... | // Return `true` if the input `word` is a Swedish stop word.
// | [
"Return",
"true",
"if",
"the",
"input",
"word",
"is",
"a",
"Swedish",
"stop",
"word",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/swedish/common.go#L37-L56 | test |
kljensen/snowball | snowballword/snowballword.go | New | func New(in string) (word *SnowballWord) {
word = &SnowballWord{RS: []rune(in)}
word.R1start = len(word.RS)
word.R2start = len(word.RS)
word.RVstart = len(word.RS)
return
} | go | func New(in string) (word *SnowballWord) {
word = &SnowballWord{RS: []rune(in)}
word.R1start = len(word.RS)
word.R2start = len(word.RS)
word.RVstart = len(word.RS)
return
} | [
"func",
"New",
"(",
"in",
"string",
")",
"(",
"word",
"*",
"SnowballWord",
")",
"{",
"word",
"=",
"&",
"SnowballWord",
"{",
"RS",
":",
"[",
"]",
"rune",
"(",
"in",
")",
"}",
"\n",
"word",
".",
"R1start",
"=",
"len",
"(",
"word",
".",
"RS",
")",... | // Create a new SnowballWord struct | [
"Create",
"a",
"new",
"SnowballWord",
"struct"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L31-L37 | test |
kljensen/snowball | snowballword/snowballword.go | RemoveLastNRunes | func (w *SnowballWord) RemoveLastNRunes(n int) {
w.RS = w.RS[:len(w.RS)-n]
w.resetR1R2()
} | go | func (w *SnowballWord) RemoveLastNRunes(n int) {
w.RS = w.RS[:len(w.RS)-n]
w.resetR1R2()
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"RemoveLastNRunes",
"(",
"n",
"int",
")",
"{",
"w",
".",
"RS",
"=",
"w",
".",
"RS",
"[",
":",
"len",
"(",
"w",
".",
"RS",
")",
"-",
"n",
"]",
"\n",
"w",
".",
"resetR1R2",
"(",
")",
"\n",
"}"
] | // Remove the last `n` runes from the SnowballWord.
// | [
"Remove",
"the",
"last",
"n",
"runes",
"from",
"the",
"SnowballWord",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L67-L70 | test |
kljensen/snowball | snowballword/snowballword.go | resetR1R2 | func (w *SnowballWord) resetR1R2() {
rsLen := len(w.RS)
if w.R1start > rsLen {
w.R1start = rsLen
}
if w.R2start > rsLen {
w.R2start = rsLen
}
if w.RVstart > rsLen {
w.RVstart = rsLen
}
} | go | func (w *SnowballWord) resetR1R2() {
rsLen := len(w.RS)
if w.R1start > rsLen {
w.R1start = rsLen
}
if w.R2start > rsLen {
w.R2start = rsLen
}
if w.RVstart > rsLen {
w.RVstart = rsLen
}
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"resetR1R2",
"(",
")",
"{",
"rsLen",
":=",
"len",
"(",
"w",
".",
"RS",
")",
"\n",
"if",
"w",
".",
"R1start",
">",
"rsLen",
"{",
"w",
".",
"R1start",
"=",
"rsLen",
"\n",
"}",
"\n",
"if",
"w",
".",
"R... | // Resets R1start and R2start to ensure they
// are within bounds of the current rune slice. | [
"Resets",
"R1start",
"and",
"R2start",
"to",
"ensure",
"they",
"are",
"within",
"bounds",
"of",
"the",
"current",
"rune",
"slice",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L93-L104 | test |
kljensen/snowball | snowballword/snowballword.go | slice | func (w *SnowballWord) slice(start, stop int) []rune {
startMin := 0
if start < startMin {
start = startMin
}
max := len(w.RS) - 1
if start > max {
start = max
}
if stop > max {
stop = max
}
return w.RS[start:stop]
} | go | func (w *SnowballWord) slice(start, stop int) []rune {
startMin := 0
if start < startMin {
start = startMin
}
max := len(w.RS) - 1
if start > max {
start = max
}
if stop > max {
stop = max
}
return w.RS[start:stop]
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"slice",
"(",
"start",
",",
"stop",
"int",
")",
"[",
"]",
"rune",
"{",
"startMin",
":=",
"0",
"\n",
"if",
"start",
"<",
"startMin",
"{",
"start",
"=",
"startMin",
"\n",
"}",
"\n",
"max",
":=",
"len",
"(... | // Return a slice of w.RS, allowing the start
// and stop to be out of bounds.
// | [
"Return",
"a",
"slice",
"of",
"w",
".",
"RS",
"allowing",
"the",
"start",
"and",
"stop",
"to",
"be",
"out",
"of",
"bounds",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L109-L122 | test |
kljensen/snowball | snowballword/snowballword.go | FitsInR1 | func (w *SnowballWord) FitsInR1(x int) bool {
return w.R1start <= len(w.RS)-x
} | go | func (w *SnowballWord) FitsInR1(x int) bool {
return w.R1start <= len(w.RS)-x
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"FitsInR1",
"(",
"x",
"int",
")",
"bool",
"{",
"return",
"w",
".",
"R1start",
"<=",
"len",
"(",
"w",
".",
"RS",
")",
"-",
"x",
"\n",
"}"
] | // Returns true if `x` runes would fit into R1.
// | [
"Returns",
"true",
"if",
"x",
"runes",
"would",
"fit",
"into",
"R1",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L126-L128 | test |
kljensen/snowball | snowballword/snowballword.go | FitsInR2 | func (w *SnowballWord) FitsInR2(x int) bool {
return w.R2start <= len(w.RS)-x
} | go | func (w *SnowballWord) FitsInR2(x int) bool {
return w.R2start <= len(w.RS)-x
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"FitsInR2",
"(",
"x",
"int",
")",
"bool",
"{",
"return",
"w",
".",
"R2start",
"<=",
"len",
"(",
"w",
".",
"RS",
")",
"-",
"x",
"\n",
"}"
] | // Returns true if `x` runes would fit into R2.
// | [
"Returns",
"true",
"if",
"x",
"runes",
"would",
"fit",
"into",
"R2",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L132-L134 | test |
kljensen/snowball | snowballword/snowballword.go | FitsInRV | func (w *SnowballWord) FitsInRV(x int) bool {
return w.RVstart <= len(w.RS)-x
} | go | func (w *SnowballWord) FitsInRV(x int) bool {
return w.RVstart <= len(w.RS)-x
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"FitsInRV",
"(",
"x",
"int",
")",
"bool",
"{",
"return",
"w",
".",
"RVstart",
"<=",
"len",
"(",
"w",
".",
"RS",
")",
"-",
"x",
"\n",
"}"
] | // Returns true if `x` runes would fit into RV.
// | [
"Returns",
"true",
"if",
"x",
"runes",
"would",
"fit",
"into",
"RV",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L138-L140 | test |
kljensen/snowball | snowballword/snowballword.go | FirstPrefix | func (w *SnowballWord) FirstPrefix(prefixes ...string) (foundPrefix string, foundPrefixRunes []rune) {
found := false
rsLen := len(w.RS)
for _, prefix := range prefixes {
prefixRunes := []rune(prefix)
if len(prefixRunes) > rsLen {
continue
}
found = true
for i, r := range prefixRunes {
if i > rsLen... | go | func (w *SnowballWord) FirstPrefix(prefixes ...string) (foundPrefix string, foundPrefixRunes []rune) {
found := false
rsLen := len(w.RS)
for _, prefix := range prefixes {
prefixRunes := []rune(prefix)
if len(prefixRunes) > rsLen {
continue
}
found = true
for i, r := range prefixRunes {
if i > rsLen... | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"FirstPrefix",
"(",
"prefixes",
"...",
"string",
")",
"(",
"foundPrefix",
"string",
",",
"foundPrefixRunes",
"[",
"]",
"rune",
")",
"{",
"found",
":=",
"false",
"\n",
"rsLen",
":=",
"len",
"(",
"w",
".",
"RS"... | // Return the first prefix found or the empty string. | [
"Return",
"the",
"first",
"prefix",
"found",
"or",
"the",
"empty",
"string",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L182-L206 | test |
kljensen/snowball | snowballword/snowballword.go | HasSuffixRunes | func (w *SnowballWord) HasSuffixRunes(suffixRunes []rune) bool {
return w.HasSuffixRunesIn(0, len(w.RS), suffixRunes)
} | go | func (w *SnowballWord) HasSuffixRunes(suffixRunes []rune) bool {
return w.HasSuffixRunesIn(0, len(w.RS), suffixRunes)
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"HasSuffixRunes",
"(",
"suffixRunes",
"[",
"]",
"rune",
")",
"bool",
"{",
"return",
"w",
".",
"HasSuffixRunesIn",
"(",
"0",
",",
"len",
"(",
"w",
".",
"RS",
")",
",",
"suffixRunes",
")",
"\n",
"}"
] | // Return true if `w` ends with `suffixRunes`
// | [
"Return",
"true",
"if",
"w",
"ends",
"with",
"suffixRunes"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L235-L237 | test |
kljensen/snowball | snowballword/snowballword.go | FirstSuffixIfIn | func (w *SnowballWord) FirstSuffixIfIn(startPos, endPos int, suffixes ...string) (suffix string, suffixRunes []rune) {
for _, suffix := range suffixes {
suffixRunes := []rune(suffix)
if w.HasSuffixRunesIn(0, endPos, suffixRunes) {
if endPos-len(suffixRunes) >= startPos {
return suffix, suffixRunes
} else... | go | func (w *SnowballWord) FirstSuffixIfIn(startPos, endPos int, suffixes ...string) (suffix string, suffixRunes []rune) {
for _, suffix := range suffixes {
suffixRunes := []rune(suffix)
if w.HasSuffixRunesIn(0, endPos, suffixRunes) {
if endPos-len(suffixRunes) >= startPos {
return suffix, suffixRunes
} else... | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"FirstSuffixIfIn",
"(",
"startPos",
",",
"endPos",
"int",
",",
"suffixes",
"...",
"string",
")",
"(",
"suffix",
"string",
",",
"suffixRunes",
"[",
"]",
"rune",
")",
"{",
"for",
"_",
",",
"suffix",
":=",
"rang... | // Find the first suffix that ends at `endPos` in the word among
// those provided; then,
// check to see if it begins after startPos. If it does, return
// it, else return the empty string and empty rune slice. This
// may seem a counterintuitive manner to do this. However, it
// matches what is required most of th... | [
"Find",
"the",
"first",
"suffix",
"that",
"ends",
"at",
"endPos",
"in",
"the",
"word",
"among",
"those",
"provided",
";",
"then",
"check",
"to",
"see",
"if",
"it",
"begins",
"after",
"startPos",
".",
"If",
"it",
"does",
"return",
"it",
"else",
"return",
... | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L247-L264 | test |
kljensen/snowball | snowballword/snowballword.go | RemoveFirstSuffixIfIn | func (w *SnowballWord) RemoveFirstSuffixIfIn(startPos int, suffixes ...string) (suffix string, suffixRunes []rune) {
suffix, suffixRunes = w.FirstSuffixIfIn(startPos, len(w.RS), suffixes...)
if suffix != "" {
w.RemoveLastNRunes(len(suffixRunes))
}
return
} | go | func (w *SnowballWord) RemoveFirstSuffixIfIn(startPos int, suffixes ...string) (suffix string, suffixRunes []rune) {
suffix, suffixRunes = w.FirstSuffixIfIn(startPos, len(w.RS), suffixes...)
if suffix != "" {
w.RemoveLastNRunes(len(suffixRunes))
}
return
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"RemoveFirstSuffixIfIn",
"(",
"startPos",
"int",
",",
"suffixes",
"...",
"string",
")",
"(",
"suffix",
"string",
",",
"suffixRunes",
"[",
"]",
"rune",
")",
"{",
"suffix",
",",
"suffixRunes",
"=",
"w",
".",
"Fir... | // Find the first suffix in the word among those provided; then,
// check to see if it begins after startPos. If it does,
// remove it.
// | [
"Find",
"the",
"first",
"suffix",
"in",
"the",
"word",
"among",
"those",
"provided",
";",
"then",
"check",
"to",
"see",
"if",
"it",
"begins",
"after",
"startPos",
".",
"If",
"it",
"does",
"remove",
"it",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L283-L289 | test |
kljensen/snowball | snowballword/snowballword.go | RemoveFirstSuffix | func (w *SnowballWord) RemoveFirstSuffix(suffixes ...string) (suffix string, suffixRunes []rune) {
return w.RemoveFirstSuffixIn(0, suffixes...)
} | go | func (w *SnowballWord) RemoveFirstSuffix(suffixes ...string) (suffix string, suffixRunes []rune) {
return w.RemoveFirstSuffixIn(0, suffixes...)
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"RemoveFirstSuffix",
"(",
"suffixes",
"...",
"string",
")",
"(",
"suffix",
"string",
",",
"suffixRunes",
"[",
"]",
"rune",
")",
"{",
"return",
"w",
".",
"RemoveFirstSuffixIn",
"(",
"0",
",",
"suffixes",
"...",
... | // Removes the first suffix found | [
"Removes",
"the",
"first",
"suffix",
"found"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L301-L303 | test |
kljensen/snowball | snowballword/snowballword.go | FirstSuffix | func (w *SnowballWord) FirstSuffix(suffixes ...string) (suffix string, suffixRunes []rune) {
return w.FirstSuffixIfIn(0, len(w.RS), suffixes...)
} | go | func (w *SnowballWord) FirstSuffix(suffixes ...string) (suffix string, suffixRunes []rune) {
return w.FirstSuffixIfIn(0, len(w.RS), suffixes...)
} | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"FirstSuffix",
"(",
"suffixes",
"...",
"string",
")",
"(",
"suffix",
"string",
",",
"suffixRunes",
"[",
"]",
"rune",
")",
"{",
"return",
"w",
".",
"FirstSuffixIfIn",
"(",
"0",
",",
"len",
"(",
"w",
".",
"RS... | // Return the first suffix found or the empty string. | [
"Return",
"the",
"first",
"suffix",
"found",
"or",
"the",
"empty",
"string",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L306-L308 | test |
kljensen/snowball | english/preprocess.go | preprocess | func preprocess(word *snowballword.SnowballWord) {
// Clean up apostrophes
normalizeApostrophes(word)
trimLeftApostrophes(word)
// Capitalize Y's that are not behaving
// as vowels.
capitalizeYs(word)
// Find the two regions, R1 & R2
r1start, r2start := r1r2(word)
word.R1start = r1start
word.R2start = r2st... | go | func preprocess(word *snowballword.SnowballWord) {
// Clean up apostrophes
normalizeApostrophes(word)
trimLeftApostrophes(word)
// Capitalize Y's that are not behaving
// as vowels.
capitalizeYs(word)
// Find the two regions, R1 & R2
r1start, r2start := r1r2(word)
word.R1start = r1start
word.R2start = r2st... | [
"func",
"preprocess",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"{",
"normalizeApostrophes",
"(",
"word",
")",
"\n",
"trimLeftApostrophes",
"(",
"word",
")",
"\n",
"capitalizeYs",
"(",
"word",
")",
"\n",
"r1start",
",",
"r2start",
":=",
"r1... | // Applies various transformations necessary for the
// other, subsequent stemming steps. Most important
// of which is defining the two regions R1 & R2.
// | [
"Applies",
"various",
"transformations",
"necessary",
"for",
"the",
"other",
"subsequent",
"stemming",
"steps",
".",
"Most",
"important",
"of",
"which",
"is",
"defining",
"the",
"two",
"regions",
"R1",
"&",
"R2",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/preprocess.go#L11-L25 | test |
kljensen/snowball | spanish/step0.go | step0 | func step0(word *snowballword.SnowballWord) bool {
// Search for the longest among the following suffixes
suffix1, suffix1Runes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"selas", "selos", "sela", "selo", "las", "les",
"los", "nos", "me", "se", "la", "le", "lo",
)
// If the suffix empty or not in RV, w... | go | func step0(word *snowballword.SnowballWord) bool {
// Search for the longest among the following suffixes
suffix1, suffix1Runes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"selas", "selos", "sela", "selo", "las", "les",
"los", "nos", "me", "se", "la", "le", "lo",
)
// If the suffix empty or not in RV, w... | [
"func",
"step0",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix1",
",",
"suffix1Runes",
":=",
"word",
".",
"FirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\"selas\"",
",",
"... | // Step 0 is the removal of attached pronouns
// | [
"Step",
"0",
"is",
"the",
"removal",
"of",
"attached",
"pronouns"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/spanish/step0.go#L9-L74 | test |
kljensen/snowball | english/step1b.go | step1b | func step1b(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("eedly", "ingly", "edly", "ing", "eed", "ed")
switch suffix {
case "":
// No suffix found
return false
case "eed", "eedly":
// Replace by ee if in R1
if len(suffixRunes) <= len(w.RS)-w.R1start {
w.ReplaceSuffixRune... | go | func step1b(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("eedly", "ingly", "edly", "ing", "eed", "ed")
switch suffix {
case "":
// No suffix found
return false
case "eed", "eedly":
// Replace by ee if in R1
if len(suffixRunes) <= len(w.RS)-w.R1start {
w.ReplaceSuffixRune... | [
"func",
"step1b",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"w",
".",
"FirstSuffix",
"(",
"\"eedly\"",
",",
"\"ingly\"",
",",
"\"edly\"",
",",
"\"ing\"",
",",
"\"eed\"",
",",
"\"ed\"",
")",
... | // Step 1b is the normalization of various "ly" and "ed" sufficies.
// | [
"Step",
"1b",
"is",
"the",
"normalization",
"of",
"various",
"ly",
"and",
"ed",
"sufficies",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step1b.go#L9-L104 | test |
kljensen/snowball | french/step2b.go | step2b | func step2b(word *snowballword.SnowballWord) bool {
// Search for the longest among the following suffixes in RV.
//
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"eraIent", "assions", "erions", "assiez", "assent",
"èrent", "eront", "erons", "eriez", "erait", "erais",
"asses", "antes",... | go | func step2b(word *snowballword.SnowballWord) bool {
// Search for the longest among the following suffixes in RV.
//
suffix, suffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS),
"eraIent", "assions", "erions", "assiez", "assent",
"èrent", "eront", "erons", "eriez", "erait", "erais",
"asses", "antes",... | [
"func",
"step2b",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"word",
".",
"FirstSuffixIn",
"(",
"word",
".",
"RVstart",
",",
"len",
"(",
"word",
".",
"RS",
")",
",",
"\"eraIent\"",
",",
... | // Step 2b is the removal of Verb suffixes in RV
// that do not begin with "i".
// | [
"Step",
"2b",
"is",
"the",
"removal",
"of",
"Verb",
"suffixes",
"in",
"RV",
"that",
"do",
"not",
"begin",
"with",
"i",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/french/step2b.go#L10-L59 | test |
kljensen/snowball | english/common.go | capitalizeYs | func capitalizeYs(word *snowballword.SnowballWord) (numCapitalizations int) {
for i, r := range word.RS {
// (Note: Y & y unicode code points = 89 & 121)
if r == 121 && (i == 0 || isLowerVowel(word.RS[i-1])) {
word.RS[i] = 89
numCapitalizations += 1
}
}
return
} | go | func capitalizeYs(word *snowballword.SnowballWord) (numCapitalizations int) {
for i, r := range word.RS {
// (Note: Y & y unicode code points = 89 & 121)
if r == 121 && (i == 0 || isLowerVowel(word.RS[i-1])) {
word.RS[i] = 89
numCapitalizations += 1
}
}
return
} | [
"func",
"capitalizeYs",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"(",
"numCapitalizations",
"int",
")",
"{",
"for",
"i",
",",
"r",
":=",
"range",
"word",
".",
"RS",
"{",
"if",
"r",
"==",
"121",
"&&",
"(",
"i",
"==",
"0",
"||",
"i... | // Capitalize all 'Y's preceded by vowels or starting a word
// | [
"Capitalize",
"all",
"Y",
"s",
"preceded",
"by",
"vowels",
"or",
"starting",
"a",
"word"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/common.go#L53-L64 | test |
kljensen/snowball | english/common.go | uncapitalizeYs | func uncapitalizeYs(word *snowballword.SnowballWord) {
for i, r := range word.RS {
// (Note: Y & y unicode code points = 89 & 121)
if r == 89 {
word.RS[i] = 121
}
}
return
} | go | func uncapitalizeYs(word *snowballword.SnowballWord) {
for i, r := range word.RS {
// (Note: Y & y unicode code points = 89 & 121)
if r == 89 {
word.RS[i] = 121
}
}
return
} | [
"func",
"uncapitalizeYs",
"(",
"word",
"*",
"snowballword",
".",
"SnowballWord",
")",
"{",
"for",
"i",
",",
"r",
":=",
"range",
"word",
".",
"RS",
"{",
"if",
"r",
"==",
"89",
"{",
"word",
".",
"RS",
"[",
"i",
"]",
"=",
"121",
"\n",
"}",
"\n",
"... | // Uncapitalize all 'Y's
// | [
"Uncapitalize",
"all",
"Y",
"s"
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/common.go#L68-L78 | test |
kljensen/snowball | english/common.go | stemSpecialWord | func stemSpecialWord(word string) (stemmed string) {
switch word {
case "skis":
stemmed = "ski"
case "skies":
stemmed = "sky"
case "dying":
stemmed = "die"
case "lying":
stemmed = "lie"
case "tying":
stemmed = "tie"
case "idly":
stemmed = "idl"
case "gently":
stemmed = "gentl"
case "ugly":
stem... | go | func stemSpecialWord(word string) (stemmed string) {
switch word {
case "skis":
stemmed = "ski"
case "skies":
stemmed = "sky"
case "dying":
stemmed = "die"
case "lying":
stemmed = "lie"
case "tying":
stemmed = "tie"
case "idly":
stemmed = "idl"
case "gently":
stemmed = "gentl"
case "ugly":
stem... | [
"func",
"stemSpecialWord",
"(",
"word",
"string",
")",
"(",
"stemmed",
"string",
")",
"{",
"switch",
"word",
"{",
"case",
"\"skis\"",
":",
"stemmed",
"=",
"\"ski\"",
"\n",
"case",
"\"skies\"",
":",
"stemmed",
"=",
"\"sky\"",
"\n",
"case",
"\"dying\"",
":",... | // Returns the stemmed version of a word if it is a special
// case, otherwise returns the empty string.
// | [
"Returns",
"the",
"stemmed",
"version",
"of",
"a",
"word",
"if",
"it",
"is",
"a",
"special",
"case",
"otherwise",
"returns",
"the",
"empty",
"string",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/common.go#L118-L202 | test |
kljensen/snowball | english/common.go | isShortWord | func isShortWord(w *snowballword.SnowballWord) (isShort bool) {
// If r1 is not empty, the word is not short
if w.R1start < len(w.RS) {
return
}
// Otherwise it must end in a short syllable
return endsShortSyllable(w, len(w.RS))
} | go | func isShortWord(w *snowballword.SnowballWord) (isShort bool) {
// If r1 is not empty, the word is not short
if w.R1start < len(w.RS) {
return
}
// Otherwise it must end in a short syllable
return endsShortSyllable(w, len(w.RS))
} | [
"func",
"isShortWord",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"(",
"isShort",
"bool",
")",
"{",
"if",
"w",
".",
"R1start",
"<",
"len",
"(",
"w",
".",
"RS",
")",
"{",
"return",
"\n",
"}",
"\n",
"return",
"endsShortSyllable",
"(",
"w"... | // A word is called short if it ends in a short syllable, and if R1 is null.
// | [
"A",
"word",
"is",
"called",
"short",
"if",
"it",
"ends",
"in",
"a",
"short",
"syllable",
"and",
"if",
"R1",
"is",
"null",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/common.go#L230-L239 | test |
kljensen/snowball | english/step1a.go | step1a | func step1a(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("sses", "ied", "ies", "us", "ss", "s")
switch suffix {
case "sses":
// Replace by ss
w.ReplaceSuffixRunes(suffixRunes, []rune("ss"), true)
return true
case "ies", "ied":
// Replace by i if preceded by more than one le... | go | func step1a(w *snowballword.SnowballWord) bool {
suffix, suffixRunes := w.FirstSuffix("sses", "ied", "ies", "us", "ss", "s")
switch suffix {
case "sses":
// Replace by ss
w.ReplaceSuffixRunes(suffixRunes, []rune("ss"), true)
return true
case "ies", "ied":
// Replace by i if preceded by more than one le... | [
"func",
"step1a",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"suffix",
",",
"suffixRunes",
":=",
"w",
".",
"FirstSuffix",
"(",
"\"sses\"",
",",
"\"ied\"",
",",
"\"ies\"",
",",
"\"us\"",
",",
"\"ss\"",
",",
"\"s\"",
")",
"\n",
... | // Step 1a is normalization of various special "s"-endings.
// | [
"Step",
"1a",
"is",
"normalization",
"of",
"various",
"special",
"s",
"-",
"endings",
"."
] | 115fa8f6419dcfb9ec4653997b1c6803a5eff962 | https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/step1a.go#L9-L53 | test |
tylerb/gls | gls.go | Set | func Set(key string, value interface{}) {
gid := curGoroutineID()
dataLock.Lock()
if data[gid] == nil {
data[gid] = Values{}
}
data[gid][key] = value
dataLock.Unlock()
} | go | func Set(key string, value interface{}) {
gid := curGoroutineID()
dataLock.Lock()
if data[gid] == nil {
data[gid] = Values{}
}
data[gid][key] = value
dataLock.Unlock()
} | [
"func",
"Set",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"gid",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"data",
"[",
"gid",
"]",
"==",
"nil",
"{",
"data",
"[",
"gid",
"]",
... | // Set sets the value by key and associates it with the current goroutine. | [
"Set",
"sets",
"the",
"value",
"by",
"key",
"and",
"associates",
"it",
"with",
"the",
"current",
"goroutine",
"."
] | e606233f194d6c314156dc6a35f21a42a470c6f6 | https://github.com/tylerb/gls/blob/e606233f194d6c314156dc6a35f21a42a470c6f6/gls.go#L39-L47 | test |
tylerb/gls | gls.go | Get | func Get(key string) interface{} {
gid := curGoroutineID()
dataLock.RLock()
if data[gid] == nil {
dataLock.RUnlock()
return nil
}
value := data[gid][key]
dataLock.RUnlock()
return value
} | go | func Get(key string) interface{} {
gid := curGoroutineID()
dataLock.RLock()
if data[gid] == nil {
dataLock.RUnlock()
return nil
}
value := data[gid][key]
dataLock.RUnlock()
return value
} | [
"func",
"Get",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"gid",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"RLock",
"(",
")",
"\n",
"if",
"data",
"[",
"gid",
"]",
"==",
"nil",
"{",
"dataLock",
".",
"RUnlock",
"(",
")",
... | // Get gets the value by key as it exists for the current goroutine. | [
"Get",
"gets",
"the",
"value",
"by",
"key",
"as",
"it",
"exists",
"for",
"the",
"current",
"goroutine",
"."
] | e606233f194d6c314156dc6a35f21a42a470c6f6 | https://github.com/tylerb/gls/blob/e606233f194d6c314156dc6a35f21a42a470c6f6/gls.go#L50-L60 | test |
tylerb/gls | gls.go | Cleanup | func Cleanup() {
gid := curGoroutineID()
dataLock.Lock()
delete(data, gid)
dataLock.Unlock()
} | go | func Cleanup() {
gid := curGoroutineID()
dataLock.Lock()
delete(data, gid)
dataLock.Unlock()
} | [
"func",
"Cleanup",
"(",
")",
"{",
"gid",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"data",
",",
"gid",
")",
"\n",
"dataLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Cleanup removes all data associated with this goroutine. If this is not
// called, the data may persist for the lifetime of your application. This
// must be called from the very first goroutine to invoke Set | [
"Cleanup",
"removes",
"all",
"data",
"associated",
"with",
"this",
"goroutine",
".",
"If",
"this",
"is",
"not",
"called",
"the",
"data",
"may",
"persist",
"for",
"the",
"lifetime",
"of",
"your",
"application",
".",
"This",
"must",
"be",
"called",
"from",
"... | e606233f194d6c314156dc6a35f21a42a470c6f6 | https://github.com/tylerb/gls/blob/e606233f194d6c314156dc6a35f21a42a470c6f6/gls.go#L80-L85 | test |
tylerb/gls | gls.go | getValues | func getValues() Values {
gid := curGoroutineID()
dataLock.Lock()
values := data[gid]
dataLock.Unlock()
return values
} | go | func getValues() Values {
gid := curGoroutineID()
dataLock.Lock()
values := data[gid]
dataLock.Unlock()
return values
} | [
"func",
"getValues",
"(",
")",
"Values",
"{",
"gid",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"values",
":=",
"data",
"[",
"gid",
"]",
"\n",
"dataLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"values",
"\n",
... | // getValues unlinks two goroutines | [
"getValues",
"unlinks",
"two",
"goroutines"
] | e606233f194d6c314156dc6a35f21a42a470c6f6 | https://github.com/tylerb/gls/blob/e606233f194d6c314156dc6a35f21a42a470c6f6/gls.go#L88-L94 | test |
tylerb/gls | gls.go | linkGRs | func linkGRs(parentData Values) {
childID := curGoroutineID()
dataLock.Lock()
data[childID] = parentData
dataLock.Unlock()
} | go | func linkGRs(parentData Values) {
childID := curGoroutineID()
dataLock.Lock()
data[childID] = parentData
dataLock.Unlock()
} | [
"func",
"linkGRs",
"(",
"parentData",
"Values",
")",
"{",
"childID",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"data",
"[",
"childID",
"]",
"=",
"parentData",
"\n",
"dataLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // linkGRs links two goroutines together, allowing the child to access the
// data present in the parent. | [
"linkGRs",
"links",
"two",
"goroutines",
"together",
"allowing",
"the",
"child",
"to",
"access",
"the",
"data",
"present",
"in",
"the",
"parent",
"."
] | e606233f194d6c314156dc6a35f21a42a470c6f6 | https://github.com/tylerb/gls/blob/e606233f194d6c314156dc6a35f21a42a470c6f6/gls.go#L98-L103 | test |
tylerb/gls | gls.go | unlinkGRs | func unlinkGRs() {
childID := curGoroutineID()
dataLock.Lock()
delete(data, childID)
dataLock.Unlock()
} | go | func unlinkGRs() {
childID := curGoroutineID()
dataLock.Lock()
delete(data, childID)
dataLock.Unlock()
} | [
"func",
"unlinkGRs",
"(",
")",
"{",
"childID",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"data",
",",
"childID",
")",
"\n",
"dataLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // unlinkGRs unlinks two goroutines | [
"unlinkGRs",
"unlinks",
"two",
"goroutines"
] | e606233f194d6c314156dc6a35f21a42a470c6f6 | https://github.com/tylerb/gls/blob/e606233f194d6c314156dc6a35f21a42a470c6f6/gls.go#L106-L111 | test |
cloudfoundry-incubator/cf-test-helpers | helpers/app_commands.go | AppUri | func AppUri(appName, path string, config helpersinternal.CurlConfig) string {
uriCreator := &helpersinternal.AppUriCreator{CurlConfig: config}
return uriCreator.AppUri(appName, path)
} | go | func AppUri(appName, path string, config helpersinternal.CurlConfig) string {
uriCreator := &helpersinternal.AppUriCreator{CurlConfig: config}
return uriCreator.AppUri(appName, path)
} | [
"func",
"AppUri",
"(",
"appName",
",",
"path",
"string",
",",
"config",
"helpersinternal",
".",
"CurlConfig",
")",
"string",
"{",
"uriCreator",
":=",
"&",
"helpersinternal",
".",
"AppUriCreator",
"{",
"CurlConfig",
":",
"config",
"}",
"\n",
"return",
"uriCreat... | // Gets an app's endpoint with the specified path | [
"Gets",
"an",
"app",
"s",
"endpoint",
"with",
"the",
"specified",
"path"
] | 83791edc4b0a2d48b602088c30332063b8f02f32 | https://github.com/cloudfoundry-incubator/cf-test-helpers/blob/83791edc4b0a2d48b602088c30332063b8f02f32/helpers/app_commands.go#L12-L16 | test |
cloudfoundry-incubator/cf-test-helpers | helpers/app_commands.go | CurlAppWithTimeout | func CurlAppWithTimeout(cfg helpersinternal.CurlConfig, appName, path string, timeout time.Duration, args ...string) string {
appCurler := helpersinternal.NewAppCurler(Curl, cfg)
return appCurler.CurlAndWait(cfg, appName, path, timeout, args...)
} | go | func CurlAppWithTimeout(cfg helpersinternal.CurlConfig, appName, path string, timeout time.Duration, args ...string) string {
appCurler := helpersinternal.NewAppCurler(Curl, cfg)
return appCurler.CurlAndWait(cfg, appName, path, timeout, args...)
} | [
"func",
"CurlAppWithTimeout",
"(",
"cfg",
"helpersinternal",
".",
"CurlConfig",
",",
"appName",
",",
"path",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"args",
"...",
"string",
")",
"string",
"{",
"appCurler",
":=",
"helpersinternal",
".",
"NewApp... | // Curls an app's endpoint and exit successfully before the specified timeout | [
"Curls",
"an",
"app",
"s",
"endpoint",
"and",
"exit",
"successfully",
"before",
"the",
"specified",
"timeout"
] | 83791edc4b0a2d48b602088c30332063b8f02f32 | https://github.com/cloudfoundry-incubator/cf-test-helpers/blob/83791edc4b0a2d48b602088c30332063b8f02f32/helpers/app_commands.go#L19-L22 | test |
cloudfoundry-incubator/cf-test-helpers | helpers/app_commands.go | CurlApp | func CurlApp(cfg helpersinternal.CurlConfig, appName, path string, args ...string) string {
appCurler := helpersinternal.NewAppCurler(Curl, cfg)
return appCurler.CurlAndWait(cfg, appName, path, CURL_TIMEOUT, args...)
} | go | func CurlApp(cfg helpersinternal.CurlConfig, appName, path string, args ...string) string {
appCurler := helpersinternal.NewAppCurler(Curl, cfg)
return appCurler.CurlAndWait(cfg, appName, path, CURL_TIMEOUT, args...)
} | [
"func",
"CurlApp",
"(",
"cfg",
"helpersinternal",
".",
"CurlConfig",
",",
"appName",
",",
"path",
"string",
",",
"args",
"...",
"string",
")",
"string",
"{",
"appCurler",
":=",
"helpersinternal",
".",
"NewAppCurler",
"(",
"Curl",
",",
"cfg",
")",
"\n",
"re... | // Curls an app's endpoint and exit successfully before the default timeout | [
"Curls",
"an",
"app",
"s",
"endpoint",
"and",
"exit",
"successfully",
"before",
"the",
"default",
"timeout"
] | 83791edc4b0a2d48b602088c30332063b8f02f32 | https://github.com/cloudfoundry-incubator/cf-test-helpers/blob/83791edc4b0a2d48b602088c30332063b8f02f32/helpers/app_commands.go#L25-L28 | test |
cloudfoundry-incubator/cf-test-helpers | helpers/app_commands.go | CurlAppRoot | func CurlAppRoot(cfg helpersinternal.CurlConfig, appName string) string {
appCurler := helpersinternal.NewAppCurler(Curl, cfg)
return appCurler.CurlAndWait(cfg, appName, "/", CURL_TIMEOUT)
} | go | func CurlAppRoot(cfg helpersinternal.CurlConfig, appName string) string {
appCurler := helpersinternal.NewAppCurler(Curl, cfg)
return appCurler.CurlAndWait(cfg, appName, "/", CURL_TIMEOUT)
} | [
"func",
"CurlAppRoot",
"(",
"cfg",
"helpersinternal",
".",
"CurlConfig",
",",
"appName",
"string",
")",
"string",
"{",
"appCurler",
":=",
"helpersinternal",
".",
"NewAppCurler",
"(",
"Curl",
",",
"cfg",
")",
"\n",
"return",
"appCurler",
".",
"CurlAndWait",
"("... | // Curls an app's root endpoint and exit successfully before the default timeout | [
"Curls",
"an",
"app",
"s",
"root",
"endpoint",
"and",
"exit",
"successfully",
"before",
"the",
"default",
"timeout"
] | 83791edc4b0a2d48b602088c30332063b8f02f32 | https://github.com/cloudfoundry-incubator/cf-test-helpers/blob/83791edc4b0a2d48b602088c30332063b8f02f32/helpers/app_commands.go#L31-L34 | test |
gernest/mention | mention.go | GetTags | func GetTags(prefix rune, str string, terminator ...rune) (tags []Tag) {
// If we have no terminators given, default to only whitespace
if len(terminator) == 0 {
terminator = []rune(" ")
}
// get list of indexes in our str that is a terminator
// Always include the beginning of our str a terminator. This is so w... | go | func GetTags(prefix rune, str string, terminator ...rune) (tags []Tag) {
// If we have no terminators given, default to only whitespace
if len(terminator) == 0 {
terminator = []rune(" ")
}
// get list of indexes in our str that is a terminator
// Always include the beginning of our str a terminator. This is so w... | [
"func",
"GetTags",
"(",
"prefix",
"rune",
",",
"str",
"string",
",",
"terminator",
"...",
"rune",
")",
"(",
"tags",
"[",
"]",
"Tag",
")",
"{",
"if",
"len",
"(",
"terminator",
")",
"==",
"0",
"{",
"terminator",
"=",
"[",
"]",
"rune",
"(",
"\" \"",
... | // GetTags returns a slice of Tags, that is all characters after rune char up
// to occurrence of space or another occurrence of rune char. Additionally you
// can provide a coma separated unicode characters to be used as terminating
// sequence. | [
"GetTags",
"returns",
"a",
"slice",
"of",
"Tags",
"that",
"is",
"all",
"characters",
"after",
"rune",
"char",
"up",
"to",
"occurrence",
"of",
"space",
"or",
"another",
"occurrence",
"of",
"rune",
"char",
".",
"Additionally",
"you",
"can",
"provide",
"a",
"... | d48aa4355f942e79e1a4ac2bd08c5c46371b78ca | https://github.com/gernest/mention/blob/d48aa4355f942e79e1a4ac2bd08c5c46371b78ca/mention.go#L27-L61 | test |
gernest/mention | mention.go | GetTagsAsUniqueStrings | func GetTagsAsUniqueStrings(prefix rune, str string, terminator ...rune) (strs []string) {
tags := GetTags(prefix, str, terminator...)
for _, tag := range tags {
strs = append(strs, tag.Tag)
}
return uniquify(strs)
} | go | func GetTagsAsUniqueStrings(prefix rune, str string, terminator ...rune) (strs []string) {
tags := GetTags(prefix, str, terminator...)
for _, tag := range tags {
strs = append(strs, tag.Tag)
}
return uniquify(strs)
} | [
"func",
"GetTagsAsUniqueStrings",
"(",
"prefix",
"rune",
",",
"str",
"string",
",",
"terminator",
"...",
"rune",
")",
"(",
"strs",
"[",
"]",
"string",
")",
"{",
"tags",
":=",
"GetTags",
"(",
"prefix",
",",
"str",
",",
"terminator",
"...",
")",
"\n",
"f... | // GetTagsAsUniqueStrings gets all tags as a slice of unique strings. This is
// here to have a means of being somewhat backwards compatible with previous
// versions of mention | [
"GetTagsAsUniqueStrings",
"gets",
"all",
"tags",
"as",
"a",
"slice",
"of",
"unique",
"strings",
".",
"This",
"is",
"here",
"to",
"have",
"a",
"means",
"of",
"being",
"somewhat",
"backwards",
"compatible",
"with",
"previous",
"versions",
"of",
"mention"
] | d48aa4355f942e79e1a4ac2bd08c5c46371b78ca | https://github.com/gernest/mention/blob/d48aa4355f942e79e1a4ac2bd08c5c46371b78ca/mention.go#L66-L72 | test |
gernest/mention | mention.go | isTerminator | func isTerminator(r rune, terminator ...rune) bool {
for _, t := range terminator {
if r == t {
return true
}
}
return unicode.IsSpace(r) || !unicode.IsPrint(r)
} | go | func isTerminator(r rune, terminator ...rune) bool {
for _, t := range terminator {
if r == t {
return true
}
}
return unicode.IsSpace(r) || !unicode.IsPrint(r)
} | [
"func",
"isTerminator",
"(",
"r",
"rune",
",",
"terminator",
"...",
"rune",
")",
"bool",
"{",
"for",
"_",
",",
"t",
":=",
"range",
"terminator",
"{",
"if",
"r",
"==",
"t",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"unicode",
".",... | // Is given rune listed as a terminator | [
"Is",
"given",
"rune",
"listed",
"as",
"a",
"terminator"
] | d48aa4355f942e79e1a4ac2bd08c5c46371b78ca | https://github.com/gernest/mention/blob/d48aa4355f942e79e1a4ac2bd08c5c46371b78ca/mention.go#L75-L82 | test |
gernest/mention | mention.go | uniquify | func uniquify(in []string) (out []string) {
for _, i := range in {
if i == "" {
continue
}
for _, o := range out {
if i == o {
continue
}
}
out = append(out, i)
}
return
} | go | func uniquify(in []string) (out []string) {
for _, i := range in {
if i == "" {
continue
}
for _, o := range out {
if i == o {
continue
}
}
out = append(out, i)
}
return
} | [
"func",
"uniquify",
"(",
"in",
"[",
"]",
"string",
")",
"(",
"out",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"in",
"{",
"if",
"i",
"==",
"\"\"",
"{",
"continue",
"\n",
"}",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
... | // Ensures the given slice of strings are unique and that none are empty
// strings | [
"Ensures",
"the",
"given",
"slice",
"of",
"strings",
"are",
"unique",
"and",
"that",
"none",
"are",
"empty",
"strings"
] | d48aa4355f942e79e1a4ac2bd08c5c46371b78ca | https://github.com/gernest/mention/blob/d48aa4355f942e79e1a4ac2bd08c5c46371b78ca/mention.go#L86-L99 | test |
gin-contrib/location | location.go | New | func New(config Config) gin.HandlerFunc {
location := newLocation(config)
return func(c *gin.Context) {
location.applyToContext(c)
}
} | go | func New(config Config) gin.HandlerFunc {
location := newLocation(config)
return func(c *gin.Context) {
location.applyToContext(c)
}
} | [
"func",
"New",
"(",
"config",
"Config",
")",
"gin",
".",
"HandlerFunc",
"{",
"location",
":=",
"newLocation",
"(",
"config",
")",
"\n",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"location",
".",
"applyToContext",
"(",
"c",
")",
... | // New returns the location middleware with user-defined custom configuration. | [
"New",
"returns",
"the",
"location",
"middleware",
"with",
"user",
"-",
"defined",
"custom",
"configuration",
"."
] | 0462caccbb9cc0b222a2d75a64830c360c603798 | https://github.com/gin-contrib/location/blob/0462caccbb9cc0b222a2d75a64830c360c603798/location.go#L41-L47 | test |
gin-contrib/location | location.go | Get | func Get(c *gin.Context) *url.URL {
v, ok := c.Get(key)
if !ok {
return nil
}
vv, ok := v.(*url.URL)
if !ok {
return nil
}
return vv
} | go | func Get(c *gin.Context) *url.URL {
v, ok := c.Get(key)
if !ok {
return nil
}
vv, ok := v.(*url.URL)
if !ok {
return nil
}
return vv
} | [
"func",
"Get",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"*",
"url",
".",
"URL",
"{",
"v",
",",
"ok",
":=",
"c",
".",
"Get",
"(",
"key",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"vv",
",",
"ok",
":=",
"v",
".",
... | // Get returns the Location information for the incoming http.Request from the
// context. If the location is not set a nil value is returned. | [
"Get",
"returns",
"the",
"Location",
"information",
"for",
"the",
"incoming",
"http",
".",
"Request",
"from",
"the",
"context",
".",
"If",
"the",
"location",
"is",
"not",
"set",
"a",
"nil",
"value",
"is",
"returned",
"."
] | 0462caccbb9cc0b222a2d75a64830c360c603798 | https://github.com/gin-contrib/location/blob/0462caccbb9cc0b222a2d75a64830c360c603798/location.go#L51-L65 | test |
libp2p/go-libp2p-crypto | rsa.go | GenerateRSAKeyPair | func GenerateRSAKeyPair(bits int, src io.Reader) (PrivKey, PubKey, error) {
if bits < 512 {
return nil, nil, ErrRsaKeyTooSmall
}
priv, err := rsa.GenerateKey(src, bits)
if err != nil {
return nil, nil, err
}
pk := &priv.PublicKey
return &RsaPrivateKey{sk: priv}, &RsaPublicKey{pk}, nil
} | go | func GenerateRSAKeyPair(bits int, src io.Reader) (PrivKey, PubKey, error) {
if bits < 512 {
return nil, nil, ErrRsaKeyTooSmall
}
priv, err := rsa.GenerateKey(src, bits)
if err != nil {
return nil, nil, err
}
pk := &priv.PublicKey
return &RsaPrivateKey{sk: priv}, &RsaPublicKey{pk}, nil
} | [
"func",
"GenerateRSAKeyPair",
"(",
"bits",
"int",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"if",
"bits",
"<",
"512",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrRsaKeyTooSmall",
"\n",
"}",
"\n",
"pri... | // GenerateRSAKeyPair generates a new rsa private and public key | [
"GenerateRSAKeyPair",
"generates",
"a",
"new",
"rsa",
"private",
"and",
"public",
"key"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L33-L43 | test |
libp2p/go-libp2p-crypto | rsa.go | Verify | func (pk *RsaPublicKey) Verify(data, sig []byte) (bool, error) {
hashed := sha256.Sum256(data)
err := rsa.VerifyPKCS1v15(pk.k, crypto.SHA256, hashed[:], sig)
if err != nil {
return false, err
}
return true, nil
} | go | func (pk *RsaPublicKey) Verify(data, sig []byte) (bool, error) {
hashed := sha256.Sum256(data)
err := rsa.VerifyPKCS1v15(pk.k, crypto.SHA256, hashed[:], sig)
if err != nil {
return false, err
}
return true, nil
} | [
"func",
"(",
"pk",
"*",
"RsaPublicKey",
")",
"Verify",
"(",
"data",
",",
"sig",
"[",
"]",
"byte",
")",
"(",
"bool",
",",
"error",
")",
"{",
"hashed",
":=",
"sha256",
".",
"Sum256",
"(",
"data",
")",
"\n",
"err",
":=",
"rsa",
".",
"VerifyPKCS1v15",
... | // Verify compares a signature against input data | [
"Verify",
"compares",
"a",
"signature",
"against",
"input",
"data"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L46-L53 | test |
libp2p/go-libp2p-crypto | rsa.go | Encrypt | func (pk *RsaPublicKey) Encrypt(b []byte) ([]byte, error) {
return rsa.EncryptPKCS1v15(rand.Reader, pk.k, b)
} | go | func (pk *RsaPublicKey) Encrypt(b []byte) ([]byte, error) {
return rsa.EncryptPKCS1v15(rand.Reader, pk.k, b)
} | [
"func",
"(",
"pk",
"*",
"RsaPublicKey",
")",
"Encrypt",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"rsa",
".",
"EncryptPKCS1v15",
"(",
"rand",
".",
"Reader",
",",
"pk",
".",
"k",
",",
"b",
")",
"\n... | // Encrypt returns encrypted bytes from the inpu data | [
"Encrypt",
"returns",
"encrypted",
"bytes",
"from",
"the",
"inpu",
"data"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L69-L71 | test |
libp2p/go-libp2p-crypto | rsa.go | Sign | func (sk *RsaPrivateKey) Sign(message []byte) ([]byte, error) {
hashed := sha256.Sum256(message)
return rsa.SignPKCS1v15(rand.Reader, sk.sk, crypto.SHA256, hashed[:])
} | go | func (sk *RsaPrivateKey) Sign(message []byte) ([]byte, error) {
hashed := sha256.Sum256(message)
return rsa.SignPKCS1v15(rand.Reader, sk.sk, crypto.SHA256, hashed[:])
} | [
"func",
"(",
"sk",
"*",
"RsaPrivateKey",
")",
"Sign",
"(",
"message",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"hashed",
":=",
"sha256",
".",
"Sum256",
"(",
"message",
")",
"\n",
"return",
"rsa",
".",
"SignPKCS1v15",
"(... | // Sign returns a signature of the input data | [
"Sign",
"returns",
"a",
"signature",
"of",
"the",
"input",
"data"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L79-L82 | test |
libp2p/go-libp2p-crypto | rsa.go | GetPublic | func (sk *RsaPrivateKey) GetPublic() PubKey {
if sk.pk == nil {
sk.pk = &sk.sk.PublicKey
}
return &RsaPublicKey{sk.pk}
} | go | func (sk *RsaPrivateKey) GetPublic() PubKey {
if sk.pk == nil {
sk.pk = &sk.sk.PublicKey
}
return &RsaPublicKey{sk.pk}
} | [
"func",
"(",
"sk",
"*",
"RsaPrivateKey",
")",
"GetPublic",
"(",
")",
"PubKey",
"{",
"if",
"sk",
".",
"pk",
"==",
"nil",
"{",
"sk",
".",
"pk",
"=",
"&",
"sk",
".",
"sk",
".",
"PublicKey",
"\n",
"}",
"\n",
"return",
"&",
"RsaPublicKey",
"{",
"sk",
... | // GetPublic returns a public key | [
"GetPublic",
"returns",
"a",
"public",
"key"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L85-L90 | test |
libp2p/go-libp2p-crypto | rsa.go | Decrypt | func (sk *RsaPrivateKey) Decrypt(b []byte) ([]byte, error) {
return rsa.DecryptPKCS1v15(rand.Reader, sk.sk, b)
} | go | func (sk *RsaPrivateKey) Decrypt(b []byte) ([]byte, error) {
return rsa.DecryptPKCS1v15(rand.Reader, sk.sk, b)
} | [
"func",
"(",
"sk",
"*",
"RsaPrivateKey",
")",
"Decrypt",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"rsa",
".",
"DecryptPKCS1v15",
"(",
"rand",
".",
"Reader",
",",
"sk",
".",
"sk",
",",
"b",
")",
"... | // Decrypt returns decrypted bytes of the input encrypted bytes | [
"Decrypt",
"returns",
"decrypted",
"bytes",
"of",
"the",
"input",
"encrypted",
"bytes"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L93-L95 | test |
libp2p/go-libp2p-crypto | rsa.go | UnmarshalRsaPrivateKey | func UnmarshalRsaPrivateKey(b []byte) (PrivKey, error) {
sk, err := x509.ParsePKCS1PrivateKey(b)
if err != nil {
return nil, err
}
if sk.N.BitLen() < 512 {
return nil, ErrRsaKeyTooSmall
}
return &RsaPrivateKey{sk: sk}, nil
} | go | func UnmarshalRsaPrivateKey(b []byte) (PrivKey, error) {
sk, err := x509.ParsePKCS1PrivateKey(b)
if err != nil {
return nil, err
}
if sk.N.BitLen() < 512 {
return nil, ErrRsaKeyTooSmall
}
return &RsaPrivateKey{sk: sk}, nil
} | [
"func",
"UnmarshalRsaPrivateKey",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"PrivKey",
",",
"error",
")",
"{",
"sk",
",",
"err",
":=",
"x509",
".",
"ParsePKCS1PrivateKey",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // UnmarshalRsaPrivateKey returns a private key from the input x509 bytes | [
"UnmarshalRsaPrivateKey",
"returns",
"a",
"private",
"key",
"from",
"the",
"input",
"x509",
"bytes"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/rsa.go#L117-L126 | test |
libp2p/go-libp2p-crypto | key.go | GenerateKeyPair | func GenerateKeyPair(typ, bits int) (PrivKey, PubKey, error) {
return GenerateKeyPairWithReader(typ, bits, rand.Reader)
} | go | func GenerateKeyPair(typ, bits int) (PrivKey, PubKey, error) {
return GenerateKeyPairWithReader(typ, bits, rand.Reader)
} | [
"func",
"GenerateKeyPair",
"(",
"typ",
",",
"bits",
"int",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"return",
"GenerateKeyPairWithReader",
"(",
"typ",
",",
"bits",
",",
"rand",
".",
"Reader",
")",
"\n",
"}"
] | // GenerateKeyPair generates a private and public key | [
"GenerateKeyPair",
"generates",
"a",
"private",
"and",
"public",
"key"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L113-L115 | test |
libp2p/go-libp2p-crypto | key.go | GenerateKeyPairWithReader | func GenerateKeyPairWithReader(typ, bits int, src io.Reader) (PrivKey, PubKey, error) {
switch typ {
case RSA:
return GenerateRSAKeyPair(bits, src)
case Ed25519:
return GenerateEd25519Key(src)
case Secp256k1:
return GenerateSecp256k1Key(src)
case ECDSA:
return GenerateECDSAKeyPair(src)
default:
return n... | go | func GenerateKeyPairWithReader(typ, bits int, src io.Reader) (PrivKey, PubKey, error) {
switch typ {
case RSA:
return GenerateRSAKeyPair(bits, src)
case Ed25519:
return GenerateEd25519Key(src)
case Secp256k1:
return GenerateSecp256k1Key(src)
case ECDSA:
return GenerateECDSAKeyPair(src)
default:
return n... | [
"func",
"GenerateKeyPairWithReader",
"(",
"typ",
",",
"bits",
"int",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"switch",
"typ",
"{",
"case",
"RSA",
":",
"return",
"GenerateRSAKeyPair",
"(",
"bits",
",",
... | // GenerateKeyPairWithReader returns a keypair of the given type and bitsize | [
"GenerateKeyPairWithReader",
"returns",
"a",
"keypair",
"of",
"the",
"given",
"type",
"and",
"bitsize"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L118-L131 | test |
libp2p/go-libp2p-crypto | key.go | GenerateEKeyPair | func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) {
var curve elliptic.Curve
switch curveName {
case "P-256":
curve = elliptic.P256()
case "P-384":
curve = elliptic.P384()
case "P-521":
curve = elliptic.P521()
}
priv, x, y, err := elliptic.GenerateKey(curve, rand.Reader)
if err != ni... | go | func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) {
var curve elliptic.Curve
switch curveName {
case "P-256":
curve = elliptic.P256()
case "P-384":
curve = elliptic.P384()
case "P-521":
curve = elliptic.P521()
}
priv, x, y, err := elliptic.GenerateKey(curve, rand.Reader)
if err != ni... | [
"func",
"GenerateEKeyPair",
"(",
"curveName",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"GenSharedKey",
",",
"error",
")",
"{",
"var",
"curve",
"elliptic",
".",
"Curve",
"\n",
"switch",
"curveName",
"{",
"case",
"\"P-256\"",
":",
"curve",
"=",
"elliptic",... | // GenerateEKeyPair returns an ephemeral public key and returns a function that will compute
// the shared secret key. Used in the identify module.
//
// Focuses only on ECDH now, but can be made more general in the future. | [
"GenerateEKeyPair",
"returns",
"an",
"ephemeral",
"public",
"key",
"and",
"returns",
"a",
"function",
"that",
"will",
"compute",
"the",
"shared",
"secret",
"key",
".",
"Used",
"in",
"the",
"identify",
"module",
".",
"Focuses",
"only",
"on",
"ECDH",
"now",
"b... | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L137-L174 | test |
libp2p/go-libp2p-crypto | key.go | UnmarshalPublicKey | func UnmarshalPublicKey(data []byte) (PubKey, error) {
pmes := new(pb.PublicKey)
err := proto.Unmarshal(data, pmes)
if err != nil {
return nil, err
}
um, ok := PubKeyUnmarshallers[pmes.GetType()]
if !ok {
return nil, ErrBadKeyType
}
return um(pmes.GetData())
} | go | func UnmarshalPublicKey(data []byte) (PubKey, error) {
pmes := new(pb.PublicKey)
err := proto.Unmarshal(data, pmes)
if err != nil {
return nil, err
}
um, ok := PubKeyUnmarshallers[pmes.GetType()]
if !ok {
return nil, ErrBadKeyType
}
return um(pmes.GetData())
} | [
"func",
"UnmarshalPublicKey",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"PubKey",
",",
"error",
")",
"{",
"pmes",
":=",
"new",
"(",
"pb",
".",
"PublicKey",
")",
"\n",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"data",
",",
"pmes",
")",
"\n",
"if",... | // UnmarshalPublicKey converts a protobuf serialized public key into its
// representative object | [
"UnmarshalPublicKey",
"converts",
"a",
"protobuf",
"serialized",
"public",
"key",
"into",
"its",
"representative",
"object"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L274-L287 | test |
libp2p/go-libp2p-crypto | key.go | MarshalPublicKey | func MarshalPublicKey(k PubKey) ([]byte, error) {
pbmes := new(pb.PublicKey)
pbmes.Type = k.Type()
data, err := k.Raw()
if err != nil {
return nil, err
}
pbmes.Data = data
return proto.Marshal(pbmes)
} | go | func MarshalPublicKey(k PubKey) ([]byte, error) {
pbmes := new(pb.PublicKey)
pbmes.Type = k.Type()
data, err := k.Raw()
if err != nil {
return nil, err
}
pbmes.Data = data
return proto.Marshal(pbmes)
} | [
"func",
"MarshalPublicKey",
"(",
"k",
"PubKey",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pbmes",
":=",
"new",
"(",
"pb",
".",
"PublicKey",
")",
"\n",
"pbmes",
".",
"Type",
"=",
"k",
".",
"Type",
"(",
")",
"\n",
"data",
",",
"err",
"... | // MarshalPublicKey converts a public key object into a protobuf serialized
// public key | [
"MarshalPublicKey",
"converts",
"a",
"public",
"key",
"object",
"into",
"a",
"protobuf",
"serialized",
"public",
"key"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L291-L301 | test |
libp2p/go-libp2p-crypto | key.go | UnmarshalPrivateKey | func UnmarshalPrivateKey(data []byte) (PrivKey, error) {
pmes := new(pb.PrivateKey)
err := proto.Unmarshal(data, pmes)
if err != nil {
return nil, err
}
um, ok := PrivKeyUnmarshallers[pmes.GetType()]
if !ok {
return nil, ErrBadKeyType
}
return um(pmes.GetData())
} | go | func UnmarshalPrivateKey(data []byte) (PrivKey, error) {
pmes := new(pb.PrivateKey)
err := proto.Unmarshal(data, pmes)
if err != nil {
return nil, err
}
um, ok := PrivKeyUnmarshallers[pmes.GetType()]
if !ok {
return nil, ErrBadKeyType
}
return um(pmes.GetData())
} | [
"func",
"UnmarshalPrivateKey",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"PrivKey",
",",
"error",
")",
"{",
"pmes",
":=",
"new",
"(",
"pb",
".",
"PrivateKey",
")",
"\n",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"data",
",",
"pmes",
")",
"\n",
"i... | // UnmarshalPrivateKey converts a protobuf serialized private key into its
// representative object | [
"UnmarshalPrivateKey",
"converts",
"a",
"protobuf",
"serialized",
"private",
"key",
"into",
"its",
"representative",
"object"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L305-L318 | test |
libp2p/go-libp2p-crypto | key.go | MarshalPrivateKey | func MarshalPrivateKey(k PrivKey) ([]byte, error) {
pbmes := new(pb.PrivateKey)
pbmes.Type = k.Type()
data, err := k.Raw()
if err != nil {
return nil, err
}
pbmes.Data = data
return proto.Marshal(pbmes)
} | go | func MarshalPrivateKey(k PrivKey) ([]byte, error) {
pbmes := new(pb.PrivateKey)
pbmes.Type = k.Type()
data, err := k.Raw()
if err != nil {
return nil, err
}
pbmes.Data = data
return proto.Marshal(pbmes)
} | [
"func",
"MarshalPrivateKey",
"(",
"k",
"PrivKey",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pbmes",
":=",
"new",
"(",
"pb",
".",
"PrivateKey",
")",
"\n",
"pbmes",
".",
"Type",
"=",
"k",
".",
"Type",
"(",
")",
"\n",
"data",
",",
"err",
... | // MarshalPrivateKey converts a key object into its protobuf serialized form. | [
"MarshalPrivateKey",
"converts",
"a",
"key",
"object",
"into",
"its",
"protobuf",
"serialized",
"form",
"."
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L321-L331 | test |
libp2p/go-libp2p-crypto | key.go | KeyEqual | func KeyEqual(k1, k2 Key) bool {
if k1 == k2 {
return true
}
b1, err1 := k1.Bytes()
b2, err2 := k2.Bytes()
return bytes.Equal(b1, b2) && err1 == err2
} | go | func KeyEqual(k1, k2 Key) bool {
if k1 == k2 {
return true
}
b1, err1 := k1.Bytes()
b2, err2 := k2.Bytes()
return bytes.Equal(b1, b2) && err1 == err2
} | [
"func",
"KeyEqual",
"(",
"k1",
",",
"k2",
"Key",
")",
"bool",
"{",
"if",
"k1",
"==",
"k2",
"{",
"return",
"true",
"\n",
"}",
"\n",
"b1",
",",
"err1",
":=",
"k1",
".",
"Bytes",
"(",
")",
"\n",
"b2",
",",
"err2",
":=",
"k2",
".",
"Bytes",
"(",
... | // KeyEqual checks whether two | [
"KeyEqual",
"checks",
"whether",
"two"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/key.go#L344-L352 | test |
libp2p/go-libp2p-crypto | ecdsa.go | GenerateECDSAKeyPair | func GenerateECDSAKeyPair(src io.Reader) (PrivKey, PubKey, error) {
return GenerateECDSAKeyPairWithCurve(ECDSACurve, src)
} | go | func GenerateECDSAKeyPair(src io.Reader) (PrivKey, PubKey, error) {
return GenerateECDSAKeyPairWithCurve(ECDSACurve, src)
} | [
"func",
"GenerateECDSAKeyPair",
"(",
"src",
"io",
".",
"Reader",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"return",
"GenerateECDSAKeyPairWithCurve",
"(",
"ECDSACurve",
",",
"src",
")",
"\n",
"}"
] | // GenerateECDSAKeyPair generates a new ecdsa private and public key | [
"GenerateECDSAKeyPair",
"generates",
"a",
"new",
"ecdsa",
"private",
"and",
"public",
"key"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/ecdsa.go#L45-L47 | test |
libp2p/go-libp2p-crypto | ecdsa.go | GenerateECDSAKeyPairWithCurve | func GenerateECDSAKeyPairWithCurve(curve elliptic.Curve, src io.Reader) (PrivKey, PubKey, error) {
priv, err := ecdsa.GenerateKey(curve, src)
if err != nil {
return nil, nil, err
}
return &ECDSAPrivateKey{priv}, &ECDSAPublicKey{&priv.PublicKey}, nil
} | go | func GenerateECDSAKeyPairWithCurve(curve elliptic.Curve, src io.Reader) (PrivKey, PubKey, error) {
priv, err := ecdsa.GenerateKey(curve, src)
if err != nil {
return nil, nil, err
}
return &ECDSAPrivateKey{priv}, &ECDSAPublicKey{&priv.PublicKey}, nil
} | [
"func",
"GenerateECDSAKeyPairWithCurve",
"(",
"curve",
"elliptic",
".",
"Curve",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"priv",
",",
"err",
":=",
"ecdsa",
".",
"GenerateKey",
"(",
"curve",
",",
"src",... | // GenerateECDSAKeyPairWithCurve generates a new ecdsa private and public key with a speicified curve | [
"GenerateECDSAKeyPairWithCurve",
"generates",
"a",
"new",
"ecdsa",
"private",
"and",
"public",
"key",
"with",
"a",
"speicified",
"curve"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/ecdsa.go#L50-L57 | test |
libp2p/go-libp2p-crypto | ecdsa.go | ECDSAKeyPairFromKey | func ECDSAKeyPairFromKey(priv *ecdsa.PrivateKey) (PrivKey, PubKey, error) {
if priv == nil {
return nil, nil, ErrNilPrivateKey
}
return &ECDSAPrivateKey{priv}, &ECDSAPublicKey{&priv.PublicKey}, nil
} | go | func ECDSAKeyPairFromKey(priv *ecdsa.PrivateKey) (PrivKey, PubKey, error) {
if priv == nil {
return nil, nil, ErrNilPrivateKey
}
return &ECDSAPrivateKey{priv}, &ECDSAPublicKey{&priv.PublicKey}, nil
} | [
"func",
"ECDSAKeyPairFromKey",
"(",
"priv",
"*",
"ecdsa",
".",
"PrivateKey",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"if",
"priv",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrNilPrivateKey",
"\n",
"}",
"\n",
"return",
"&... | // ECDSAKeyPairFromKey generates a new ecdsa private and public key from an input private key | [
"ECDSAKeyPairFromKey",
"generates",
"a",
"new",
"ecdsa",
"private",
"and",
"public",
"key",
"from",
"an",
"input",
"private",
"key"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/ecdsa.go#L60-L66 | test |
libp2p/go-libp2p-crypto | ecdsa.go | UnmarshalECDSAPrivateKey | func UnmarshalECDSAPrivateKey(data []byte) (PrivKey, error) {
priv, err := x509.ParseECPrivateKey(data)
if err != nil {
return nil, err
}
return &ECDSAPrivateKey{priv}, nil
} | go | func UnmarshalECDSAPrivateKey(data []byte) (PrivKey, error) {
priv, err := x509.ParseECPrivateKey(data)
if err != nil {
return nil, err
}
return &ECDSAPrivateKey{priv}, nil
} | [
"func",
"UnmarshalECDSAPrivateKey",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"PrivKey",
",",
"error",
")",
"{",
"priv",
",",
"err",
":=",
"x509",
".",
"ParseECPrivateKey",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"... | // UnmarshalECDSAPrivateKey returns a private key from x509 bytes | [
"UnmarshalECDSAPrivateKey",
"returns",
"a",
"private",
"key",
"from",
"x509",
"bytes"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/ecdsa.go#L79-L86 | test |
libp2p/go-libp2p-crypto | ecdsa.go | UnmarshalECDSAPublicKey | func UnmarshalECDSAPublicKey(data []byte) (PubKey, error) {
pubIfc, err := x509.ParsePKIXPublicKey(data)
if err != nil {
return nil, err
}
pub, ok := pubIfc.(*ecdsa.PublicKey)
if !ok {
return nil, ErrNotECDSAPubKey
}
return &ECDSAPublicKey{pub}, nil
} | go | func UnmarshalECDSAPublicKey(data []byte) (PubKey, error) {
pubIfc, err := x509.ParsePKIXPublicKey(data)
if err != nil {
return nil, err
}
pub, ok := pubIfc.(*ecdsa.PublicKey)
if !ok {
return nil, ErrNotECDSAPubKey
}
return &ECDSAPublicKey{pub}, nil
} | [
"func",
"UnmarshalECDSAPublicKey",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"PubKey",
",",
"error",
")",
"{",
"pubIfc",
",",
"err",
":=",
"x509",
".",
"ParsePKIXPublicKey",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // UnmarshalECDSAPublicKey returns the public key from x509 bytes | [
"UnmarshalECDSAPublicKey",
"returns",
"the",
"public",
"key",
"from",
"x509",
"bytes"
] | 9d2fed53443f745e6dc4d02bdcc94d9742a0ca84 | https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/ecdsa.go#L89-L101 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.