id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
17,100
apcera/logray
iooutput.go
ioOutputFormatTZOffset
func ioOutputFormatTZOffset(ld *LineData, b *bytes.Buffer) error { _, offset := ld.TimeStamp.Zone() hour := offset / (60 * 60) minute := (offset / 60) % 60 c := "-" if hour >= 0 { c = "+" } else { hour *= -1 } _, err := b.WriteString(fmt.Sprintf("%s%02d%02d", c, hour, minute)) return err }
go
func ioOutputFormatTZOffset(ld *LineData, b *bytes.Buffer) error { _, offset := ld.TimeStamp.Zone() hour := offset / (60 * 60) minute := (offset / 60) % 60 c := "-" if hour >= 0 { c = "+" } else { hour *= -1 } _, err := b.WriteString(fmt.Sprintf("%s%02d%02d", c, hour, minute)) return err }
[ "func", "ioOutputFormatTZOffset", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "offset", ":=", "ld", ".", "TimeStamp", ".", "Zone", "(", ")", "\n", "hour", ":=", "offset", "/", "(", "60", "*", "60"...
// Formatting function used to implement the %tzoffset% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%tzoffset%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L585-L597
17,101
apcera/logray
iooutput.go
ioOutputFormatTZ
func ioOutputFormatTZ(ld *LineData, b *bytes.Buffer) error { name, _ := ld.TimeStamp.Zone() _, err := b.WriteString(name) return err }
go
func ioOutputFormatTZ(ld *LineData, b *bytes.Buffer) error { name, _ := ld.TimeStamp.Zone() _, err := b.WriteString(name) return err }
[ "func", "ioOutputFormatTZ", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "name", ",", "_", ":=", "ld", ".", "TimeStamp", ".", "Zone", "(", ")", "\n", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "n...
// Formatting function used to implement the %tz% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%tz%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L600-L604
17,102
apcera/logray
iooutput.go
ioOutputFormatHostname
func ioOutputFormatHostname(ld *LineData, b *bytes.Buffer) error { name, err := os.Hostname() if err != nil { return err } _, err = b.WriteString(name) return err }
go
func ioOutputFormatHostname(ld *LineData, b *bytes.Buffer) error { name, err := os.Hostname() if err != nil { return err } _, err = b.WriteString(name) return err }
[ "func", "ioOutputFormatHostname", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "name", ",", "err", ":=", "os", ".", "Hostname", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n"...
// Formatting function used to implement the %hostname% code.
[ "Formatting", "function", "used", "to", "implement", "the", "%hostname%", "code", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L607-L614
17,103
apcera/logray
iooutput.go
ioOutputFormatPid
func ioOutputFormatPid(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%d", os.Getpid())) return err }
go
func ioOutputFormatPid(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%d", os.Getpid())) return err }
[ "func", "ioOutputFormatPid", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "os", ".", "Getpid", "(", ")", ")...
// Formatting function used to implement the %pid% code
[ "Formatting", "function", "used", "to", "implement", "the", "%pid%", "code" ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L617-L620
17,104
apcera/logray
iooutput.go
ioOutputFormatPackage
func ioOutputFormatPackage(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.CallingPackage) return err }
go
func ioOutputFormatPackage(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.CallingPackage) return err }
[ "func", "ioOutputFormatPackage", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "ld", ".", "CallingPackage", ")", "\n", "return", "err", "\n", "}" ]
// Formatting function used to implement the %package% code
[ "Formatting", "function", "used", "to", "implement", "the", "%package%", "code" ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L623-L626
17,105
apcera/logray
iooutput.go
ioOutputFormatFunction
func ioOutputFormatFunction(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.CallingFunction) return err }
go
func ioOutputFormatFunction(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.CallingFunction) return err }
[ "func", "ioOutputFormatFunction", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "ld", ".", "CallingFunction", ")", "\n", "return", "err", "\n", "}" ]
// Formatting function used to implement the %function% code
[ "Formatting", "function", "used", "to", "implement", "the", "%function%", "code" ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L629-L632
17,106
apcera/logray
iooutput.go
ioOutputFormatSourceFile
func ioOutputFormatSourceFile(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.SourceFile) return err }
go
func ioOutputFormatSourceFile(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(ld.SourceFile) return err }
[ "func", "ioOutputFormatSourceFile", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "ld", ".", "SourceFile", ")", "\n", "return", "err", "\n", "}" ]
// Formatting function used to implement the %sourcefile% code
[ "Formatting", "function", "used", "to", "implement", "the", "%sourcefile%", "code" ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L635-L638
17,107
apcera/logray
iooutput.go
ioOutputFormatSourceLine
func ioOutputFormatSourceLine(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%d", ld.SourceLine)) return err }
go
func ioOutputFormatSourceLine(ld *LineData, b *bytes.Buffer) error { _, err := b.WriteString(fmt.Sprintf("%d", ld.SourceLine)) return err }
[ "func", "ioOutputFormatSourceLine", "(", "ld", "*", "LineData", ",", "b", "*", "bytes", ".", "Buffer", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ld", ".", "SourceLine", ")", ...
// Formatting function used to implement the %sourceline% code
[ "Formatting", "function", "used", "to", "implement", "the", "%sourceline%", "code" ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/iooutput.go#L641-L644
17,108
apcera/logray
worker.go
Process
func (b *backgroundFlusher) Process() { b.logger.outputMutex.RLock() defer b.logger.outputMutex.RUnlock() for _, o := range b.logger.outputs { o.OutputWrapper.Output.Flush() } if b.updateChan != nil { close(b.updateChan) } }
go
func (b *backgroundFlusher) Process() { b.logger.outputMutex.RLock() defer b.logger.outputMutex.RUnlock() for _, o := range b.logger.outputs { o.OutputWrapper.Output.Flush() } if b.updateChan != nil { close(b.updateChan) } }
[ "func", "(", "b", "*", "backgroundFlusher", ")", "Process", "(", ")", "{", "b", ".", "logger", ".", "outputMutex", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "logger", ".", "outputMutex", ".", "RUnlock", "(", ")", "\n\n", "for", "_", ",", "o"...
// Called in order to flush all output's associated with the logger.
[ "Called", "in", "order", "to", "flush", "all", "output", "s", "associated", "with", "the", "logger", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/worker.go#L20-L30
17,109
apcera/logray
worker.go
Process
func (b *backgroundLineLogger) Process() { b.logger.outputMutex.RLock() defer b.logger.outputMutex.RUnlock() for _, o := range b.logger.outputs { if o.Class&b.lineData.Class == b.lineData.Class { o.OutputWrapper.Output.Write(&b.lineData) } } }
go
func (b *backgroundLineLogger) Process() { b.logger.outputMutex.RLock() defer b.logger.outputMutex.RUnlock() for _, o := range b.logger.outputs { if o.Class&b.lineData.Class == b.lineData.Class { o.OutputWrapper.Output.Write(&b.lineData) } } }
[ "func", "(", "b", "*", "backgroundLineLogger", ")", "Process", "(", ")", "{", "b", ".", "logger", ".", "outputMutex", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "logger", ".", "outputMutex", ".", "RUnlock", "(", ")", "\n\n", "for", "_", ",", ...
// Calls the appropriate functions to commit logging data into the proper // outputs.
[ "Calls", "the", "appropriate", "functions", "to", "commit", "logging", "data", "into", "the", "proper", "outputs", "." ]
684fe44f71d86f7cc3b1ed98633c83351cb2cad7
https://github.com/apcera/logray/blob/684fe44f71d86f7cc3b1ed98633c83351cb2cad7/worker.go#L40-L49
17,110
mailgun/timetools
provider.go
SleepProvider
func SleepProvider(currentTime time.Time) TimeProvider { return &sleepableTime{ currentTime: currentTime, waiters: make(map[time.Time][]chan time.Time), } }
go
func SleepProvider(currentTime time.Time) TimeProvider { return &sleepableTime{ currentTime: currentTime, waiters: make(map[time.Time][]chan time.Time), } }
[ "func", "SleepProvider", "(", "currentTime", "time", ".", "Time", ")", "TimeProvider", "{", "return", "&", "sleepableTime", "{", "currentTime", ":", "currentTime", ",", "waiters", ":", "make", "(", "map", "[", "time", ".", "Time", "]", "[", "]", "chan", ...
// SleepProvider returns a TimeProvider that has good fakes for // time.Sleep and time.After. Both functions will behave as if // time is frozen until you call AdvanceTimeBy, at which point // any calls to time.Sleep that should return do return and // any ticks from time.After that should happen do happen.
[ "SleepProvider", "returns", "a", "TimeProvider", "that", "has", "good", "fakes", "for", "time", ".", "Sleep", "and", "time", ".", "After", ".", "Both", "functions", "will", "behave", "as", "if", "time", "is", "frozen", "until", "you", "call", "AdvanceTimeBy"...
f3a7b8ffff474320c4f5cc564c9abb2c52ded8bc
https://github.com/mailgun/timetools/blob/f3a7b8ffff474320c4f5cc564c9abb2c52ded8bc/provider.go#L62-L67
17,111
mailgun/timetools
provider.go
AdvanceTimeBy
func AdvanceTimeBy(st TimeProvider, d time.Duration) { t := st.(*sleepableTime) t.mu.Lock() defer t.mu.Unlock() t.currentTime = t.currentTime.Add(d) for k, v := range t.waiters { if k.Before(t.currentTime) { for _, c := range v { c <- t.currentTime } delete(t.waiters, k) } } }
go
func AdvanceTimeBy(st TimeProvider, d time.Duration) { t := st.(*sleepableTime) t.mu.Lock() defer t.mu.Unlock() t.currentTime = t.currentTime.Add(d) for k, v := range t.waiters { if k.Before(t.currentTime) { for _, c := range v { c <- t.currentTime } delete(t.waiters, k) } } }
[ "func", "AdvanceTimeBy", "(", "st", "TimeProvider", ",", "d", "time", ".", "Duration", ")", "{", "t", ":=", "st", ".", "(", "*", "sleepableTime", ")", "\n", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(",...
// AdvanceTimeBy simulates advancing time by some time.Duration d. // This function panics if st is not the result of a call to // SleepProvider.
[ "AdvanceTimeBy", "simulates", "advancing", "time", "by", "some", "time", ".", "Duration", "d", ".", "This", "function", "panics", "if", "st", "is", "not", "the", "result", "of", "a", "call", "to", "SleepProvider", "." ]
f3a7b8ffff474320c4f5cc564c9abb2c52ded8bc
https://github.com/mailgun/timetools/blob/f3a7b8ffff474320c4f5cc564c9abb2c52ded8bc/provider.go#L90-L104
17,112
Atrox/haikunatorgo
haikunator.go
New
func New() *Haikunator { return &Haikunator{ Adjectives: adjectives, Nouns: nouns, Delimiter: "-", TokenLength: 4, TokenHex: false, TokenChars: numbers, Random: rand.New(rand.NewSource(time.Now().UnixNano())), } }
go
func New() *Haikunator { return &Haikunator{ Adjectives: adjectives, Nouns: nouns, Delimiter: "-", TokenLength: 4, TokenHex: false, TokenChars: numbers, Random: rand.New(rand.NewSource(time.Now().UnixNano())), } }
[ "func", "New", "(", ")", "*", "Haikunator", "{", "return", "&", "Haikunator", "{", "Adjectives", ":", "adjectives", ",", "Nouns", ":", "nouns", ",", "Delimiter", ":", "\"", "\"", ",", "TokenLength", ":", "4", ",", "TokenHex", ":", "false", ",", "TokenC...
// New creates a new Haikunator with all default options
[ "New", "creates", "a", "new", "Haikunator", "with", "all", "default", "options" ]
f18f2ff9374972f8da3c2063970bd6be202ec78b
https://github.com/Atrox/haikunatorgo/blob/f18f2ff9374972f8da3c2063970bd6be202ec78b/haikunator.go#L60-L70
17,113
Atrox/haikunatorgo
haikunator.go
Haikunate
func (h *Haikunator) Haikunate() string { adjective := h.randomString(h.Adjectives) noun := h.randomString(h.Nouns) token := h.buildToken() sections := deleteEmpty(adjective, noun, token) return strings.Join(sections, h.Delimiter) }
go
func (h *Haikunator) Haikunate() string { adjective := h.randomString(h.Adjectives) noun := h.randomString(h.Nouns) token := h.buildToken() sections := deleteEmpty(adjective, noun, token) return strings.Join(sections, h.Delimiter) }
[ "func", "(", "h", "*", "Haikunator", ")", "Haikunate", "(", ")", "string", "{", "adjective", ":=", "h", ".", "randomString", "(", "h", ".", "Adjectives", ")", "\n", "noun", ":=", "h", ".", "randomString", "(", "h", ".", "Nouns", ")", "\n", "token", ...
// Haikunate generates a random Heroku-like string
[ "Haikunate", "generates", "a", "random", "Heroku", "-", "like", "string" ]
f18f2ff9374972f8da3c2063970bd6be202ec78b
https://github.com/Atrox/haikunatorgo/blob/f18f2ff9374972f8da3c2063970bd6be202ec78b/haikunator.go#L73-L80
17,114
Atrox/haikunatorgo
haikunator.go
buildToken
func (h *Haikunator) buildToken() string { var chars []rune if h.TokenHex { chars = []rune(hex) } else { chars = []rune(h.TokenChars) } size := len(chars) if size <= 0 { return "" } var buffer bytes.Buffer for i := 0; i < h.TokenLength; i++ { index := h.Random.Intn(size) buffer.WriteRune(chars[i...
go
func (h *Haikunator) buildToken() string { var chars []rune if h.TokenHex { chars = []rune(hex) } else { chars = []rune(h.TokenChars) } size := len(chars) if size <= 0 { return "" } var buffer bytes.Buffer for i := 0; i < h.TokenLength; i++ { index := h.Random.Intn(size) buffer.WriteRune(chars[i...
[ "func", "(", "h", "*", "Haikunator", ")", "buildToken", "(", ")", "string", "{", "var", "chars", "[", "]", "rune", "\n\n", "if", "h", ".", "TokenHex", "{", "chars", "=", "[", "]", "rune", "(", "hex", ")", "\n", "}", "else", "{", "chars", "=", "...
// buildToken creates and builds random token
[ "buildToken", "creates", "and", "builds", "random", "token" ]
f18f2ff9374972f8da3c2063970bd6be202ec78b
https://github.com/Atrox/haikunatorgo/blob/f18f2ff9374972f8da3c2063970bd6be202ec78b/haikunator.go#L83-L106
17,115
Atrox/haikunatorgo
haikunator.go
randomString
func (h *Haikunator) randomString(s []string) string { size := len(s) if size <= 0 { return "" } return s[h.Random.Intn(size)] }
go
func (h *Haikunator) randomString(s []string) string { size := len(s) if size <= 0 { return "" } return s[h.Random.Intn(size)] }
[ "func", "(", "h", "*", "Haikunator", ")", "randomString", "(", "s", "[", "]", "string", ")", "string", "{", "size", ":=", "len", "(", "s", ")", "\n\n", "if", "size", "<=", "0", "{", "return", "\"", "\"", "\n", "}", "\n\n", "return", "s", "[", "...
// randomString returns random string from slice
[ "randomString", "returns", "random", "string", "from", "slice" ]
f18f2ff9374972f8da3c2063970bd6be202ec78b
https://github.com/Atrox/haikunatorgo/blob/f18f2ff9374972f8da3c2063970bd6be202ec78b/haikunator.go#L109-L117
17,116
Atrox/haikunatorgo
haikunator.go
deleteEmpty
func deleteEmpty(s ...string) []string { var r []string for _, str := range s { if str != "" { r = append(r, str) } } return r }
go
func deleteEmpty(s ...string) []string { var r []string for _, str := range s { if str != "" { r = append(r, str) } } return r }
[ "func", "deleteEmpty", "(", "s", "...", "string", ")", "[", "]", "string", "{", "var", "r", "[", "]", "string", "\n", "for", "_", ",", "str", ":=", "range", "s", "{", "if", "str", "!=", "\"", "\"", "{", "r", "=", "append", "(", "r", ",", "str...
// deleteEmpty deletes empty strings from slice
[ "deleteEmpty", "deletes", "empty", "strings", "from", "slice" ]
f18f2ff9374972f8da3c2063970bd6be202ec78b
https://github.com/Atrox/haikunatorgo/blob/f18f2ff9374972f8da3c2063970bd6be202ec78b/haikunator.go#L120-L128
17,117
gobuffalo/makr
file.go
NewFile
func NewFile(path string, t string) File { return File{ Path: path, Template: t, TemplateFuncs: Helpers, Permission: 0664, Should: func(data Data) bool { return true }, } }
go
func NewFile(path string, t string) File { return File{ Path: path, Template: t, TemplateFuncs: Helpers, Permission: 0664, Should: func(data Data) bool { return true }, } }
[ "func", "NewFile", "(", "path", "string", ",", "t", "string", ")", "File", "{", "return", "File", "{", "Path", ":", "path", ",", "Template", ":", "t", ",", "TemplateFuncs", ":", "Helpers", ",", "Permission", ":", "0664", ",", "Should", ":", "func", "...
// NewFile set up with sensible defaults
[ "NewFile", "set", "up", "with", "sensible", "defaults" ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/file.go#L80-L90
17,118
gobuffalo/makr
go_commands.go
GoGet
func GoGet(pkg string, opts ...string) *exec.Cmd { var cmd *exec.Cmd turnOffMods(func() { args := append([]string{"get"}, opts...) args = append(args, pkg) cmd = exec.Command(envy.Get("GO_BIN", "go"), args...) }) return cmd }
go
func GoGet(pkg string, opts ...string) *exec.Cmd { var cmd *exec.Cmd turnOffMods(func() { args := append([]string{"get"}, opts...) args = append(args, pkg) cmd = exec.Command(envy.Get("GO_BIN", "go"), args...) }) return cmd }
[ "func", "GoGet", "(", "pkg", "string", ",", "opts", "...", "string", ")", "*", "exec", ".", "Cmd", "{", "var", "cmd", "*", "exec", ".", "Cmd", "\n", "turnOffMods", "(", "func", "(", ")", "{", "args", ":=", "append", "(", "[", "]", "string", "{", ...
// GoGet downloads and installs packages and dependencies
[ "GoGet", "downloads", "and", "installs", "packages", "and", "dependencies" ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/go_commands.go#L34-L42
17,119
gobuffalo/makr
go_commands.go
GoFmt
func GoFmt(files ...string) *exec.Cmd { if len(files) == 0 { files = []string{"."} } c := "gofmt" _, err := exec.LookPath("goimports") if err == nil { c = "goimports" } _, err = exec.LookPath("gofmt") if err != nil { return exec.Command("echo", "could not find gofmt or goimports") } args := []string{"-w...
go
func GoFmt(files ...string) *exec.Cmd { if len(files) == 0 { files = []string{"."} } c := "gofmt" _, err := exec.LookPath("goimports") if err == nil { c = "goimports" } _, err = exec.LookPath("gofmt") if err != nil { return exec.Command("echo", "could not find gofmt or goimports") } args := []string{"-w...
[ "func", "GoFmt", "(", "files", "...", "string", ")", "*", "exec", ".", "Cmd", "{", "if", "len", "(", "files", ")", "==", "0", "{", "files", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "}", "\n", "c", ":=", "\"", "\"", "\n", "_", ",...
// GoFmt is command that will use `goimports` if available, // or fail back to `gofmt` otherwise.
[ "GoFmt", "is", "command", "that", "will", "use", "goimports", "if", "available", "or", "fail", "back", "to", "gofmt", "otherwise", "." ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/go_commands.go#L46-L62
17,120
gobuffalo/makr
makr.go
Add
func (g *Generator) Add(r Runnable) { g.Runners = append(g.Runners, r) }
go
func (g *Generator) Add(r Runnable) { g.Runners = append(g.Runners, r) }
[ "func", "(", "g", "*", "Generator", ")", "Add", "(", "r", "Runnable", ")", "{", "g", ".", "Runners", "=", "append", "(", "g", ".", "Runners", ",", "r", ")", "\n", "}" ]
// Add a Runnable generator to the list
[ "Add", "a", "Runnable", "generator", "to", "the", "list" ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/makr.go#L40-L42
17,121
gobuffalo/makr
makr.go
Run
func (g *Generator) Run(rootPath string, data Data) error { // defer g.fmt(rootPath) dd := Data{} for k, v := range data { dd[k] = v } for k, v := range g.Data { dd[k] = v } ctx, cancel := context.WithCancel(context.Background()) defer cancel() return chdir(rootPath, func() error { if g.Should != nil { ...
go
func (g *Generator) Run(rootPath string, data Data) error { // defer g.fmt(rootPath) dd := Data{} for k, v := range data { dd[k] = v } for k, v := range g.Data { dd[k] = v } ctx, cancel := context.WithCancel(context.Background()) defer cancel() return chdir(rootPath, func() error { if g.Should != nil { ...
[ "func", "(", "g", "*", "Generator", ")", "Run", "(", "rootPath", "string", ",", "data", "Data", ")", "error", "{", "// defer g.fmt(rootPath)", "dd", ":=", "Data", "{", "}", "\n", "for", "k", ",", "v", ":=", "range", "data", "{", "dd", "[", "k", "]"...
// Run all of the generators
[ "Run", "all", "of", "the", "generators" ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/makr.go#L45-L84
17,122
gobuffalo/makr
makr.go
Fmt
func (g *Generator) Fmt(rootPath string) { pwd, _ := os.Getwd() files := []string{} filepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error { path = strings.TrimPrefix(path, pwd+"/") if strings.Contains(path, ".git") || strings.Contains(path, "node_modules") || strings.Contains(path, "vendor...
go
func (g *Generator) Fmt(rootPath string) { pwd, _ := os.Getwd() files := []string{} filepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error { path = strings.TrimPrefix(path, pwd+"/") if strings.Contains(path, ".git") || strings.Contains(path, "node_modules") || strings.Contains(path, "vendor...
[ "func", "(", "g", "*", "Generator", ")", "Fmt", "(", "rootPath", "string", ")", "{", "pwd", ",", "_", ":=", "os", ".", "Getwd", "(", ")", "\n", "files", ":=", "[", "]", "string", "{", "}", "\n", "filepath", ".", "Walk", "(", "rootPath", ",", "f...
// Fmt formats Go code using `goimports` if available, or `gofmt` otherwise.
[ "Fmt", "formats", "Go", "code", "using", "goimports", "if", "available", "or", "gofmt", "otherwise", "." ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/makr.go#L87-L111
17,123
gobuffalo/makr
helpers.go
toJSON
func toJSON(v interface{}) string { b, err := json.Marshal(v) if err != nil { return err.Error() } return string(b) }
go
func toJSON(v interface{}) string { b, err := json.Marshal(v) if err != nil { return err.Error() } return string(b) }
[ "func", "toJSON", "(", "v", "interface", "{", "}", ")", "string", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ".", "Error", "(", ")", "\n", "}", "\n", "return", "strin...
// ToJSON converts an interface into a string.
[ "ToJSON", "converts", "an", "interface", "into", "a", "string", "." ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/helpers.go#L27-L33
17,124
gobuffalo/makr
command.go
NewCommand
func NewCommand(cmd *exec.Cmd) Command { return Command{ Command: cmd, Should: nullShould, } }
go
func NewCommand(cmd *exec.Cmd) Command { return Command{ Command: cmd, Should: nullShould, } }
[ "func", "NewCommand", "(", "cmd", "*", "exec", ".", "Cmd", ")", "Command", "{", "return", "Command", "{", "Command", ":", "cmd", ",", "Should", ":", "nullShould", ",", "}", "\n", "}" ]
// NewCommand ready to run
[ "NewCommand", "ready", "to", "run" ]
bfe537384e6f4cf8a4d9d149bae4f519b186c9fe
https://github.com/gobuffalo/makr/blob/bfe537384e6f4cf8a4d9d149bae4f519b186c9fe/command.go#L33-L38
17,125
plouc/go-gitlab-client
gitlab/gitlab.go
NewGitlab
func NewGitlab(baseUrl, apiPath, token string) *Gitlab { config := &tls.Config{InsecureSkipVerify: *skipCertVerify} tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, TLSClientConfig: config, } client := &http.Client{Transport: tr} if apiPath == "" { apiPath = "/api/v4" } return &Gitlab{ ...
go
func NewGitlab(baseUrl, apiPath, token string) *Gitlab { config := &tls.Config{InsecureSkipVerify: *skipCertVerify} tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, TLSClientConfig: config, } client := &http.Client{Transport: tr} if apiPath == "" { apiPath = "/api/v4" } return &Gitlab{ ...
[ "func", "NewGitlab", "(", "baseUrl", ",", "apiPath", ",", "token", "string", ")", "*", "Gitlab", "{", "config", ":=", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "*", "skipCertVerify", "}", "\n", "tr", ":=", "&", "http", ".", "Transport", ...
// NewGitlab generates a new gitlab service
[ "NewGitlab", "generates", "a", "new", "gitlab", "service" ]
28ef62c6f58bb480809e5347ba630ae7352e78cf
https://github.com/plouc/go-gitlab-client/blob/28ef62c6f58bb480809e5347ba630ae7352e78cf/gitlab/gitlab.go#L75-L93
17,126
plouc/go-gitlab-client
gitlab/gitlab.go
ResourceUrlQ
func (g *Gitlab) ResourceUrlQ(path string, params map[string]string, qs interface{}) *url.URL { u := g.ResourceUrl(path, params) if qs != nil { v, err := query.Values(qs) if err != nil { panic("Error while building gitlab url, unable to set query string") } u.RawQuery = v.Encode() } return u }
go
func (g *Gitlab) ResourceUrlQ(path string, params map[string]string, qs interface{}) *url.URL { u := g.ResourceUrl(path, params) if qs != nil { v, err := query.Values(qs) if err != nil { panic("Error while building gitlab url, unable to set query string") } u.RawQuery = v.Encode() } return u }
[ "func", "(", "g", "*", "Gitlab", ")", "ResourceUrlQ", "(", "path", "string", ",", "params", "map", "[", "string", "]", "string", ",", "qs", "interface", "{", "}", ")", "*", "url", ".", "URL", "{", "u", ":=", "g", ".", "ResourceUrl", "(", "path", ...
// ResourceUrlQ generates an url and appends a query string to it if available
[ "ResourceUrlQ", "generates", "an", "url", "and", "appends", "a", "query", "string", "to", "it", "if", "available" ]
28ef62c6f58bb480809e5347ba630ae7352e78cf
https://github.com/plouc/go-gitlab-client/blob/28ef62c6f58bb480809e5347ba630ae7352e78cf/gitlab/gitlab.go#L117-L130
17,127
plouc/go-gitlab-client
gitlab/hook_payload.go
ParseHook
func ParseHook(payload []byte) (*HookPayload, error) { hp := HookPayload{} if err := json.Unmarshal(payload, &hp); err != nil { return nil, err } // Basic sanity check switch { case len(hp.ObjectKind) == 0: // Assume this is a post-receive within repository if len(hp.After) == 0 { return nil, fmt.Errorf...
go
func ParseHook(payload []byte) (*HookPayload, error) { hp := HookPayload{} if err := json.Unmarshal(payload, &hp); err != nil { return nil, err } // Basic sanity check switch { case len(hp.ObjectKind) == 0: // Assume this is a post-receive within repository if len(hp.After) == 0 { return nil, fmt.Errorf...
[ "func", "ParseHook", "(", "payload", "[", "]", "byte", ")", "(", "*", "HookPayload", ",", "error", ")", "{", "hp", ":=", "HookPayload", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "payload", ",", "&", "hp", ")", ";", "err", ...
// ParseHook parses hook payload from GitLab
[ "ParseHook", "parses", "hook", "payload", "from", "GitLab" ]
28ef62c6f58bb480809e5347ba630ae7352e78cf
https://github.com/plouc/go-gitlab-client/blob/28ef62c6f58bb480809e5347ba630ae7352e78cf/gitlab/hook_payload.go#L82-L108
17,128
plouc/go-gitlab-client
gitlab/hook_payload.go
Branch
func (h *HookPayload) Branch() string { ref := h.Ref if h.ObjectAttributes != nil && len(h.ObjectAttributes.Ref) > 0 { ref = h.ObjectAttributes.Ref } return strings.TrimPrefix(ref, "refs/heads/") }
go
func (h *HookPayload) Branch() string { ref := h.Ref if h.ObjectAttributes != nil && len(h.ObjectAttributes.Ref) > 0 { ref = h.ObjectAttributes.Ref } return strings.TrimPrefix(ref, "refs/heads/") }
[ "func", "(", "h", "*", "HookPayload", ")", "Branch", "(", ")", "string", "{", "ref", ":=", "h", ".", "Ref", "\n", "if", "h", ".", "ObjectAttributes", "!=", "nil", "&&", "len", "(", "h", ".", "ObjectAttributes", ".", "Ref", ")", ">", "0", "{", "re...
// Branch returns current branch for pipeline and push event hook // payload // This function returns empty string for any other events
[ "Branch", "returns", "current", "branch", "for", "pipeline", "and", "push", "event", "hook", "payload", "This", "function", "returns", "empty", "string", "for", "any", "other", "events" ]
28ef62c6f58bb480809e5347ba630ae7352e78cf
https://github.com/plouc/go-gitlab-client/blob/28ef62c6f58bb480809e5347ba630ae7352e78cf/gitlab/hook_payload.go#L113-L120
17,129
plouc/go-gitlab-client
gitlab/hook_payload.go
Head
func (h *HookPayload) Head() hCommit { c := hCommit{} for _, cm := range h.Commits { if h.After == cm.Id { return cm } } return c }
go
func (h *HookPayload) Head() hCommit { c := hCommit{} for _, cm := range h.Commits { if h.After == cm.Id { return cm } } return c }
[ "func", "(", "h", "*", "HookPayload", ")", "Head", "(", ")", "hCommit", "{", "c", ":=", "hCommit", "{", "}", "\n", "for", "_", ",", "cm", ":=", "range", "h", ".", "Commits", "{", "if", "h", ".", "After", "==", "cm", ".", "Id", "{", "return", ...
// Head returns the latest changeset for push event hook payload
[ "Head", "returns", "the", "latest", "changeset", "for", "push", "event", "hook", "payload" ]
28ef62c6f58bb480809e5347ba630ae7352e78cf
https://github.com/plouc/go-gitlab-client/blob/28ef62c6f58bb480809e5347ba630ae7352e78cf/gitlab/hook_payload.go#L123-L131
17,130
rveen/ogdl
gettypes.go
Int64
func (g *Graph) Int64(def ...int64) int64 { n, ok := _int64f(g.String()) if !ok { if len(def) == 0 { return 0 } return def[0] } return n }
go
func (g *Graph) Int64(def ...int64) int64 { n, ok := _int64f(g.String()) if !ok { if len(def) == 0 { return 0 } return def[0] } return n }
[ "func", "(", "g", "*", "Graph", ")", "Int64", "(", "def", "...", "int64", ")", "int64", "{", "n", ",", "ok", ":=", "_int64f", "(", "g", ".", "String", "(", ")", ")", "\n", "if", "!", "ok", "{", "if", "len", "(", "def", ")", "==", "0", "{", ...
// Int64 returns the node as an int64. If the node is not a number, it // returns 0, or the default value if given.
[ "Int64", "returns", "the", "node", "as", "an", "int64", ".", "If", "the", "node", "is", "not", "a", "number", "it", "returns", "0", "or", "the", "default", "value", "if", "given", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L40-L49
17,131
rveen/ogdl
gettypes.go
Float64
func (g *Graph) Float64(def ...float64) float64 { n, ok := _float64f(g.String()) if !ok { if len(def) == 0 { return math.NaN() } return def[0] } return n }
go
func (g *Graph) Float64(def ...float64) float64 { n, ok := _float64f(g.String()) if !ok { if len(def) == 0 { return math.NaN() } return def[0] } return n }
[ "func", "(", "g", "*", "Graph", ")", "Float64", "(", "def", "...", "float64", ")", "float64", "{", "n", ",", "ok", ":=", "_float64f", "(", "g", ".", "String", "(", ")", ")", "\n", "if", "!", "ok", "{", "if", "len", "(", "def", ")", "==", "0",...
// Float64 returns the node as a float64. If the node is not a number, it // return NaN, or the default value if given.
[ "Float64", "returns", "the", "node", "as", "a", "float64", ".", "If", "the", "node", "is", "not", "a", "number", "it", "return", "NaN", "or", "the", "default", "value", "if", "given", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L53-L62
17,132
rveen/ogdl
gettypes.go
Bool
func (g *Graph) Bool(def ...bool) bool { n, ok := _boolf(g.String()) if !ok { if len(def) == 0 { return false } return def[0] } return n }
go
func (g *Graph) Bool(def ...bool) bool { n, ok := _boolf(g.String()) if !ok { if len(def) == 0 { return false } return def[0] } return n }
[ "func", "(", "g", "*", "Graph", ")", "Bool", "(", "def", "...", "bool", ")", "bool", "{", "n", ",", "ok", ":=", "_boolf", "(", "g", ".", "String", "(", ")", ")", "\n", "if", "!", "ok", "{", "if", "len", "(", "def", ")", "==", "0", "{", "r...
// Bool returns the node as a boolean. If the node is not a // boolean, it returns false, or the default value if given.
[ "Bool", "returns", "the", "node", "as", "a", "boolean", ".", "If", "the", "node", "is", "not", "a", "boolean", "it", "returns", "false", "or", "the", "default", "value", "if", "given", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L66-L75
17,133
rveen/ogdl
gettypes.go
String
func (g *Graph) String(def ...string) string { // If g is nil, return default or nothing if g == nil { if len(def) == 0 { return "" } return def[0] } return _string(g.Interface()) }
go
func (g *Graph) String(def ...string) string { // If g is nil, return default or nothing if g == nil { if len(def) == 0 { return "" } return def[0] } return _string(g.Interface()) }
[ "func", "(", "g", "*", "Graph", ")", "String", "(", "def", "...", "string", ")", "string", "{", "// If g is nil, return default or nothing", "if", "g", "==", "nil", "{", "if", "len", "(", "def", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "...
// String returns a string representation of this node, or an empty string. // This function doesn't return an error, because it is mostly used in single // variable return situations. // String accepts one default value, which will be returned instead of an // empty string.
[ "String", "returns", "a", "string", "representation", "of", "this", "node", "or", "an", "empty", "string", ".", "This", "function", "doesn", "t", "return", "an", "error", "because", "it", "is", "mostly", "used", "in", "single", "variable", "return", "situati...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L92-L103
17,134
rveen/ogdl
gettypes.go
ThisString
func (g *Graph) ThisString(def ...string) string { // If g is nil, return default or nothing if g == nil { if len(def) == 0 { return "" } return def[0] } return _string(g.This) }
go
func (g *Graph) ThisString(def ...string) string { // If g is nil, return default or nothing if g == nil { if len(def) == 0 { return "" } return def[0] } return _string(g.This) }
[ "func", "(", "g", "*", "Graph", ")", "ThisString", "(", "def", "...", "string", ")", "string", "{", "// If g is nil, return default or nothing", "if", "g", "==", "nil", "{", "if", "len", "(", "def", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}",...
// ThisString returns the current node content as a string
[ "ThisString", "returns", "the", "current", "node", "content", "as", "a", "string" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L106-L117
17,135
rveen/ogdl
gettypes.go
ThisScalar
func (g *Graph) ThisScalar() interface{} { itf := g.This if itf == nil && g.Out != nil { itf = g.Out[0].This } // If it ca be parsed as a number, return it. n := number(itf) if n != nil { return n } // If it can be parsed as a bool, return it. b, ok := _boolf(itf) if ok { return b } // Else return...
go
func (g *Graph) ThisScalar() interface{} { itf := g.This if itf == nil && g.Out != nil { itf = g.Out[0].This } // If it ca be parsed as a number, return it. n := number(itf) if n != nil { return n } // If it can be parsed as a bool, return it. b, ok := _boolf(itf) if ok { return b } // Else return...
[ "func", "(", "g", "*", "Graph", ")", "ThisScalar", "(", ")", "interface", "{", "}", "{", "itf", ":=", "g", ".", "This", "\n", "if", "itf", "==", "nil", "&&", "g", ".", "Out", "!=", "nil", "{", "itf", "=", "g", ".", "Out", "[", "0", "]", "."...
// ThisScalar returns this node's content as an interface
[ "ThisScalar", "returns", "this", "node", "s", "content", "as", "an", "interface" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L187-L208
17,136
rveen/ogdl
gettypes.go
Interface
func (g *Graph) Interface() interface{} { if g.Out != nil && len(g.Out) != 0 { return g.Out[0].This } return nil }
go
func (g *Graph) Interface() interface{} { if g.Out != nil && len(g.Out) != 0 { return g.Out[0].This } return nil }
[ "func", "(", "g", "*", "Graph", ")", "Interface", "(", ")", "interface", "{", "}", "{", "if", "g", ".", "Out", "!=", "nil", "&&", "len", "(", "g", ".", "Out", ")", "!=", "0", "{", "return", "g", ".", "Out", "[", "0", "]", ".", "This", "\n",...
// Interface returns the first child of this node as an interface
[ "Interface", "returns", "the", "first", "child", "of", "this", "node", "as", "an", "interface" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L211-L216
17,137
rveen/ogdl
gettypes.go
number
func number(itf interface{}) interface{} { if itf == nil { return nil } f, ok := _float64(itf) if ok { return f } i, ok := _int64(itf) if ok { return i } s := _string(itf) if len(s) == 0 { return nil } if isInteger(s) { n, err := strconv.ParseInt(s, 10, 64) if err != nil { return nil }...
go
func number(itf interface{}) interface{} { if itf == nil { return nil } f, ok := _float64(itf) if ok { return f } i, ok := _int64(itf) if ok { return i } s := _string(itf) if len(s) == 0 { return nil } if isInteger(s) { n, err := strconv.ParseInt(s, 10, 64) if err != nil { return nil }...
[ "func", "number", "(", "itf", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "itf", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "f", ",", "ok", ":=", "_float64", "(", "itf", ")", "\n", "if", "ok", "{", "return", "f", "\...
// number tries hard to convert the parameter to an int64 or float64. If it // cannot, then it returns nil.
[ "number", "tries", "hard", "to", "convert", "the", "parameter", "to", "an", "int64", "or", "float64", ".", "If", "it", "cannot", "then", "it", "returns", "nil", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L220-L254
17,138
rveen/ogdl
gettypes.go
GetBytes
func (g *Graph) GetBytes(path string) ([]byte, error) { if len(path) == 0 { return g.Bytes(), nil } i := g.Get(path) if i == nil { return nil, errors.New("not found") } if i.Len() == 0 { return nil, errors.New("Get() design error: not subnodes") } return _bytes(i.Out[0].This), nil }
go
func (g *Graph) GetBytes(path string) ([]byte, error) { if len(path) == 0 { return g.Bytes(), nil } i := g.Get(path) if i == nil { return nil, errors.New("not found") } if i.Len() == 0 { return nil, errors.New("Get() design error: not subnodes") } return _bytes(i.Out[0].This), nil }
[ "func", "(", "g", "*", "Graph", ")", "GetBytes", "(", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "path", ")", "==", "0", "{", "return", "g", ".", "Bytes", "(", ")", ",", "nil", "\n", "}", "\n\n", ...
// GetBytes returns the result of applying a path to the given Graph. // The result is returned as a byte slice.
[ "GetBytes", "returns", "the", "result", "of", "applying", "a", "path", "to", "the", "given", "Graph", ".", "The", "result", "is", "returned", "as", "a", "byte", "slice", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L277-L291
17,139
rveen/ogdl
gettypes.go
GetInt64
func (g *Graph) GetInt64(path string) (int64, error) { if len(path) == 0 { return g.Int64(), nil } i := g.Get(path) if i == nil { return 0, errors.New("not found") } if i.Len() == 0 { return 0, errors.New("Get() design error: not subnodes") } j, ok := _int64f(i.Out[0].This) if !ok { return 0, errors....
go
func (g *Graph) GetInt64(path string) (int64, error) { if len(path) == 0 { return g.Int64(), nil } i := g.Get(path) if i == nil { return 0, errors.New("not found") } if i.Len() == 0 { return 0, errors.New("Get() design error: not subnodes") } j, ok := _int64f(i.Out[0].This) if !ok { return 0, errors....
[ "func", "(", "g", "*", "Graph", ")", "GetInt64", "(", "path", "string", ")", "(", "int64", ",", "error", ")", "{", "if", "len", "(", "path", ")", "==", "0", "{", "return", "g", ".", "Int64", "(", ")", ",", "nil", "\n", "}", "\n\n", "i", ":=",...
// GetInt64 returns the result of applying a path to the given Graph. // The result is returned as an int64. If the path result cannot be converted // to an integer, then an error is returned.
[ "GetInt64", "returns", "the", "result", "of", "applying", "a", "path", "to", "the", "given", "Graph", ".", "The", "result", "is", "returned", "as", "an", "int64", ".", "If", "the", "path", "result", "cannot", "be", "converted", "to", "an", "integer", "th...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L296-L314
17,140
rveen/ogdl
gettypes.go
GetFloat64
func (g *Graph) GetFloat64(path string) (float64, error) { if len(path) == 0 { return g.Float64(), nil } i := g.Get(path) if i == nil { return 0, errors.New("not found") } if i.Len() == 0 { return 0, errors.New("Get() design error: not subnodes") } j, ok := _float64f(i.Out[0].This) if !ok { return 0,...
go
func (g *Graph) GetFloat64(path string) (float64, error) { if len(path) == 0 { return g.Float64(), nil } i := g.Get(path) if i == nil { return 0, errors.New("not found") } if i.Len() == 0 { return 0, errors.New("Get() design error: not subnodes") } j, ok := _float64f(i.Out[0].This) if !ok { return 0,...
[ "func", "(", "g", "*", "Graph", ")", "GetFloat64", "(", "path", "string", ")", "(", "float64", ",", "error", ")", "{", "if", "len", "(", "path", ")", "==", "0", "{", "return", "g", ".", "Float64", "(", ")", ",", "nil", "\n", "}", "\n\n", "i", ...
// GetFloat64 returns the result of applying a path to the given Graph. // The result is returned as a float64. If the path result cannot be converted // to a float, then an error is returned.
[ "GetFloat64", "returns", "the", "result", "of", "applying", "a", "path", "to", "the", "given", "Graph", ".", "The", "result", "is", "returned", "as", "a", "float64", ".", "If", "the", "path", "result", "cannot", "be", "converted", "to", "a", "float", "th...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L319-L337
17,141
rveen/ogdl
gettypes.go
GetBool
func (g *Graph) GetBool(path string) (bool, error) { if len(path) == 0 { return g.Bool(), nil } i := g.Get(path) if i == nil { return false, errors.New("not found") } if i.Len() == 0 { return false, errors.New("Get() design error: not subnodes") } j, ok := _boolf(i.Out[0].This) if !ok { return false,...
go
func (g *Graph) GetBool(path string) (bool, error) { if len(path) == 0 { return g.Bool(), nil } i := g.Get(path) if i == nil { return false, errors.New("not found") } if i.Len() == 0 { return false, errors.New("Get() design error: not subnodes") } j, ok := _boolf(i.Out[0].This) if !ok { return false,...
[ "func", "(", "g", "*", "Graph", ")", "GetBool", "(", "path", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "len", "(", "path", ")", "==", "0", "{", "return", "g", ".", "Bool", "(", ")", ",", "nil", "\n", "}", "\n\n", "i", ":=", ...
// GetBool returns the result of applying a path to the given Graph. // The result is returned as a bool. If the path result cannot be converted // to a boolean, then an error is returned.
[ "GetBool", "returns", "the", "result", "of", "applying", "a", "path", "to", "the", "given", "Graph", ".", "The", "result", "is", "returned", "as", "a", "bool", ".", "If", "the", "path", "result", "cannot", "be", "converted", "to", "a", "boolean", "then",...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L342-L360
17,142
rveen/ogdl
gettypes.go
isNumber
func isNumber(s string) bool { if len(s) == 0 { return false } if !IsDigit(rune(s[0])) { if len(s) < 2 || s[0] != '-' || !IsDigit(rune(s[1])) { return false } } return true }
go
func isNumber(s string) bool { if len(s) == 0 { return false } if !IsDigit(rune(s[0])) { if len(s) < 2 || s[0] != '-' || !IsDigit(rune(s[1])) { return false } } return true }
[ "func", "isNumber", "(", "s", "string", ")", "bool", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "if", "!", "IsDigit", "(", "rune", "(", "s", "[", "0", "]", ")", ")", "{", "if", "len", "(", "s", ")",...
// isNumber is only used in eval.go
[ "isNumber", "is", "only", "used", "in", "eval", ".", "go" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L584-L594
17,143
rveen/ogdl
gettypes.go
isInteger
func isInteger(s string) bool { l := len(s) if l == 0 { return false } i := 0 for ; i < l; i++ { if !IsSpaceChar(s[i]) { break } } if s[i] == '-' { i++ } n := 0 for ; i < l; i++ { if !IsDigit(rune(s[i])) { break } n++ } if n == 0 { return false } for ; i < l; i++ { if !IsSp...
go
func isInteger(s string) bool { l := len(s) if l == 0 { return false } i := 0 for ; i < l; i++ { if !IsSpaceChar(s[i]) { break } } if s[i] == '-' { i++ } n := 0 for ; i < l; i++ { if !IsDigit(rune(s[i])) { break } n++ } if n == 0 { return false } for ; i < l; i++ { if !IsSp...
[ "func", "isInteger", "(", "s", "string", ")", "bool", "{", "l", ":=", "len", "(", "s", ")", "\n\n", "if", "l", "==", "0", "{", "return", "false", "\n", "}", "\n\n", "i", ":=", "0", "\n\n", "for", ";", "i", "<", "l", ";", "i", "++", "{", "if...
// IsInteger returns true for strings containing exclusively digits, with an // optional minus sign at the beginning. Starting and trailing spaces are // allowed.
[ "IsInteger", "returns", "true", "for", "strings", "containing", "exclusively", "digits", "with", "an", "optional", "minus", "sign", "at", "the", "beginning", ".", "Starting", "and", "trailing", "spaces", "are", "allowed", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/gettypes.go#L599-L638
17,144
rveen/ogdl
flow.go
NewPath
func NewPath(s string) *Graph { p := NewParser(bytes.NewBuffer([]byte(s))) p.Path() g := p.Graph() g.This = TypePath return g }
go
func NewPath(s string) *Graph { p := NewParser(bytes.NewBuffer([]byte(s))) p.Path() g := p.Graph() g.This = TypePath return g }
[ "func", "NewPath", "(", "s", "string", ")", "*", "Graph", "{", "p", ":=", "NewParser", "(", "bytes", ".", "NewBuffer", "(", "[", "]", "byte", "(", "s", ")", ")", ")", "\n", "p", ".", "Path", "(", ")", "\n", "g", ":=", "p", ".", "Graph", "(", ...
// NewPath takes a Unicode string representing an OGDL path, parses it and // returns it as a Graph object. // // It also parses extended paths, as those used in templates, which may have // argument lists.
[ "NewPath", "takes", "a", "Unicode", "string", "representing", "an", "OGDL", "path", "parses", "it", "and", "returns", "it", "as", "a", "Graph", "object", ".", "It", "also", "parses", "extended", "paths", "as", "those", "used", "in", "templates", "which", "...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/flow.go#L13-L19
17,145
rveen/ogdl
lexer.go
NewLexer
func NewLexer(rd io.Reader) *Lexer { p := Lexer{} p.rd = rd p.lastByte = bufSize p.buf = make([]byte, bufSize) p.r = -1 p.fill() return &p }
go
func NewLexer(rd io.Reader) *Lexer { p := Lexer{} p.rd = rd p.lastByte = bufSize p.buf = make([]byte, bufSize) p.r = -1 p.fill() return &p }
[ "func", "NewLexer", "(", "rd", "io", ".", "Reader", ")", "*", "Lexer", "{", "p", ":=", "Lexer", "{", "}", "\n", "p", ".", "rd", "=", "rd", "\n", "p", ".", "lastByte", "=", "bufSize", "\n", "p", ".", "buf", "=", "make", "(", "[", "]", "byte", ...
// NewLexer returns a new Lexer whose buffer has the default size.
[ "NewLexer", "returns", "a", "new", "Lexer", "whose", "buffer", "has", "the", "default", "size", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L51-L59
17,146
rveen/ogdl
lexer.go
fill
func (p *Lexer) fill() { if p.r >= 0 && p.r < bufSize { return } // Read new data: try a limited number of times. // The first time read the full buffer, else only half. offset := 0 if p.r >= 0 { copy(p.buf, p.buf[halfSize:]) p.r = halfSize offset = halfSize } else { p.r = 0 } for i := maxConsecut...
go
func (p *Lexer) fill() { if p.r >= 0 && p.r < bufSize { return } // Read new data: try a limited number of times. // The first time read the full buffer, else only half. offset := 0 if p.r >= 0 { copy(p.buf, p.buf[halfSize:]) p.r = halfSize offset = halfSize } else { p.r = 0 } for i := maxConsecut...
[ "func", "(", "p", "*", "Lexer", ")", "fill", "(", ")", "{", "if", "p", ".", "r", ">=", "0", "&&", "p", ".", "r", "<", "bufSize", "{", "return", "\n", "}", "\n\n", "// Read new data: try a limited number of times.", "// The first time read the full buffer, else...
// fill reads a new chunk into the buffer. // // The first time, the buffer is filled completely. After reading the last byte from // the buffer, the last half is preserved and moved to the start, and the other // half filled with new bytes, if available.
[ "fill", "reads", "a", "new", "chunk", "into", "the", "buffer", ".", "The", "first", "time", "the", "buffer", "is", "filled", "completely", ".", "After", "reading", "the", "last", "byte", "from", "the", "buffer", "the", "last", "half", "is", "preserved", ...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L66-L100
17,147
rveen/ogdl
lexer.go
PeekByte
func (p *Lexer) PeekByte() byte { c, err := p.Byte() if err != nil { return 0 } p.UnreadByte() return c }
go
func (p *Lexer) PeekByte() byte { c, err := p.Byte() if err != nil { return 0 } p.UnreadByte() return c }
[ "func", "(", "p", "*", "Lexer", ")", "PeekByte", "(", ")", "byte", "{", "c", ",", "err", ":=", "p", ".", "Byte", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "0", "\n", "}", "\n\n", "p", ".", "UnreadByte", "(", ")", "\n", "retur...
// PeekByte returns the next byte witohut consuming it
[ "PeekByte", "returns", "the", "next", "byte", "witohut", "consuming", "it" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L109-L118
17,148
rveen/ogdl
lexer.go
PeekRune
func (p *Lexer) PeekRune() (rune, error) { r, err := p.Rune() if err != nil { return 0, nil } return r, p.UnreadRune() }
go
func (p *Lexer) PeekRune() (rune, error) { r, err := p.Rune() if err != nil { return 0, nil } return r, p.UnreadRune() }
[ "func", "(", "p", "*", "Lexer", ")", "PeekRune", "(", ")", "(", "rune", ",", "error", ")", "{", "r", ",", "err", ":=", "p", ".", "Rune", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "nil", "\n", "}", "\n\n", "return", ...
// PeekRune returns the next rune witohut consuming it
[ "PeekRune", "returns", "the", "next", "rune", "witohut", "consuming", "it" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L121-L129
17,149
rveen/ogdl
lexer.go
Byte
func (p *Lexer) Byte() (byte, error) { if p.lastByte < bufSize && p.r >= p.lastByte { p.r = p.lastByte + 1 return 0, ErrEOS } c := p.buf[p.r] p.r++ p.fill() return c, nil }
go
func (p *Lexer) Byte() (byte, error) { if p.lastByte < bufSize && p.r >= p.lastByte { p.r = p.lastByte + 1 return 0, ErrEOS } c := p.buf[p.r] p.r++ p.fill() return c, nil }
[ "func", "(", "p", "*", "Lexer", ")", "Byte", "(", ")", "(", "byte", ",", "error", ")", "{", "if", "p", ".", "lastByte", "<", "bufSize", "&&", "p", ".", "r", ">=", "p", ".", "lastByte", "{", "p", ".", "r", "=", "p", ".", "lastByte", "+", "1"...
// Byte reads and returns a single byte. // If no byte is available, returns 0 and an error.
[ "Byte", "reads", "and", "returns", "a", "single", "byte", ".", "If", "no", "byte", "is", "available", "returns", "0", "and", "an", "error", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L133-L143
17,150
rveen/ogdl
lexer.go
UnreadRune
func (p *Lexer) UnreadRune() error { if len(p.lastRuneSize) == 0 { return ErrInvalidUnread } p.r -= p.lastRuneSize[len(p.lastRuneSize)-1] p.lastRuneSize = p.lastRuneSize[:len(p.lastRuneSize)-1] return nil }
go
func (p *Lexer) UnreadRune() error { if len(p.lastRuneSize) == 0 { return ErrInvalidUnread } p.r -= p.lastRuneSize[len(p.lastRuneSize)-1] p.lastRuneSize = p.lastRuneSize[:len(p.lastRuneSize)-1] return nil }
[ "func", "(", "p", "*", "Lexer", ")", "UnreadRune", "(", ")", "error", "{", "if", "len", "(", "p", ".", "lastRuneSize", ")", "==", "0", "{", "return", "ErrInvalidUnread", "\n", "}", "\n\n", "p", ".", "r", "-=", "p", ".", "lastRuneSize", "[", "len", ...
// UnreadRune unreads the last rune.
[ "UnreadRune", "unreads", "the", "last", "rune", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L171-L180
17,151
rveen/ogdl
lexer.go
String
func (p *Lexer) String() (string, bool) { var buf []byte for { c, _ := p.Byte() if !IsTextChar(c) { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
go
func (p *Lexer) String() (string, bool) { var buf []byte for { c, _ := p.Byte() if !IsTextChar(c) { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
[ "func", "(", "p", "*", "Lexer", ")", "String", "(", ")", "(", "string", ",", "bool", ")", "{", "var", "buf", "[", "]", "byte", "\n\n", "for", "{", "c", ",", "_", ":=", "p", ".", "Byte", "(", ")", "\n", "if", "!", "IsTextChar", "(", "c", ")"...
// String is a concatenation of characters that are > 0x20
[ "String", "is", "a", "concatenation", "of", "characters", "that", "are", ">", "0x20" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L183-L197
17,152
rveen/ogdl
lexer.go
StringStop
func (p *Lexer) StringStop(stopBytes []byte) (string, bool) { var buf []byte for { c, _ := p.Byte() if !IsTextChar(c) || bytes.IndexByte(stopBytes, c) != -1 { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
go
func (p *Lexer) StringStop(stopBytes []byte) (string, bool) { var buf []byte for { c, _ := p.Byte() if !IsTextChar(c) || bytes.IndexByte(stopBytes, c) != -1 { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
[ "func", "(", "p", "*", "Lexer", ")", "StringStop", "(", "stopBytes", "[", "]", "byte", ")", "(", "string", ",", "bool", ")", "{", "var", "buf", "[", "]", "byte", "\n\n", "for", "{", "c", ",", "_", ":=", "p", ".", "Byte", "(", ")", "\n", "if",...
// StringStop is a concatenation of text bytes that are not in the parameter stopBytes
[ "StringStop", "is", "a", "concatenation", "of", "text", "bytes", "that", "are", "not", "in", "the", "parameter", "stopBytes" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L200-L214
17,153
rveen/ogdl
lexer.go
End
func (p *Lexer) End() bool { c, err := p.Byte() if err != nil { return true } if IsEndChar(c) { return true } p.UnreadByte() return false }
go
func (p *Lexer) End() bool { c, err := p.Byte() if err != nil { return true } if IsEndChar(c) { return true } p.UnreadByte() return false }
[ "func", "(", "p", "*", "Lexer", ")", "End", "(", ")", "bool", "{", "c", ",", "err", ":=", "p", ".", "Byte", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "if", "IsEndChar", "(", "c", ")", "{", "return",...
// End returns true if the end of stream has been reached.
[ "End", "returns", "true", "if", "the", "end", "of", "stream", "has", "been", "reached", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L233-L245
17,154
rveen/ogdl
lexer.go
WhiteSpace
func (p *Lexer) WhiteSpace() bool { any := false for { c, _ := p.Byte() if c != 13 && c != 10 && c != 9 && c != 32 { break } any = true } p.UnreadByte() return any }
go
func (p *Lexer) WhiteSpace() bool { any := false for { c, _ := p.Byte() if c != 13 && c != 10 && c != 9 && c != 32 { break } any = true } p.UnreadByte() return any }
[ "func", "(", "p", "*", "Lexer", ")", "WhiteSpace", "(", ")", "bool", "{", "any", ":=", "false", "\n", "for", "{", "c", ",", "_", ":=", "p", ".", "Byte", "(", ")", "\n", "if", "c", "!=", "13", "&&", "c", "!=", "10", "&&", "c", "!=", "9", "...
// WhiteSpace is equivalent to Space | Break. It consumes all white space, // whether spaces, tabs or newlines
[ "WhiteSpace", "is", "equivalent", "to", "Space", "|", "Break", ".", "It", "consumes", "all", "white", "space", "whether", "spaces", "tabs", "or", "newlines" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L249-L262
17,155
rveen/ogdl
lexer.go
Quoted
func (p *Lexer) Quoted(ind int) (string, bool, error) { c1, _ := p.Byte() if c1 != '"' && c1 != '\'' { p.UnreadByte() return "", false, nil } var buf []byte var c2 byte for { c, _ := p.Byte() if IsEndChar(c) { return "", false, ErrUnterminatedQuotedString } if c == c1 && c2 != '\\' { break ...
go
func (p *Lexer) Quoted(ind int) (string, bool, error) { c1, _ := p.Byte() if c1 != '"' && c1 != '\'' { p.UnreadByte() return "", false, nil } var buf []byte var c2 byte for { c, _ := p.Byte() if IsEndChar(c) { return "", false, ErrUnterminatedQuotedString } if c == c1 && c2 != '\\' { break ...
[ "func", "(", "p", "*", "Lexer", ")", "Quoted", "(", "ind", "int", ")", "(", "string", ",", "bool", ",", "error", ")", "{", "c1", ",", "_", ":=", "p", ".", "Byte", "(", ")", "\n", "if", "c1", "!=", "'\"'", "&&", "c1", "!=", "'\\''", "{", "p"...
// Quoted string. Can have newlines in it. It returns the string if any, a bool // indicating if a quoted string was found, and a possible error.
[ "Quoted", "string", ".", "Can", "have", "newlines", "in", "it", ".", "It", "returns", "the", "string", "if", "any", "a", "bool", "indicating", "if", "a", "quoted", "string", "was", "found", "and", "a", "possible", "error", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L301-L348
17,156
rveen/ogdl
lexer.go
Operator
func (p *Lexer) Operator() (string, bool) { var buf []byte for { c, _ := p.Byte() if !isOperatorChar(c) { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
go
func (p *Lexer) Operator() (string, bool) { var buf []byte for { c, _ := p.Byte() if !isOperatorChar(c) { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
[ "func", "(", "p", "*", "Lexer", ")", "Operator", "(", ")", "(", "string", ",", "bool", ")", "{", "var", "buf", "[", "]", "byte", "\n\n", "for", "{", "c", ",", "_", ":=", "p", ".", "Byte", "(", ")", "\n", "if", "!", "isOperatorChar", "(", "c",...
// Operator returns true if it finds an operator at the current parser position // It returns also the operator found.
[ "Operator", "returns", "true", "if", "it", "finds", "an", "operator", "at", "the", "current", "parser", "position", "It", "returns", "also", "the", "operator", "found", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L424-L438
17,157
rveen/ogdl
lexer.go
TemplateText
func (p *Lexer) TemplateText() (string, bool) { var buf []byte for { c, _ := p.Byte() if !isTemplateTextChar(c) { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
go
func (p *Lexer) TemplateText() (string, bool) { var buf []byte for { c, _ := p.Byte() if !isTemplateTextChar(c) { break } buf = append(buf, c) } p.UnreadByte() return string(buf), len(buf) > 0 }
[ "func", "(", "p", "*", "Lexer", ")", "TemplateText", "(", ")", "(", "string", ",", "bool", ")", "{", "var", "buf", "[", "]", "byte", "\n\n", "for", "{", "c", ",", "_", ":=", "p", ".", "Byte", "(", ")", "\n", "if", "!", "isTemplateTextChar", "("...
// TemplateText parses text in a template.
[ "TemplateText", "parses", "text", "in", "a", "template", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/lexer.go#L441-L454
17,158
rveen/ogdl
graph.go
Equals
func (g *Graph) Equals(c *Graph) bool { if c.This != g.This { return false } if g.Len() != c.Len() { return false } for i := 0; i < g.Len(); i++ { if !g.Out[i].Equals(c.Out[i]) { return false } } return true }
go
func (g *Graph) Equals(c *Graph) bool { if c.This != g.This { return false } if g.Len() != c.Len() { return false } for i := 0; i < g.Len(); i++ { if !g.Out[i].Equals(c.Out[i]) { return false } } return true }
[ "func", "(", "g", "*", "Graph", ")", "Equals", "(", "c", "*", "Graph", ")", "bool", "{", "if", "c", ".", "This", "!=", "g", ".", "This", "{", "return", "false", "\n", "}", "\n", "if", "g", ".", "Len", "(", ")", "!=", "c", ".", "Len", "(", ...
// Equals returns true if the given graph and the receiver graph are equal.
[ "Equals", "returns", "true", "if", "the", "given", "graph", "and", "the", "receiver", "graph", "are", "equal", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L39-L54
17,159
rveen/ogdl
graph.go
Add
func (g *Graph) Add(n interface{}) *Graph { if g == nil { return nil } if node, ok := n.(*Graph); ok && node != nil { g.Out = append(g.Out, node) return node } gg := Graph{n, nil} g.Out = append(g.Out, &gg) return &gg }
go
func (g *Graph) Add(n interface{}) *Graph { if g == nil { return nil } if node, ok := n.(*Graph); ok && node != nil { g.Out = append(g.Out, node) return node } gg := Graph{n, nil} g.Out = append(g.Out, &gg) return &gg }
[ "func", "(", "g", "*", "Graph", ")", "Add", "(", "n", "interface", "{", "}", ")", "*", "Graph", "{", "if", "g", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "node", ",", "ok", ":=", "n", ".", "(", "*", "Graph", ")", ";", "ok"...
// Add adds a subnode to the current node.
[ "Add", "adds", "a", "subnode", "to", "the", "current", "node", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L57-L71
17,160
rveen/ogdl
graph.go
AddNodes
func (g *Graph) AddNodes(g2 *Graph) *Graph { if g == nil { return nil } if g2 != nil { g.Out = append(g.Out, g2.Out...) } return g }
go
func (g *Graph) AddNodes(g2 *Graph) *Graph { if g == nil { return nil } if g2 != nil { g.Out = append(g.Out, g2.Out...) } return g }
[ "func", "(", "g", "*", "Graph", ")", "AddNodes", "(", "g2", "*", "Graph", ")", "*", "Graph", "{", "if", "g", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "g2", "!=", "nil", "{", "g", ".", "Out", "=", "append", "(", "g", ".", ...
// AddNodes adds subnodes of the given Graph to the current node.
[ "AddNodes", "adds", "subnodes", "of", "the", "given", "Graph", "to", "the", "current", "node", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L91-L101
17,161
rveen/ogdl
graph.go
addEqualNodes
func (g *Graph) addEqualNodes(g2 *Graph, key string, recurse bool) *Graph { if g2 != nil { for _, n := range g2.Out { if key == _string(n.This) { g.AddNodes(n) } if recurse { g.addEqualNodes(n, key, true) } } } return g }
go
func (g *Graph) addEqualNodes(g2 *Graph, key string, recurse bool) *Graph { if g2 != nil { for _, n := range g2.Out { if key == _string(n.This) { g.AddNodes(n) } if recurse { g.addEqualNodes(n, key, true) } } } return g }
[ "func", "(", "g", "*", "Graph", ")", "addEqualNodes", "(", "g2", "*", "Graph", ",", "key", "string", ",", "recurse", "bool", ")", "*", "Graph", "{", "if", "g2", "!=", "nil", "{", "for", "_", ",", "n", ":=", "range", "g2", ".", "Out", "{", "if",...
// addEqualNodes adds subnodes of the given Graph to the current node, // if their content equals the given key. Optionally recurse into subnodes // of the receiver graph.
[ "addEqualNodes", "adds", "subnodes", "of", "the", "given", "Graph", "to", "the", "current", "node", "if", "their", "content", "equals", "the", "given", "key", ".", "Optionally", "recurse", "into", "subnodes", "of", "the", "receiver", "graph", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L106-L118
17,162
rveen/ogdl
graph.go
Node
func (g *Graph) Node(s string) *Graph { if g == nil || g.Out == nil { return nil } for _, node := range g.Out { if s == _string(node.This) { return node } } return nil }
go
func (g *Graph) Node(s string) *Graph { if g == nil || g.Out == nil { return nil } for _, node := range g.Out { if s == _string(node.This) { return node } } return nil }
[ "func", "(", "g", "*", "Graph", ")", "Node", "(", "s", "string", ")", "*", "Graph", "{", "if", "g", "==", "nil", "||", "g", ".", "Out", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "for", "_", ",", "node", ":=", "range", "g", ".", "O...
// Node returns the first subnode whose string value is equal to the given string. // It returns nil if not found.
[ "Node", "returns", "the", "first", "subnode", "whose", "string", "value", "is", "equal", "to", "the", "given", "string", ".", "It", "returns", "nil", "if", "not", "found", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L160-L171
17,163
rveen/ogdl
graph.go
Create
func (g *Graph) Create(s string) *Graph { n := g.Node(s) if n == nil { return g.Add(s) } n.Clear() return n }
go
func (g *Graph) Create(s string) *Graph { n := g.Node(s) if n == nil { return g.Add(s) } n.Clear() return n }
[ "func", "(", "g", "*", "Graph", ")", "Create", "(", "s", "string", ")", "*", "Graph", "{", "n", ":=", "g", ".", "Node", "(", "s", ")", "\n", "if", "n", "==", "nil", "{", "return", "g", ".", "Add", "(", "s", ")", "\n", "}", "\n", "n", ".",...
// Create returns the first subnode whose string value is equal to the given string, // with its subnodes deleted. If not found, the node is created and returned.
[ "Create", "returns", "the", "first", "subnode", "whose", "string", "value", "is", "equal", "to", "the", "given", "string", "with", "its", "subnodes", "deleted", ".", "If", "not", "found", "the", "node", "is", "created", "and", "returned", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L175-L182
17,164
rveen/ogdl
graph.go
GetAt
func (g *Graph) GetAt(i int) *Graph { if i >= len(g.Out) || i < 0 { return nil } return g.Out[i] }
go
func (g *Graph) GetAt(i int) *Graph { if i >= len(g.Out) || i < 0 { return nil } return g.Out[i] }
[ "func", "(", "g", "*", "Graph", ")", "GetAt", "(", "i", "int", ")", "*", "Graph", "{", "if", "i", ">=", "len", "(", "g", ".", "Out", ")", "||", "i", "<", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "g", ".", "Out", "[", "i", "...
// GetAt returns a subnode by index, or nil if the index is out of range.
[ "GetAt", "returns", "a", "subnode", "by", "index", "or", "nil", "if", "the", "index", "is", "out", "of", "range", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L185-L191
17,165
rveen/ogdl
graph.go
Delete
func (g *Graph) Delete(n interface{}) { if g == nil { return } for i := 0; i < g.Len(); i++ { if g.Out[i].This == n { if i < (g.Len() - 1) { g.Out = append(g.Out[:i], g.Out[i+1:]...) } else { g.Out = g.Out[:i] } i-- } } }
go
func (g *Graph) Delete(n interface{}) { if g == nil { return } for i := 0; i < g.Len(); i++ { if g.Out[i].This == n { if i < (g.Len() - 1) { g.Out = append(g.Out[:i], g.Out[i+1:]...) } else { g.Out = g.Out[:i] } i-- } } }
[ "func", "(", "g", "*", "Graph", ")", "Delete", "(", "n", "interface", "{", "}", ")", "{", "if", "g", "==", "nil", "{", "return", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "g", ".", "Len", "(", ")", ";", "i", "++", "{", "if", ...
// Delete removes all subnodes with the given content
[ "Delete", "removes", "all", "subnodes", "with", "the", "given", "content" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L216-L231
17,166
rveen/ogdl
graph.go
Clear
func (g *Graph) Clear() { if g == nil || g.Out == nil { return } g.Out = nil }
go
func (g *Graph) Clear() { if g == nil || g.Out == nil { return } g.Out = nil }
[ "func", "(", "g", "*", "Graph", ")", "Clear", "(", ")", "{", "if", "g", "==", "nil", "||", "g", ".", "Out", "==", "nil", "{", "return", "\n", "}", "\n", "g", ".", "Out", "=", "nil", "\n", "}" ]
// Clear removes all subnodes
[ "Clear", "removes", "all", "subnodes" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L234-L240
17,167
rveen/ogdl
graph.go
DeleteAt
func (g *Graph) DeleteAt(i int) { if i < 0 || i >= g.Len() { return } if i < (g.Len() - 1) { g.Out = append(g.Out[:i], g.Out[i+1:]...) } else { g.Out = g.Out[:i] } }
go
func (g *Graph) DeleteAt(i int) { if i < 0 || i >= g.Len() { return } if i < (g.Len() - 1) { g.Out = append(g.Out[:i], g.Out[i+1:]...) } else { g.Out = g.Out[:i] } }
[ "func", "(", "g", "*", "Graph", ")", "DeleteAt", "(", "i", "int", ")", "{", "if", "i", "<", "0", "||", "i", ">=", "g", ".", "Len", "(", ")", "{", "return", "\n", "}", "\n", "if", "i", "<", "(", "g", ".", "Len", "(", ")", "-", "1", ")", ...
// DeleteAt removes a subnode by index
[ "DeleteAt", "removes", "a", "subnode", "by", "index" ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L243-L252
17,168
rveen/ogdl
graph.go
Set
func (g *Graph) Set(s string, val interface{}) *Graph { if g == nil { return nil } // Parse the input string into a Path graph. path := NewPath(s) if path == nil { return nil } return g.set(path, val) }
go
func (g *Graph) Set(s string, val interface{}) *Graph { if g == nil { return nil } // Parse the input string into a Path graph. path := NewPath(s) if path == nil { return nil } return g.set(path, val) }
[ "func", "(", "g", "*", "Graph", ")", "Set", "(", "s", "string", ",", "val", "interface", "{", "}", ")", "*", "Graph", "{", "if", "g", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// Parse the input string into a Path graph.", "path", ":=", "N...
// Set sets the first occurrence of the given path to the value given.
[ "Set", "sets", "the", "first", "occurrence", "of", "the", "given", "path", "to", "the", "value", "given", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L255-L267
17,169
rveen/ogdl
graph.go
Text
func (g *Graph) Text() string { if g == nil { return "" } buffer := &bytes.Buffer{} // Do not print the 'root' node for _, node := range g.Out { node._text(0, buffer, false) } // remove trailing \n s := buffer.String() if len(s) == 0 { return "" } if s[len(s)-1] == '\n' { s = s[0 : len(s)-1] }...
go
func (g *Graph) Text() string { if g == nil { return "" } buffer := &bytes.Buffer{} // Do not print the 'root' node for _, node := range g.Out { node._text(0, buffer, false) } // remove trailing \n s := buffer.String() if len(s) == 0 { return "" } if s[len(s)-1] == '\n' { s = s[0 : len(s)-1] }...
[ "func", "(", "g", "*", "Graph", ")", "Text", "(", ")", "string", "{", "if", "g", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "buffer", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "// Do not print the 'root' node", "for", "_", ...
// Text is the OGDL text emitter. It converts a Graph into OGDL text. // // Strings are quoted if they contain spaces, newlines or special // characters. Null elements are not printed, and act as transparent nodes.
[ "Text", "is", "the", "OGDL", "text", "emitter", ".", "It", "converts", "a", "Graph", "into", "OGDL", "text", ".", "Strings", "are", "quoted", "if", "they", "contain", "spaces", "newlines", "or", "special", "characters", ".", "Null", "elements", "are", "not...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L333-L366
17,170
rveen/ogdl
graph.go
Substitute
func (g *Graph) Substitute(s string, v interface{}) { if g == nil || g.Out == nil { return } for _, n := range g.Out { if _string(n.This) == s { n.This = v } n.Substitute(s, v) } }
go
func (g *Graph) Substitute(s string, v interface{}) { if g == nil || g.Out == nil { return } for _, n := range g.Out { if _string(n.This) == s { n.This = v } n.Substitute(s, v) } }
[ "func", "(", "g", "*", "Graph", ")", "Substitute", "(", "s", "string", ",", "v", "interface", "{", "}", ")", "{", "if", "g", "==", "nil", "||", "g", ".", "Out", "==", "nil", "{", "return", "\n", "}", "\n", "for", "_", ",", "n", ":=", "range",...
// Substitute traverses the graph substituting all nodes with content // equal to s by v.
[ "Substitute", "traverses", "the", "graph", "substituting", "all", "nodes", "with", "content", "equal", "to", "s", "by", "v", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/graph.go#L486-L497
17,171
rveen/ogdl
schema.go
Check
func (g *Graph) Check(x *Graph) (bool, string) { for i := 0; i < g.Len(); i++ { ns := g.GetAt(i) nx := x.GetAt(i) b := ns.checkNode(nx) if !b { if ns != nil { return false, "want " + ns.ThisString() + ", got " + nx.ThisString() } } ok, mess := ns.Check(nx) if !ok { return false, mess } ...
go
func (g *Graph) Check(x *Graph) (bool, string) { for i := 0; i < g.Len(); i++ { ns := g.GetAt(i) nx := x.GetAt(i) b := ns.checkNode(nx) if !b { if ns != nil { return false, "want " + ns.ThisString() + ", got " + nx.ThisString() } } ok, mess := ns.Check(nx) if !ok { return false, mess } ...
[ "func", "(", "g", "*", "Graph", ")", "Check", "(", "x", "*", "Graph", ")", "(", "bool", ",", "string", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "g", ".", "Len", "(", ")", ";", "i", "++", "{", "ns", ":=", "g", ".", "GetAt", "(", "...
// Check returns true if the Graph given as a parameter conforms to the // schema represented by the receiver Graph.
[ "Check", "returns", "true", "if", "the", "Graph", "given", "as", "a", "parameter", "conforms", "to", "the", "schema", "represented", "by", "the", "receiver", "Graph", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/schema.go#L9-L29
17,172
rveen/ogdl
expression.go
ast
func (g *Graph) ast() { if g == nil { return } for _, node := range g.Out { if node.ThisString() == TypeExpression { node._ast() } else { node.ast() } } }
go
func (g *Graph) ast() { if g == nil { return } for _, node := range g.Out { if node.ThisString() == TypeExpression { node._ast() } else { node.ast() } } }
[ "func", "(", "g", "*", "Graph", ")", "ast", "(", ")", "{", "if", "g", "==", "nil", "{", "return", "\n", "}", "\n\n", "for", "_", ",", "node", ":=", "range", "g", ".", "Out", "{", "if", "node", ".", "ThisString", "(", ")", "==", "TypeExpression"...
// Ast reorganizes the expression graph in the form of an abstract syntax tree.
[ "Ast", "reorganizes", "the", "expression", "graph", "in", "the", "form", "of", "an", "abstract", "syntax", "tree", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/expression.go#L24-L37
17,173
rveen/ogdl
template.go
NewTemplateFromBytes
func NewTemplateFromBytes(b []byte) *Graph { p := NewParser(bytes.NewBuffer(b)) p.Template() t := p.Graph() t.This = TypeTemplate t.ast() t.simplify() t.flow() return t }
go
func NewTemplateFromBytes(b []byte) *Graph { p := NewParser(bytes.NewBuffer(b)) p.Template() t := p.Graph() t.This = TypeTemplate t.ast() t.simplify() t.flow() return t }
[ "func", "NewTemplateFromBytes", "(", "b", "[", "]", "byte", ")", "*", "Graph", "{", "p", ":=", "NewParser", "(", "bytes", ".", "NewBuffer", "(", "b", ")", ")", "\n", "p", ".", "Template", "(", ")", "\n\n", "t", ":=", "p", ".", "Graph", "(", ")", ...
// NewTemplateFromBytes has the same function as NewTemplate except that the input stream // is a byte array.
[ "NewTemplateFromBytes", "has", "the", "same", "function", "as", "NewTemplate", "except", "that", "the", "input", "stream", "is", "a", "byte", "array", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/template.go#L54-L65
17,174
rveen/ogdl
template.go
Process
func (g *Graph) Process(ctx *Graph) []byte { buffer := &bytes.Buffer{} g.process(ctx, buffer) return buffer.Bytes() }
go
func (g *Graph) Process(ctx *Graph) []byte { buffer := &bytes.Buffer{} g.process(ctx, buffer) return buffer.Bytes() }
[ "func", "(", "g", "*", "Graph", ")", "Process", "(", "ctx", "*", "Graph", ")", "[", "]", "byte", "{", "buffer", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "g", ".", "process", "(", "ctx", ",", "buffer", ")", "\n\n", "return", "buffer", ...
// Process processes the parsed template, returning the resulting text in a byte array. // The variable parts are resolved out of the Graph given.
[ "Process", "processes", "the", "parsed", "template", "returning", "the", "resulting", "text", "in", "a", "byte", "array", ".", "The", "variable", "parts", "are", "resolved", "out", "of", "the", "Graph", "given", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/template.go#L69-L76
17,175
rveen/ogdl
template.go
simplify
func (g *Graph) simplify() { if g == nil { return } for _, node := range g.Out { if TypePath == node.ThisString() { s := node.GetAt(0).ThisString() switch s { case "if": node.This = TypeIf node.DeleteAt(0) case "end": node.This = TypeEnd node.DeleteAt(0) case "else": node.Th...
go
func (g *Graph) simplify() { if g == nil { return } for _, node := range g.Out { if TypePath == node.ThisString() { s := node.GetAt(0).ThisString() switch s { case "if": node.This = TypeIf node.DeleteAt(0) case "end": node.This = TypeEnd node.DeleteAt(0) case "else": node.Th...
[ "func", "(", "g", "*", "Graph", ")", "simplify", "(", ")", "{", "if", "g", "==", "nil", "{", "return", "\n", "}", "\n\n", "for", "_", ",", "node", ":=", "range", "g", ".", "Out", "{", "if", "TypePath", "==", "node", ".", "ThisString", "(", ")",...
// simplify converts !p TYPE in !TYPE for keywords if, end, else, for and break.
[ "simplify", "converts", "!p", "TYPE", "in", "!TYPE", "for", "keywords", "if", "end", "else", "for", "and", "break", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/template.go#L166-L196
17,176
rveen/ogdl
template.go
flow
func (g *Graph) flow() { n := 0 var nod *Graph for i := 0; i < g.Len(); i++ { node := g.Out[i] s := node.ThisString() if s == TypeIf || s == TypeFor { n++ if n == 1 { nod = node.Add(TypeTemplate) continue } } if s == TypeElse { if n == 1 { nod.flow() nod = node continue ...
go
func (g *Graph) flow() { n := 0 var nod *Graph for i := 0; i < g.Len(); i++ { node := g.Out[i] s := node.ThisString() if s == TypeIf || s == TypeFor { n++ if n == 1 { nod = node.Add(TypeTemplate) continue } } if s == TypeElse { if n == 1 { nod.flow() nod = node continue ...
[ "func", "(", "g", "*", "Graph", ")", "flow", "(", ")", "{", "n", ":=", "0", "\n", "var", "nod", "*", "Graph", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "g", ".", "Len", "(", ")", ";", "i", "++", "{", "node", ":=", "g", ".", "Out", "...
// flow nests 'if' and 'for' loops.
[ "flow", "nests", "if", "and", "for", "loops", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/template.go#L199-L241
17,177
rveen/ogdl
log.go
OpenLog
func OpenLog(file string) (*Log, error) { f, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE, 0666) if err != nil { return nil, err } log := Log{f, true} return &log, nil }
go
func OpenLog(file string) (*Log, error) { f, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE, 0666) if err != nil { return nil, err } log := Log{f, true} return &log, nil }
[ "func", "OpenLog", "(", "file", "string", ")", "(", "*", "Log", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "file", ",", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", ",", "0666", ")", "\n", "if", "err", "!=", ...
// OpenLog opens a log file. If the file doesn't exist, it is created.
[ "OpenLog", "opens", "a", "log", "file", ".", "If", "the", "file", "doesn", "t", "exist", "it", "is", "created", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/log.go#L19-L29
17,178
rveen/ogdl
log.go
Add
func (log *Log) Add(g *Graph) int64 { b := g.Binary() if b == nil { return 0 } i, _ := log.f.Seek(0, 2) log.f.Write(b) if log.autoSync { log.f.Sync() } return i }
go
func (log *Log) Add(g *Graph) int64 { b := g.Binary() if b == nil { return 0 } i, _ := log.f.Seek(0, 2) log.f.Write(b) if log.autoSync { log.f.Sync() } return i }
[ "func", "(", "log", "*", "Log", ")", "Add", "(", "g", "*", "Graph", ")", "int64", "{", "b", ":=", "g", ".", "Binary", "(", ")", "\n\n", "if", "b", "==", "nil", "{", "return", "0", "\n", "}", "\n\n", "i", ",", "_", ":=", "log", ".", "f", "...
// Add adds an OGDL object to the log. The starting position into the log // is returned.
[ "Add", "adds", "an", "OGDL", "object", "to", "the", "log", ".", "The", "starting", "position", "into", "the", "log", "is", "returned", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/log.go#L43-L60
17,179
rveen/ogdl
log.go
AddBinary
func (log *Log) AddBinary(b []byte) int64 { i, _ := log.f.Seek(0, 2) log.f.Write(b) if log.autoSync { log.f.Sync() } return i }
go
func (log *Log) AddBinary(b []byte) int64 { i, _ := log.f.Seek(0, 2) log.f.Write(b) if log.autoSync { log.f.Sync() } return i }
[ "func", "(", "log", "*", "Log", ")", "AddBinary", "(", "b", "[", "]", "byte", ")", "int64", "{", "i", ",", "_", ":=", "log", ".", "f", ".", "Seek", "(", "0", ",", "2", ")", "\n", "log", ".", "f", ".", "Write", "(", "b", ")", "\n\n", "if",...
// AddBinary adds an OGDL binary object to the log. The starting position into // the log is returned.
[ "AddBinary", "adds", "an", "OGDL", "binary", "object", "to", "the", "log", ".", "The", "starting", "position", "into", "the", "log", "is", "returned", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/log.go#L64-L74
17,180
rveen/ogdl
log.go
Get
func (log *Log) Get(i int64) (*Graph, int64, error) { /* Position in file */ _, err := log.f.Seek(i, 0) if err != nil { return nil, -1, err } p := newBinParser(log.f) g := p.parse() if p.n == 0 { return g, -1, nil } return g, i + int64(p.n), err }
go
func (log *Log) Get(i int64) (*Graph, int64, error) { /* Position in file */ _, err := log.f.Seek(i, 0) if err != nil { return nil, -1, err } p := newBinParser(log.f) g := p.parse() if p.n == 0 { return g, -1, nil } return g, i + int64(p.n), err }
[ "func", "(", "log", "*", "Log", ")", "Get", "(", "i", "int64", ")", "(", "*", "Graph", ",", "int64", ",", "error", ")", "{", "/* Position in file */", "_", ",", "err", ":=", "log", ".", "f", ".", "Seek", "(", "i", ",", "0", ")", "\n", "if", "...
// Get returns the OGDL object at the position given and the position of the // next object, or an error.
[ "Get", "returns", "the", "OGDL", "object", "at", "the", "position", "given", "and", "the", "position", "of", "the", "next", "object", "or", "an", "error", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/log.go#L78-L94
17,181
rveen/ogdl
log.go
GetBinary
func (log *Log) GetBinary(i int64) ([]byte, int64, error) { // Position in file _, err := log.f.Seek(i, 0) if err != nil { return nil, 0, err } /* Read until EOS of binary OGDL. There should be a Header first. */ p := newBinParser(log.f) if !p.header() { return nil, 0, err } for { lev, _, _ /* t...
go
func (log *Log) GetBinary(i int64) ([]byte, int64, error) { // Position in file _, err := log.f.Seek(i, 0) if err != nil { return nil, 0, err } /* Read until EOS of binary OGDL. There should be a Header first. */ p := newBinParser(log.f) if !p.header() { return nil, 0, err } for { lev, _, _ /* t...
[ "func", "(", "log", "*", "Log", ")", "GetBinary", "(", "i", "int64", ")", "(", "[", "]", "byte", ",", "int64", ",", "error", ")", "{", "// Position in file", "_", ",", "err", ":=", "log", ".", "f", ".", "Seek", "(", "i", ",", "0", ")", "\n", ...
// GetBinary returns the OGDL object at the position given and the position of the // next object, or an error. The object returned is in binary form, exactly // as it is stored in the log.
[ "GetBinary", "returns", "the", "OGDL", "object", "at", "the", "position", "given", "and", "the", "position", "of", "the", "next", "object", "or", "an", "error", ".", "The", "object", "returned", "is", "in", "binary", "form", "exactly", "as", "it", "is", ...
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/log.go#L99-L130
17,182
rveen/ogdl
binary.go
FromBinaryReader
func FromBinaryReader(r io.Reader) *Graph { p := newBinParser(r) return p.parse() }
go
func FromBinaryReader(r io.Reader) *Graph { p := newBinParser(r) return p.parse() }
[ "func", "FromBinaryReader", "(", "r", "io", ".", "Reader", ")", "*", "Graph", "{", "p", ":=", "newBinParser", "(", "r", ")", "\n", "return", "p", ".", "parse", "(", ")", "\n", "}" ]
// FromBinaryReader converts an OGDL binary stream of bytes into a Graph.
[ "FromBinaryReader", "converts", "an", "OGDL", "binary", "stream", "of", "bytes", "into", "a", "Graph", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/binary.go#L71-L74
17,183
rveen/ogdl
binary.go
Binary
func (g *Graph) Binary() []byte { if g == nil { return nil } // Header buf := make([]byte, 3) buf[0] = 1 buf[1] = 'G' buf[2] = 0 // The 'root' node is bypassed (it's the 'holder') for _, node := range g.Out { buf = node.bin(1, buf) } // Ending null buf = append(buf, 0) return buf }
go
func (g *Graph) Binary() []byte { if g == nil { return nil } // Header buf := make([]byte, 3) buf[0] = 1 buf[1] = 'G' buf[2] = 0 // The 'root' node is bypassed (it's the 'holder') for _, node := range g.Out { buf = node.bin(1, buf) } // Ending null buf = append(buf, 0) return buf }
[ "func", "(", "g", "*", "Graph", ")", "Binary", "(", ")", "[", "]", "byte", "{", "if", "g", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// Header", "buf", ":=", "make", "(", "[", "]", "byte", ",", "3", ")", "\n", "buf", "[", "0", ...
// Binary converts a Graph to a binary OGDL byte stream.
[ "Binary", "converts", "a", "Graph", "to", "a", "binary", "OGDL", "byte", "stream", "." ]
60b0e542a67492da26c19e680662b29786ef1ee3
https://github.com/rveen/ogdl/blob/60b0e542a67492da26c19e680662b29786ef1ee3/binary.go#L83-L104
17,184
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
17,185
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
17,186
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
17,187
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
17,188
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
17,189
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
17,190
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
17,191
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
17,192
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
17,193
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
17,194
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
17,195
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
17,196
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
17,197
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
17,198
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
17,199
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