id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
139,200 | rveen/ogdl | binary.go | parse | func (p *binParser) parse() *Graph {
if p == nil || !p.header() {
return nil
}
ev := &SimpleEventHandler{}
for {
lev, bin, b := p.line(true)
if lev == 0 {
break
}
// Store the content in the same format as it was sent (string or []byte)
if bin {
ev.AddBytesAt(b, lev-1)
} else {
ev.AddAt(st... | go | func (p *binParser) parse() *Graph {
if p == nil || !p.header() {
return nil
}
ev := &SimpleEventHandler{}
for {
lev, bin, b := p.line(true)
if lev == 0 {
break
}
// Store the content in the same format as it was sent (string or []byte)
if bin {
ev.AddBytesAt(b, lev-1)
} else {
ev.AddAt(st... | [
"func",
"(",
"p",
"*",
"binParser",
")",
"parse",
"(",
")",
"*",
"Graph",
"{",
"if",
"p",
"==",
"nil",
"||",
"!",
"p",
".",
"header",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"ev",
":=",
"&",
"SimpleEventHandler",
"{",
"}",
"\n\n",
"f... | // Parse parses a binary OGDL stream and returns a Graph. | [
"Parse",
"parses",
"a",
"binary",
"OGDL",
"stream",
"and",
"returns",
"a",
"Graph",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/binary.go#L125-L146 |
139,201 | rveen/ogdl | binary.go | newVarInt | func newVarInt(i int) []byte {
if i < 0 {
return nil
}
if i < 0x80 {
b := make([]byte, 1)
b[0] = byte(i)
return b
}
if i < 0x4000 {
b := make([]byte, 2)
b[0] = byte(i>>8 | 0x80)
b[1] = byte(i & 0xff)
return b
}
if i < 0x200000 {
b := make([]byte, 3)
b[0] = byte(i>>16 | 0xc0)
b[1] = byte... | go | func newVarInt(i int) []byte {
if i < 0 {
return nil
}
if i < 0x80 {
b := make([]byte, 1)
b[0] = byte(i)
return b
}
if i < 0x4000 {
b := make([]byte, 2)
b[0] = byte(i>>8 | 0x80)
b[1] = byte(i & 0xff)
return b
}
if i < 0x200000 {
b := make([]byte, 3)
b[0] = byte(i>>16 | 0xc0)
b[1] = byte... | [
"func",
"newVarInt",
"(",
"i",
"int",
")",
"[",
"]",
"byte",
"{",
"if",
"i",
"<",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"i",
"<",
"0x80",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"b",
"[",
"0",
"]"... | // newVarInt produces a variable integer from an int.
// Only positive integers are accepted. | [
"newVarInt",
"produces",
"a",
"variable",
"integer",
"from",
"an",
"int",
".",
"Only",
"positive",
"integers",
"are",
"accepted",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/binary.go#L150-L187 |
139,202 | rveen/ogdl | parser.go | NewParser | func NewParser(rd io.Reader) *Parser {
p := Parser{}
p.rd = rd
p.lastByte = bufSize
p.buf = make([]byte, bufSize)
p.ev = &SimpleEventHandler{}
p.r = -1
p.fill()
return &p
} | go | func NewParser(rd io.Reader) *Parser {
p := Parser{}
p.rd = rd
p.lastByte = bufSize
p.buf = make([]byte, bufSize)
p.ev = &SimpleEventHandler{}
p.r = -1
p.fill()
return &p
} | [
"func",
"NewParser",
"(",
"rd",
"io",
".",
"Reader",
")",
"*",
"Parser",
"{",
"p",
":=",
"Parser",
"{",
"}",
"\n",
"p",
".",
"rd",
"=",
"rd",
"\n",
"p",
".",
"lastByte",
"=",
"bufSize",
"\n",
"p",
".",
"buf",
"=",
"make",
"(",
"[",
"]",
"byte... | // NewParser return a new Parser from a Reader | [
"NewParser",
"return",
"a",
"new",
"Parser",
"from",
"a",
"Reader"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/parser.go#L20-L29 |
139,203 | rveen/ogdl | parser.go | FromReader | func FromReader(r io.Reader) *Graph {
p := NewParser(r)
p.Ogdl()
return p.Graph()
} | go | func FromReader(r io.Reader) *Graph {
p := NewParser(r)
p.Ogdl()
return p.Graph()
} | [
"func",
"FromReader",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Graph",
"{",
"p",
":=",
"NewParser",
"(",
"r",
")",
"\n",
"p",
".",
"Ogdl",
"(",
")",
"\n",
"return",
"p",
".",
"Graph",
"(",
")",
"\n",
"}"
] | // FromReader parses OGDL text coming from a generic io.Reader | [
"FromReader",
"parses",
"OGDL",
"text",
"coming",
"from",
"a",
"generic",
"io",
".",
"Reader"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/parser.go#L70-L74 |
139,204 | rveen/ogdl | parser.go | FromFile | func FromFile(s string) *Graph {
b, err := ioutil.ReadFile(s)
if err != nil || len(b) == 0 {
return nil
}
buf := bytes.NewBuffer(b)
p := NewParser(buf)
p.Ogdl()
return p.Graph()
} | go | func FromFile(s string) *Graph {
b, err := ioutil.ReadFile(s)
if err != nil || len(b) == 0 {
return nil
}
buf := bytes.NewBuffer(b)
p := NewParser(buf)
p.Ogdl()
return p.Graph()
} | [
"func",
"FromFile",
"(",
"s",
"string",
")",
"*",
"Graph",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"len",
"(",
"b",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"... | // FromFile parses OGDL text contained in a file. It returns a Graph | [
"FromFile",
"parses",
"OGDL",
"text",
"contained",
"in",
"a",
"file",
".",
"It",
"returns",
"a",
"Graph"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/parser.go#L77-L87 |
139,205 | rveen/ogdl | ogdlrf/client.go | Dial | func (rf *Client) Dial() error {
rf.Close()
conn, err := net.Dial("tcp", rf.Host)
rf.conn = conn
return err
} | go | func (rf *Client) Dial() error {
rf.Close()
conn, err := net.Dial("tcp", rf.Host)
rf.conn = conn
return err
} | [
"func",
"(",
"rf",
"*",
"Client",
")",
"Dial",
"(",
")",
"error",
"{",
"rf",
".",
"Close",
"(",
")",
"\n",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"rf",
".",
"Host",
")",
"\n",
"rf",
".",
"conn",
"=",
"conn",
"\n... | // Dial opens the TCP connection | [
"Dial",
"opens",
"the",
"TCP",
"connection"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/client.go#L34-L39 |
139,206 | rveen/ogdl | ogdlrf/client.go | Call | func (rf *Client) Call(g *ogdl.Graph) (*ogdl.Graph, error) {
log.Printf("Client.Call to %s, %d", rf.Host, rf.Protocol)
var err error
var r *ogdl.Graph
n := 2
for {
if rf.conn == nil {
err = rf.Dial()
if err != nil {
return nil, errors.New("Cannot establish a connection to " + rf.Host)
}
}
if... | go | func (rf *Client) Call(g *ogdl.Graph) (*ogdl.Graph, error) {
log.Printf("Client.Call to %s, %d", rf.Host, rf.Protocol)
var err error
var r *ogdl.Graph
n := 2
for {
if rf.conn == nil {
err = rf.Dial()
if err != nil {
return nil, errors.New("Cannot establish a connection to " + rf.Host)
}
}
if... | [
"func",
"(",
"rf",
"*",
"Client",
")",
"Call",
"(",
"g",
"*",
"ogdl",
".",
"Graph",
")",
"(",
"*",
"ogdl",
".",
"Graph",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"rf",
".",
"Host",
",",
"rf",
".",
"Protocol",
")",
... | // Call makes a request and returns the response. It dials the host if not
// connected. | [
"Call",
"makes",
"a",
"request",
"and",
"returns",
"the",
"response",
".",
"It",
"dials",
"the",
"host",
"if",
"not",
"connected",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/client.go#L43-L76 |
139,207 | rveen/ogdl | ogdlrf/client.go | callV2 | func (rf *Client) callV2(g *ogdl.Graph) (*ogdl.Graph, error) {
// Convert graph to []byte
buf := g.Binary()
// Send LEN
b4 := make([]byte, 4)
binary.BigEndian.PutUint32(b4, uint32(len(buf)))
rf.conn.SetDeadline(time.Now().Add(time.Second * time.Duration(rf.Timeout)))
i, err := rf.conn.Write(b4)
if i != 4 || ... | go | func (rf *Client) callV2(g *ogdl.Graph) (*ogdl.Graph, error) {
// Convert graph to []byte
buf := g.Binary()
// Send LEN
b4 := make([]byte, 4)
binary.BigEndian.PutUint32(b4, uint32(len(buf)))
rf.conn.SetDeadline(time.Now().Add(time.Second * time.Duration(rf.Timeout)))
i, err := rf.conn.Write(b4)
if i != 4 || ... | [
"func",
"(",
"rf",
"*",
"Client",
")",
"callV2",
"(",
"g",
"*",
"ogdl",
".",
"Graph",
")",
"(",
"*",
"ogdl",
".",
"Graph",
",",
"error",
")",
"{",
"// Convert graph to []byte",
"buf",
":=",
"g",
".",
"Binary",
"(",
")",
"\n\n",
"// Send LEN",
"b4",
... | // Call makes a remote call. It sends the given Graph in binary format to the server
// and returns the response Graph. | [
"Call",
"makes",
"a",
"remote",
"call",
".",
"It",
"sends",
"the",
"given",
"Graph",
"in",
"binary",
"format",
"to",
"the",
"server",
"and",
"returns",
"the",
"response",
"Graph",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/client.go#L80-L146 |
139,208 | rveen/ogdl | ogdlrf/client.go | Close | func (rf *Client) Close() {
if rf.conn != nil {
rf.conn.Close()
rf.conn = nil
}
} | go | func (rf *Client) Close() {
if rf.conn != nil {
rf.conn.Close()
rf.conn = nil
}
} | [
"func",
"(",
"rf",
"*",
"Client",
")",
"Close",
"(",
")",
"{",
"if",
"rf",
".",
"conn",
"!=",
"nil",
"{",
"rf",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"rf",
".",
"conn",
"=",
"nil",
"\n",
"}",
"\n",
"}"
] | // Close closes the underlying connection, if open. | [
"Close",
"closes",
"the",
"underlying",
"connection",
"if",
"open",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/client.go#L179-L184 |
139,209 | rveen/ogdl | ogdlrf/server.go | AddRoute | func (srv *Server) AddRoute(path string, f Function) {
if srv.rtable == nil {
srv.rtable = make(map[string]Function)
}
srv.rtable[path] = f
} | go | func (srv *Server) AddRoute(path string, f Function) {
if srv.rtable == nil {
srv.rtable = make(map[string]Function)
}
srv.rtable[path] = f
} | [
"func",
"(",
"srv",
"*",
"Server",
")",
"AddRoute",
"(",
"path",
"string",
",",
"f",
"Function",
")",
"{",
"if",
"srv",
".",
"rtable",
"==",
"nil",
"{",
"srv",
".",
"rtable",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"Function",
")",
"\n",
"}"... | // AddRoute associates a handler function with the given path. A path in this
// context is the first child of the incomming request. | [
"AddRoute",
"associates",
"a",
"handler",
"function",
"with",
"the",
"given",
"path",
".",
"A",
"path",
"in",
"this",
"context",
"is",
"the",
"first",
"child",
"of",
"the",
"incomming",
"request",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/server.go#L28-L33 |
139,210 | rveen/ogdl | ogdlrf/server.go | Serve | func (srv *Server) Serve() error {
if srv.Protocol == 1 {
return Serve1(srv.Host, srv.router(), srv.Timeout)
}
return Serve(srv.Host, srv.router(), srv.Timeout)
} | go | func (srv *Server) Serve() error {
if srv.Protocol == 1 {
return Serve1(srv.Host, srv.router(), srv.Timeout)
}
return Serve(srv.Host, srv.router(), srv.Timeout)
} | [
"func",
"(",
"srv",
"*",
"Server",
")",
"Serve",
"(",
")",
"error",
"{",
"if",
"srv",
".",
"Protocol",
"==",
"1",
"{",
"return",
"Serve1",
"(",
"srv",
".",
"Host",
",",
"srv",
".",
"router",
"(",
")",
",",
"srv",
".",
"Timeout",
")",
"\n",
"}",... | // Serve starts a remote function server. Handler functions should be set up with
// AddRoute. | [
"Serve",
"starts",
"a",
"remote",
"function",
"server",
".",
"Handler",
"functions",
"should",
"be",
"set",
"up",
"with",
"AddRoute",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/server.go#L54-L59 |
139,211 | rveen/ogdl | ogdlrf/server.go | Serve | func Serve(host string, handler Function, timeout int) error {
l, err := net.Listen("tcp", host)
if err != nil {
return err
}
defer l.Close()
for {
// Wait for a connection.
conn, err := l.Accept()
if err != nil {
log.Println(err)
continue
}
// Handle the connection in a new goroutine.
go pr... | go | func Serve(host string, handler Function, timeout int) error {
l, err := net.Listen("tcp", host)
if err != nil {
return err
}
defer l.Close()
for {
// Wait for a connection.
conn, err := l.Accept()
if err != nil {
log.Println(err)
continue
}
// Handle the connection in a new goroutine.
go pr... | [
"func",
"Serve",
"(",
"host",
"string",
",",
"handler",
"Function",
",",
"timeout",
"int",
")",
"error",
"{",
"l",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"host",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\... | // Serve starts a remote function server. Incomming requests should be handled
// by the given Function. This version of Serve doesn't work with AddRoute. | [
"Serve",
"starts",
"a",
"remote",
"function",
"server",
".",
"Incomming",
"requests",
"should",
"be",
"handled",
"by",
"the",
"given",
"Function",
".",
"This",
"version",
"of",
"Serve",
"doesn",
"t",
"work",
"with",
"AddRoute",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/server.go#L63-L82 |
139,212 | rveen/ogdl | ogdlrf/server.go | Serve1 | func Serve1(host string, handler Function, timeout int) error {
l, err := net.Listen("tcp", host)
if err != nil {
return err
}
for {
// Wait for a connection.
conn, err := l.Accept()
if err != nil {
log.Println(err)
continue
}
// Handle the connection in a new goroutine.
go process1(conn, han... | go | func Serve1(host string, handler Function, timeout int) error {
l, err := net.Listen("tcp", host)
if err != nil {
return err
}
for {
// Wait for a connection.
conn, err := l.Accept()
if err != nil {
log.Println(err)
continue
}
// Handle the connection in a new goroutine.
go process1(conn, han... | [
"func",
"Serve1",
"(",
"host",
"string",
",",
"handler",
"Function",
",",
"timeout",
"int",
")",
"error",
"{",
"l",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"host",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"... | // Serve1 starts a remote function server. Incomming requests should be handled
// by the given Function. This version of Serve doesn't work with AddRoute. | [
"Serve1",
"starts",
"a",
"remote",
"function",
"server",
".",
"Incomming",
"requests",
"should",
"be",
"handled",
"by",
"the",
"given",
"Function",
".",
"This",
"version",
"of",
"Serve",
"doesn",
"t",
"work",
"with",
"AddRoute",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/server.go#L86-L104 |
139,213 | rveen/ogdl | ogdlrf/server.go | process | func process(c net.Conn, handler Function, timeout int) {
defer c.Close()
b4 := make([]byte, 4)
log.Println("starting Server.process: connection accepted")
for {
// Each message has a 4 byte header, an integer indicating the length:
//
// message = LEN(uint32) BYTES
//
// Thus, first read 4 bytes ... | go | func process(c net.Conn, handler Function, timeout int) {
defer c.Close()
b4 := make([]byte, 4)
log.Println("starting Server.process: connection accepted")
for {
// Each message has a 4 byte header, an integer indicating the length:
//
// message = LEN(uint32) BYTES
//
// Thus, first read 4 bytes ... | [
"func",
"process",
"(",
"c",
"net",
".",
"Conn",
",",
"handler",
"Function",
",",
"timeout",
"int",
")",
"{",
"defer",
"c",
".",
"Close",
"(",
")",
"\n\n",
"b4",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n\n",
"log",
".",
"Println",
... | // process handles the request through the given handler. | [
"process",
"handles",
"the",
"request",
"through",
"the",
"given",
"handler",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/server.go#L107-L192 |
139,214 | rveen/ogdl | ogdlrf/server.go | process1 | func process1(c net.Conn, handler Function, timeout int) {
defer c.Close()
for {
// Set a time out (maximum time until next message)
c.SetReadDeadline(time.Now().Add(time.Second * time.Duration(timeout)))
// Read the incoming object
g := ogdl.FromBinaryReader(c)
if g == nil {
break
}
r := handle... | go | func process1(c net.Conn, handler Function, timeout int) {
defer c.Close()
for {
// Set a time out (maximum time until next message)
c.SetReadDeadline(time.Now().Add(time.Second * time.Duration(timeout)))
// Read the incoming object
g := ogdl.FromBinaryReader(c)
if g == nil {
break
}
r := handle... | [
"func",
"process1",
"(",
"c",
"net",
".",
"Conn",
",",
"handler",
"Function",
",",
"timeout",
"int",
")",
"{",
"defer",
"c",
".",
"Close",
"(",
")",
"\n\n",
"for",
"{",
"// Set a time out (maximum time until next message)",
"c",
".",
"SetReadDeadline",
"(",
... | // Old format, without the initial length indicator | [
"Old",
"format",
"without",
"the",
"initial",
"length",
"indicator"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/ogdlrf/server.go#L195-L226 |
139,215 | rveen/ogdl | eval.go | Eval | func (g *Graph) Eval(e *Graph) (interface{}, error) {
switch e.ThisString() {
case TypePath:
return g.evalPath(e)
case TypeExpression:
return g.evalExpression(e)
}
// A complex object that is not a path or expression: return as is.
if e.Len() != 0 {
return e, nil
}
// A constant: return in its normaliz... | go | func (g *Graph) Eval(e *Graph) (interface{}, error) {
switch e.ThisString() {
case TypePath:
return g.evalPath(e)
case TypeExpression:
return g.evalExpression(e)
}
// A complex object that is not a path or expression: return as is.
if e.Len() != 0 {
return e, nil
}
// A constant: return in its normaliz... | [
"func",
"(",
"g",
"*",
"Graph",
")",
"Eval",
"(",
"e",
"*",
"Graph",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"switch",
"e",
".",
"ThisString",
"(",
")",
"{",
"case",
"TypePath",
":",
"return",
"g",
".",
"evalPath",
"(",
"e",
")... | // import "fmt"
// Eval takes a parsed expression and evaluates it
// in the context of the current graph. | [
"import",
"fmt",
"Eval",
"takes",
"a",
"parsed",
"expression",
"and",
"evaluates",
"it",
"in",
"the",
"context",
"of",
"the",
"current",
"graph",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/eval.go#L11-L28 |
139,216 | rveen/ogdl | eval.go | evalBool | func (g *Graph) evalBool(e *Graph) bool {
i, err := g.Eval(e)
if err != nil {
return false
}
b, _ := _boolf(i)
return b
} | go | func (g *Graph) evalBool(e *Graph) bool {
i, err := g.Eval(e)
if err != nil {
return false
}
b, _ := _boolf(i)
return b
} | [
"func",
"(",
"g",
"*",
"Graph",
")",
"evalBool",
"(",
"e",
"*",
"Graph",
")",
"bool",
"{",
"i",
",",
"err",
":=",
"g",
".",
"Eval",
"(",
"e",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"b",
",",
"_",
":=",... | // EvalBool takes a parsed expression and evaluates it in the context of the
// current graph, and converts the result to a boolean. | [
"EvalBool",
"takes",
"a",
"parsed",
"expression",
"and",
"evaluates",
"it",
"in",
"the",
"context",
"of",
"the",
"current",
"graph",
"and",
"converts",
"the",
"result",
"to",
"a",
"boolean",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/eval.go#L32-L39 |
139,217 | rveen/ogdl | eval.go | assign | func (g *Graph) assign(p *Graph, v interface{}, op int) interface{} {
if op == '=' {
return g.set(p, v)
}
// if p doesn't exist, just set it to the value given
left, _ := g.getPath(p)
if left != nil {
return g.set(p, calc(left.Out[0].This, v, op))
}
switch op {
case '+':
return g.set(p, v)
case '-':
... | go | func (g *Graph) assign(p *Graph, v interface{}, op int) interface{} {
if op == '=' {
return g.set(p, v)
}
// if p doesn't exist, just set it to the value given
left, _ := g.getPath(p)
if left != nil {
return g.set(p, calc(left.Out[0].This, v, op))
}
switch op {
case '+':
return g.set(p, v)
case '-':
... | [
"func",
"(",
"g",
"*",
"Graph",
")",
"assign",
"(",
"p",
"*",
"Graph",
",",
"v",
"interface",
"{",
"}",
",",
"op",
"int",
")",
"interface",
"{",
"}",
"{",
"if",
"op",
"==",
"'='",
"{",
"return",
"g",
".",
"set",
"(",
"p",
",",
"v",
")",
"\n... | // assign modifies the context graph | [
"assign",
"modifies",
"the",
"context",
"graph"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/eval.go#L545-L571 |
139,218 | rveen/ogdl | block.go | tree | func (p *Parser) tree(ns int, types bool) {
for {
b, err := p.line(ns, types)
if !b || err != nil {
break
}
}
p.End()
} | go | func (p *Parser) tree(ns int, types bool) {
for {
b, err := p.line(ns, types)
if !b || err != nil {
break
}
}
p.End()
} | [
"func",
"(",
"p",
"*",
"Parser",
")",
"tree",
"(",
"ns",
"int",
",",
"types",
"bool",
")",
"{",
"for",
"{",
"b",
",",
"err",
":=",
"p",
".",
"line",
"(",
"ns",
",",
"types",
")",
"\n",
"if",
"!",
"b",
"||",
"err",
"!=",
"nil",
"{",
"break",... | // tree reads all lines with indentation >= ns | [
"tree",
"reads",
"all",
"lines",
"with",
"indentation",
">",
"=",
"ns"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/block.go#L45-L53 |
139,219 | rveen/ogdl | event.go | AddBytes | func (e *SimpleEventHandler) AddBytes(b []byte) {
e.items = append(e.items, b)
e.levels = append(e.levels, e.current)
} | go | func (e *SimpleEventHandler) AddBytes(b []byte) {
e.items = append(e.items, b)
e.levels = append(e.levels, e.current)
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"AddBytes",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"e",
".",
"items",
"=",
"append",
"(",
"e",
".",
"items",
",",
"b",
")",
"\n",
"e",
".",
"levels",
"=",
"append",
"(",
"e",
".",
"levels",
",",
... | // AddBytes creates a byte array node at the current level | [
"AddBytes",
"creates",
"a",
"byte",
"array",
"node",
"at",
"the",
"current",
"level"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L16-L19 |
139,220 | rveen/ogdl | event.go | Add | func (e *SimpleEventHandler) Add(s string) {
e.items = append(e.items, s)
e.levels = append(e.levels, e.current)
} | go | func (e *SimpleEventHandler) Add(s string) {
e.items = append(e.items, s)
e.levels = append(e.levels, e.current)
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"Add",
"(",
"s",
"string",
")",
"{",
"e",
".",
"items",
"=",
"append",
"(",
"e",
".",
"items",
",",
"s",
")",
"\n",
"e",
".",
"levels",
"=",
"append",
"(",
"e",
".",
"levels",
",",
"e",
".",
"... | // Add creates a string node at the current level. | [
"Add",
"creates",
"a",
"string",
"node",
"at",
"the",
"current",
"level",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L22-L25 |
139,221 | rveen/ogdl | event.go | AddItf | func (e *SimpleEventHandler) AddItf(i interface{}) {
e.items = append(e.items, i)
e.levels = append(e.levels, e.current)
} | go | func (e *SimpleEventHandler) AddItf(i interface{}) {
e.items = append(e.items, i)
e.levels = append(e.levels, e.current)
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"AddItf",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"e",
".",
"items",
"=",
"append",
"(",
"e",
".",
"items",
",",
"i",
")",
"\n",
"e",
".",
"levels",
"=",
"append",
"(",
"e",
".",
"levels",
",... | // AddItf creates a string node at the current level. | [
"AddItf",
"creates",
"a",
"string",
"node",
"at",
"the",
"current",
"level",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L28-L31 |
139,222 | rveen/ogdl | event.go | AddBytesAt | func (e *SimpleEventHandler) AddBytesAt(b []byte, lv int) {
e.items = append(e.items, b)
e.levels = append(e.levels, lv)
if e.max < lv {
e.max = lv
}
} | go | func (e *SimpleEventHandler) AddBytesAt(b []byte, lv int) {
e.items = append(e.items, b)
e.levels = append(e.levels, lv)
if e.max < lv {
e.max = lv
}
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"AddBytesAt",
"(",
"b",
"[",
"]",
"byte",
",",
"lv",
"int",
")",
"{",
"e",
".",
"items",
"=",
"append",
"(",
"e",
".",
"items",
",",
"b",
")",
"\n",
"e",
".",
"levels",
"=",
"append",
"(",
"e",
... | // AddBytesAt creates a byte array node at the specified level | [
"AddBytesAt",
"creates",
"a",
"byte",
"array",
"node",
"at",
"the",
"specified",
"level"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L34-L40 |
139,223 | rveen/ogdl | event.go | AddAt | func (e *SimpleEventHandler) AddAt(s string, lv int) {
e.items = append(e.items, s)
e.levels = append(e.levels, lv)
if e.max < lv {
e.max = lv
}
} | go | func (e *SimpleEventHandler) AddAt(s string, lv int) {
e.items = append(e.items, s)
e.levels = append(e.levels, lv)
if e.max < lv {
e.max = lv
}
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"AddAt",
"(",
"s",
"string",
",",
"lv",
"int",
")",
"{",
"e",
".",
"items",
"=",
"append",
"(",
"e",
".",
"items",
",",
"s",
")",
"\n",
"e",
".",
"levels",
"=",
"append",
"(",
"e",
".",
"levels"... | // AddAt creates a string node at the specified level. | [
"AddAt",
"creates",
"a",
"string",
"node",
"at",
"the",
"specified",
"level",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L43-L49 |
139,224 | rveen/ogdl | event.go | Delete | func (e *SimpleEventHandler) Delete() {
e.items = e.items[0 : len(e.items)-1]
e.levels = e.levels[0 : len(e.levels)-1]
} | go | func (e *SimpleEventHandler) Delete() {
e.items = e.items[0 : len(e.items)-1]
e.levels = e.levels[0 : len(e.levels)-1]
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"Delete",
"(",
")",
"{",
"e",
".",
"items",
"=",
"e",
".",
"items",
"[",
"0",
":",
"len",
"(",
"e",
".",
"items",
")",
"-",
"1",
"]",
"\n",
"e",
".",
"levels",
"=",
"e",
".",
"levels",
"[",
... | // Delete removes the last node added | [
"Delete",
"removes",
"the",
"last",
"node",
"added"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L52-L55 |
139,225 | rveen/ogdl | event.go | SetLevel | func (e *SimpleEventHandler) SetLevel(l int) {
e.current = l
if e.max < l {
e.max = l
}
} | go | func (e *SimpleEventHandler) SetLevel(l int) {
e.current = l
if e.max < l {
e.max = l
}
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"SetLevel",
"(",
"l",
"int",
")",
"{",
"e",
".",
"current",
"=",
"l",
"\n",
"if",
"e",
".",
"max",
"<",
"l",
"{",
"e",
".",
"max",
"=",
"l",
"\n",
"}",
"\n",
"}"
] | // SetLevel sets the current level | [
"SetLevel",
"sets",
"the",
"current",
"level"
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L63-L68 |
139,226 | rveen/ogdl | event.go | Inc | func (e *SimpleEventHandler) Inc() {
e.current++
if e.max < e.current {
e.max = e.current
}
} | go | func (e *SimpleEventHandler) Inc() {
e.current++
if e.max < e.current {
e.max = e.current
}
} | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"Inc",
"(",
")",
"{",
"e",
".",
"current",
"++",
"\n",
"if",
"e",
".",
"max",
"<",
"e",
".",
"current",
"{",
"e",
".",
"max",
"=",
"e",
".",
"current",
"\n",
"}",
"\n",
"}"
] | // Inc increments the current level by 1. | [
"Inc",
"increments",
"the",
"current",
"level",
"by",
"1",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L71-L76 |
139,227 | rveen/ogdl | event.go | Tree | func (e *SimpleEventHandler) Tree() *Graph {
g := make([]*Graph, e.max+2)
g[0] = New("_")
/*
println("ev.Tree", len(e.items), len(e.levels), e.max)
for i := 0; i < len(e.items); i++ {
fmt.Printf(" - %d %v\n", e.levels[i], e.items[i])
}
*/
for i := 0; i < len(e.items); i++ {
lv := e.levels[i] + 1
ite... | go | func (e *SimpleEventHandler) Tree() *Graph {
g := make([]*Graph, e.max+2)
g[0] = New("_")
/*
println("ev.Tree", len(e.items), len(e.levels), e.max)
for i := 0; i < len(e.items); i++ {
fmt.Printf(" - %d %v\n", e.levels[i], e.items[i])
}
*/
for i := 0; i < len(e.items); i++ {
lv := e.levels[i] + 1
ite... | [
"func",
"(",
"e",
"*",
"SimpleEventHandler",
")",
"Tree",
"(",
")",
"*",
"Graph",
"{",
"g",
":=",
"make",
"(",
"[",
"]",
"*",
"Graph",
",",
"e",
".",
"max",
"+",
"2",
")",
"\n",
"g",
"[",
"0",
"]",
"=",
"New",
"(",
"\"",
"\"",
")",
"\n",
... | // Tree returns the Graph object built from
// the events sent to this event handler.
// | [
"Tree",
"returns",
"the",
"Graph",
"object",
"built",
"from",
"the",
"events",
"sent",
"to",
"this",
"event",
"handler",
"."
] | 60b0e542a67492da26c19e680662b29786ef1ee3 | https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/event.go#L88-L109 |
139,228 | cloudflare/bm | bm.go | Expand | func (e *Expander) Expand(p []byte) (q []byte, err error) {
// This is done to capture the extreme case that an out of
// bounds error occurs in the expansion. This should never
// happen, but this protects against a corrupt compressed
// block. If this occurs then we return no data at all to
// prevent any bad d... | go | func (e *Expander) Expand(p []byte) (q []byte, err error) {
// This is done to capture the extreme case that an out of
// bounds error occurs in the expansion. This should never
// happen, but this protects against a corrupt compressed
// block. If this occurs then we return no data at all to
// prevent any bad d... | [
"func",
"(",
"e",
"*",
"Expander",
")",
"Expand",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"q",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"// This is done to capture the extreme case that an out of",
"// bounds error occurs in the expansion. This should never",
... | // Expand expands the compressed data into a buffer | [
"Expand",
"expands",
"the",
"compressed",
"data",
"into",
"a",
"buffer"
] | cf552e842b6ab45d3cd9b2529f935d49f9bc7370 | https://github.com/cloudflare/bm/blob/cf552e842b6ab45d3cd9b2529f935d49f9bc7370/bm.go#L472-L534 |
139,229 | hortonworks/gohadoop | hadoop_common/security/digestmd5.go | validateChallengeParameters | func validateChallengeParameters(challengeParams map[string]string) error {
var errString string
realm, exists := challengeParams["realm"]
if !exists || len(realm) == 0 {
errString += "missing or invalid realm. "
}
nonce, exists := challengeParams["nonce"]
if !exists || len(nonce) == 0 {
errString += "missi... | go | func validateChallengeParameters(challengeParams map[string]string) error {
var errString string
realm, exists := challengeParams["realm"]
if !exists || len(realm) == 0 {
errString += "missing or invalid realm. "
}
nonce, exists := challengeParams["nonce"]
if !exists || len(nonce) == 0 {
errString += "missi... | [
"func",
"validateChallengeParameters",
"(",
"challengeParams",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"var",
"errString",
"string",
"\n\n",
"realm",
",",
"exists",
":=",
"challengeParams",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"exists",
"||... | //we only support a very specific digest-md5 mechanism for the moment
//multiple realm, qop not supported | [
"we",
"only",
"support",
"a",
"very",
"specific",
"digest",
"-",
"md5",
"mechanism",
"for",
"the",
"moment",
"multiple",
"realm",
"qop",
"not",
"supported"
] | 4e92e1475b38a7c84eed25df0d04b98dfef30982 | https://github.com/hortonworks/gohadoop/blob/4e92e1475b38a7c84eed25df0d04b98dfef30982/hadoop_common/security/digestmd5.go#L46-L79 |
139,230 | hortonworks/gohadoop | hadoop_yarn/containermanagement_service.pb.go | DialContainerManagementProtocolService | func DialContainerManagementProtocolService(host string, port int) (ContainerManagementProtocolService, error) {
clientId, _ := uuid.NewV4()
ugi, _ := gohadoop.CreateSimpleUGIProto()
c := &hadoop_ipc_client.Client{ClientId: clientId, Ugi: ugi, ServerAddress: net.JoinHostPort(host, strconv.Itoa(port))}
return &Conta... | go | func DialContainerManagementProtocolService(host string, port int) (ContainerManagementProtocolService, error) {
clientId, _ := uuid.NewV4()
ugi, _ := gohadoop.CreateSimpleUGIProto()
c := &hadoop_ipc_client.Client{ClientId: clientId, Ugi: ugi, ServerAddress: net.JoinHostPort(host, strconv.Itoa(port))}
return &Conta... | [
"func",
"DialContainerManagementProtocolService",
"(",
"host",
"string",
",",
"port",
"int",
")",
"(",
"ContainerManagementProtocolService",
",",
"error",
")",
"{",
"clientId",
",",
"_",
":=",
"uuid",
".",
"NewV4",
"(",
")",
"\n",
"ugi",
",",
"_",
":=",
"goh... | // DialContainerManagementProtocolService connects to an ContainerManagementProtocolService at the specified network address. | [
"DialContainerManagementProtocolService",
"connects",
"to",
"an",
"ContainerManagementProtocolService",
"at",
"the",
"specified",
"network",
"address",
"."
] | 4e92e1475b38a7c84eed25df0d04b98dfef30982 | https://github.com/hortonworks/gohadoop/blob/4e92e1475b38a7c84eed25df0d04b98dfef30982/hadoop_yarn/containermanagement_service.pb.go#L50-L55 |
139,231 | hortonworks/gohadoop | hadoop_yarn/applicationclient_service.pb.go | DialApplicationClientProtocolService | func DialApplicationClientProtocolService(conf yarn_conf.YarnConfiguration) (ApplicationClientProtocolService, error) {
clientId, _ := uuid.NewV4()
ugi, _ := gohadoop.CreateSimpleUGIProto()
serverAddress, _ := conf.GetRMAddress()
c := &hadoop_ipc_client.Client{ClientId: clientId, Ugi: ugi, ServerAddress: serverAddr... | go | func DialApplicationClientProtocolService(conf yarn_conf.YarnConfiguration) (ApplicationClientProtocolService, error) {
clientId, _ := uuid.NewV4()
ugi, _ := gohadoop.CreateSimpleUGIProto()
serverAddress, _ := conf.GetRMAddress()
c := &hadoop_ipc_client.Client{ClientId: clientId, Ugi: ugi, ServerAddress: serverAddr... | [
"func",
"DialApplicationClientProtocolService",
"(",
"conf",
"yarn_conf",
".",
"YarnConfiguration",
")",
"(",
"ApplicationClientProtocolService",
",",
"error",
")",
"{",
"clientId",
",",
"_",
":=",
"uuid",
".",
"NewV4",
"(",
")",
"\n",
"ugi",
",",
"_",
":=",
"... | // DialApplicationClientProtocolService connects to an ApplicationClientProtocolService at the specified network address. | [
"DialApplicationClientProtocolService",
"connects",
"to",
"an",
"ApplicationClientProtocolService",
"at",
"the",
"specified",
"network",
"address",
"."
] | 4e92e1475b38a7c84eed25df0d04b98dfef30982 | https://github.com/hortonworks/gohadoop/blob/4e92e1475b38a7c84eed25df0d04b98dfef30982/hadoop_yarn/applicationclient_service.pb.go#L86-L92 |
139,232 | hortonworks/gohadoop | hadoop_yarn/yarn_client/am_rm_client_async.go | periodicAllocate | func (c *AMRMClientAsync) periodicAllocate() {
for {
select {
case <-c.stop:
log.Println("stop notification received. stopping allocate routine.")
return
default:
}
response, err := c.client.Allocate()
if err != nil {
log.Println("async allocate failed. terminating periodic allocate. error: ", e... | go | func (c *AMRMClientAsync) periodicAllocate() {
for {
select {
case <-c.stop:
log.Println("stop notification received. stopping allocate routine.")
return
default:
}
response, err := c.client.Allocate()
if err != nil {
log.Println("async allocate failed. terminating periodic allocate. error: ", e... | [
"func",
"(",
"c",
"*",
"AMRMClientAsync",
")",
"periodicAllocate",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"c",
".",
"stop",
":",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"default",
":",
"}",
"\n\n",
"respo... | //Periodically call the the Resource Manager with an allocate call | [
"Periodically",
"call",
"the",
"the",
"Resource",
"Manager",
"with",
"an",
"allocate",
"call"
] | 4e92e1475b38a7c84eed25df0d04b98dfef30982 | https://github.com/hortonworks/gohadoop/blob/4e92e1475b38a7c84eed25df0d04b98dfef30982/hadoop_yarn/yarn_client/am_rm_client_async.go#L50-L98 |
139,233 | xyproto/term | examples/repeat/main.go | Repeat | func Repeat() {
OUT:
for {
// Retrieve user input, with a prompt. Use ReadLn() for no prompt.
line := term.Ask("> ")
// Check if the user wants to quit
switch line {
case "quit", "end", "exit", "q":
break OUT
}
// Repeat what was just said
fmt.Println("You said: " + line)
}
} | go | func Repeat() {
OUT:
for {
// Retrieve user input, with a prompt. Use ReadLn() for no prompt.
line := term.Ask("> ")
// Check if the user wants to quit
switch line {
case "quit", "end", "exit", "q":
break OUT
}
// Repeat what was just said
fmt.Println("You said: " + line)
}
} | [
"func",
"Repeat",
"(",
")",
"{",
"OUT",
":",
"for",
"{",
"// Retrieve user input, with a prompt. Use ReadLn() for no prompt.",
"line",
":=",
"term",
".",
"Ask",
"(",
"\"",
"\"",
")",
"\n\n",
"// Check if the user wants to quit",
"switch",
"line",
"{",
"case",
"\"",
... | // Loop and echo the input until "quit" is typed | [
"Loop",
"and",
"echo",
"the",
"input",
"until",
"quit",
"is",
"typed"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/examples/repeat/main.go#L10-L25 |
139,234 | xyproto/term | curses.go | Write | func Write(x int, y int, text string, fg termbox.Attribute, bg termbox.Attribute) {
//runeCount := utf8.RuneCountInString(text)
pos := x
for _, r := range text {
termbox.SetCell(pos, y, r, fg, bg)
pos++
}
} | go | func Write(x int, y int, text string, fg termbox.Attribute, bg termbox.Attribute) {
//runeCount := utf8.RuneCountInString(text)
pos := x
for _, r := range text {
termbox.SetCell(pos, y, r, fg, bg)
pos++
}
} | [
"func",
"Write",
"(",
"x",
"int",
",",
"y",
"int",
",",
"text",
"string",
",",
"fg",
"termbox",
".",
"Attribute",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"{",
"//runeCount := utf8.RuneCountInString(text)",
"pos",
":=",
"x",
"\n",
"for",
"_",
",",
"r... | // Place text at the given x and y coordinate.
// fg is the foreground color, while bg is the background color. | [
"Place",
"text",
"at",
"the",
"given",
"x",
"and",
"y",
"coordinate",
".",
"fg",
"is",
"the",
"foreground",
"color",
"while",
"bg",
"is",
"the",
"background",
"color",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/curses.go#L23-L30 |
139,235 | xyproto/term | curses.go | WriteRune | func WriteRune(x int, y int, r rune, fg termbox.Attribute, bg termbox.Attribute) {
termbox.SetCell(x, y, r, fg, bg)
} | go | func WriteRune(x int, y int, r rune, fg termbox.Attribute, bg termbox.Attribute) {
termbox.SetCell(x, y, r, fg, bg)
} | [
"func",
"WriteRune",
"(",
"x",
"int",
",",
"y",
"int",
",",
"r",
"rune",
",",
"fg",
"termbox",
".",
"Attribute",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"{",
"termbox",
".",
"SetCell",
"(",
"x",
",",
"y",
",",
"r",
",",
"fg",
",",
"bg",
")... | // Place a rune at the given x and y coordinate.
// fg is the foreground color, while bg is the background color. | [
"Place",
"a",
"rune",
"at",
"the",
"given",
"x",
"and",
"y",
"coordinate",
".",
"fg",
"is",
"the",
"foreground",
"color",
"while",
"bg",
"is",
"the",
"background",
"color",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/curses.go#L34-L36 |
139,236 | xyproto/term | curses.go | Say | func Say(x int, y int, text string) {
pos := x
for _, r := range text {
termbox.SetCell(pos, y, r, TEXTCOLOR, BG)
pos++
}
} | go | func Say(x int, y int, text string) {
pos := x
for _, r := range text {
termbox.SetCell(pos, y, r, TEXTCOLOR, BG)
pos++
}
} | [
"func",
"Say",
"(",
"x",
"int",
",",
"y",
"int",
",",
"text",
"string",
")",
"{",
"pos",
":=",
"x",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"text",
"{",
"termbox",
".",
"SetCell",
"(",
"pos",
",",
"y",
",",
"r",
",",
"TEXTCOLOR",
",",
"BG"... | // Place text at the given x and y coordinate,
// using the default color scheme. | [
"Place",
"text",
"at",
"the",
"given",
"x",
"and",
"y",
"coordinate",
"using",
"the",
"default",
"color",
"scheme",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/curses.go#L40-L46 |
139,237 | xyproto/term | curses.go | WaitForKey | func WaitForKey() {
for {
e := PollEvent()
switch e.Type {
case termbox.EventKey:
switch e.Key {
case termbox.KeyEsc, termbox.KeyEnter, termbox.KeySpace:
return
}
}
}
} | go | func WaitForKey() {
for {
e := PollEvent()
switch e.Type {
case termbox.EventKey:
switch e.Key {
case termbox.KeyEsc, termbox.KeyEnter, termbox.KeySpace:
return
}
}
}
} | [
"func",
"WaitForKey",
"(",
")",
"{",
"for",
"{",
"e",
":=",
"PollEvent",
"(",
")",
"\n",
"switch",
"e",
".",
"Type",
"{",
"case",
"termbox",
".",
"EventKey",
":",
"switch",
"e",
".",
"Key",
"{",
"case",
"termbox",
".",
"KeyEsc",
",",
"termbox",
"."... | // Wait for Esc, Enter or Space to be pressed | [
"Wait",
"for",
"Esc",
"Enter",
"or",
"Space",
"to",
"be",
"pressed"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/curses.go#L85-L96 |
139,238 | xyproto/term | misc.go | ReadLn | func ReadLn() string {
reader := bufio.NewReader(os.Stdin)
line, err := reader.ReadString('\n')
if err != nil {
return ""
}
return line[:len(line)-1]
} | go | func ReadLn() string {
reader := bufio.NewReader(os.Stdin)
line, err := reader.ReadString('\n')
if err != nil {
return ""
}
return line[:len(line)-1]
} | [
"func",
"ReadLn",
"(",
")",
"string",
"{",
"reader",
":=",
"bufio",
".",
"NewReader",
"(",
"os",
".",
"Stdin",
")",
"\n",
"line",
",",
"err",
":=",
"reader",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",... | // Read a line from stdin | [
"Read",
"a",
"line",
"from",
"stdin"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/misc.go#L26-L33 |
139,239 | xyproto/term | misc.go | MapS | func MapS(f func(string) string, sl []string) (result []string) {
result = make([]string, len(sl))
for i := range sl {
result[i] = f(sl[i])
}
return result
} | go | func MapS(f func(string) string, sl []string) (result []string) {
result = make([]string, len(sl))
for i := range sl {
result[i] = f(sl[i])
}
return result
} | [
"func",
"MapS",
"(",
"f",
"func",
"(",
"string",
")",
"string",
",",
"sl",
"[",
"]",
"string",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"result",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"sl",
")",
")",
"\n",
"for",
"i"... | // Map a function on each element of a slice of strings | [
"Map",
"a",
"function",
"on",
"each",
"element",
"of",
"a",
"slice",
"of",
"strings"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/misc.go#L59-L65 |
139,240 | xyproto/term | misc.go | FilterS | func FilterS(f func(string) bool, sl []string) (result []string) {
result = make([]string, 0)
for i := range sl {
if f(sl[i]) {
result = append(result, sl[i])
}
}
return result
} | go | func FilterS(f func(string) bool, sl []string) (result []string) {
result = make([]string, 0)
for i := range sl {
if f(sl[i]) {
result = append(result, sl[i])
}
}
return result
} | [
"func",
"FilterS",
"(",
"f",
"func",
"(",
"string",
")",
"bool",
",",
"sl",
"[",
"]",
"string",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"result",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"i",
":=",
"range",
... | // Filter out all strings where the function does not return true | [
"Filter",
"out",
"all",
"strings",
"where",
"the",
"function",
"does",
"not",
"return",
"true"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/misc.go#L68-L76 |
139,241 | xyproto/term | misc.go | Repeat | func Repeat(text string, n int) string {
var sb strings.Builder
for i := 0; i < n; i++ {
sb.WriteString(text)
}
return sb.String()
} | go | func Repeat(text string, n int) string {
var sb strings.Builder
for i := 0; i < n; i++ {
sb.WriteString(text)
}
return sb.String()
} | [
"func",
"Repeat",
"(",
"text",
"string",
",",
"n",
"int",
")",
"string",
"{",
"var",
"sb",
"strings",
".",
"Builder",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"sb",
".",
"WriteString",
"(",
"text",
")",
"\n",
"}",
... | // Repeat a string n number of times | [
"Repeat",
"a",
"string",
"n",
"number",
"of",
"times"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/misc.go#L96-L102 |
139,242 | xyproto/term | misc.go | RepeatRune | func RepeatRune(r rune, n int) string {
var sb strings.Builder
for i := 0; i < n; i++ {
sb.WriteRune(r)
}
return sb.String()
} | go | func RepeatRune(r rune, n int) string {
var sb strings.Builder
for i := 0; i < n; i++ {
sb.WriteRune(r)
}
return sb.String()
} | [
"func",
"RepeatRune",
"(",
"r",
"rune",
",",
"n",
"int",
")",
"string",
"{",
"var",
"sb",
"strings",
".",
"Builder",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"sb",
".",
"WriteRune",
"(",
"r",
")",
"\n",
"}",
"\n",... | // Repeat a rune n number of times | [
"Repeat",
"a",
"rune",
"n",
"number",
"of",
"times"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/misc.go#L105-L111 |
139,243 | xyproto/term | term.go | Err | func (o *TextOutput) Err(msg string) {
if o.enabled {
fmt.Fprintf(os.Stderr, o.DarkRed(msg)+"\n")
}
} | go | func (o *TextOutput) Err(msg string) {
if o.enabled {
fmt.Fprintf(os.Stderr, o.DarkRed(msg)+"\n")
}
} | [
"func",
"(",
"o",
"*",
"TextOutput",
")",
"Err",
"(",
"msg",
"string",
")",
"{",
"if",
"o",
".",
"enabled",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"o",
".",
"DarkRed",
"(",
"msg",
")",
"+",
"\"",
"\\n",
"\"",
")",
"\n",
"}... | // Write an error message in red to stderr if output is enabled | [
"Write",
"an",
"error",
"message",
"in",
"red",
"to",
"stderr",
"if",
"output",
"is",
"enabled"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/term.go#L23-L27 |
139,244 | xyproto/term | term.go | ErrExit | func (o *TextOutput) ErrExit(msg string) {
o.Err(msg)
os.Exit(1)
} | go | func (o *TextOutput) ErrExit(msg string) {
o.Err(msg)
os.Exit(1)
} | [
"func",
"(",
"o",
"*",
"TextOutput",
")",
"ErrExit",
"(",
"msg",
"string",
")",
"{",
"o",
".",
"Err",
"(",
"msg",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
] | // Write an error message to stderr and quit with exit code 1 | [
"Write",
"an",
"error",
"message",
"to",
"stderr",
"and",
"quit",
"with",
"exit",
"code",
"1"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/term.go#L30-L33 |
139,245 | xyproto/term | term.go | Println | func (o *TextOutput) Println(msg string) {
if o.enabled {
fmt.Println(msg)
}
} | go | func (o *TextOutput) Println(msg string) {
if o.enabled {
fmt.Println(msg)
}
} | [
"func",
"(",
"o",
"*",
"TextOutput",
")",
"Println",
"(",
"msg",
"string",
")",
"{",
"if",
"o",
".",
"enabled",
"{",
"fmt",
".",
"Println",
"(",
"msg",
")",
"\n",
"}",
"\n",
"}"
] | // Write a message to stdout if output is enabled | [
"Write",
"a",
"message",
"to",
"stdout",
"if",
"output",
"is",
"enabled"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/term.go#L36-L40 |
139,246 | xyproto/term | term.go | colorOn | func (o *TextOutput) colorOn(num1 int, num2 int) string {
if o.color {
return fmt.Sprintf("\033[%d;%dm", num1, num2)
}
return ""
} | go | func (o *TextOutput) colorOn(num1 int, num2 int) string {
if o.color {
return fmt.Sprintf("\033[%d;%dm", num1, num2)
}
return ""
} | [
"func",
"(",
"o",
"*",
"TextOutput",
")",
"colorOn",
"(",
"num1",
"int",
",",
"num2",
"int",
")",
"string",
"{",
"if",
"o",
".",
"color",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\"",
",",
"num1",
",",
"num2",
")",
"\n",
"}",
... | // Changes the color state in the terminal emulator | [
"Changes",
"the",
"color",
"state",
"in",
"the",
"terminal",
"emulator"
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/term.go#L48-L53 |
139,247 | xyproto/term | guielements.go | DrawBox | func DrawBox(r *Box, extrude bool) *Rect {
x := r.frame.X
y := r.frame.Y
width := r.frame.W
height := r.frame.H
FG1 := BOXLIGHT
FG2 := BOXDARK
if !extrude {
FG1 = BOXDARK
FG2 = BOXLIGHT
}
WriteRune(x, y, TLCHAR, FG1, BOXBG)
Write(x+1, y, RepeatRune(HCHAR, width-2), FG1, BOXBG)
WriteRune(x+width-1, y, TRC... | go | func DrawBox(r *Box, extrude bool) *Rect {
x := r.frame.X
y := r.frame.Y
width := r.frame.W
height := r.frame.H
FG1 := BOXLIGHT
FG2 := BOXDARK
if !extrude {
FG1 = BOXDARK
FG2 = BOXLIGHT
}
WriteRune(x, y, TLCHAR, FG1, BOXBG)
Write(x+1, y, RepeatRune(HCHAR, width-2), FG1, BOXBG)
WriteRune(x+width-1, y, TRC... | [
"func",
"DrawBox",
"(",
"r",
"*",
"Box",
",",
"extrude",
"bool",
")",
"*",
"Rect",
"{",
"x",
":=",
"r",
".",
"frame",
".",
"X",
"\n",
"y",
":=",
"r",
".",
"frame",
".",
"Y",
"\n",
"width",
":=",
"r",
".",
"frame",
".",
"W",
"\n",
"height",
... | // Draw a box using ASCII graphics.
// The given Box struct defines the size and placement.
// If extrude is True, the box looks a bit more like it's sticking out. | [
"Draw",
"a",
"box",
"using",
"ASCII",
"graphics",
".",
"The",
"given",
"Box",
"struct",
"defines",
"the",
"size",
"and",
"placement",
".",
"If",
"extrude",
"is",
"True",
"the",
"box",
"looks",
"a",
"bit",
"more",
"like",
"it",
"s",
"sticking",
"out",
"... | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/guielements.go#L11-L34 |
139,248 | xyproto/term | guielements.go | DrawList | func DrawList(r *Box, items []string, selected int) {
for i, s := range items {
color := LISTTEXT
if i == selected {
color = LISTFOCUS
}
Write(r.frame.X, r.frame.Y+i, s, color, BOXBG)
}
} | go | func DrawList(r *Box, items []string, selected int) {
for i, s := range items {
color := LISTTEXT
if i == selected {
color = LISTFOCUS
}
Write(r.frame.X, r.frame.Y+i, s, color, BOXBG)
}
} | [
"func",
"DrawList",
"(",
"r",
"*",
"Box",
",",
"items",
"[",
"]",
"string",
",",
"selected",
"int",
")",
"{",
"for",
"i",
",",
"s",
":=",
"range",
"items",
"{",
"color",
":=",
"LISTTEXT",
"\n",
"if",
"i",
"==",
"selected",
"{",
"color",
"=",
"LIS... | // Draw a list widget. Takes a Box struct for the size and position.
// Takes a list of strings to be listed and an int that represents
// which item is currently selected. Does not scroll or wrap. | [
"Draw",
"a",
"list",
"widget",
".",
"Takes",
"a",
"Box",
"struct",
"for",
"the",
"size",
"and",
"position",
".",
"Takes",
"a",
"list",
"of",
"strings",
"to",
"be",
"listed",
"and",
"an",
"int",
"that",
"represents",
"which",
"item",
"is",
"currently",
... | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/guielements.go#L39-L47 |
139,249 | xyproto/term | guielements.go | DrawButton | func DrawButton(x, y int, text string, active bool) {
color := BUTTONTEXT
if active {
color = BUTTONFOCUS
}
Write(x, y, "< ", color, BG)
Write(x+3, y, text, color, BG)
Write(x+3+len(text), y, " >", color, BG)
} | go | func DrawButton(x, y int, text string, active bool) {
color := BUTTONTEXT
if active {
color = BUTTONFOCUS
}
Write(x, y, "< ", color, BG)
Write(x+3, y, text, color, BG)
Write(x+3+len(text), y, " >", color, BG)
} | [
"func",
"DrawButton",
"(",
"x",
",",
"y",
"int",
",",
"text",
"string",
",",
"active",
"bool",
")",
"{",
"color",
":=",
"BUTTONTEXT",
"\n",
"if",
"active",
"{",
"color",
"=",
"BUTTONFOCUS",
"\n",
"}",
"\n",
"Write",
"(",
"x",
",",
"y",
",",
"\"",
... | // Draws a button widget at the given placement,
// with the given text. If active is False,
// it will look more "grayed out". | [
"Draws",
"a",
"button",
"widget",
"at",
"the",
"given",
"placement",
"with",
"the",
"given",
"text",
".",
"If",
"active",
"is",
"False",
"it",
"will",
"look",
"more",
"grayed",
"out",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/guielements.go#L52-L60 |
139,250 | xyproto/term | guielements.go | DrawAsciiArt | func DrawAsciiArt(x, y int, text string) int {
var i int
for i, line := range Splitlines(text) {
Write(x, y+i, line, TEXTCOLOR, BOXBG)
}
return y + i
} | go | func DrawAsciiArt(x, y int, text string) int {
var i int
for i, line := range Splitlines(text) {
Write(x, y+i, line, TEXTCOLOR, BOXBG)
}
return y + i
} | [
"func",
"DrawAsciiArt",
"(",
"x",
",",
"y",
"int",
",",
"text",
"string",
")",
"int",
"{",
"var",
"i",
"int",
"\n",
"for",
"i",
",",
"line",
":=",
"range",
"Splitlines",
"(",
"text",
")",
"{",
"Write",
"(",
"x",
",",
"y",
"+",
"i",
",",
"line",... | // Outputs a multiline string at the given coordinates.
// Uses the box background color.
// Returns the final y coordinate after drawing. | [
"Outputs",
"a",
"multiline",
"string",
"at",
"the",
"given",
"coordinates",
".",
"Uses",
"the",
"box",
"background",
"color",
".",
"Returns",
"the",
"final",
"y",
"coordinate",
"after",
"drawing",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/guielements.go#L65-L71 |
139,251 | xyproto/term | guielements.go | DrawRaw | func DrawRaw(x, y int, text string) int {
var i int
for i, line := range Splitlines(text) {
Write(x, y+i, line, TEXTCOLOR, BG)
}
return y + i
} | go | func DrawRaw(x, y int, text string) int {
var i int
for i, line := range Splitlines(text) {
Write(x, y+i, line, TEXTCOLOR, BG)
}
return y + i
} | [
"func",
"DrawRaw",
"(",
"x",
",",
"y",
"int",
",",
"text",
"string",
")",
"int",
"{",
"var",
"i",
"int",
"\n",
"for",
"i",
",",
"line",
":=",
"range",
"Splitlines",
"(",
"text",
")",
"{",
"Write",
"(",
"x",
",",
"y",
"+",
"i",
",",
"line",
",... | // Outputs a multiline string at the given coordinates.
// Uses the default background color.
// Returns the final y coordinate after drawing. | [
"Outputs",
"a",
"multiline",
"string",
"at",
"the",
"given",
"coordinates",
".",
"Uses",
"the",
"default",
"background",
"color",
".",
"Returns",
"the",
"final",
"y",
"coordinate",
"after",
"drawing",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/guielements.go#L76-L82 |
139,252 | xyproto/term | boxes.go | Center | func (b *Box) Center(container *Box) {
widthleftover := container.inner.W - b.frame.W
heightleftover := container.inner.H - b.frame.H
b.frame.X = container.inner.X + widthleftover/2
b.frame.Y = container.inner.Y + heightleftover/2
} | go | func (b *Box) Center(container *Box) {
widthleftover := container.inner.W - b.frame.W
heightleftover := container.inner.H - b.frame.H
b.frame.X = container.inner.X + widthleftover/2
b.frame.Y = container.inner.Y + heightleftover/2
} | [
"func",
"(",
"b",
"*",
"Box",
")",
"Center",
"(",
"container",
"*",
"Box",
")",
"{",
"widthleftover",
":=",
"container",
".",
"inner",
".",
"W",
"-",
"b",
".",
"frame",
".",
"W",
"\n",
"heightleftover",
":=",
"container",
".",
"inner",
".",
"H",
"-... | // Place a Box at the center of the given container. | [
"Place",
"a",
"Box",
"at",
"the",
"center",
"of",
"the",
"given",
"container",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/boxes.go#L36-L41 |
139,253 | xyproto/term | boxes.go | FillWithMargins | func (b *Box) FillWithMargins(container *Box, margins int) {
b.Fill(container)
b.frame.X += margins
b.frame.Y += margins
b.frame.W -= margins * 2
b.frame.H -= margins * 2
} | go | func (b *Box) FillWithMargins(container *Box, margins int) {
b.Fill(container)
b.frame.X += margins
b.frame.Y += margins
b.frame.W -= margins * 2
b.frame.H -= margins * 2
} | [
"func",
"(",
"b",
"*",
"Box",
")",
"FillWithMargins",
"(",
"container",
"*",
"Box",
",",
"margins",
"int",
")",
"{",
"b",
".",
"Fill",
"(",
"container",
")",
"\n",
"b",
".",
"frame",
".",
"X",
"+=",
"margins",
"\n",
"b",
".",
"frame",
".",
"Y",
... | // Place a Box inside a given container, with the given margins.
// Margins are given in number of characters. | [
"Place",
"a",
"Box",
"inside",
"a",
"given",
"container",
"with",
"the",
"given",
"margins",
".",
"Margins",
"are",
"given",
"in",
"number",
"of",
"characters",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/boxes.go#L53-L59 |
139,254 | xyproto/term | boxes.go | FillWithPercentageMargins | func (b *Box) FillWithPercentageMargins(container *Box, horizmarginp float32, vertmarginp float32) {
horizmargin := int(float32(container.inner.W) * horizmarginp)
vertmargin := int(float32(container.inner.H) * vertmarginp)
b.Fill(container)
b.frame.X += horizmargin
b.frame.Y += vertmargin
b.frame.W -= horizmargin... | go | func (b *Box) FillWithPercentageMargins(container *Box, horizmarginp float32, vertmarginp float32) {
horizmargin := int(float32(container.inner.W) * horizmarginp)
vertmargin := int(float32(container.inner.H) * vertmarginp)
b.Fill(container)
b.frame.X += horizmargin
b.frame.Y += vertmargin
b.frame.W -= horizmargin... | [
"func",
"(",
"b",
"*",
"Box",
")",
"FillWithPercentageMargins",
"(",
"container",
"*",
"Box",
",",
"horizmarginp",
"float32",
",",
"vertmarginp",
"float32",
")",
"{",
"horizmargin",
":=",
"int",
"(",
"float32",
"(",
"container",
".",
"inner",
".",
"W",
")"... | // Place a Box inside a given container, using the given percentage wise ratios.
// horizmarginp can for example be 0.1 for a 10% horizontal margin around
// the inner box. vertmarginp works similarly, but for the vertical margins. | [
"Place",
"a",
"Box",
"inside",
"a",
"given",
"container",
"using",
"the",
"given",
"percentage",
"wise",
"ratios",
".",
"horizmarginp",
"can",
"for",
"example",
"be",
"0",
".",
"1",
"for",
"a",
"10%",
"horizontal",
"margin",
"around",
"the",
"inner",
"box"... | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/boxes.go#L64-L72 |
139,255 | xyproto/term | boxes.go | GetContentPos | func (b *Box) GetContentPos() (int, int) {
return b.inner.X, b.inner.Y
} | go | func (b *Box) GetContentPos() (int, int) {
return b.inner.X, b.inner.Y
} | [
"func",
"(",
"b",
"*",
"Box",
")",
"GetContentPos",
"(",
")",
"(",
"int",
",",
"int",
")",
"{",
"return",
"b",
".",
"inner",
".",
"X",
",",
"b",
".",
"inner",
".",
"Y",
"\n",
"}"
] | // Retrieves the position of the inner rectangle. | [
"Retrieves",
"the",
"position",
"of",
"the",
"inner",
"rectangle",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/boxes.go#L75-L77 |
139,256 | xyproto/term | boxes.go | Place | func (b *Box) Place(container *Box) {
b.frame.X = container.inner.X
b.frame.Y = container.inner.Y
} | go | func (b *Box) Place(container *Box) {
b.frame.X = container.inner.X
b.frame.Y = container.inner.Y
} | [
"func",
"(",
"b",
"*",
"Box",
")",
"Place",
"(",
"container",
"*",
"Box",
")",
"{",
"b",
".",
"frame",
".",
"X",
"=",
"container",
".",
"inner",
".",
"X",
"\n",
"b",
".",
"frame",
".",
"Y",
"=",
"container",
".",
"inner",
".",
"Y",
"\n",
"}"
... | // Place a Box within the given container. | [
"Place",
"a",
"Box",
"within",
"the",
"given",
"container",
"."
] | 28a7b668c67eafc39c1cb77bd1a397e00d80dd95 | https://github.com/xyproto/term/blob/28a7b668c67eafc39c1cb77bd1a397e00d80dd95/boxes.go#L110-L113 |
139,257 | luizbafilho/fusis | fusis/operations.go | GetService | func (b *FusisBalancer) GetService(name string) (*types.Service, error) {
return b.store.GetService(name)
} | go | func (b *FusisBalancer) GetService(name string) (*types.Service, error) {
return b.store.GetService(name)
} | [
"func",
"(",
"b",
"*",
"FusisBalancer",
")",
"GetService",
"(",
"name",
"string",
")",
"(",
"*",
"types",
".",
"Service",
",",
"error",
")",
"{",
"return",
"b",
".",
"store",
".",
"GetService",
"(",
"name",
")",
"\n",
"}"
] | //GetService get a service | [
"GetService",
"get",
"a",
"service"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/fusis/operations.go#L15-L17 |
139,258 | luizbafilho/fusis | fusis/balancer.go | cleanup | func (b *FusisBalancer) cleanup() error {
b.flushVips()
if out, err := exec.Command("ipvsadm", "--clear").CombinedOutput(); err != nil {
log.Fatal(fmt.Errorf("Running ipvsadm --clear failed with message: `%s`, error: %v", strings.TrimSpace(string(out)), err))
}
return nil
} | go | func (b *FusisBalancer) cleanup() error {
b.flushVips()
if out, err := exec.Command("ipvsadm", "--clear").CombinedOutput(); err != nil {
log.Fatal(fmt.Errorf("Running ipvsadm --clear failed with message: `%s`, error: %v", strings.TrimSpace(string(out)), err))
}
return nil
} | [
"func",
"(",
"b",
"*",
"FusisBalancer",
")",
"cleanup",
"(",
")",
"error",
"{",
"b",
".",
"flushVips",
"(",
")",
"\n\n",
"if",
"out",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"CombinedOutput",
"(",
")"... | // Utility method to cleanup state for tests | [
"Utility",
"method",
"to",
"cleanup",
"state",
"for",
"tests"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/fusis/balancer.go#L290-L298 |
139,259 | luizbafilho/fusis | net/net.go | AddIp | func AddIp(ip, iface string) error {
link, err := netlink.LinkByName(iface)
if err != nil {
return err
}
addr, err := netlink.ParseAddr(ip)
if err != nil {
return err
}
return netlink.AddrAdd(link, addr)
} | go | func AddIp(ip, iface string) error {
link, err := netlink.LinkByName(iface)
if err != nil {
return err
}
addr, err := netlink.ParseAddr(ip)
if err != nil {
return err
}
return netlink.AddrAdd(link, addr)
} | [
"func",
"AddIp",
"(",
"ip",
",",
"iface",
"string",
")",
"error",
"{",
"link",
",",
"err",
":=",
"netlink",
".",
"LinkByName",
"(",
"iface",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"addr",
",",
"err",
":=",
"... | //AddIp it receives a CIDR Address and add it to the given interface | [
"AddIp",
"it",
"receives",
"a",
"CIDR",
"Address",
"and",
"add",
"it",
"to",
"the",
"given",
"interface"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/net/net.go#L13-L25 |
139,260 | luizbafilho/fusis | ipam/ipam.go | New | func New(state state.State, config *config.BalancerConfig) (Allocator, error) {
var rangeCursor *ipaddr.Cursor
var err error
ranges := strings.Join(config.Ipam.Ranges, ",")
if ranges != "" {
rangeCursor, err = ipaddr.Parse(ranges)
if err != nil {
return nil, errors.Wrap(err, "error parsing IPAM ranges")
}... | go | func New(state state.State, config *config.BalancerConfig) (Allocator, error) {
var rangeCursor *ipaddr.Cursor
var err error
ranges := strings.Join(config.Ipam.Ranges, ",")
if ranges != "" {
rangeCursor, err = ipaddr.Parse(ranges)
if err != nil {
return nil, errors.Wrap(err, "error parsing IPAM ranges")
}... | [
"func",
"New",
"(",
"state",
"state",
".",
"State",
",",
"config",
"*",
"config",
".",
"BalancerConfig",
")",
"(",
"Allocator",
",",
"error",
")",
"{",
"var",
"rangeCursor",
"*",
"ipaddr",
".",
"Cursor",
"\n",
"var",
"err",
"error",
"\n\n",
"ranges",
"... | //Init initilizes ipam module | [
"Init",
"initilizes",
"ipam",
"module"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/ipam/ipam.go#L29-L42 |
139,261 | luizbafilho/fusis | ipam/ipam.go | AllocateVIP | func (i *Ipam) AllocateVIP(s *types.Service) error {
if i.rangeCursor == nil {
return ErrNoVipAvailable
}
for pos := i.rangeCursor.Next(); pos != nil; pos = i.rangeCursor.Next() {
//TODO: make it compatible if IPv6
// Verifies if it is a base IP address. example: 10.0.100.0; 192.168.1.0
if pos.IP.To4()[3] =... | go | func (i *Ipam) AllocateVIP(s *types.Service) error {
if i.rangeCursor == nil {
return ErrNoVipAvailable
}
for pos := i.rangeCursor.Next(); pos != nil; pos = i.rangeCursor.Next() {
//TODO: make it compatible if IPv6
// Verifies if it is a base IP address. example: 10.0.100.0; 192.168.1.0
if pos.IP.To4()[3] =... | [
"func",
"(",
"i",
"*",
"Ipam",
")",
"AllocateVIP",
"(",
"s",
"*",
"types",
".",
"Service",
")",
"error",
"{",
"if",
"i",
".",
"rangeCursor",
"==",
"nil",
"{",
"return",
"ErrNoVipAvailable",
"\n",
"}",
"\n\n",
"for",
"pos",
":=",
"i",
".",
"rangeCurso... | //Allocate allocates a new avaliable ip | [
"Allocate",
"allocates",
"a",
"new",
"avaliable",
"ip"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/ipam/ipam.go#L45-L67 |
139,262 | luizbafilho/fusis | state/state.go | New | func New() (State, error) {
state := &FusisState{
services: Services{},
destinations: Destinations{},
}
return state, nil
} | go | func New() (State, error) {
state := &FusisState{
services: Services{},
destinations: Destinations{},
}
return state, nil
} | [
"func",
"New",
"(",
")",
"(",
"State",
",",
"error",
")",
"{",
"state",
":=",
"&",
"FusisState",
"{",
"services",
":",
"Services",
"{",
"}",
",",
"destinations",
":",
"Destinations",
"{",
"}",
",",
"}",
"\n\n",
"return",
"state",
",",
"nil",
"\n",
... | // New creates a new Engine | [
"New",
"creates",
"a",
"new",
"Engine"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/state/state.go#L40-L47 |
139,263 | luizbafilho/fusis | ipvs/ipvs.go | New | func New() (*Ipvs, error) {
handler, err := ipvs.New("")
if err != nil {
return nil, fmt.Errorf("[ipvs] Initialisation failed: %v", err)
}
if err := handler.Flush(); err != nil {
return nil, fmt.Errorf("[ipvs] Flushing table failed: %v", err)
}
return &Ipvs{
handler: handler,
}, nil
} | go | func New() (*Ipvs, error) {
handler, err := ipvs.New("")
if err != nil {
return nil, fmt.Errorf("[ipvs] Initialisation failed: %v", err)
}
if err := handler.Flush(); err != nil {
return nil, fmt.Errorf("[ipvs] Flushing table failed: %v", err)
}
return &Ipvs{
handler: handler,
}, nil
} | [
"func",
"New",
"(",
")",
"(",
"*",
"Ipvs",
",",
"error",
")",
"{",
"handler",
",",
"err",
":=",
"ipvs",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
... | //New creates a new ipvs struct and flushes the IPVS Table | [
"New",
"creates",
"a",
"new",
"ipvs",
"struct",
"and",
"flushes",
"the",
"IPVS",
"Table"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/ipvs/ipvs.go#L30-L43 |
139,264 | luizbafilho/fusis | ipvs/ipvs.go | Sync | func (ipvs *Ipvs) Sync(state state.State) error {
start := time.Now()
defer func() {
log.Debugf("[ipvs] Sync took %v", time.Since(start))
}()
ipvs.Lock()
defer ipvs.Unlock()
log.Debug("[ipvs] Syncing")
stateSet := ipvs.getStateServicesSet(state)
currentSet, err := ipvs.getCurrentServicesSet()
if err != nil... | go | func (ipvs *Ipvs) Sync(state state.State) error {
start := time.Now()
defer func() {
log.Debugf("[ipvs] Sync took %v", time.Since(start))
}()
ipvs.Lock()
defer ipvs.Unlock()
log.Debug("[ipvs] Syncing")
stateSet := ipvs.getStateServicesSet(state)
currentSet, err := ipvs.getCurrentServicesSet()
if err != nil... | [
"func",
"(",
"ipvs",
"*",
"Ipvs",
")",
"Sync",
"(",
"state",
"state",
".",
"State",
")",
"error",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"time",
".",
... | // Sync syncs all ipvs rules present in state to kernel | [
"Sync",
"syncs",
"all",
"ipvs",
"rules",
"present",
"in",
"state",
"to",
"kernel"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/ipvs/ipvs.go#L46-L94 |
139,265 | luizbafilho/fusis | iptables/iptables.go | Sync | func (i IptablesMngr) Sync(s state.State) error {
start := time.Now()
defer func() {
log.Debugf("[iptables ] Sync took %v", time.Since(start))
}()
log.Debug("[iptables] Syncing")
stateSet, err := i.getStateRulesSet(s)
if err != nil {
return err
}
kernelSet, err := i.getKernelRulesSet()
if err != nil {
... | go | func (i IptablesMngr) Sync(s state.State) error {
start := time.Now()
defer func() {
log.Debugf("[iptables ] Sync took %v", time.Since(start))
}()
log.Debug("[iptables] Syncing")
stateSet, err := i.getStateRulesSet(s)
if err != nil {
return err
}
kernelSet, err := i.getKernelRulesSet()
if err != nil {
... | [
"func",
"(",
"i",
"IptablesMngr",
")",
"Sync",
"(",
"s",
"state",
".",
"State",
")",
"error",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"time",
".",
"Sinc... | // Sync syncs all iptables rules | [
"Sync",
"syncs",
"all",
"iptables",
"rules"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/iptables/iptables.go#L80-L122 |
139,266 | luizbafilho/fusis | store/store.go | AddService | func (s *FusisStore) AddService(svc *types.Service) error {
svcKey := s.key("services", svc.GetId())
ipvsKey := s.key("ipvs-ids", "services", svc.IpvsId())
// Validating service
if err := s.validateService(svc); err != nil {
return err
}
value, err := json.Marshal(svc)
if err != nil {
return errors.Wrapf(er... | go | func (s *FusisStore) AddService(svc *types.Service) error {
svcKey := s.key("services", svc.GetId())
ipvsKey := s.key("ipvs-ids", "services", svc.IpvsId())
// Validating service
if err := s.validateService(svc); err != nil {
return err
}
value, err := json.Marshal(svc)
if err != nil {
return errors.Wrapf(er... | [
"func",
"(",
"s",
"*",
"FusisStore",
")",
"AddService",
"(",
"svc",
"*",
"types",
".",
"Service",
")",
"error",
"{",
"svcKey",
":=",
"s",
".",
"key",
"(",
"\"",
"\"",
",",
"svc",
".",
"GetId",
"(",
")",
")",
"\n",
"ipvsKey",
":=",
"s",
".",
"ke... | //
// AddService adds a new services to store. It validates the name
// uniqueness and the IPVS uniqueness by saving the IPVS key
// in the store, which consists in a combination of address, port
// and protocol. | [
"AddService",
"adds",
"a",
"new",
"services",
"to",
"store",
".",
"It",
"validates",
"the",
"name",
"uniqueness",
"and",
"the",
"IPVS",
"uniqueness",
"by",
"saving",
"the",
"IPVS",
"key",
"in",
"the",
"store",
"which",
"consists",
"in",
"a",
"combination",
... | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/store/store.go#L227-L260 |
139,267 | luizbafilho/fusis | api/api.go | Serve | func (as ApiService) Serve() {
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
host := os.Getenv("HOST")
if host == "" {
host = "0.0.0.0"
}
address := host + ":" + port
// Start server
as.echo.Logger.Fatal(as.echo.Start(address))
} | go | func (as ApiService) Serve() {
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
host := os.Getenv("HOST")
if host == "" {
host = "0.0.0.0"
}
address := host + ":" + port
// Start server
as.echo.Logger.Fatal(as.echo.Start(address))
} | [
"func",
"(",
"as",
"ApiService",
")",
"Serve",
"(",
")",
"{",
"port",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"port",
"==",
"\"",
"\"",
"{",
"port",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"host",
":=",
"os",
".",
"Getenv",
"... | // Serve starts the api.
// Binds IP using HOST env or 0.0.0.0
// Binds to port using PORT env or 8000 | [
"Serve",
"starts",
"the",
"api",
".",
"Binds",
"IP",
"using",
"HOST",
"env",
"or",
"0",
".",
"0",
".",
"0",
".",
"0",
"Binds",
"to",
"port",
"using",
"PORT",
"env",
"or",
"8000"
] | 22c38b193875a17eeeaf1fd1efd40698ed5ad424 | https://github.com/luizbafilho/fusis/blob/22c38b193875a17eeeaf1fd1efd40698ed5ad424/api/api.go#L53-L68 |
139,268 | jeevatkm/go-model | model.go | AddConversion | func AddConversion(in interface{}, out interface{}, converter Converter) {
srcType := extractType(in)
targetType := extractType(out)
AddConversionByType(srcType, targetType, converter)
} | go | func AddConversion(in interface{}, out interface{}, converter Converter) {
srcType := extractType(in)
targetType := extractType(out)
AddConversionByType(srcType, targetType, converter)
} | [
"func",
"AddConversion",
"(",
"in",
"interface",
"{",
"}",
",",
"out",
"interface",
"{",
"}",
",",
"converter",
"Converter",
")",
"{",
"srcType",
":=",
"extractType",
"(",
"in",
")",
"\n",
"targetType",
":=",
"extractType",
"(",
"out",
")",
"\n",
"AddCon... | // AddConversion mothod allows registering a custom `Converter` into the global `converterMap`
// by supplying pointers of the target types. | [
"AddConversion",
"mothod",
"allows",
"registering",
"a",
"custom",
"Converter",
"into",
"the",
"global",
"converterMap",
"by",
"supplying",
"pointers",
"of",
"the",
"target",
"types",
"."
] | da0e6703b9dcc406eb59261cee520054cf6e22e0 | https://github.com/jeevatkm/go-model/blob/da0e6703b9dcc406eb59261cee520054cf6e22e0/model.go#L94-L98 |
139,269 | jeevatkm/go-model | model.go | AddConversionByType | func AddConversionByType(srcType reflect.Type, targetType reflect.Type, converter Converter) {
if _, ok := converterMap[srcType]; !ok {
converterMap[srcType] = map[reflect.Type]Converter{}
}
converterMap[srcType][targetType] = converter
} | go | func AddConversionByType(srcType reflect.Type, targetType reflect.Type, converter Converter) {
if _, ok := converterMap[srcType]; !ok {
converterMap[srcType] = map[reflect.Type]Converter{}
}
converterMap[srcType][targetType] = converter
} | [
"func",
"AddConversionByType",
"(",
"srcType",
"reflect",
".",
"Type",
",",
"targetType",
"reflect",
".",
"Type",
",",
"converter",
"Converter",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"converterMap",
"[",
"srcType",
"]",
";",
"!",
"ok",
"{",
"converterMap",... | // AddConversionByType allows registering a custom `Converter` into golbal `converterMap` by types. | [
"AddConversionByType",
"allows",
"registering",
"a",
"custom",
"Converter",
"into",
"golbal",
"converterMap",
"by",
"types",
"."
] | da0e6703b9dcc406eb59261cee520054cf6e22e0 | https://github.com/jeevatkm/go-model/blob/da0e6703b9dcc406eb59261cee520054cf6e22e0/model.go#L101-L106 |
139,270 | jeevatkm/go-model | model.go | RemoveConversion | func RemoveConversion(in interface{}, out interface{}) {
srcType := extractType(in)
targetType := extractType(out)
if _, ok := converterMap[srcType]; !ok {
return
}
if _, ok := converterMap[srcType][targetType]; !ok {
return
}
delete(converterMap[srcType], targetType)
} | go | func RemoveConversion(in interface{}, out interface{}) {
srcType := extractType(in)
targetType := extractType(out)
if _, ok := converterMap[srcType]; !ok {
return
}
if _, ok := converterMap[srcType][targetType]; !ok {
return
}
delete(converterMap[srcType], targetType)
} | [
"func",
"RemoveConversion",
"(",
"in",
"interface",
"{",
"}",
",",
"out",
"interface",
"{",
"}",
")",
"{",
"srcType",
":=",
"extractType",
"(",
"in",
")",
"\n",
"targetType",
":=",
"extractType",
"(",
"out",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"co... | // RemoveConversion registered conversions | [
"RemoveConversion",
"registered",
"conversions"
] | da0e6703b9dcc406eb59261cee520054cf6e22e0 | https://github.com/jeevatkm/go-model/blob/da0e6703b9dcc406eb59261cee520054cf6e22e0/model.go#L109-L119 |
139,271 | jeevatkm/go-model | model.go | init | func init() {
noTraverseTypeList = map[reflect.Type]bool{}
converterMap = map[reflect.Type]map[reflect.Type]Converter{}
// Default NoTraverseTypeList
// --------------------------
// Auto No Traverse struct list for not traversing Deep Level
// However, field value will be evaluated/processed by go-model library... | go | func init() {
noTraverseTypeList = map[reflect.Type]bool{}
converterMap = map[reflect.Type]map[reflect.Type]Converter{}
// Default NoTraverseTypeList
// --------------------------
// Auto No Traverse struct list for not traversing Deep Level
// However, field value will be evaluated/processed by go-model library... | [
"func",
"init",
"(",
")",
"{",
"noTraverseTypeList",
"=",
"map",
"[",
"reflect",
".",
"Type",
"]",
"bool",
"{",
"}",
"\n",
"converterMap",
"=",
"map",
"[",
"reflect",
".",
"Type",
"]",
"map",
"[",
"reflect",
".",
"Type",
"]",
"Converter",
"{",
"}",
... | //
// go-model init
// | [
"go",
"-",
"model",
"init"
] | da0e6703b9dcc406eb59261cee520054cf6e22e0 | https://github.com/jeevatkm/go-model/blob/da0e6703b9dcc406eb59261cee520054cf6e22e0/model.go#L625-L645 |
139,272 | jeevatkm/go-model | model.go | doCopy | func doCopy(dv, sv reflect.Value) []error {
dv = indirect(dv)
sv = indirect(sv)
fields := modelFields(sv)
var errs []error
for _, f := range fields {
sfv := sv.FieldByName(f.Name)
tag := newTag(f.Tag.Get(TagName))
if tag.isOmitField() {
continue
}
// check type is in NoTraverseTypeList or has 'not... | go | func doCopy(dv, sv reflect.Value) []error {
dv = indirect(dv)
sv = indirect(sv)
fields := modelFields(sv)
var errs []error
for _, f := range fields {
sfv := sv.FieldByName(f.Name)
tag := newTag(f.Tag.Get(TagName))
if tag.isOmitField() {
continue
}
// check type is in NoTraverseTypeList or has 'not... | [
"func",
"doCopy",
"(",
"dv",
",",
"sv",
"reflect",
".",
"Value",
")",
"[",
"]",
"error",
"{",
"dv",
"=",
"indirect",
"(",
"dv",
")",
"\n",
"sv",
"=",
"indirect",
"(",
"sv",
")",
"\n",
"fields",
":=",
"modelFields",
"(",
"sv",
")",
"\n\n",
"var",
... | //
// Non-exported methods of model library
// | [
"Non",
"-",
"exported",
"methods",
"of",
"model",
"library"
] | da0e6703b9dcc406eb59261cee520054cf6e22e0 | https://github.com/jeevatkm/go-model/blob/da0e6703b9dcc406eb59261cee520054cf6e22e0/model.go#L651-L721 |
139,273 | hypebeast/go-osc | osc/osc.go | AddMsgHandler | func (s *OscDispatcher) AddMsgHandler(addr string, handler HandlerFunc) error {
if addr == "*" {
s.defaultHandler = handler
return nil
}
for _, chr := range "*?,[]{}# " {
if strings.Contains(addr, fmt.Sprintf("%c", chr)) {
return errors.New("OSC Address string may not contain any characters in \"*?,[]{}#")
... | go | func (s *OscDispatcher) AddMsgHandler(addr string, handler HandlerFunc) error {
if addr == "*" {
s.defaultHandler = handler
return nil
}
for _, chr := range "*?,[]{}# " {
if strings.Contains(addr, fmt.Sprintf("%c", chr)) {
return errors.New("OSC Address string may not contain any characters in \"*?,[]{}#")
... | [
"func",
"(",
"s",
"*",
"OscDispatcher",
")",
"AddMsgHandler",
"(",
"addr",
"string",
",",
"handler",
"HandlerFunc",
")",
"error",
"{",
"if",
"addr",
"==",
"\"",
"\"",
"{",
"s",
".",
"defaultHandler",
"=",
"handler",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // AddMsgHandler adds a new message handler for the given OSC address. | [
"AddMsgHandler",
"adds",
"a",
"new",
"message",
"handler",
"for",
"the",
"given",
"OSC",
"address",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L119-L136 |
139,274 | hypebeast/go-osc | osc/osc.go | Dispatch | func (s *OscDispatcher) Dispatch(packet Packet) {
switch packet.(type) {
default:
return
case *Message:
msg, _ := packet.(*Message)
for addr, handler := range s.handlers {
if msg.Match(addr) {
handler.HandleMessage(msg)
}
}
if s.defaultHandler != nil {
s.defaultHandler.HandleMessage(msg)
}
... | go | func (s *OscDispatcher) Dispatch(packet Packet) {
switch packet.(type) {
default:
return
case *Message:
msg, _ := packet.(*Message)
for addr, handler := range s.handlers {
if msg.Match(addr) {
handler.HandleMessage(msg)
}
}
if s.defaultHandler != nil {
s.defaultHandler.HandleMessage(msg)
}
... | [
"func",
"(",
"s",
"*",
"OscDispatcher",
")",
"Dispatch",
"(",
"packet",
"Packet",
")",
"{",
"switch",
"packet",
".",
"(",
"type",
")",
"{",
"default",
":",
"return",
"\n\n",
"case",
"*",
"Message",
":",
"msg",
",",
"_",
":=",
"packet",
".",
"(",
"*... | // Dispatch dispatches OSC packets. Implements the Dispatcher interface. | [
"Dispatch",
"dispatches",
"OSC",
"packets",
".",
"Implements",
"the",
"Dispatcher",
"interface",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L139-L178 |
139,275 | hypebeast/go-osc | osc/osc.go | Append | func (msg *Message) Append(args ...interface{}) {
msg.Arguments = append(msg.Arguments, args...)
} | go | func (msg *Message) Append(args ...interface{}) {
msg.Arguments = append(msg.Arguments, args...)
} | [
"func",
"(",
"msg",
"*",
"Message",
")",
"Append",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"msg",
".",
"Arguments",
"=",
"append",
"(",
"msg",
".",
"Arguments",
",",
"args",
"...",
")",
"\n",
"}"
] | // Append appends the given arguments to the arguments list. | [
"Append",
"appends",
"the",
"given",
"arguments",
"to",
"the",
"arguments",
"list",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L190-L192 |
139,276 | hypebeast/go-osc | osc/osc.go | Equals | func (msg *Message) Equals(m *Message) bool {
return reflect.DeepEqual(msg, m)
} | go | func (msg *Message) Equals(m *Message) bool {
return reflect.DeepEqual(msg, m)
} | [
"func",
"(",
"msg",
"*",
"Message",
")",
"Equals",
"(",
"m",
"*",
"Message",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"msg",
",",
"m",
")",
"\n",
"}"
] | // Equals returns true if the given OSC Message `m` is equal to the current OSC
// Message. It checks if the OSC address and the arguments are equal. Returns
// true if the current object and `m` are equal. | [
"Equals",
"returns",
"true",
"if",
"the",
"given",
"OSC",
"Message",
"m",
"is",
"equal",
"to",
"the",
"current",
"OSC",
"Message",
".",
"It",
"checks",
"if",
"the",
"OSC",
"address",
"and",
"the",
"arguments",
"are",
"equal",
".",
"Returns",
"true",
"if"... | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L197-L199 |
139,277 | hypebeast/go-osc | osc/osc.go | ClearData | func (msg *Message) ClearData() {
msg.Arguments = msg.Arguments[len(msg.Arguments):]
} | go | func (msg *Message) ClearData() {
msg.Arguments = msg.Arguments[len(msg.Arguments):]
} | [
"func",
"(",
"msg",
"*",
"Message",
")",
"ClearData",
"(",
")",
"{",
"msg",
".",
"Arguments",
"=",
"msg",
".",
"Arguments",
"[",
"len",
"(",
"msg",
".",
"Arguments",
")",
":",
"]",
"\n",
"}"
] | // ClearData removes all arguments from the OSC Message. | [
"ClearData",
"removes",
"all",
"arguments",
"from",
"the",
"OSC",
"Message",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L208-L210 |
139,278 | hypebeast/go-osc | osc/osc.go | Match | func (msg *Message) Match(addr string) bool {
exp := getRegEx(msg.Address)
if exp.MatchString(addr) {
return true
}
return false
} | go | func (msg *Message) Match(addr string) bool {
exp := getRegEx(msg.Address)
if exp.MatchString(addr) {
return true
}
return false
} | [
"func",
"(",
"msg",
"*",
"Message",
")",
"Match",
"(",
"addr",
"string",
")",
"bool",
"{",
"exp",
":=",
"getRegEx",
"(",
"msg",
".",
"Address",
")",
"\n",
"if",
"exp",
".",
"MatchString",
"(",
"addr",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // Match returns true, if the address of the OSC Message matches the given
// address. The match is case sensitive! | [
"Match",
"returns",
"true",
"if",
"the",
"address",
"of",
"the",
"OSC",
"Message",
"matches",
"the",
"given",
"address",
".",
"The",
"match",
"is",
"case",
"sensitive!"
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L214-L220 |
139,279 | hypebeast/go-osc | osc/osc.go | TypeTags | func (msg *Message) TypeTags() (string, error) {
if msg == nil {
return "", fmt.Errorf("message is nil")
}
tags := ","
for _, m := range msg.Arguments {
s, err := getTypeTag(m)
if err != nil {
return "", err
}
tags += s
}
return tags, nil
} | go | func (msg *Message) TypeTags() (string, error) {
if msg == nil {
return "", fmt.Errorf("message is nil")
}
tags := ","
for _, m := range msg.Arguments {
s, err := getTypeTag(m)
if err != nil {
return "", err
}
tags += s
}
return tags, nil
} | [
"func",
"(",
"msg",
"*",
"Message",
")",
"TypeTags",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"msg",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"tags",
":=",
"\"",
... | // TypeTags returns the type tag string. | [
"TypeTags",
"returns",
"the",
"type",
"tag",
"string",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L223-L238 |
139,280 | hypebeast/go-osc | osc/osc.go | Append | func (b *Bundle) Append(pck Packet) error {
switch t := pck.(type) {
default:
return fmt.Errorf("unsupported OSC packet type: only Bundle and Message are supported")
case *Bundle:
b.Bundles = append(b.Bundles, t)
case *Message:
b.Messages = append(b.Messages, t)
}
return nil
} | go | func (b *Bundle) Append(pck Packet) error {
switch t := pck.(type) {
default:
return fmt.Errorf("unsupported OSC packet type: only Bundle and Message are supported")
case *Bundle:
b.Bundles = append(b.Bundles, t)
case *Message:
b.Messages = append(b.Messages, t)
}
return nil
} | [
"func",
"(",
"b",
"*",
"Bundle",
")",
"Append",
"(",
"pck",
"Packet",
")",
"error",
"{",
"switch",
"t",
":=",
"pck",
".",
"(",
"type",
")",
"{",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n\n",
"case",
"*",
"Bundle",
... | // Append appends an OSC bundle or OSC message to the bundle. | [
"Append",
"appends",
"an",
"OSC",
"bundle",
"or",
"OSC",
"message",
"to",
"the",
"bundle",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L391-L404 |
139,281 | hypebeast/go-osc | osc/osc.go | SetLocalAddr | func (c *Client) SetLocalAddr(ip string, port int) error {
laddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", ip, port))
if err != nil {
return err
}
c.laddr = laddr
return nil
} | go | func (c *Client) SetLocalAddr(ip string, port int) error {
laddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", ip, port))
if err != nil {
return err
}
c.laddr = laddr
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetLocalAddr",
"(",
"ip",
"string",
",",
"port",
"int",
")",
"error",
"{",
"laddr",
",",
"err",
":=",
"net",
".",
"ResolveUDPAddr",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ip",
",... | // SetLocalAddr sets the local address. | [
"SetLocalAddr",
"sets",
"the",
"local",
"address",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L495-L502 |
139,282 | hypebeast/go-osc | osc/osc.go | Send | func (c *Client) Send(packet Packet) error {
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", c.ip, c.port))
if err != nil {
return err
}
conn, err := net.DialUDP("udp", c.laddr, addr)
if err != nil {
return err
}
defer conn.Close()
data, err := packet.MarshalBinary()
if err != nil {
return e... | go | func (c *Client) Send(packet Packet) error {
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", c.ip, c.port))
if err != nil {
return err
}
conn, err := net.DialUDP("udp", c.laddr, addr)
if err != nil {
return err
}
defer conn.Close()
data, err := packet.MarshalBinary()
if err != nil {
return e... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Send",
"(",
"packet",
"Packet",
")",
"error",
"{",
"addr",
",",
"err",
":=",
"net",
".",
"ResolveUDPAddr",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ip",
",",
"c",
".",
... | // Send sends an OSC Bundle or an OSC Message. | [
"Send",
"sends",
"an",
"OSC",
"Bundle",
"or",
"an",
"OSC",
"Message",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L505-L525 |
139,283 | hypebeast/go-osc | osc/osc.go | ListenAndServe | func (s *Server) ListenAndServe() error {
if s.Dispatcher == nil {
s.Dispatcher = NewOscDispatcher()
}
ln, err := net.ListenPacket("udp", s.Addr)
if err != nil {
return err
}
return s.Serve(ln)
} | go | func (s *Server) ListenAndServe() error {
if s.Dispatcher == nil {
s.Dispatcher = NewOscDispatcher()
}
ln, err := net.ListenPacket("udp", s.Addr)
if err != nil {
return err
}
return s.Serve(ln)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ListenAndServe",
"(",
")",
"error",
"{",
"if",
"s",
".",
"Dispatcher",
"==",
"nil",
"{",
"s",
".",
"Dispatcher",
"=",
"NewOscDispatcher",
"(",
")",
"\n",
"}",
"\n\n",
"ln",
",",
"err",
":=",
"net",
".",
"Liste... | // ListenAndServe retrieves incoming OSC packets and dispatches the retrieved
// OSC packets. | [
"ListenAndServe",
"retrieves",
"incoming",
"OSC",
"packets",
"and",
"dispatches",
"the",
"retrieved",
"OSC",
"packets",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L542-L552 |
139,284 | hypebeast/go-osc | osc/osc.go | Serve | func (s *Server) Serve(c net.PacketConn) error {
var tempDelay time.Duration
for {
msg, err := s.readFromConnection(c)
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
tempDelay *= 2
}
if max := 1 * time... | go | func (s *Server) Serve(c net.PacketConn) error {
var tempDelay time.Duration
for {
msg, err := s.readFromConnection(c)
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
tempDelay *= 2
}
if max := 1 * time... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Serve",
"(",
"c",
"net",
".",
"PacketConn",
")",
"error",
"{",
"var",
"tempDelay",
"time",
".",
"Duration",
"\n",
"for",
"{",
"msg",
",",
"err",
":=",
"s",
".",
"readFromConnection",
"(",
"c",
")",
"\n",
"if",... | // Serve retrieves incoming OSC packets from the given connection and dispatches
// retrieved OSC packets. If something goes wrong an error is returned. | [
"Serve",
"retrieves",
"incoming",
"OSC",
"packets",
"from",
"the",
"given",
"connection",
"and",
"dispatches",
"retrieved",
"OSC",
"packets",
".",
"If",
"something",
"goes",
"wrong",
"an",
"error",
"is",
"returned",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L556-L578 |
139,285 | hypebeast/go-osc | osc/osc.go | ReceivePacket | func (s *Server) ReceivePacket(c net.PacketConn) (Packet, error) {
return s.readFromConnection(c)
} | go | func (s *Server) ReceivePacket(c net.PacketConn) (Packet, error) {
return s.readFromConnection(c)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ReceivePacket",
"(",
"c",
"net",
".",
"PacketConn",
")",
"(",
"Packet",
",",
"error",
")",
"{",
"return",
"s",
".",
"readFromConnection",
"(",
"c",
")",
"\n",
"}"
] | // ReceivePacket listens for incoming OSC packets and returns the packet if one is received. | [
"ReceivePacket",
"listens",
"for",
"incoming",
"OSC",
"packets",
"and",
"returns",
"the",
"packet",
"if",
"one",
"is",
"received",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L581-L583 |
139,286 | hypebeast/go-osc | osc/osc.go | readFromConnection | func (s *Server) readFromConnection(c net.PacketConn) (Packet, error) {
if s.ReadTimeout != 0 {
if err := c.SetReadDeadline(time.Now().Add(s.ReadTimeout)); err != nil {
return nil, err
}
}
data := make([]byte, 65535)
n, _, err := c.ReadFrom(data)
if err != nil {
return nil, err
}
var start int
p, err... | go | func (s *Server) readFromConnection(c net.PacketConn) (Packet, error) {
if s.ReadTimeout != 0 {
if err := c.SetReadDeadline(time.Now().Add(s.ReadTimeout)); err != nil {
return nil, err
}
}
data := make([]byte, 65535)
n, _, err := c.ReadFrom(data)
if err != nil {
return nil, err
}
var start int
p, err... | [
"func",
"(",
"s",
"*",
"Server",
")",
"readFromConnection",
"(",
"c",
"net",
".",
"PacketConn",
")",
"(",
"Packet",
",",
"error",
")",
"{",
"if",
"s",
".",
"ReadTimeout",
"!=",
"0",
"{",
"if",
"err",
":=",
"c",
".",
"SetReadDeadline",
"(",
"time",
... | // readFromConnection retrieves OSC packets. | [
"readFromConnection",
"retrieves",
"OSC",
"packets",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L586-L605 |
139,287 | hypebeast/go-osc | osc/osc.go | ParsePacket | func ParsePacket(msg string) (Packet, error) {
var start int
p, err := readPacket(bufio.NewReader(bytes.NewBufferString(msg)), &start, len(msg))
if err != nil {
return nil, err
}
return p, nil
} | go | func ParsePacket(msg string) (Packet, error) {
var start int
p, err := readPacket(bufio.NewReader(bytes.NewBufferString(msg)), &start, len(msg))
if err != nil {
return nil, err
}
return p, nil
} | [
"func",
"ParsePacket",
"(",
"msg",
"string",
")",
"(",
"Packet",
",",
"error",
")",
"{",
"var",
"start",
"int",
"\n",
"p",
",",
"err",
":=",
"readPacket",
"(",
"bufio",
".",
"NewReader",
"(",
"bytes",
".",
"NewBufferString",
"(",
"msg",
")",
")",
","... | // ParsePacket parses the given msg string and returns a Packet | [
"ParsePacket",
"parses",
"the",
"given",
"msg",
"string",
"and",
"returns",
"a",
"Packet"
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L608-L615 |
139,288 | hypebeast/go-osc | osc/osc.go | readPacket | func readPacket(reader *bufio.Reader, start *int, end int) (Packet, error) {
//var buf []byte
buf, err := reader.Peek(1)
if err != nil {
return nil, err
}
// An OSC Message starts with a '/'
if buf[0] == '/' {
packet, err := readMessage(reader, start)
if err != nil {
return nil, err
}
return packet,... | go | func readPacket(reader *bufio.Reader, start *int, end int) (Packet, error) {
//var buf []byte
buf, err := reader.Peek(1)
if err != nil {
return nil, err
}
// An OSC Message starts with a '/'
if buf[0] == '/' {
packet, err := readMessage(reader, start)
if err != nil {
return nil, err
}
return packet,... | [
"func",
"readPacket",
"(",
"reader",
"*",
"bufio",
".",
"Reader",
",",
"start",
"*",
"int",
",",
"end",
"int",
")",
"(",
"Packet",
",",
"error",
")",
"{",
"//var buf []byte",
"buf",
",",
"err",
":=",
"reader",
".",
"Peek",
"(",
"1",
")",
"\n",
"if"... | // receivePacket receives an OSC packet from the given reader. | [
"receivePacket",
"receives",
"an",
"OSC",
"packet",
"from",
"the",
"given",
"reader",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L618-L643 |
139,289 | hypebeast/go-osc | osc/osc.go | readBundle | func readBundle(reader *bufio.Reader, start *int, end int) (*Bundle, error) {
// Read the '#bundle' OSC string
startTag, n, err := readPaddedString(reader)
if err != nil {
return nil, err
}
*start += n
if startTag != bundleTagString {
return nil, fmt.Errorf("Invalid bundle start tag: %s", startTag)
}
// R... | go | func readBundle(reader *bufio.Reader, start *int, end int) (*Bundle, error) {
// Read the '#bundle' OSC string
startTag, n, err := readPaddedString(reader)
if err != nil {
return nil, err
}
*start += n
if startTag != bundleTagString {
return nil, fmt.Errorf("Invalid bundle start tag: %s", startTag)
}
// R... | [
"func",
"readBundle",
"(",
"reader",
"*",
"bufio",
".",
"Reader",
",",
"start",
"*",
"int",
",",
"end",
"int",
")",
"(",
"*",
"Bundle",
",",
"error",
")",
"{",
"// Read the '#bundle' OSC string",
"startTag",
",",
"n",
",",
"err",
":=",
"readPaddedString",
... | // readBundle reads an Bundle from reader. | [
"readBundle",
"reads",
"an",
"Bundle",
"from",
"reader",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L646-L687 |
139,290 | hypebeast/go-osc | osc/osc.go | readMessage | func readMessage(reader *bufio.Reader, start *int) (*Message, error) {
// First, read the OSC address
addr, n, err := readPaddedString(reader)
if err != nil {
return nil, err
}
*start += n
// Read all arguments
msg := NewMessage(addr)
if err = readArguments(msg, reader, start); err != nil {
return nil, err... | go | func readMessage(reader *bufio.Reader, start *int) (*Message, error) {
// First, read the OSC address
addr, n, err := readPaddedString(reader)
if err != nil {
return nil, err
}
*start += n
// Read all arguments
msg := NewMessage(addr)
if err = readArguments(msg, reader, start); err != nil {
return nil, err... | [
"func",
"readMessage",
"(",
"reader",
"*",
"bufio",
".",
"Reader",
",",
"start",
"*",
"int",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"// First, read the OSC address",
"addr",
",",
"n",
",",
"err",
":=",
"readPaddedString",
"(",
"reader",
")",
"... | // readMessage from `reader`. | [
"readMessage",
"from",
"reader",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L690-L705 |
139,291 | hypebeast/go-osc | osc/osc.go | readArguments | func readArguments(msg *Message, reader *bufio.Reader, start *int) error {
// Read the type tag string
var n int
typetags, n, err := readPaddedString(reader)
if err != nil {
return err
}
*start += n
// If the typetag doesn't start with ',', it's not valid
if typetags[0] != ',' {
return errors.New("unsuppor... | go | func readArguments(msg *Message, reader *bufio.Reader, start *int) error {
// Read the type tag string
var n int
typetags, n, err := readPaddedString(reader)
if err != nil {
return err
}
*start += n
// If the typetag doesn't start with ',', it's not valid
if typetags[0] != ',' {
return errors.New("unsuppor... | [
"func",
"readArguments",
"(",
"msg",
"*",
"Message",
",",
"reader",
"*",
"bufio",
".",
"Reader",
",",
"start",
"*",
"int",
")",
"error",
"{",
"// Read the type tag string",
"var",
"n",
"int",
"\n",
"typetags",
",",
"n",
",",
"err",
":=",
"readPaddedString"... | // readArguments from `reader` and add them to the OSC message `msg`. | [
"readArguments",
"from",
"reader",
"and",
"add",
"them",
"to",
"the",
"OSC",
"message",
"msg",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L708-L797 |
139,292 | hypebeast/go-osc | osc/osc.go | MarshalBinary | func (t *Timetag) MarshalBinary() ([]byte, error) {
data := new(bytes.Buffer)
if err := binary.Write(data, binary.BigEndian, t.timeTag); err != nil {
return []byte{}, err
}
return data.Bytes(), nil
} | go | func (t *Timetag) MarshalBinary() ([]byte, error) {
data := new(bytes.Buffer)
if err := binary.Write(data, binary.BigEndian, t.timeTag); err != nil {
return []byte{}, err
}
return data.Bytes(), nil
} | [
"func",
"(",
"t",
"*",
"Timetag",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"data",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"if",
"err",
":=",
"binary",
".",
"Write",
"(",
"data",
",",
"binary",
... | // MarshalBinary converts the OSC time tag to a byte array. | [
"MarshalBinary",
"converts",
"the",
"OSC",
"time",
"tag",
"to",
"a",
"byte",
"array",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L840-L846 |
139,293 | hypebeast/go-osc | osc/osc.go | SetTime | func (t *Timetag) SetTime(time time.Time) {
t.time = time
t.timeTag = timeToTimetag(time)
} | go | func (t *Timetag) SetTime(time time.Time) {
t.time = time
t.timeTag = timeToTimetag(time)
} | [
"func",
"(",
"t",
"*",
"Timetag",
")",
"SetTime",
"(",
"time",
"time",
".",
"Time",
")",
"{",
"t",
".",
"time",
"=",
"time",
"\n",
"t",
".",
"timeTag",
"=",
"timeToTimetag",
"(",
"time",
")",
"\n",
"}"
] | // SetTime sets the value of the OSC time tag. | [
"SetTime",
"sets",
"the",
"value",
"of",
"the",
"OSC",
"time",
"tag",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L849-L852 |
139,294 | hypebeast/go-osc | osc/osc.go | ExpiresIn | func (t *Timetag) ExpiresIn() time.Duration {
if t.timeTag <= 1 {
return 0
}
tt := timetagToTime(t.timeTag)
seconds := tt.Sub(time.Now())
if seconds <= 0 {
return 0
}
return seconds
} | go | func (t *Timetag) ExpiresIn() time.Duration {
if t.timeTag <= 1 {
return 0
}
tt := timetagToTime(t.timeTag)
seconds := tt.Sub(time.Now())
if seconds <= 0 {
return 0
}
return seconds
} | [
"func",
"(",
"t",
"*",
"Timetag",
")",
"ExpiresIn",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"t",
".",
"timeTag",
"<=",
"1",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"tt",
":=",
"timetagToTime",
"(",
"t",
".",
"timeTag",
")",
"\n",
"seconds",
... | // ExpiresIn calculates the number of seconds until the current time is the
// same as the value of the time tag. It returns zero if the value of the
// time tag is in the past. | [
"ExpiresIn",
"calculates",
"the",
"number",
"of",
"seconds",
"until",
"the",
"current",
"time",
"is",
"the",
"same",
"as",
"the",
"value",
"of",
"the",
"time",
"tag",
".",
"It",
"returns",
"zero",
"if",
"the",
"value",
"of",
"the",
"time",
"tag",
"is",
... | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L857-L870 |
139,295 | hypebeast/go-osc | osc/osc.go | timetagToTime | func timetagToTime(timetag uint64) (t time.Time) {
return time.Unix(int64((timetag>>32)-secondsFrom1900To1970), int64(timetag&0xffffffff))
} | go | func timetagToTime(timetag uint64) (t time.Time) {
return time.Unix(int64((timetag>>32)-secondsFrom1900To1970), int64(timetag&0xffffffff))
} | [
"func",
"timetagToTime",
"(",
"timetag",
"uint64",
")",
"(",
"t",
"time",
".",
"Time",
")",
"{",
"return",
"time",
".",
"Unix",
"(",
"int64",
"(",
"(",
"timetag",
">>",
"32",
")",
"-",
"secondsFrom1900To1970",
")",
",",
"int64",
"(",
"timetag",
"&",
... | // timetagToTime converts the given timetag to a time object. | [
"timetagToTime",
"converts",
"the",
"given",
"timetag",
"to",
"a",
"time",
"object",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L888-L890 |
139,296 | hypebeast/go-osc | osc/osc.go | writeBlob | func writeBlob(data []byte, buf *bytes.Buffer) (int, error) {
// Add the size of the blob
dlen := int32(len(data))
if err := binary.Write(buf, binary.BigEndian, dlen); err != nil {
return 0, err
}
// Write the data
if _, err := buf.Write(data); err != nil {
return 0, nil
}
// Add padding bytes if necessar... | go | func writeBlob(data []byte, buf *bytes.Buffer) (int, error) {
// Add the size of the blob
dlen := int32(len(data))
if err := binary.Write(buf, binary.BigEndian, dlen); err != nil {
return 0, err
}
// Write the data
if _, err := buf.Write(data); err != nil {
return 0, nil
}
// Add padding bytes if necessar... | [
"func",
"writeBlob",
"(",
"data",
"[",
"]",
"byte",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"(",
"int",
",",
"error",
")",
"{",
"// Add the size of the blob",
"dlen",
":=",
"int32",
"(",
"len",
"(",
"data",
")",
")",
"\n",
"if",
"err",
":=",
... | // writeBlob writes the data byte array as an OSC blob into buff. If the length
// of data isn't 32-bit aligned, padding bytes will be added. | [
"writeBlob",
"writes",
"the",
"data",
"byte",
"array",
"as",
"an",
"OSC",
"blob",
"into",
"buff",
".",
"If",
"the",
"length",
"of",
"data",
"isn",
"t",
"32",
"-",
"bit",
"aligned",
"padding",
"bytes",
"will",
"be",
"added",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L927-L951 |
139,297 | hypebeast/go-osc | osc/osc.go | readPaddedString | func readPaddedString(reader *bufio.Reader) (string, int, error) {
// Read the string from the reader
str, err := reader.ReadString(0)
if err != nil {
return "", 0, err
}
n := len(str)
// Remove the string delimiter, in order to calculate the right amount
// of padding bytes
str = str[:len(str)-1]
// Remov... | go | func readPaddedString(reader *bufio.Reader) (string, int, error) {
// Read the string from the reader
str, err := reader.ReadString(0)
if err != nil {
return "", 0, err
}
n := len(str)
// Remove the string delimiter, in order to calculate the right amount
// of padding bytes
str = str[:len(str)-1]
// Remov... | [
"func",
"readPaddedString",
"(",
"reader",
"*",
"bufio",
".",
"Reader",
")",
"(",
"string",
",",
"int",
",",
"error",
")",
"{",
"// Read the string from the reader",
"str",
",",
"err",
":=",
"reader",
".",
"ReadString",
"(",
"0",
")",
"\n",
"if",
"err",
... | // readPaddedString reads a padded string from the given reader. The padding
// bytes are removed from the reader. | [
"readPaddedString",
"reads",
"a",
"padded",
"string",
"from",
"the",
"given",
"reader",
".",
"The",
"padding",
"bytes",
"are",
"removed",
"from",
"the",
"reader",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L955-L978 |
139,298 | hypebeast/go-osc | osc/osc.go | writePaddedString | func writePaddedString(str string, buf *bytes.Buffer) (int, error) {
// Write the string to the buffer
n, err := buf.WriteString(str)
if err != nil {
return 0, err
}
// Calculate the padding bytes needed and create a buffer for the padding bytes
numPadBytes := padBytesNeeded(len(str))
if numPadBytes > 0 {
p... | go | func writePaddedString(str string, buf *bytes.Buffer) (int, error) {
// Write the string to the buffer
n, err := buf.WriteString(str)
if err != nil {
return 0, err
}
// Calculate the padding bytes needed and create a buffer for the padding bytes
numPadBytes := padBytesNeeded(len(str))
if numPadBytes > 0 {
p... | [
"func",
"writePaddedString",
"(",
"str",
"string",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"(",
"int",
",",
"error",
")",
"{",
"// Write the string to the buffer",
"n",
",",
"err",
":=",
"buf",
".",
"WriteString",
"(",
"str",
")",
"\n",
"if",
"err"... | // writePaddedString writes a string with padding bytes to the a buffer.
// Returns, the number of written bytes and an error if any. | [
"writePaddedString",
"writes",
"a",
"string",
"with",
"padding",
"bytes",
"to",
"the",
"a",
"buffer",
".",
"Returns",
"the",
"number",
"of",
"written",
"bytes",
"and",
"an",
"error",
"if",
"any",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L982-L1002 |
139,299 | hypebeast/go-osc | osc/osc.go | addressExists | func addressExists(addr string, handlers map[string]Handler) bool {
for h := range handlers {
if h == addr {
return true
}
}
return false
} | go | func addressExists(addr string, handlers map[string]Handler) bool {
for h := range handlers {
if h == addr {
return true
}
}
return false
} | [
"func",
"addressExists",
"(",
"addr",
"string",
",",
"handlers",
"map",
"[",
"string",
"]",
"Handler",
")",
"bool",
"{",
"for",
"h",
":=",
"range",
"handlers",
"{",
"if",
"h",
"==",
"addr",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",... | // addressExists returns true if the OSC address `addr` is found in `handlers`. | [
"addressExists",
"returns",
"true",
"if",
"the",
"OSC",
"address",
"addr",
"is",
"found",
"in",
"handlers",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L1020-L1027 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.