id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,400 | cloudfoundry/lager | lagerctx/context.go | FromContext | func FromContext(ctx context.Context) lager.Logger {
l, ok := ctx.Value(contextKey{}).(lager.Logger)
if !ok {
return &discardLogger{}
}
return l
} | go | func FromContext(ctx context.Context) lager.Logger {
l, ok := ctx.Value(contextKey{}).(lager.Logger)
if !ok {
return &discardLogger{}
}
return l
} | [
"func",
"FromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"lager",
".",
"Logger",
"{",
"l",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"contextKey",
"{",
"}",
")",
".",
"(",
"lager",
".",
"Logger",
")",
"\n",
"if",
"!",
"ok",
"{",
"retur... | // FromContext returns the logger contained in the context, or an inert logger
// that will not log anything. | [
"FromContext",
"returns",
"the",
"logger",
"contained",
"in",
"the",
"context",
"or",
"an",
"inert",
"logger",
"that",
"will",
"not",
"log",
"anything",
"."
] | 54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6 | https://github.com/cloudfoundry/lager/blob/54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6/lagerctx/context.go#L18-L25 |
17,401 | cloudfoundry/lager | lagerctx/context.go | WithSession | func WithSession(ctx context.Context, task string, data ...lager.Data) lager.Logger {
return FromContext(ctx).Session(task, data...)
} | go | func WithSession(ctx context.Context, task string, data ...lager.Data) lager.Logger {
return FromContext(ctx).Session(task, data...)
} | [
"func",
"WithSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"task",
"string",
",",
"data",
"...",
"lager",
".",
"Data",
")",
"lager",
".",
"Logger",
"{",
"return",
"FromContext",
"(",
"ctx",
")",
".",
"Session",
"(",
"task",
",",
"data",
"...",
... | // WithSession returns a new logger that has, for convenience, had a new
// session created on it. | [
"WithSession",
"returns",
"a",
"new",
"logger",
"that",
"has",
"for",
"convenience",
"had",
"a",
"new",
"session",
"created",
"on",
"it",
"."
] | 54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6 | https://github.com/cloudfoundry/lager/blob/54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6/lagerctx/context.go#L29-L31 |
17,402 | cloudfoundry/lager | lagerctx/context.go | WithData | func WithData(ctx context.Context, data lager.Data) lager.Logger {
return FromContext(ctx).WithData(data)
} | go | func WithData(ctx context.Context, data lager.Data) lager.Logger {
return FromContext(ctx).WithData(data)
} | [
"func",
"WithData",
"(",
"ctx",
"context",
".",
"Context",
",",
"data",
"lager",
".",
"Data",
")",
"lager",
".",
"Logger",
"{",
"return",
"FromContext",
"(",
"ctx",
")",
".",
"WithData",
"(",
"data",
")",
"\n",
"}"
] | // WithData returns a new logger that has, for convenience, had new data added
// to on it. | [
"WithData",
"returns",
"a",
"new",
"logger",
"that",
"has",
"for",
"convenience",
"had",
"new",
"data",
"added",
"to",
"on",
"it",
"."
] | 54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6 | https://github.com/cloudfoundry/lager/blob/54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6/lagerctx/context.go#L35-L37 |
17,403 | nicolasazrak/caddy-cache | url_lock.go | Adquire | func (allLocks *URLLock) Adquire(key string) *sync.Mutex {
bucketIndex := allLocks.getBucketIndexForKey(key)
allLocks.globalLocks[bucketIndex].Lock()
defer allLocks.globalLocks[bucketIndex].Unlock()
lock, exists := allLocks.keys[bucketIndex][key]
if !exists {
lock = new(sync.Mutex)
allLocks.keys[bucketIndex][... | go | func (allLocks *URLLock) Adquire(key string) *sync.Mutex {
bucketIndex := allLocks.getBucketIndexForKey(key)
allLocks.globalLocks[bucketIndex].Lock()
defer allLocks.globalLocks[bucketIndex].Unlock()
lock, exists := allLocks.keys[bucketIndex][key]
if !exists {
lock = new(sync.Mutex)
allLocks.keys[bucketIndex][... | [
"func",
"(",
"allLocks",
"*",
"URLLock",
")",
"Adquire",
"(",
"key",
"string",
")",
"*",
"sync",
".",
"Mutex",
"{",
"bucketIndex",
":=",
"allLocks",
".",
"getBucketIndexForKey",
"(",
"key",
")",
"\n",
"allLocks",
".",
"globalLocks",
"[",
"bucketIndex",
"]"... | // Adquire a lock for given key | [
"Adquire",
"a",
"lock",
"for",
"given",
"key"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/url_lock.go#L32-L44 |
17,404 | nicolasazrak/caddy-cache | handler.go | NewHandler | func NewHandler(Next httpserver.Handler, config *Config) *Handler {
return &Handler{
Config: config,
Cache: NewHTTPCache(config.CacheKeyTemplate),
URLLocks: NewURLLock(),
Next: Next,
}
} | go | func NewHandler(Next httpserver.Handler, config *Config) *Handler {
return &Handler{
Config: config,
Cache: NewHTTPCache(config.CacheKeyTemplate),
URLLocks: NewURLLock(),
Next: Next,
}
} | [
"func",
"NewHandler",
"(",
"Next",
"httpserver",
".",
"Handler",
",",
"config",
"*",
"Config",
")",
"*",
"Handler",
"{",
"return",
"&",
"Handler",
"{",
"Config",
":",
"config",
",",
"Cache",
":",
"NewHTTPCache",
"(",
"config",
".",
"CacheKeyTemplate",
")",... | // NewHandler creates a new Handler using Next middleware | [
"NewHandler",
"creates",
"a",
"new",
"Handler",
"using",
"Next",
"middleware"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/handler.go#L51-L58 |
17,405 | nicolasazrak/caddy-cache | storage/no_storage.go | Flush | func (b *NoStorage) Flush() error {
if f, ok := b.w.(http.Flusher); ok {
f.Flush()
}
return nil
} | go | func (b *NoStorage) Flush() error {
if f, ok := b.w.(http.Flusher); ok {
f.Flush()
}
return nil
} | [
"func",
"(",
"b",
"*",
"NoStorage",
")",
"Flush",
"(",
")",
"error",
"{",
"if",
"f",
",",
"ok",
":=",
"b",
".",
"w",
".",
"(",
"http",
".",
"Flusher",
")",
";",
"ok",
"{",
"f",
".",
"Flush",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",... | // Flush does nothing in a buffer | [
"Flush",
"does",
"nothing",
"in",
"a",
"buffer"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/no_storage.go#L28-L33 |
17,406 | nicolasazrak/caddy-cache | cache_entry.go | NewHTTPCacheEntry | func NewHTTPCacheEntry(key string, request *http.Request, response *Response, config *Config) *HTTPCacheEntry {
isPublic, expiration := getCacheableStatus(request, response, config)
return &HTTPCacheEntry{
key: key,
isPublic: isPublic,
expiration: expiration,
Request: request,
Response: respo... | go | func NewHTTPCacheEntry(key string, request *http.Request, response *Response, config *Config) *HTTPCacheEntry {
isPublic, expiration := getCacheableStatus(request, response, config)
return &HTTPCacheEntry{
key: key,
isPublic: isPublic,
expiration: expiration,
Request: request,
Response: respo... | [
"func",
"NewHTTPCacheEntry",
"(",
"key",
"string",
",",
"request",
"*",
"http",
".",
"Request",
",",
"response",
"*",
"Response",
",",
"config",
"*",
"Config",
")",
"*",
"HTTPCacheEntry",
"{",
"isPublic",
",",
"expiration",
":=",
"getCacheableStatus",
"(",
"... | // NewHTTPCacheEntry creates a new HTTPCacheEntry for the given request and response
// and it also calculates if the response is public | [
"NewHTTPCacheEntry",
"creates",
"a",
"new",
"HTTPCacheEntry",
"for",
"the",
"given",
"request",
"and",
"response",
"and",
"it",
"also",
"calculates",
"if",
"the",
"response",
"is",
"public"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/cache_entry.go#L23-L33 |
17,407 | nicolasazrak/caddy-cache | cache_entry.go | WriteBodyTo | func (e *HTTPCacheEntry) WriteBodyTo(w http.ResponseWriter) error {
if !e.isPublic {
return e.writePrivateResponse(w)
}
return e.writePublicResponse(w)
} | go | func (e *HTTPCacheEntry) WriteBodyTo(w http.ResponseWriter) error {
if !e.isPublic {
return e.writePrivateResponse(w)
}
return e.writePublicResponse(w)
} | [
"func",
"(",
"e",
"*",
"HTTPCacheEntry",
")",
"WriteBodyTo",
"(",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"if",
"!",
"e",
".",
"isPublic",
"{",
"return",
"e",
".",
"writePrivateResponse",
"(",
"w",
")",
"\n",
"}",
"\n",
"return",
"e",
... | // WriteBodyTo sends the body to the http.ResponseWritter | [
"WriteBodyTo",
"sends",
"the",
"body",
"to",
"the",
"http",
".",
"ResponseWritter"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/cache_entry.go#L61-L66 |
17,408 | nicolasazrak/caddy-cache | storage/file.go | NewFileStorage | func NewFileStorage(path string) (ResponseStorage, error) {
file, err := ioutil.TempFile(path, "caddy-cache-")
if err != nil {
return nil, err
}
return &FileStorage{
file: file,
subscription: NewSubscription(),
}, nil
} | go | func NewFileStorage(path string) (ResponseStorage, error) {
file, err := ioutil.TempFile(path, "caddy-cache-")
if err != nil {
return nil, err
}
return &FileStorage{
file: file,
subscription: NewSubscription(),
}, nil
} | [
"func",
"NewFileStorage",
"(",
"path",
"string",
")",
"(",
"ResponseStorage",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"path",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // NewFileStorage creates a new temp file that will be used as a the storage of the cache entry | [
"NewFileStorage",
"creates",
"a",
"new",
"temp",
"file",
"that",
"will",
"be",
"used",
"as",
"a",
"the",
"storage",
"of",
"the",
"cache",
"entry"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/file.go#L16-L25 |
17,409 | nicolasazrak/caddy-cache | storage/file.go | Flush | func (f *FileStorage) Flush() error {
defer f.subscription.NotifyAll(0)
return f.file.Sync()
} | go | func (f *FileStorage) Flush() error {
defer f.subscription.NotifyAll(0)
return f.file.Sync()
} | [
"func",
"(",
"f",
"*",
"FileStorage",
")",
"Flush",
"(",
")",
"error",
"{",
"defer",
"f",
".",
"subscription",
".",
"NotifyAll",
"(",
"0",
")",
"\n",
"return",
"f",
".",
"file",
".",
"Sync",
"(",
")",
"\n",
"}"
] | // Flush syncs the underlying file | [
"Flush",
"syncs",
"the",
"underlying",
"file"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/file.go#L33-L36 |
17,410 | nicolasazrak/caddy-cache | storage/file.go | Clean | func (f *FileStorage) Clean() error {
f.subscription.WaitAll() // Wait until every subscriber ends waiting every result
return os.Remove(f.file.Name())
} | go | func (f *FileStorage) Clean() error {
f.subscription.WaitAll() // Wait until every subscriber ends waiting every result
return os.Remove(f.file.Name())
} | [
"func",
"(",
"f",
"*",
"FileStorage",
")",
"Clean",
"(",
")",
"error",
"{",
"f",
".",
"subscription",
".",
"WaitAll",
"(",
")",
"// Wait until every subscriber ends waiting every result",
"\n",
"return",
"os",
".",
"Remove",
"(",
"f",
".",
"file",
".",
"Name... | // Clean removes the file | [
"Clean",
"removes",
"the",
"file"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/file.go#L39-L42 |
17,411 | nicolasazrak/caddy-cache | storage/file.go | Close | func (f *FileStorage) Close() error {
f.subscription.Close()
return f.file.Close()
} | go | func (f *FileStorage) Close() error {
f.subscription.Close()
return f.file.Close()
} | [
"func",
"(",
"f",
"*",
"FileStorage",
")",
"Close",
"(",
")",
"error",
"{",
"f",
".",
"subscription",
".",
"Close",
"(",
")",
"\n",
"return",
"f",
".",
"file",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close the underlying file | [
"Close",
"the",
"underlying",
"file"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/file.go#L45-L48 |
17,412 | nicolasazrak/caddy-cache | storage/file.go | GetReader | func (f *FileStorage) GetReader() (io.ReadCloser, error) {
newFile, err := os.Open(f.file.Name())
if err != nil {
return nil, err
}
return &FileReader{
content: newFile,
subscription: f.subscription.NewSubscriber(),
unsubscribe: f.subscription.RemoveSubscriber,
}, nil
} | go | func (f *FileStorage) GetReader() (io.ReadCloser, error) {
newFile, err := os.Open(f.file.Name())
if err != nil {
return nil, err
}
return &FileReader{
content: newFile,
subscription: f.subscription.NewSubscriber(),
unsubscribe: f.subscription.RemoveSubscriber,
}, nil
} | [
"func",
"(",
"f",
"*",
"FileStorage",
")",
"GetReader",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"newFile",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"f",
".",
"file",
".",
"Name",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
... | // GetReader returns a new file descriptor to the same file | [
"GetReader",
"returns",
"a",
"new",
"file",
"descriptor",
"to",
"the",
"same",
"file"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/file.go#L51-L61 |
17,413 | nicolasazrak/caddy-cache | storage/file.go | Close | func (r *FileReader) Close() error {
err := r.content.Close()
r.unsubscribe(r.subscription)
return err
} | go | func (r *FileReader) Close() error {
err := r.content.Close()
r.unsubscribe(r.subscription)
return err
} | [
"func",
"(",
"r",
"*",
"FileReader",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"r",
".",
"content",
".",
"Close",
"(",
")",
"\n",
"r",
".",
"unsubscribe",
"(",
"r",
".",
"subscription",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the underlying storage | [
"Close",
"closes",
"the",
"underlying",
"storage"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/storage/file.go#L84-L88 |
17,414 | nicolasazrak/caddy-cache | setup.go | Setup | func Setup(c *caddy.Controller) error {
config, err := cacheParse(c)
if err != nil {
return err
}
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
return NewHandler(next, config)
})
c.OnStartup(func() error {
if config.Path == "" {
return nil
}
return os.Mkd... | go | func Setup(c *caddy.Controller) error {
config, err := cacheParse(c)
if err != nil {
return err
}
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
return NewHandler(next, config)
})
c.OnStartup(func() error {
if config.Path == "" {
return nil
}
return os.Mkd... | [
"func",
"Setup",
"(",
"c",
"*",
"caddy",
".",
"Controller",
")",
"error",
"{",
"config",
",",
"err",
":=",
"cacheParse",
"(",
"c",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"httpserver",
".",
"GetConfig",
"(",
... | // Setup creates a new cache middleware | [
"Setup",
"creates",
"a",
"new",
"cache",
"middleware"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/setup.go#L37-L56 |
17,415 | nicolasazrak/caddy-cache | response.go | NewResponse | func NewResponse() *Response {
r := &Response{
Code: 200,
HeaderMap: http.Header{},
body: nil,
closeNotify: make(chan bool, 1),
bodyLock: new(sync.RWMutex),
closedLock: new(sync.RWMutex),
headersLock: new(sync.RWMutex),
}
r.bodyLock.Lock()
r.closedLock.Lock()
r.headersLock.Lock()... | go | func NewResponse() *Response {
r := &Response{
Code: 200,
HeaderMap: http.Header{},
body: nil,
closeNotify: make(chan bool, 1),
bodyLock: new(sync.RWMutex),
closedLock: new(sync.RWMutex),
headersLock: new(sync.RWMutex),
}
r.bodyLock.Lock()
r.closedLock.Lock()
r.headersLock.Lock()... | [
"func",
"NewResponse",
"(",
")",
"*",
"Response",
"{",
"r",
":=",
"&",
"Response",
"{",
"Code",
":",
"200",
",",
"HeaderMap",
":",
"http",
".",
"Header",
"{",
"}",
",",
"body",
":",
"nil",
",",
"closeNotify",
":",
"make",
"(",
"chan",
"bool",
",",
... | // NewResponse returns an initialized Response. | [
"NewResponse",
"returns",
"an",
"initialized",
"Response",
"."
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/response.go#L27-L42 |
17,416 | nicolasazrak/caddy-cache | response.go | writeHeader | func (rw *Response) writeHeader(b []byte, str string) {
if rw.wroteHeader {
return
}
if len(str) > 512 {
str = str[:512]
}
m := rw.Header()
_, hasType := m["Content-Type"]
hasTE := m.Get("Transfer-Encoding") != ""
if !hasType && !hasTE {
if b == nil {
b = []byte(str)
}
m.Set("Content-Type", http.... | go | func (rw *Response) writeHeader(b []byte, str string) {
if rw.wroteHeader {
return
}
if len(str) > 512 {
str = str[:512]
}
m := rw.Header()
_, hasType := m["Content-Type"]
hasTE := m.Get("Transfer-Encoding") != ""
if !hasType && !hasTE {
if b == nil {
b = []byte(str)
}
m.Set("Content-Type", http.... | [
"func",
"(",
"rw",
"*",
"Response",
")",
"writeHeader",
"(",
"b",
"[",
"]",
"byte",
",",
"str",
"string",
")",
"{",
"if",
"rw",
".",
"wroteHeader",
"{",
"return",
"\n",
"}",
"\n",
"if",
"len",
"(",
"str",
")",
">",
"512",
"{",
"str",
"=",
"str"... | // writeHeader writes a header if it was not written yet and
// detects Content-Type if needed.
//
// bytes or str are the beginning of the response body.
// We pass both to avoid unnecessarily generate garbage
// in rw.WriteString which was created for performance reasons.
// Non-nil bytes win. | [
"writeHeader",
"writes",
"a",
"header",
"if",
"it",
"was",
"not",
"written",
"yet",
"and",
"detects",
"Content",
"-",
"Type",
"if",
"needed",
".",
"bytes",
"or",
"str",
"are",
"the",
"beginning",
"of",
"the",
"response",
"body",
".",
"We",
"pass",
"both"... | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/response.go#L61-L81 |
17,417 | nicolasazrak/caddy-cache | response.go | Write | func (rw *Response) Write(buf []byte) (int, error) {
if !rw.wroteHeader {
rw.writeHeader(buf, "")
}
if !rw.firstByteSent {
rw.firstByteSent = true
rw.WaitBody()
}
if rw.body != nil {
return rw.body.Write(buf)
}
return 0, errors.New("No storage")
} | go | func (rw *Response) Write(buf []byte) (int, error) {
if !rw.wroteHeader {
rw.writeHeader(buf, "")
}
if !rw.firstByteSent {
rw.firstByteSent = true
rw.WaitBody()
}
if rw.body != nil {
return rw.body.Write(buf)
}
return 0, errors.New("No storage")
} | [
"func",
"(",
"rw",
"*",
"Response",
")",
"Write",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"!",
"rw",
".",
"wroteHeader",
"{",
"rw",
".",
"writeHeader",
"(",
"buf",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
... | // Write is the io.Writer interface with the modification required
// To wait the body. This will wait until SetBody is called with
// The desired storage. | [
"Write",
"is",
"the",
"io",
".",
"Writer",
"interface",
"with",
"the",
"modification",
"required",
"To",
"wait",
"the",
"body",
".",
"This",
"will",
"wait",
"until",
"SetBody",
"is",
"called",
"with",
"The",
"desired",
"storage",
"."
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/response.go#L86-L101 |
17,418 | nicolasazrak/caddy-cache | response.go | Clean | func (rw *Response) Clean() error {
if rw.body == nil {
return nil
}
return rw.body.Clean()
} | go | func (rw *Response) Clean() error {
if rw.body == nil {
return nil
}
return rw.body.Clean()
} | [
"func",
"(",
"rw",
"*",
"Response",
")",
"Clean",
"(",
")",
"error",
"{",
"if",
"rw",
".",
"body",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"rw",
".",
"body",
".",
"Clean",
"(",
")",
"\n",
"}"
] | // Clean the body if it is set | [
"Clean",
"the",
"body",
"if",
"it",
"is",
"set"
] | 234a8f7be1fccfc4e88e87e9dbc14a4b679323c8 | https://github.com/nicolasazrak/caddy-cache/blob/234a8f7be1fccfc4e88e87e9dbc14a4b679323c8/response.go#L162-L168 |
17,419 | labstack/echo-contrib | session/session.go | Get | func Get(name string, c echo.Context) (*sessions.Session, error) {
store := c.Get(key).(sessions.Store)
return store.Get(c.Request(), name)
} | go | func Get(name string, c echo.Context) (*sessions.Session, error) {
store := c.Get(key).(sessions.Store)
return store.Get(c.Request(), name)
} | [
"func",
"Get",
"(",
"name",
"string",
",",
"c",
"echo",
".",
"Context",
")",
"(",
"*",
"sessions",
".",
"Session",
",",
"error",
")",
"{",
"store",
":=",
"c",
".",
"Get",
"(",
"key",
")",
".",
"(",
"sessions",
".",
"Store",
")",
"\n",
"return",
... | // Get returns a named session. | [
"Get",
"returns",
"a",
"named",
"session",
"."
] | 7fa08ffe94428b4dce1c2ef3dd15648c88d88b89 | https://github.com/labstack/echo-contrib/blob/7fa08ffe94428b4dce1c2ef3dd15648c88d88b89/session/session.go#L34-L37 |
17,420 | labstack/echo-contrib | session/session.go | Middleware | func Middleware(store sessions.Store) echo.MiddlewareFunc {
c := DefaultConfig
c.Store = store
return MiddlewareWithConfig(c)
} | go | func Middleware(store sessions.Store) echo.MiddlewareFunc {
c := DefaultConfig
c.Store = store
return MiddlewareWithConfig(c)
} | [
"func",
"Middleware",
"(",
"store",
"sessions",
".",
"Store",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultConfig",
"\n",
"c",
".",
"Store",
"=",
"store",
"\n",
"return",
"MiddlewareWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // Middleware returns a Session middleware. | [
"Middleware",
"returns",
"a",
"Session",
"middleware",
"."
] | 7fa08ffe94428b4dce1c2ef3dd15648c88d88b89 | https://github.com/labstack/echo-contrib/blob/7fa08ffe94428b4dce1c2ef3dd15648c88d88b89/session/session.go#L40-L44 |
17,421 | labstack/echo-contrib | casbin/casbin.go | Middleware | func Middleware(ce *casbin.Enforcer) echo.MiddlewareFunc {
c := DefaultConfig
c.Enforcer = ce
return MiddlewareWithConfig(c)
} | go | func Middleware(ce *casbin.Enforcer) echo.MiddlewareFunc {
c := DefaultConfig
c.Enforcer = ce
return MiddlewareWithConfig(c)
} | [
"func",
"Middleware",
"(",
"ce",
"*",
"casbin",
".",
"Enforcer",
")",
"echo",
".",
"MiddlewareFunc",
"{",
"c",
":=",
"DefaultConfig",
"\n",
"c",
".",
"Enforcer",
"=",
"ce",
"\n",
"return",
"MiddlewareWithConfig",
"(",
"c",
")",
"\n",
"}"
] | // Middleware returns a CasbinAuth middleware.
//
// For valid credentials it calls the next handler.
// For missing or invalid credentials, it sends "401 - Unauthorized" response. | [
"Middleware",
"returns",
"a",
"CasbinAuth",
"middleware",
".",
"For",
"valid",
"credentials",
"it",
"calls",
"the",
"next",
"handler",
".",
"For",
"missing",
"or",
"invalid",
"credentials",
"it",
"sends",
"401",
"-",
"Unauthorized",
"response",
"."
] | 7fa08ffe94428b4dce1c2ef3dd15648c88d88b89 | https://github.com/labstack/echo-contrib/blob/7fa08ffe94428b4dce1c2ef3dd15648c88d88b89/casbin/casbin.go#L76-L80 |
17,422 | 0xrawsec/golang-evtx | tools/evtxdump/evtxdump.go | update | func (s *stats) update(channel string, eventID int64) {
s.Lock()
if _, ok := s.ChannelStats[channel]; !ok {
s.ChannelStats[channel] = make(eventIDStat)
}
s.ChannelStats[channel][eventID]++
s.EventCount++
s.Unlock()
} | go | func (s *stats) update(channel string, eventID int64) {
s.Lock()
if _, ok := s.ChannelStats[channel]; !ok {
s.ChannelStats[channel] = make(eventIDStat)
}
s.ChannelStats[channel][eventID]++
s.EventCount++
s.Unlock()
} | [
"func",
"(",
"s",
"*",
"stats",
")",
"update",
"(",
"channel",
"string",
",",
"eventID",
"int64",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"s",
".",
"ChannelStats",
"[",
"channel",
"]",
";",
"!",
"ok",
"{",
"s",
... | // update stats in a stat sturcture | [
"update",
"stats",
"in",
"a",
"stat",
"sturcture"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/tools/evtxdump/evtxdump.go#L92-L100 |
17,423 | 0xrawsec/golang-evtx | tools/evtxdump/evtxdump.go | print | func (s *stats) print() {
fmt.Printf("Channel,EventID,Count\n")
for c := range s.ChannelStats {
for eid, cnt := range s.ChannelStats[c] {
fmt.Printf("%s,%d,%d\n", c, eid, cnt)
}
}
//fmt.Printf("Total Events: %d\n", s.EventCount)
} | go | func (s *stats) print() {
fmt.Printf("Channel,EventID,Count\n")
for c := range s.ChannelStats {
for eid, cnt := range s.ChannelStats[c] {
fmt.Printf("%s,%d,%d\n", c, eid, cnt)
}
}
//fmt.Printf("Total Events: %d\n", s.EventCount)
} | [
"func",
"(",
"s",
"*",
"stats",
")",
"print",
"(",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"for",
"c",
":=",
"range",
"s",
".",
"ChannelStats",
"{",
"for",
"eid",
",",
"cnt",
":=",
"range",
"s",
".",
"ChannelStats",
"... | // prints in CSV format | [
"prints",
"in",
"CSV",
"format"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/tools/evtxdump/evtxdump.go#L103-L111 |
17,424 | 0xrawsec/golang-evtx | tools/evtxdump/evtxdump.go | fetchChunkFromReader | func fetchChunkFromReader(r io.ReadSeeker, offset int64) (evtx.Chunk, error) {
var err error
c := evtx.NewChunk()
evtx.GoToSeeker(r, offset)
c.Offset = offset
c.Data = make([]byte, evtx.ChunkSize)
if _, err = r.Read(c.Data); err != nil {
return c, err
}
reader := bytes.NewReader(c.Data)
c.ParseChunkHeader(re... | go | func fetchChunkFromReader(r io.ReadSeeker, offset int64) (evtx.Chunk, error) {
var err error
c := evtx.NewChunk()
evtx.GoToSeeker(r, offset)
c.Offset = offset
c.Data = make([]byte, evtx.ChunkSize)
if _, err = r.Read(c.Data); err != nil {
return c, err
}
reader := bytes.NewReader(c.Data)
c.ParseChunkHeader(re... | [
"func",
"fetchChunkFromReader",
"(",
"r",
"io",
".",
"ReadSeeker",
",",
"offset",
"int64",
")",
"(",
"evtx",
".",
"Chunk",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"c",
":=",
"evtx",
".",
"NewChunk",
"(",
")",
"\n",
"evtx",
".",
"GoToSeek... | // return an evtx.Chunk object from a reader | [
"return",
"an",
"evtx",
".",
"Chunk",
"object",
"from",
"a",
"reader"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/tools/evtxdump/evtxdump.go#L132-L158 |
17,425 | 0xrawsec/golang-evtx | tools/evtxdump/evtxdump.go | carveFile | func carveFile(datafile string, offset int64, limit int) {
chunkCnt := 0
f, err := os.Open(datafile)
if err != nil {
log.LogErrorAndExit(err)
}
defer f.Close()
f.Seek(offset, os.SEEK_SET)
dup, err := os.Open(datafile)
if err != nil {
log.LogErrorAndExit(err)
}
defer dup.Close()
dup.Seek(offset, os.SEEK_S... | go | func carveFile(datafile string, offset int64, limit int) {
chunkCnt := 0
f, err := os.Open(datafile)
if err != nil {
log.LogErrorAndExit(err)
}
defer f.Close()
f.Seek(offset, os.SEEK_SET)
dup, err := os.Open(datafile)
if err != nil {
log.LogErrorAndExit(err)
}
defer dup.Close()
dup.Seek(offset, os.SEEK_S... | [
"func",
"carveFile",
"(",
"datafile",
"string",
",",
"offset",
"int64",
",",
"limit",
"int",
")",
"{",
"chunkCnt",
":=",
"0",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"datafile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"... | // main routine to carve a file | [
"main",
"routine",
"to",
"carve",
"a",
"file"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/tools/evtxdump/evtxdump.go#L161-L192 |
17,426 | 0xrawsec/golang-evtx | tools/evtxdump/evtxdump.go | printEvent | func printEvent(e *evtx.GoEvtxMap) {
if e != nil {
t, err := e.GetTime(&evtx.SystemTimePath)
// If not between start and stop we do not print
if time.Time(start) != defaultTime && time.Time(stop) != defaultTime {
if t.Before(time.Time(start)) || t.After(time.Time(stop)) {
return
}
}
// If before ... | go | func printEvent(e *evtx.GoEvtxMap) {
if e != nil {
t, err := e.GetTime(&evtx.SystemTimePath)
// If not between start and stop we do not print
if time.Time(start) != defaultTime && time.Time(stop) != defaultTime {
if t.Before(time.Time(start)) || t.After(time.Time(stop)) {
return
}
}
// If before ... | [
"func",
"printEvent",
"(",
"e",
"*",
"evtx",
".",
"GoEvtxMap",
")",
"{",
"if",
"e",
"!=",
"nil",
"{",
"t",
",",
"err",
":=",
"e",
".",
"GetTime",
"(",
"&",
"evtx",
".",
"SystemTimePath",
")",
"\n\n",
"// If not between start and stop we do not print",
"if"... | // small routine that prints the EVTX event | [
"small",
"routine",
"that",
"prints",
"the",
"EVTX",
"event"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/tools/evtxdump/evtxdump.go#L195-L231 |
17,427 | 0xrawsec/golang-evtx | evtx/evtx.go | New | func New(filepath string) (ef File, err error) {
file, err := os.Open(filepath)
if err != nil {
return
}
ef.file = file
ef.ParseFileHeader()
return
} | go | func New(filepath string) (ef File, err error) {
file, err := os.Open(filepath)
if err != nil {
return
}
ef.file = file
ef.ParseFileHeader()
return
} | [
"func",
"New",
"(",
"filepath",
"string",
")",
"(",
"ef",
"File",
",",
"err",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filepath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"ef",
".",
"file... | // New EvtxFile structure initialized from file
// @filepath : filepath of the evtx file to parse
// return File : File structure initialized | [
"New",
"EvtxFile",
"structure",
"initialized",
"from",
"file"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/evtx.go#L72-L80 |
17,428 | 0xrawsec/golang-evtx | evtx/evtx.go | ParseFileHeader | func (ef *File) ParseFileHeader() {
ef.Lock()
defer ef.Unlock()
GoToSeeker(ef.file, 0)
err := encoding.Unmarshal(ef.file, &ef.Header, Endianness)
if err != nil {
panic(err)
}
} | go | func (ef *File) ParseFileHeader() {
ef.Lock()
defer ef.Unlock()
GoToSeeker(ef.file, 0)
err := encoding.Unmarshal(ef.file, &ef.Header, Endianness)
if err != nil {
panic(err)
}
} | [
"func",
"(",
"ef",
"*",
"File",
")",
"ParseFileHeader",
"(",
")",
"{",
"ef",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ef",
".",
"Unlock",
"(",
")",
"\n",
"GoToSeeker",
"(",
"ef",
".",
"file",
",",
"0",
")",
"\n",
"err",
":=",
"encoding",
".",
"Un... | // ParseFileHeader parses a the file header of the file structure and modifies
// the Header of the current structure | [
"ParseFileHeader",
"parses",
"a",
"the",
"file",
"header",
"of",
"the",
"file",
"structure",
"and",
"modifies",
"the",
"Header",
"of",
"the",
"current",
"structure"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/evtx.go#L95-L103 |
17,429 | 0xrawsec/golang-evtx | evtx/evtx.go | FetchChunk | func (ef *File) FetchChunk(offset int64) (Chunk, error) {
ef.Lock()
defer ef.Unlock()
c := NewChunk()
GoToSeeker(ef.file, offset)
c.Offset = offset
c.Data = make([]byte, ChunkSize)
if _, err := ef.file.Read(c.Data); err != nil {
return c, err
}
reader := bytes.NewReader(c.Data)
c.ParseChunkHeader(reader)
/... | go | func (ef *File) FetchChunk(offset int64) (Chunk, error) {
ef.Lock()
defer ef.Unlock()
c := NewChunk()
GoToSeeker(ef.file, offset)
c.Offset = offset
c.Data = make([]byte, ChunkSize)
if _, err := ef.file.Read(c.Data); err != nil {
return c, err
}
reader := bytes.NewReader(c.Data)
c.ParseChunkHeader(reader)
/... | [
"func",
"(",
"ef",
"*",
"File",
")",
"FetchChunk",
"(",
"offset",
"int64",
")",
"(",
"Chunk",
",",
"error",
")",
"{",
"ef",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ef",
".",
"Unlock",
"(",
")",
"\n",
"c",
":=",
"NewChunk",
"(",
")",
"\n",
"GoToS... | // FetchChunk fetches a Chunk
// @offset : offset in the current file where to find the Chunk
// return Chunk : Chunk parsed | [
"FetchChunk",
"fetches",
"a",
"Chunk"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/evtx.go#L153-L175 |
17,430 | 0xrawsec/golang-evtx | evtx/evtx.go | monitorChunks | func (ef *File) monitorChunks(stop chan bool, sleep time.Duration) (cc chan Chunk) {
cc = make(chan Chunk, 4)
sleepTime := sleep
markedChunks := datastructs.NewSyncedSet()
// Main routine to feed the Chunk Channel
go func() {
defer close(cc)
firstLoopFlag := !ef.monitorExisting
for {
// Parse the file he... | go | func (ef *File) monitorChunks(stop chan bool, sleep time.Duration) (cc chan Chunk) {
cc = make(chan Chunk, 4)
sleepTime := sleep
markedChunks := datastructs.NewSyncedSet()
// Main routine to feed the Chunk Channel
go func() {
defer close(cc)
firstLoopFlag := !ef.monitorExisting
for {
// Parse the file he... | [
"func",
"(",
"ef",
"*",
"File",
")",
"monitorChunks",
"(",
"stop",
"chan",
"bool",
",",
"sleep",
"time",
".",
"Duration",
")",
"(",
"cc",
"chan",
"Chunk",
")",
"{",
"cc",
"=",
"make",
"(",
"chan",
"Chunk",
",",
"4",
")",
"\n",
"sleepTime",
":=",
... | // monitorChunks returns a chan of the new Chunks found in the file under
// monitoring created after the monitoring started
// @stop: a channel used to stop the monitoring if needed
// @sleep: sleep time
// return (chan Chunk) | [
"monitorChunks",
"returns",
"a",
"chan",
"of",
"the",
"new",
"Chunks",
"found",
"in",
"the",
"file",
"under",
"monitoring",
"created",
"after",
"the",
"monitoring",
"started"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/evtx.go#L230-L303 |
17,431 | 0xrawsec/golang-evtx | evtx/evtx.go | MonitorEvents | func (ef *File) MonitorEvents(stop chan bool, sleep ...time.Duration) (cgem chan *GoEvtxMap) {
// Normally, it should not be needed to add a second check here on the
// EventRecordID since the record ids in the chunks are not supposed to overlap
// TODO: Add a EventRecordID marker if needed
sleepTime := DefaultMoni... | go | func (ef *File) MonitorEvents(stop chan bool, sleep ...time.Duration) (cgem chan *GoEvtxMap) {
// Normally, it should not be needed to add a second check here on the
// EventRecordID since the record ids in the chunks are not supposed to overlap
// TODO: Add a EventRecordID marker if needed
sleepTime := DefaultMoni... | [
"func",
"(",
"ef",
"*",
"File",
")",
"MonitorEvents",
"(",
"stop",
"chan",
"bool",
",",
"sleep",
"...",
"time",
".",
"Duration",
")",
"(",
"cgem",
"chan",
"*",
"GoEvtxMap",
")",
"{",
"// Normally, it should not be needed to add a second check here on the",
"// Eve... | // MonitorEvents returns a chan pointers to all the GoEvtxMap found in the File
// under monitoring. This is the fast version
// @stop: a channel used to stop the monitoring if needed
// return (chan *GoEvtxMap) | [
"MonitorEvents",
"returns",
"a",
"chan",
"pointers",
"to",
"all",
"the",
"GoEvtxMap",
"found",
"in",
"the",
"File",
"under",
"monitoring",
".",
"This",
"is",
"the",
"fast",
"version"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/evtx.go#L395-L428 |
17,432 | 0xrawsec/golang-evtx | evtx/utils.go | MarshalJSON | func (u UTCTime) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("\"%s\"", time.Time(u).UTC().Format(time.RFC3339Nano))), nil
} | go | func (u UTCTime) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("\"%s\"", time.Time(u).UTC().Format(time.RFC3339Nano))), nil
} | [
"func",
"(",
"u",
"UTCTime",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"time",
".",
"Time",
"(",
"u",
")",
".",
"... | // MarshalJSON implements JSON serialization | [
"MarshalJSON",
"implements",
"JSON",
"serialization"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/utils.go#L131-L133 |
17,433 | 0xrawsec/golang-evtx | evtx/chunk.go | Validate | func (ch *ChunkHeader) Validate() error {
if string(ch.Magic[:]) != ChunkMagic {
return fmt.Errorf("Invalid chunk magic: %q", ch.Magic)
}
if ch.SizeHeader != 128 {
return fmt.Errorf("Invalid chunk header size: %d instead of 128", ch.SizeHeader)
}
if ch.OffsetLastRec >= ChunkSize {
return fmt.Errorf("Last eve... | go | func (ch *ChunkHeader) Validate() error {
if string(ch.Magic[:]) != ChunkMagic {
return fmt.Errorf("Invalid chunk magic: %q", ch.Magic)
}
if ch.SizeHeader != 128 {
return fmt.Errorf("Invalid chunk header size: %d instead of 128", ch.SizeHeader)
}
if ch.OffsetLastRec >= ChunkSize {
return fmt.Errorf("Last eve... | [
"func",
"(",
"ch",
"*",
"ChunkHeader",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"string",
"(",
"ch",
".",
"Magic",
"[",
":",
"]",
")",
"!=",
"ChunkMagic",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ch",
".",
"Magic",
")",
... | // Validate controls the validity of the chunk header | [
"Validate",
"controls",
"the",
"validity",
"of",
"the",
"chunk",
"header"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L57-L68 |
17,434 | 0xrawsec/golang-evtx | evtx/chunk.go | ParseChunkHeader | func (c *Chunk) ParseChunkHeader(reader io.ReadSeeker) {
err := encoding.Unmarshal(reader, &c.Header, Endianness)
if err != nil {
panic(err)
}
} | go | func (c *Chunk) ParseChunkHeader(reader io.ReadSeeker) {
err := encoding.Unmarshal(reader, &c.Header, Endianness)
if err != nil {
panic(err)
}
} | [
"func",
"(",
"c",
"*",
"Chunk",
")",
"ParseChunkHeader",
"(",
"reader",
"io",
".",
"ReadSeeker",
")",
"{",
"err",
":=",
"encoding",
".",
"Unmarshal",
"(",
"reader",
",",
"&",
"c",
".",
"Header",
",",
"Endianness",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // ParseChunkHeader parses a chunk header at offset | [
"ParseChunkHeader",
"parses",
"a",
"chunk",
"header",
"at",
"offset"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L111-L116 |
17,435 | 0xrawsec/golang-evtx | evtx/chunk.go | Less | func (c Chunk) Less(s *datastructs.Sortable) bool {
other := (*s).(Chunk)
return c.Header.NumFirstRecLog < other.Header.NumFirstRecLog
} | go | func (c Chunk) Less(s *datastructs.Sortable) bool {
other := (*s).(Chunk)
return c.Header.NumFirstRecLog < other.Header.NumFirstRecLog
} | [
"func",
"(",
"c",
"Chunk",
")",
"Less",
"(",
"s",
"*",
"datastructs",
".",
"Sortable",
")",
"bool",
"{",
"other",
":=",
"(",
"*",
"s",
")",
".",
"(",
"Chunk",
")",
"\n",
"return",
"c",
".",
"Header",
".",
"NumFirstRecLog",
"<",
"other",
".",
"Hea... | // Less implement datastructs.Sortable | [
"Less",
"implement",
"datastructs",
".",
"Sortable"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L119-L122 |
17,436 | 0xrawsec/golang-evtx | evtx/chunk.go | ParseStringTable | func (c *Chunk) ParseStringTable(reader io.ReadSeeker) {
strOffset := int32(0)
for i := int64(0); i < sizeStringBucket*4; i += 4 {
encoding.Unmarshal(reader, &strOffset, Endianness)
if strOffset > 0 {
cs, err := StringAt(reader, int64(strOffset))
if err != nil {
if !ModeCarving {
panic(err)
}
... | go | func (c *Chunk) ParseStringTable(reader io.ReadSeeker) {
strOffset := int32(0)
for i := int64(0); i < sizeStringBucket*4; i += 4 {
encoding.Unmarshal(reader, &strOffset, Endianness)
if strOffset > 0 {
cs, err := StringAt(reader, int64(strOffset))
if err != nil {
if !ModeCarving {
panic(err)
}
... | [
"func",
"(",
"c",
"*",
"Chunk",
")",
"ParseStringTable",
"(",
"reader",
"io",
".",
"ReadSeeker",
")",
"{",
"strOffset",
":=",
"int32",
"(",
"0",
")",
"\n",
"for",
"i",
":=",
"int64",
"(",
"0",
")",
";",
"i",
"<",
"sizeStringBucket",
"*",
"4",
";",
... | // ParseStringTable parses the string table located at the current offset in the
// reader and modify the chunk object
// @reader : reader object to parse string table from | [
"ParseStringTable",
"parses",
"the",
"string",
"table",
"located",
"at",
"the",
"current",
"offset",
"in",
"the",
"reader",
"and",
"modify",
"the",
"chunk",
"object"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L127-L142 |
17,437 | 0xrawsec/golang-evtx | evtx/chunk.go | ParseTemplateTable | func (c *Chunk) ParseTemplateTable(reader io.ReadSeeker) error {
templateDataOffset := int32(0)
for i := int32(0); i < sizeTemplateBucket*4; i = i + 4 {
//parse(buf, i, &tempOffsetTable[j])
err := encoding.Unmarshal(reader, &templateDataOffset, Endianness)
if err != nil {
// panic(err)
log.DebugDontPanic(... | go | func (c *Chunk) ParseTemplateTable(reader io.ReadSeeker) error {
templateDataOffset := int32(0)
for i := int32(0); i < sizeTemplateBucket*4; i = i + 4 {
//parse(buf, i, &tempOffsetTable[j])
err := encoding.Unmarshal(reader, &templateDataOffset, Endianness)
if err != nil {
// panic(err)
log.DebugDontPanic(... | [
"func",
"(",
"c",
"*",
"Chunk",
")",
"ParseTemplateTable",
"(",
"reader",
"io",
".",
"ReadSeeker",
")",
"error",
"{",
"templateDataOffset",
":=",
"int32",
"(",
"0",
")",
"\n",
"for",
"i",
":=",
"int32",
"(",
"0",
")",
";",
"i",
"<",
"sizeTemplateBucket... | // ParseTemplaTable parses the template table located at the current offset in
// the reader passed as parameter and modifies the current Chunk object
// @reader : reader object to parse string table from | [
"ParseTemplaTable",
"parses",
"the",
"template",
"table",
"located",
"at",
"the",
"current",
"offset",
"in",
"the",
"reader",
"passed",
"as",
"parameter",
"and",
"modifies",
"the",
"current",
"Chunk",
"object"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L147-L174 |
17,438 | 0xrawsec/golang-evtx | evtx/chunk.go | ParseEventOffsets | func (c *Chunk) ParseEventOffsets(reader io.ReadSeeker) (err error) {
c.EventOffsets = make([]int32, 0)
offsetEvent := int32(BackupSeeker(reader))
c.EventOffsets = append(c.EventOffsets, offsetEvent)
for offsetEvent <= c.Header.OffsetLastRec {
eh := EventHeader{}
GoToSeeker(reader, int64(offsetEvent))
if err ... | go | func (c *Chunk) ParseEventOffsets(reader io.ReadSeeker) (err error) {
c.EventOffsets = make([]int32, 0)
offsetEvent := int32(BackupSeeker(reader))
c.EventOffsets = append(c.EventOffsets, offsetEvent)
for offsetEvent <= c.Header.OffsetLastRec {
eh := EventHeader{}
GoToSeeker(reader, int64(offsetEvent))
if err ... | [
"func",
"(",
"c",
"*",
"Chunk",
")",
"ParseEventOffsets",
"(",
"reader",
"io",
".",
"ReadSeeker",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"EventOffsets",
"=",
"make",
"(",
"[",
"]",
"int32",
",",
"0",
")",
"\n",
"offsetEvent",
":=",
"int32",
... | // ParseEventOffsets parses the offsets at which we can find the events and
// modifies the current Chunk object
// @reader : reader object to parse event offsets from | [
"ParseEventOffsets",
"parses",
"the",
"offsets",
"at",
"which",
"we",
"can",
"find",
"the",
"events",
"and",
"modifies",
"the",
"current",
"Chunk",
"object"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L179-L203 |
17,439 | 0xrawsec/golang-evtx | evtx/chunk.go | ParseEvent | func (c *Chunk) ParseEvent(offset int64) (e Event) {
if int64(c.Header.OffsetLastRec) < offset {
return
}
reader := bytes.NewReader(c.Data)
GoToSeeker(reader, offset)
e.Offset = offset
err := encoding.Unmarshal(reader, &e.Header, Endianness)
if err != nil {
panic(err)
}
/*err := encoding.Unmarshal(reader, ... | go | func (c *Chunk) ParseEvent(offset int64) (e Event) {
if int64(c.Header.OffsetLastRec) < offset {
return
}
reader := bytes.NewReader(c.Data)
GoToSeeker(reader, offset)
e.Offset = offset
err := encoding.Unmarshal(reader, &e.Header, Endianness)
if err != nil {
panic(err)
}
/*err := encoding.Unmarshal(reader, ... | [
"func",
"(",
"c",
"*",
"Chunk",
")",
"ParseEvent",
"(",
"offset",
"int64",
")",
"(",
"e",
"Event",
")",
"{",
"if",
"int64",
"(",
"c",
".",
"Header",
".",
"OffsetLastRec",
")",
"<",
"offset",
"{",
"return",
"\n",
"}",
"\n",
"reader",
":=",
"bytes",
... | // ParseEvent parses an Event from the current chunk located at the relative
// offset in c.Data, does not alter the current Chunk structure
// @offset : offset to parse the Event at
// return Event : parsed Event | [
"ParseEvent",
"parses",
"an",
"Event",
"from",
"the",
"current",
"chunk",
"located",
"at",
"the",
"relative",
"offset",
"in",
"c",
".",
"Data",
"does",
"not",
"alter",
"the",
"current",
"Chunk",
"structure"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/chunk.go#L209-L237 |
17,440 | 0xrawsec/golang-evtx | evtx/structs.go | Parse | func (e *BinXMLEntityReference) Parse(reader io.ReadSeeker) error {
err := encoding.Unmarshal(reader, &e.Token, Endianness)
if err != nil {
return err
}
err = encoding.Unmarshal(reader, &e.NameOffset, Endianness)
if err != nil {
return err
}
o := BackupSeeker(reader)
// if the Entity Name is just after
if ... | go | func (e *BinXMLEntityReference) Parse(reader io.ReadSeeker) error {
err := encoding.Unmarshal(reader, &e.Token, Endianness)
if err != nil {
return err
}
err = encoding.Unmarshal(reader, &e.NameOffset, Endianness)
if err != nil {
return err
}
o := BackupSeeker(reader)
// if the Entity Name is just after
if ... | [
"func",
"(",
"e",
"*",
"BinXMLEntityReference",
")",
"Parse",
"(",
"reader",
"io",
".",
"ReadSeeker",
")",
"error",
"{",
"err",
":=",
"encoding",
".",
"Unmarshal",
"(",
"reader",
",",
"&",
"e",
".",
"Token",
",",
"Endianness",
")",
"\n",
"if",
"err",
... | // Parse implements Element | [
"Parse",
"implements",
"Element"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/structs.go#L852-L872 |
17,441 | 0xrawsec/golang-evtx | evtx/goevtx.go | Get | func (pg *GoEvtxMap) Get(path *GoEvtxPath) (*GoEvtxElement, error) {
if len(*path) > 0 {
if i, ok := (*pg)[(*path)[0]]; ok {
if len(*path) == 1 {
cge := GoEvtxElement(i)
return &cge, nil
}
switch i.(type) {
case GoEvtxMap:
p := i.(GoEvtxMap)
np := (*path)[1:]
return p.Get(&np)
case... | go | func (pg *GoEvtxMap) Get(path *GoEvtxPath) (*GoEvtxElement, error) {
if len(*path) > 0 {
if i, ok := (*pg)[(*path)[0]]; ok {
if len(*path) == 1 {
cge := GoEvtxElement(i)
return &cge, nil
}
switch i.(type) {
case GoEvtxMap:
p := i.(GoEvtxMap)
np := (*path)[1:]
return p.Get(&np)
case... | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"Get",
"(",
"path",
"*",
"GoEvtxPath",
")",
"(",
"*",
"GoEvtxElement",
",",
"error",
")",
"{",
"if",
"len",
"(",
"*",
"path",
")",
">",
"0",
"{",
"if",
"i",
",",
"ok",
":=",
"(",
"*",
"pg",
")",
"[",
... | // Recursive search in a GoEvtxMap according to a given path
// @path : path to search for
// return *GoEvtxElement, error : pointer to the element found at path | [
"Recursive",
"search",
"in",
"a",
"GoEvtxMap",
"according",
"to",
"a",
"given",
"path"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L111-L131 |
17,442 | 0xrawsec/golang-evtx | evtx/goevtx.go | GetString | func (pg *GoEvtxMap) GetString(path *GoEvtxPath) (string, error) {
pE, err := pg.Get(path)
if err != nil {
return "", err
}
if s, ok := (*pE).(string); ok {
return s, nil
}
return "", fmt.Errorf("Bad type expect string got %T", (*pE))
} | go | func (pg *GoEvtxMap) GetString(path *GoEvtxPath) (string, error) {
pE, err := pg.Get(path)
if err != nil {
return "", err
}
if s, ok := (*pE).(string); ok {
return s, nil
}
return "", fmt.Errorf("Bad type expect string got %T", (*pE))
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"GetString",
"(",
"path",
"*",
"GoEvtxPath",
")",
"(",
"string",
",",
"error",
")",
"{",
"pE",
",",
"err",
":=",
"pg",
".",
"Get",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
... | // GetUint returns the GoEvtxElement at path as a string
// @path : path to search for
// return string, error | [
"GetUint",
"returns",
"the",
"GoEvtxElement",
"at",
"path",
"as",
"a",
"string"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L144-L153 |
17,443 | 0xrawsec/golang-evtx | evtx/goevtx.go | GetBool | func (pg *GoEvtxMap) GetBool(path *GoEvtxPath) (bool, error) {
s, err := pg.GetString(path)
if err != nil {
return false, &ErrEvtxEltNotFound{*path}
}
b, err := strconv.ParseBool(s)
if err != nil {
return false, err
}
return b, err
} | go | func (pg *GoEvtxMap) GetBool(path *GoEvtxPath) (bool, error) {
s, err := pg.GetString(path)
if err != nil {
return false, &ErrEvtxEltNotFound{*path}
}
b, err := strconv.ParseBool(s)
if err != nil {
return false, err
}
return b, err
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"GetBool",
"(",
"path",
"*",
"GoEvtxPath",
")",
"(",
"bool",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"pg",
".",
"GetString",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false"... | // GetBool returns the GoEvtxElement at path as a bool
// @path : path to search for
// return (bool, error) | [
"GetBool",
"returns",
"the",
"GoEvtxElement",
"at",
"path",
"as",
"a",
"bool"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L166-L176 |
17,444 | 0xrawsec/golang-evtx | evtx/goevtx.go | GetInt | func (pg *GoEvtxMap) GetInt(path *GoEvtxPath) (int64, error) {
s, err := pg.GetString(path)
if err != nil {
return 0, &ErrEvtxEltNotFound{*path}
}
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return 0, err
}
return i, nil
} | go | func (pg *GoEvtxMap) GetInt(path *GoEvtxPath) (int64, error) {
s, err := pg.GetString(path)
if err != nil {
return 0, &ErrEvtxEltNotFound{*path}
}
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return 0, err
}
return i, nil
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"GetInt",
"(",
"path",
"*",
"GoEvtxPath",
")",
"(",
"int64",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"pg",
".",
"GetString",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
... | // GetInt returns the GoEvtxElement at path as a int64
// @path : path to search for
// return int64, error | [
"GetInt",
"returns",
"the",
"GoEvtxElement",
"at",
"path",
"as",
"a",
"int64"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L189-L199 |
17,445 | 0xrawsec/golang-evtx | evtx/goevtx.go | GetUint | func (pg *GoEvtxMap) GetUint(path *GoEvtxPath) (uint64, error) {
s, err := pg.GetString(path)
if err != nil {
return 0, &ErrEvtxEltNotFound{*path}
}
u, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return 0, err
}
return u, nil
} | go | func (pg *GoEvtxMap) GetUint(path *GoEvtxPath) (uint64, error) {
s, err := pg.GetString(path)
if err != nil {
return 0, &ErrEvtxEltNotFound{*path}
}
u, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return 0, err
}
return u, nil
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"GetUint",
"(",
"path",
"*",
"GoEvtxPath",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"pg",
".",
"GetString",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
... | // GetUint returns the GoEvtxElement at path as a uint64
// @path : path to search for
// return uint64 | [
"GetUint",
"returns",
"the",
"GoEvtxElement",
"at",
"path",
"as",
"a",
"uint64"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L212-L222 |
17,446 | 0xrawsec/golang-evtx | evtx/goevtx.go | GetTime | func (pg *GoEvtxMap) GetTime(path *GoEvtxPath) (time.Time, error) {
t, err := pg.Get(path)
if err != nil {
return time.Time{}, &ErrEvtxEltNotFound{*path}
}
// If the value was extracted from raw BinXML (not a template) it may happen
// that the value stored at path is a string since in raw BinXML everything
// ... | go | func (pg *GoEvtxMap) GetTime(path *GoEvtxPath) (time.Time, error) {
t, err := pg.Get(path)
if err != nil {
return time.Time{}, &ErrEvtxEltNotFound{*path}
}
// If the value was extracted from raw BinXML (not a template) it may happen
// that the value stored at path is a string since in raw BinXML everything
// ... | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"GetTime",
"(",
"path",
"*",
"GoEvtxPath",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"pg",
".",
"Get",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return"... | // GetUint returns the GoEvtxElement at path as a Time struct
// @path : path to search for
// return Time | [
"GetUint",
"returns",
"the",
"GoEvtxElement",
"at",
"path",
"as",
"a",
"Time",
"struct"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L235-L253 |
17,447 | 0xrawsec/golang-evtx | evtx/goevtx.go | Equal | func (pg *GoEvtxMap) Equal(path *GoEvtxPath, i interface{}) bool {
t, err := pg.Get(path)
if err != nil {
return false
}
return reflect.DeepEqual(*t, i)
} | go | func (pg *GoEvtxMap) Equal(path *GoEvtxPath, i interface{}) bool {
t, err := pg.Get(path)
if err != nil {
return false
}
return reflect.DeepEqual(*t, i)
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"Equal",
"(",
"path",
"*",
"GoEvtxPath",
",",
"i",
"interface",
"{",
"}",
")",
"bool",
"{",
"t",
",",
"err",
":=",
"pg",
".",
"Get",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fal... | // Equal returns true if element at path is equal to i
// @path : path at witch GoEvtxElement is located
// @i : interface to test equality with
// return bool : true if equality is verified | [
"Equal",
"returns",
"true",
"if",
"element",
"at",
"path",
"is",
"equal",
"to",
"i"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L325-L331 |
17,448 | 0xrawsec/golang-evtx | evtx/goevtx.go | AnyEqual | func (pg *GoEvtxMap) AnyEqual(path *GoEvtxPath, is []interface{}) bool {
t, err := pg.Get(path)
if err != nil {
return false
}
for _, i := range is {
if reflect.DeepEqual(i, *t) {
return true
}
}
return false
} | go | func (pg *GoEvtxMap) AnyEqual(path *GoEvtxPath, is []interface{}) bool {
t, err := pg.Get(path)
if err != nil {
return false
}
for _, i := range is {
if reflect.DeepEqual(i, *t) {
return true
}
}
return false
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"AnyEqual",
"(",
"path",
"*",
"GoEvtxPath",
",",
"is",
"[",
"]",
"interface",
"{",
"}",
")",
"bool",
"{",
"t",
",",
"err",
":=",
"pg",
".",
"Get",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Equal returns true if element at path is equal to any object
// @path : path at witch GoEvtxElement is located
// @is : slice of interface to test equality with
// return bool : true if equality is verified | [
"Equal",
"returns",
"true",
"if",
"element",
"at",
"path",
"is",
"equal",
"to",
"any",
"object"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L337-L348 |
17,449 | 0xrawsec/golang-evtx | evtx/goevtx.go | RegexMatch | func (pg *GoEvtxMap) RegexMatch(path *GoEvtxPath, pattern *regexp.Regexp) bool {
s, err := pg.GetString(path)
if err != nil {
return false
}
return pattern.MatchString(s)
} | go | func (pg *GoEvtxMap) RegexMatch(path *GoEvtxPath, pattern *regexp.Regexp) bool {
s, err := pg.GetString(path)
if err != nil {
return false
}
return pattern.MatchString(s)
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"RegexMatch",
"(",
"path",
"*",
"GoEvtxPath",
",",
"pattern",
"*",
"regexp",
".",
"Regexp",
")",
"bool",
"{",
"s",
",",
"err",
":=",
"pg",
".",
"GetString",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // RegexMatch returns true if GoEvtxElement located at path matches a regexp
// @path : path at witch GoEvtxElement is located
// @pattern : regexp to test
// return bool | [
"RegexMatch",
"returns",
"true",
"if",
"GoEvtxElement",
"located",
"at",
"path",
"matches",
"a",
"regexp"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L354-L360 |
17,450 | 0xrawsec/golang-evtx | evtx/goevtx.go | Set | func (pg *GoEvtxMap) Set(path *GoEvtxPath, new GoEvtxElement) error {
if len(*path) > 0 {
i := (*pg)[(*path)[0]]
if len(*path) == 1 {
(*pg)[(*path)[0]] = new
return nil
}
switch i.(type) {
case GoEvtxMap:
p := i.(GoEvtxMap)
np := (*path)[1:]
return p.Set(&np, new)
case map[string]interface{}... | go | func (pg *GoEvtxMap) Set(path *GoEvtxPath, new GoEvtxElement) error {
if len(*path) > 0 {
i := (*pg)[(*path)[0]]
if len(*path) == 1 {
(*pg)[(*path)[0]] = new
return nil
}
switch i.(type) {
case GoEvtxMap:
p := i.(GoEvtxMap)
np := (*path)[1:]
return p.Set(&np, new)
case map[string]interface{}... | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"Set",
"(",
"path",
"*",
"GoEvtxPath",
",",
"new",
"GoEvtxElement",
")",
"error",
"{",
"if",
"len",
"(",
"*",
"path",
")",
">",
"0",
"{",
"i",
":=",
"(",
"*",
"pg",
")",
"[",
"(",
"*",
"path",
")",
"[... | // Set sets a new GoEvtxElement at path
// @path... : path to look for
// @new : new value
// return error if any | [
"Set",
"sets",
"a",
"new",
"GoEvtxElement",
"at",
"path"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L373-L393 |
17,451 | 0xrawsec/golang-evtx | evtx/goevtx.go | Del | func (pg *GoEvtxMap) Del(path ...string) {
if len(path) > 0 {
if ge, ok := (*pg)[path[0]]; ok {
if len(path) == 1 {
delete((*pg), path[0])
}
switch ge.(type) {
case GoEvtxMap:
p := ge.(GoEvtxMap)
p.Del(path[1:]...)
}
}
}
} | go | func (pg *GoEvtxMap) Del(path ...string) {
if len(path) > 0 {
if ge, ok := (*pg)[path[0]]; ok {
if len(path) == 1 {
delete((*pg), path[0])
}
switch ge.(type) {
case GoEvtxMap:
p := ge.(GoEvtxMap)
p.Del(path[1:]...)
}
}
}
} | [
"func",
"(",
"pg",
"*",
"GoEvtxMap",
")",
"Del",
"(",
"path",
"...",
"string",
")",
"{",
"if",
"len",
"(",
"path",
")",
">",
"0",
"{",
"if",
"ge",
",",
"ok",
":=",
"(",
"*",
"pg",
")",
"[",
"path",
"[",
"0",
"]",
"]",
";",
"ok",
"{",
"if"... | // Del deletes the object referenced by path | [
"Del",
"deletes",
"the",
"object",
"referenced",
"by",
"path"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/goevtx.go#L396-L409 |
17,452 | 0xrawsec/golang-evtx | evtx/event.go | Validate | func (h *EventHeader) Validate() error {
// Validate the event magic
if string(h.Magic[:]) != EventMagic {
return fmt.Errorf("Bad event magic %q", h.Magic)
}
// An event cannot be bigger than a Chunk since an event is embedded into a
// chunk
if h.Size >= ChunkSize {
return fmt.Errorf("Too big event")
}
// ... | go | func (h *EventHeader) Validate() error {
// Validate the event magic
if string(h.Magic[:]) != EventMagic {
return fmt.Errorf("Bad event magic %q", h.Magic)
}
// An event cannot be bigger than a Chunk since an event is embedded into a
// chunk
if h.Size >= ChunkSize {
return fmt.Errorf("Too big event")
}
// ... | [
"func",
"(",
"h",
"*",
"EventHeader",
")",
"Validate",
"(",
")",
"error",
"{",
"// Validate the event magic",
"if",
"string",
"(",
"h",
".",
"Magic",
"[",
":",
"]",
")",
"!=",
"EventMagic",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"... | // Validate controls the EventHeader | [
"Validate",
"controls",
"the",
"EventHeader"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/event.go#L21-L37 |
17,453 | 0xrawsec/golang-evtx | evtx/event.go | GoEvtxMap | func (e Event) GoEvtxMap(c *Chunk) (pge *GoEvtxMap, err error) {
// An Event can contain only BinXMLFragments
if !e.IsValid() {
err = ErrInvalidEvent
return
}
reader := bytes.NewReader(c.Data)
GoToSeeker(reader, e.Offset+EventHeaderSize)
// Bug here if we put c
element, err := Parse(reader, c, false)
if err... | go | func (e Event) GoEvtxMap(c *Chunk) (pge *GoEvtxMap, err error) {
// An Event can contain only BinXMLFragments
if !e.IsValid() {
err = ErrInvalidEvent
return
}
reader := bytes.NewReader(c.Data)
GoToSeeker(reader, e.Offset+EventHeaderSize)
// Bug here if we put c
element, err := Parse(reader, c, false)
if err... | [
"func",
"(",
"e",
"Event",
")",
"GoEvtxMap",
"(",
"c",
"*",
"Chunk",
")",
"(",
"pge",
"*",
"GoEvtxMap",
",",
"err",
"error",
")",
"{",
"// An Event can contain only BinXMLFragments",
"if",
"!",
"e",
".",
"IsValid",
"(",
")",
"{",
"err",
"=",
"ErrInvalidE... | // GoEvtxMap parses the BinXML inside the event and returns a pointer to a
// structure GoEvtxMap
// @c : chunk pointer used for template data already parsed
// return (*GoEvtxMap, error) | [
"GoEvtxMap",
"parses",
"the",
"BinXML",
"inside",
"the",
"event",
"and",
"returns",
"a",
"pointer",
"to",
"a",
"structure",
"GoEvtxMap"
] | 69fdb30898d69884050cc2b2fd2f541274e38bba | https://github.com/0xrawsec/golang-evtx/blob/69fdb30898d69884050cc2b2fd2f541274e38bba/evtx/event.go#L56-L80 |
17,454 | go-xorm/core | index.go | AddColumn | func (index *Index) AddColumn(cols ...string) {
for _, col := range cols {
index.Cols = append(index.Cols, col)
}
} | go | func (index *Index) AddColumn(cols ...string) {
for _, col := range cols {
index.Cols = append(index.Cols, col)
}
} | [
"func",
"(",
"index",
"*",
"Index",
")",
"AddColumn",
"(",
"cols",
"...",
"string",
")",
"{",
"for",
"_",
",",
"col",
":=",
"range",
"cols",
"{",
"index",
".",
"Cols",
"=",
"append",
"(",
"index",
".",
"Cols",
",",
"col",
")",
"\n",
"}",
"\n",
... | // add columns which will be composite index | [
"add",
"columns",
"which",
"will",
"be",
"composite",
"index"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/index.go#L39-L43 |
17,455 | go-xorm/core | index.go | NewIndex | func NewIndex(name string, indexType int) *Index {
return &Index{true, name, indexType, make([]string, 0)}
} | go | func NewIndex(name string, indexType int) *Index {
return &Index{true, name, indexType, make([]string, 0)}
} | [
"func",
"NewIndex",
"(",
"name",
"string",
",",
"indexType",
"int",
")",
"*",
"Index",
"{",
"return",
"&",
"Index",
"{",
"true",
",",
"name",
",",
"indexType",
",",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"}",
"\n",
"}"
] | // new an index | [
"new",
"an",
"index"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/index.go#L69-L71 |
17,456 | go-xorm/core | type.go | Type2SQLType | func Type2SQLType(t reflect.Type) (st SQLType) {
switch k := t.Kind(); k {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
st = SQLType{Int, 0, 0}
case reflect.Int64, reflect.Uint64:
st = SQLType{BigInt, 0, 0}
case reflect.Float32:
st ... | go | func Type2SQLType(t reflect.Type) (st SQLType) {
switch k := t.Kind(); k {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
st = SQLType{Int, 0, 0}
case reflect.Int64, reflect.Uint64:
st = SQLType{BigInt, 0, 0}
case reflect.Float32:
st ... | [
"func",
"Type2SQLType",
"(",
"t",
"reflect",
".",
"Type",
")",
"(",
"st",
"SQLType",
")",
"{",
"switch",
"k",
":=",
"t",
".",
"Kind",
"(",
")",
";",
"k",
"{",
"case",
"reflect",
".",
"Int",
",",
"reflect",
".",
"Int8",
",",
"reflect",
".",
"Int16... | // Type2SQLType generate SQLType acorrding Go's type | [
"Type2SQLType",
"generate",
"SQLType",
"acorrding",
"Go",
"s",
"type"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/type.go#L261-L296 |
17,457 | go-xorm/core | type.go | SQLType2Type | func SQLType2Type(st SQLType) reflect.Type {
name := strings.ToUpper(st.Name)
switch name {
case Bit, TinyInt, SmallInt, MediumInt, Int, Integer, Serial:
return reflect.TypeOf(1)
case BigInt, BigSerial:
return reflect.TypeOf(int64(1))
case Float, Real:
return reflect.TypeOf(float32(1))
case Double:
return... | go | func SQLType2Type(st SQLType) reflect.Type {
name := strings.ToUpper(st.Name)
switch name {
case Bit, TinyInt, SmallInt, MediumInt, Int, Integer, Serial:
return reflect.TypeOf(1)
case BigInt, BigSerial:
return reflect.TypeOf(int64(1))
case Float, Real:
return reflect.TypeOf(float32(1))
case Double:
return... | [
"func",
"SQLType2Type",
"(",
"st",
"SQLType",
")",
"reflect",
".",
"Type",
"{",
"name",
":=",
"strings",
".",
"ToUpper",
"(",
"st",
".",
"Name",
")",
"\n",
"switch",
"name",
"{",
"case",
"Bit",
",",
"TinyInt",
",",
"SmallInt",
",",
"MediumInt",
",",
... | // default sql type change to go types | [
"default",
"sql",
"type",
"change",
"to",
"go",
"types"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/type.go#L299-L323 |
17,458 | go-xorm/core | column.go | ValueOf | func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
dataStruct := reflect.Indirect(reflect.ValueOf(bean))
return col.ValueOfV(&dataStruct)
} | go | func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
dataStruct := reflect.Indirect(reflect.ValueOf(bean))
return col.ValueOfV(&dataStruct)
} | [
"func",
"(",
"col",
"*",
"Column",
")",
"ValueOf",
"(",
"bean",
"interface",
"{",
"}",
")",
"(",
"*",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"dataStruct",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"bean",
")",
... | // ValueOf returns column's filed of struct's value | [
"ValueOf",
"returns",
"column",
"s",
"filed",
"of",
"struct",
"s",
"value"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/column.go#L124-L127 |
17,459 | go-xorm/core | column.go | ValueOfV | func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
var fieldValue reflect.Value
fieldPath := strings.Split(col.FieldName, ".")
if dataStruct.Type().Kind() == reflect.Map {
keyValue := reflect.ValueOf(fieldPath[len(fieldPath)-1])
fieldValue = dataStruct.MapIndex(keyValue)
return &... | go | func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
var fieldValue reflect.Value
fieldPath := strings.Split(col.FieldName, ".")
if dataStruct.Type().Kind() == reflect.Map {
keyValue := reflect.ValueOf(fieldPath[len(fieldPath)-1])
fieldValue = dataStruct.MapIndex(keyValue)
return &... | [
"func",
"(",
"col",
"*",
"Column",
")",
"ValueOfV",
"(",
"dataStruct",
"*",
"reflect",
".",
"Value",
")",
"(",
"*",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"var",
"fieldValue",
"reflect",
".",
"Value",
"\n",
"fieldPath",
":=",
"strings",
".",
... | // ValueOfV returns column's filed of struct's value accept reflevt value | [
"ValueOfV",
"returns",
"column",
"s",
"filed",
"of",
"struct",
"s",
"value",
"accept",
"reflevt",
"value"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/column.go#L130-L166 |
17,460 | go-xorm/core | table.go | PKColumns | func (table *Table) PKColumns() []*Column {
columns := make([]*Column, len(table.PrimaryKeys))
for i, name := range table.PrimaryKeys {
columns[i] = table.GetColumn(name)
}
return columns
} | go | func (table *Table) PKColumns() []*Column {
columns := make([]*Column, len(table.PrimaryKeys))
for i, name := range table.PrimaryKeys {
columns[i] = table.GetColumn(name)
}
return columns
} | [
"func",
"(",
"table",
"*",
"Table",
")",
"PKColumns",
"(",
")",
"[",
"]",
"*",
"Column",
"{",
"columns",
":=",
"make",
"(",
"[",
"]",
"*",
"Column",
",",
"len",
"(",
"table",
".",
"PrimaryKeys",
")",
")",
"\n",
"for",
"i",
",",
"name",
":=",
"r... | // if has primary key, return column | [
"if",
"has",
"primary",
"key",
"return",
"column"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/table.go#L91-L97 |
17,461 | go-xorm/core | table.go | AddColumn | func (table *Table) AddColumn(col *Column) {
table.columnsSeq = append(table.columnsSeq, col.Name)
table.columns = append(table.columns, col)
colName := strings.ToLower(col.Name)
if c, ok := table.columnsMap[colName]; ok {
table.columnsMap[colName] = append(c, col)
} else {
table.columnsMap[colName] = []*Colum... | go | func (table *Table) AddColumn(col *Column) {
table.columnsSeq = append(table.columnsSeq, col.Name)
table.columns = append(table.columns, col)
colName := strings.ToLower(col.Name)
if c, ok := table.columnsMap[colName]; ok {
table.columnsMap[colName] = append(c, col)
} else {
table.columnsMap[colName] = []*Colum... | [
"func",
"(",
"table",
"*",
"Table",
")",
"AddColumn",
"(",
"col",
"*",
"Column",
")",
"{",
"table",
".",
"columnsSeq",
"=",
"append",
"(",
"table",
".",
"columnsSeq",
",",
"col",
".",
"Name",
")",
"\n",
"table",
".",
"columns",
"=",
"append",
"(",
... | // add a column to table | [
"add",
"a",
"column",
"to",
"table"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/table.go#L121-L149 |
17,462 | go-xorm/core | table.go | AddIndex | func (table *Table) AddIndex(index *Index) {
table.Indexes[index.Name] = index
} | go | func (table *Table) AddIndex(index *Index) {
table.Indexes[index.Name] = index
} | [
"func",
"(",
"table",
"*",
"Table",
")",
"AddIndex",
"(",
"index",
"*",
"Index",
")",
"{",
"table",
".",
"Indexes",
"[",
"index",
".",
"Name",
"]",
"=",
"index",
"\n",
"}"
] | // add an index or an unique to table | [
"add",
"an",
"index",
"or",
"an",
"unique",
"to",
"table"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/table.go#L152-L154 |
17,463 | go-xorm/core | db.go | Open | func Open(driverName, dataSourceName string) (*DB, error) {
db, err := sql.Open(driverName, dataSourceName)
if err != nil {
return nil, err
}
return &DB{
DB: db,
Mapper: NewCacheMapper(&SnakeMapper{}),
reflectCache: make(map[reflect.Type]*cacheStruct),
}, nil
} | go | func Open(driverName, dataSourceName string) (*DB, error) {
db, err := sql.Open(driverName, dataSourceName)
if err != nil {
return nil, err
}
return &DB{
DB: db,
Mapper: NewCacheMapper(&SnakeMapper{}),
reflectCache: make(map[reflect.Type]*cacheStruct),
}, nil
} | [
"func",
"Open",
"(",
"driverName",
",",
"dataSourceName",
"string",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"db",
",",
"err",
":=",
"sql",
".",
"Open",
"(",
"driverName",
",",
"dataSourceName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // Open opens a database | [
"Open",
"opens",
"a",
"database"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/db.go#L84-L94 |
17,464 | go-xorm/core | db.go | FromDB | func FromDB(db *sql.DB) *DB {
return &DB{
DB: db,
Mapper: NewCacheMapper(&SnakeMapper{}),
reflectCache: make(map[reflect.Type]*cacheStruct),
}
} | go | func FromDB(db *sql.DB) *DB {
return &DB{
DB: db,
Mapper: NewCacheMapper(&SnakeMapper{}),
reflectCache: make(map[reflect.Type]*cacheStruct),
}
} | [
"func",
"FromDB",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"*",
"DB",
"{",
"return",
"&",
"DB",
"{",
"DB",
":",
"db",
",",
"Mapper",
":",
"NewCacheMapper",
"(",
"&",
"SnakeMapper",
"{",
"}",
")",
",",
"reflectCache",
":",
"make",
"(",
"map",
"[",
... | // FromDB creates a DB from a sql.DB | [
"FromDB",
"creates",
"a",
"DB",
"from",
"a",
"sql",
".",
"DB"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/db.go#L97-L103 |
17,465 | go-xorm/core | db.go | QueryContext | func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) {
rows, err := db.DB.QueryContext(ctx, query, args...)
if err != nil {
if rows != nil {
rows.Close()
}
return nil, err
}
return &Rows{rows, db}, nil
} | go | func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) {
rows, err := db.DB.QueryContext(ctx, query, args...)
if err != nil {
if rows != nil {
rows.Close()
}
return nil, err
}
return &Rows{rows, db}, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"QueryContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"Rows",
",",
"error",
")",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"DB",... | // QueryContext overwrites sql.DB.QueryContext | [
"QueryContext",
"overwrites",
"sql",
".",
"DB",
".",
"QueryContext"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/db.go#L119-L128 |
17,466 | go-xorm/core | db.go | Query | func (db *DB) Query(query string, args ...interface{}) (*Rows, error) {
return db.QueryContext(context.Background(), query, args...)
} | go | func (db *DB) Query(query string, args ...interface{}) (*Rows, error) {
return db.QueryContext(context.Background(), query, args...)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"Query",
"(",
"query",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"Rows",
",",
"error",
")",
"{",
"return",
"db",
".",
"QueryContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"... | // Query overwrites sql.DB.Query | [
"Query",
"overwrites",
"sql",
".",
"DB",
".",
"Query"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/db.go#L131-L133 |
17,467 | go-xorm/core | rows.go | ScanStructByIndex | func (rs *Rows) ScanStructByIndex(dest ...interface{}) error {
if len(dest) == 0 {
return errors.New("at least one struct")
}
vvvs := make([]reflect.Value, len(dest))
for i, s := range dest {
vv := reflect.ValueOf(s)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
return errors.New("de... | go | func (rs *Rows) ScanStructByIndex(dest ...interface{}) error {
if len(dest) == 0 {
return errors.New("at least one struct")
}
vvvs := make([]reflect.Value, len(dest))
for i, s := range dest {
vv := reflect.ValueOf(s)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
return errors.New("de... | [
"func",
"(",
"rs",
"*",
"Rows",
")",
"ScanStructByIndex",
"(",
"dest",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"dest",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"vvvs"... | // scan data to a struct's pointer according field index | [
"scan",
"data",
"to",
"a",
"struct",
"s",
"pointer",
"according",
"field",
"index"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/rows.go#L38-L68 |
17,468 | go-xorm/core | rows.go | ScanSlice | func (rs *Rows) ScanSlice(dest interface{}) error {
vv := reflect.ValueOf(dest)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Slice {
return errors.New("dest should be a slice's pointer")
}
vvv := vv.Elem()
cols, err := rs.Columns()
if err != nil {
return err
}
newDest := make([]interface{}, ... | go | func (rs *Rows) ScanSlice(dest interface{}) error {
vv := reflect.ValueOf(dest)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Slice {
return errors.New("dest should be a slice's pointer")
}
vvv := vv.Elem()
cols, err := rs.Columns()
if err != nil {
return err
}
newDest := make([]interface{}, ... | [
"func",
"(",
"rs",
"*",
"Rows",
")",
"ScanSlice",
"(",
"dest",
"interface",
"{",
"}",
")",
"error",
"{",
"vv",
":=",
"reflect",
".",
"ValueOf",
"(",
"dest",
")",
"\n",
"if",
"vv",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Ptr",
"||",
"vv",
... | // scan data to a slice's pointer, slice's length should equal to columns' number | [
"scan",
"data",
"to",
"a",
"slice",
"s",
"pointer",
"slice",
"s",
"length",
"should",
"equal",
"to",
"columns",
"number"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/rows.go#L124-L156 |
17,469 | go-xorm/core | dialect.go | RegisterDialect | func RegisterDialect(dbName DbType, dialectFunc func() Dialect) {
if dialectFunc == nil {
panic("core: Register dialect is nil")
}
dialects[strings.ToLower(string(dbName))] = dialectFunc // !nashtsai! allow override dialect
} | go | func RegisterDialect(dbName DbType, dialectFunc func() Dialect) {
if dialectFunc == nil {
panic("core: Register dialect is nil")
}
dialects[strings.ToLower(string(dbName))] = dialectFunc // !nashtsai! allow override dialect
} | [
"func",
"RegisterDialect",
"(",
"dbName",
"DbType",
",",
"dialectFunc",
"func",
"(",
")",
"Dialect",
")",
"{",
"if",
"dialectFunc",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"dialects",
"[",
"strings",
".",
"ToLower",
"(",
"stri... | // RegisterDialect register database dialect | [
"RegisterDialect",
"register",
"database",
"dialect"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/dialect.go#L306-L311 |
17,470 | go-xorm/core | dialect.go | QueryDialect | func QueryDialect(dbName DbType) Dialect {
if d, ok := dialects[strings.ToLower(string(dbName))]; ok {
return d()
}
return nil
} | go | func QueryDialect(dbName DbType) Dialect {
if d, ok := dialects[strings.ToLower(string(dbName))]; ok {
return d()
}
return nil
} | [
"func",
"QueryDialect",
"(",
"dbName",
"DbType",
")",
"Dialect",
"{",
"if",
"d",
",",
"ok",
":=",
"dialects",
"[",
"strings",
".",
"ToLower",
"(",
"string",
"(",
"dbName",
")",
")",
"]",
";",
"ok",
"{",
"return",
"d",
"(",
")",
"\n",
"}",
"\n",
"... | // QueryDialect query if registed database dialect | [
"QueryDialect",
"query",
"if",
"registed",
"database",
"dialect"
] | ccc80c1adf1f6172bbc548877f50a1163041a40a | https://github.com/go-xorm/core/blob/ccc80c1adf1f6172bbc548877f50a1163041a40a/dialect.go#L314-L319 |
17,471 | thriftrw/thriftrw-go | ast/walk.go | Walk | func Walk(v Visitor, n Node) {
visitor{Visitor: v}.visit(nil, n)
} | go | func Walk(v Visitor, n Node) {
visitor{Visitor: v}.visit(nil, n)
} | [
"func",
"Walk",
"(",
"v",
"Visitor",
",",
"n",
"Node",
")",
"{",
"visitor",
"{",
"Visitor",
":",
"v",
"}",
".",
"visit",
"(",
"nil",
",",
"n",
")",
"\n",
"}"
] | // Walk walks the AST depth-first with the given visitor, starting at the
// given node. The visitor's Visit function should return a non-nil visitor if
// it wants to visit the children of the node it was called with. | [
"Walk",
"walks",
"the",
"AST",
"depth",
"-",
"first",
"with",
"the",
"given",
"visitor",
"starting",
"at",
"the",
"given",
"node",
".",
"The",
"visitor",
"s",
"Visit",
"function",
"should",
"return",
"a",
"non",
"-",
"nil",
"visitor",
"if",
"it",
"wants"... | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/walk.go#L26-L28 |
17,472 | thriftrw/thriftrw-go | wire/value_equals.go | ValuesAreEqual | func ValuesAreEqual(left, right Value) bool {
if left.typ != right.typ {
return false
}
switch left.typ {
case TBool:
return left.GetBool() == right.GetBool()
case TI8:
return left.GetI8() == right.GetI8()
case TDouble:
return left.GetDouble() == right.GetDouble()
case TI16:
return left.GetI16() == ri... | go | func ValuesAreEqual(left, right Value) bool {
if left.typ != right.typ {
return false
}
switch left.typ {
case TBool:
return left.GetBool() == right.GetBool()
case TI8:
return left.GetI8() == right.GetI8()
case TDouble:
return left.GetDouble() == right.GetDouble()
case TI16:
return left.GetI16() == ri... | [
"func",
"ValuesAreEqual",
"(",
"left",
",",
"right",
"Value",
")",
"bool",
"{",
"if",
"left",
".",
"typ",
"!=",
"right",
".",
"typ",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"switch",
"left",
".",
"typ",
"{",
"case",
"TBool",
":",
"return",
"left",... | // ValuesAreEqual checks if two values are equal. | [
"ValuesAreEqual",
"checks",
"if",
"two",
"values",
"are",
"equal",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/wire/value_equals.go#L34-L65 |
17,473 | thriftrw/thriftrw-go | wire/value_equals.go | StructsAreEqual | func StructsAreEqual(left, right Struct) bool {
if len(left.Fields) != len(right.Fields) {
return false
}
// Fields are unordered so we need to build a map to actually compare
// them.
leftFields := left.fieldMap()
rightFields := right.fieldMap()
for i, lvalue := range leftFields {
if rvalue, ok := rightF... | go | func StructsAreEqual(left, right Struct) bool {
if len(left.Fields) != len(right.Fields) {
return false
}
// Fields are unordered so we need to build a map to actually compare
// them.
leftFields := left.fieldMap()
rightFields := right.fieldMap()
for i, lvalue := range leftFields {
if rvalue, ok := rightF... | [
"func",
"StructsAreEqual",
"(",
"left",
",",
"right",
"Struct",
")",
"bool",
"{",
"if",
"len",
"(",
"left",
".",
"Fields",
")",
"!=",
"len",
"(",
"right",
".",
"Fields",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Fields are unordered so we need to... | // StructsAreEqual checks if two structs are equal. | [
"StructsAreEqual",
"checks",
"if",
"two",
"structs",
"are",
"equal",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/wire/value_equals.go#L68-L88 |
17,474 | thriftrw/thriftrw-go | wire/value_equals.go | SetsAreEqual | func SetsAreEqual(left, right ValueList) bool {
if left.ValueType() != right.ValueType() {
return false
}
if left.Size() != right.Size() {
return false
}
if isHashable(left.ValueType()) {
return setsArEqualHashable(left.Size(), left, right)
}
return setsAreEqualUnhashable(left.Size(), left, right)
} | go | func SetsAreEqual(left, right ValueList) bool {
if left.ValueType() != right.ValueType() {
return false
}
if left.Size() != right.Size() {
return false
}
if isHashable(left.ValueType()) {
return setsArEqualHashable(left.Size(), left, right)
}
return setsAreEqualUnhashable(left.Size(), left, right)
} | [
"func",
"SetsAreEqual",
"(",
"left",
",",
"right",
"ValueList",
")",
"bool",
"{",
"if",
"left",
".",
"ValueType",
"(",
")",
"!=",
"right",
".",
"ValueType",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"left",
".",
"Size",
"(",
")",
"!=... | // SetsAreEqual checks if two sets are equal. | [
"SetsAreEqual",
"checks",
"if",
"two",
"sets",
"are",
"equal",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/wire/value_equals.go#L91-L103 |
17,475 | thriftrw/thriftrw-go | wire/value_equals.go | MapsAreEqual | func MapsAreEqual(left, right MapItemList) bool {
if left.KeyType() != right.KeyType() {
return false
}
if left.ValueType() != right.ValueType() {
return false
}
if left.Size() != right.Size() {
return false
}
if isHashable(left.KeyType()) {
return mapsAreEqualHashable(left.Size(), left, right)
}
retu... | go | func MapsAreEqual(left, right MapItemList) bool {
if left.KeyType() != right.KeyType() {
return false
}
if left.ValueType() != right.ValueType() {
return false
}
if left.Size() != right.Size() {
return false
}
if isHashable(left.KeyType()) {
return mapsAreEqualHashable(left.Size(), left, right)
}
retu... | [
"func",
"MapsAreEqual",
"(",
"left",
",",
"right",
"MapItemList",
")",
"bool",
"{",
"if",
"left",
".",
"KeyType",
"(",
")",
"!=",
"right",
".",
"KeyType",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"left",
".",
"ValueType",
"(",
")",
... | // MapsAreEqual checks if two maps are equal. | [
"MapsAreEqual",
"checks",
"if",
"two",
"maps",
"are",
"equal",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/wire/value_equals.go#L145-L160 |
17,476 | thriftrw/thriftrw-go | wire/value_equals.go | ListsAreEqual | func ListsAreEqual(left, right ValueList) bool {
if left.ValueType() != right.ValueType() {
return false
}
if left.Size() != right.Size() {
return false
}
leftItems := ValueListToSlice(left)
rightItems := ValueListToSlice(right)
for i, lv := range leftItems {
rv := rightItems[i]
if !ValuesAreEqual(lv, ... | go | func ListsAreEqual(left, right ValueList) bool {
if left.ValueType() != right.ValueType() {
return false
}
if left.Size() != right.Size() {
return false
}
leftItems := ValueListToSlice(left)
rightItems := ValueListToSlice(right)
for i, lv := range leftItems {
rv := rightItems[i]
if !ValuesAreEqual(lv, ... | [
"func",
"ListsAreEqual",
"(",
"left",
",",
"right",
"ValueList",
")",
"bool",
"{",
"if",
"left",
".",
"ValueType",
"(",
")",
"!=",
"right",
".",
"ValueType",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"left",
".",
"Size",
"(",
")",
"!... | // ListsAreEqual checks if two lists are equal. | [
"ListsAreEqual",
"checks",
"if",
"two",
"lists",
"are",
"equal",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/wire/value_equals.go#L226-L245 |
17,477 | thriftrw/thriftrw-go | compile/typedef.go | compileTypedef | func compileTypedef(file string, src *ast.Typedef) (*TypedefSpec, error) {
typ, err := compileTypeReference(src.Type)
if err != nil {
return nil, err
}
annotations, err := compileAnnotations(src.Annotations)
if err != nil {
return nil, compileError{
Target: src.Name,
Line: src.Line,
Reason: err,
... | go | func compileTypedef(file string, src *ast.Typedef) (*TypedefSpec, error) {
typ, err := compileTypeReference(src.Type)
if err != nil {
return nil, err
}
annotations, err := compileAnnotations(src.Annotations)
if err != nil {
return nil, compileError{
Target: src.Name,
Line: src.Line,
Reason: err,
... | [
"func",
"compileTypedef",
"(",
"file",
"string",
",",
"src",
"*",
"ast",
".",
"Typedef",
")",
"(",
"*",
"TypedefSpec",
",",
"error",
")",
"{",
"typ",
",",
"err",
":=",
"compileTypeReference",
"(",
"src",
".",
"Type",
")",
"\n",
"if",
"err",
"!=",
"ni... | // compileTypedef compiles the given Typedef AST into a TypedefSpec. | [
"compileTypedef",
"compiles",
"the",
"given",
"Typedef",
"AST",
"into",
"a",
"TypedefSpec",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/typedef.go#L42-L64 |
17,478 | thriftrw/thriftrw-go | compile/typedef.go | Link | func (t *TypedefSpec) Link(scope Scope) (TypeSpec, error) {
if t.linked() {
return t, nil
}
var err error
t.Target, err = t.Target.Link(scope)
if err == nil {
t.root = RootTypeSpec(t.Target)
}
return t, err
} | go | func (t *TypedefSpec) Link(scope Scope) (TypeSpec, error) {
if t.linked() {
return t, nil
}
var err error
t.Target, err = t.Target.Link(scope)
if err == nil {
t.root = RootTypeSpec(t.Target)
}
return t, err
} | [
"func",
"(",
"t",
"*",
"TypedefSpec",
")",
"Link",
"(",
"scope",
"Scope",
")",
"(",
"TypeSpec",
",",
"error",
")",
"{",
"if",
"t",
".",
"linked",
"(",
")",
"{",
"return",
"t",
",",
"nil",
"\n",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"t",
"."... | // Link links the Target TypeSpec for this typedef in the given scope. | [
"Link",
"links",
"the",
"Target",
"TypeSpec",
"for",
"this",
"typedef",
"in",
"the",
"given",
"scope",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/typedef.go#L72-L83 |
17,479 | thriftrw/thriftrw-go | compile/typedef.go | ForEachTypeReference | func (t *TypedefSpec) ForEachTypeReference(f func(TypeSpec) error) error {
return f(t.Target)
} | go | func (t *TypedefSpec) ForEachTypeReference(f func(TypeSpec) error) error {
return f(t.Target)
} | [
"func",
"(",
"t",
"*",
"TypedefSpec",
")",
"ForEachTypeReference",
"(",
"f",
"func",
"(",
"TypeSpec",
")",
"error",
")",
"error",
"{",
"return",
"f",
"(",
"t",
".",
"Target",
")",
"\n",
"}"
] | // ForEachTypeReference for TypedefSpec | [
"ForEachTypeReference",
"for",
"TypedefSpec"
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/typedef.go#L96-L98 |
17,480 | thriftrw/thriftrw-go | idl/internal/parser.go | Parse | func Parse(s []byte) (*ast.Program, error) {
lex := newLexer(s)
e := yyParse(lex)
if e == 0 && !lex.parseFailed {
return lex.program, nil
}
return nil, lex.err
} | go | func Parse(s []byte) (*ast.Program, error) {
lex := newLexer(s)
e := yyParse(lex)
if e == 0 && !lex.parseFailed {
return lex.program, nil
}
return nil, lex.err
} | [
"func",
"Parse",
"(",
"s",
"[",
"]",
"byte",
")",
"(",
"*",
"ast",
".",
"Program",
",",
"error",
")",
"{",
"lex",
":=",
"newLexer",
"(",
"s",
")",
"\n",
"e",
":=",
"yyParse",
"(",
"lex",
")",
"\n",
"if",
"e",
"==",
"0",
"&&",
"!",
"lex",
".... | // Parse parses the given Thrift document. | [
"Parse",
"parses",
"the",
"given",
"Thrift",
"document",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/idl/internal/parser.go#L30-L37 |
17,481 | thriftrw/thriftrw-go | protocol/binary/envelope.go | WriteEnveloped | func (bw *Writer) WriteEnveloped(e wire.Envelope) error {
version := uint32(version1) | uint32(e.Type)
if err := bw.writeInt32(int32(version)); err != nil {
return err
}
if err := bw.writeString(e.Name); err != nil {
return err
}
if err := bw.writeInt32(e.SeqID); err != nil {
return err
}
return bw.Wr... | go | func (bw *Writer) WriteEnveloped(e wire.Envelope) error {
version := uint32(version1) | uint32(e.Type)
if err := bw.writeInt32(int32(version)); err != nil {
return err
}
if err := bw.writeString(e.Name); err != nil {
return err
}
if err := bw.writeInt32(e.SeqID); err != nil {
return err
}
return bw.Wr... | [
"func",
"(",
"bw",
"*",
"Writer",
")",
"WriteEnveloped",
"(",
"e",
"wire",
".",
"Envelope",
")",
"error",
"{",
"version",
":=",
"uint32",
"(",
"version1",
")",
"|",
"uint32",
"(",
"e",
".",
"Type",
")",
"\n\n",
"if",
"err",
":=",
"bw",
".",
"writeI... | // WriteEnveloped writes enveloped value using the strict envelope. | [
"WriteEnveloped",
"writes",
"enveloped",
"value",
"using",
"the",
"strict",
"envelope",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/protocol/binary/envelope.go#L35-L51 |
17,482 | thriftrw/thriftrw-go | gen/type.go | TypeDefinition | func TypeDefinition(g Generator, spec compile.TypeSpec) error {
switch s := spec.(type) {
case *compile.EnumSpec:
return enum(g, s)
case *compile.StructSpec:
return structure(g, s)
case *compile.TypedefSpec:
return typedef(g, s)
default:
panic(fmt.Sprintf("%q is not a defined type", spec.ThriftName()))
}
... | go | func TypeDefinition(g Generator, spec compile.TypeSpec) error {
switch s := spec.(type) {
case *compile.EnumSpec:
return enum(g, s)
case *compile.StructSpec:
return structure(g, s)
case *compile.TypedefSpec:
return typedef(g, s)
default:
panic(fmt.Sprintf("%q is not a defined type", spec.ThriftName()))
}
... | [
"func",
"TypeDefinition",
"(",
"g",
"Generator",
",",
"spec",
"compile",
".",
"TypeSpec",
")",
"error",
"{",
"switch",
"s",
":=",
"spec",
".",
"(",
"type",
")",
"{",
"case",
"*",
"compile",
".",
"EnumSpec",
":",
"return",
"enum",
"(",
"g",
",",
"s",
... | // TypeDefinition generates code for the given TypeSpec. | [
"TypeDefinition",
"generates",
"code",
"for",
"the",
"given",
"TypeSpec",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/type.go#L30-L41 |
17,483 | thriftrw/thriftrw-go | gen/type.go | isReferenceType | func isReferenceType(spec compile.TypeSpec) bool {
spec = compile.RootTypeSpec(spec)
if _, ok := spec.(*compile.BinarySpec); ok {
return true
}
switch spec.(type) {
case *compile.MapSpec, *compile.ListSpec, *compile.SetSpec:
return true
default:
return false
}
} | go | func isReferenceType(spec compile.TypeSpec) bool {
spec = compile.RootTypeSpec(spec)
if _, ok := spec.(*compile.BinarySpec); ok {
return true
}
switch spec.(type) {
case *compile.MapSpec, *compile.ListSpec, *compile.SetSpec:
return true
default:
return false
}
} | [
"func",
"isReferenceType",
"(",
"spec",
"compile",
".",
"TypeSpec",
")",
"bool",
"{",
"spec",
"=",
"compile",
".",
"RootTypeSpec",
"(",
"spec",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"spec",
".",
"(",
"*",
"compile",
".",
"BinarySpec",
")",
";",
"ok"... | // isReferenceType checks if the given TypeSpec represents a reference type.
//
// Sets, maps, lists, and slices are reference types. | [
"isReferenceType",
"checks",
"if",
"the",
"given",
"TypeSpec",
"represents",
"a",
"reference",
"type",
".",
"Sets",
"maps",
"lists",
"and",
"slices",
"are",
"reference",
"types",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/type.go#L80-L92 |
17,484 | thriftrw/thriftrw-go | gen/type.go | typeReference | func typeReference(g Generator, spec compile.TypeSpec) (string, error) {
name, err := typeName(g, spec)
if err != nil {
return "", err
}
if isStructType(spec) {
// Prepend "*" to the result if the field is not required and the type
// isn't a reference type.
name = "*" + name
}
return name, nil
} | go | func typeReference(g Generator, spec compile.TypeSpec) (string, error) {
name, err := typeName(g, spec)
if err != nil {
return "", err
}
if isStructType(spec) {
// Prepend "*" to the result if the field is not required and the type
// isn't a reference type.
name = "*" + name
}
return name, nil
} | [
"func",
"typeReference",
"(",
"g",
"Generator",
",",
"spec",
"compile",
".",
"TypeSpec",
")",
"(",
"string",
",",
"error",
")",
"{",
"name",
",",
"err",
":=",
"typeName",
"(",
"g",
",",
"spec",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\... | // typeReference returns a string representation of a reference to the given
// type. | [
"typeReference",
"returns",
"a",
"string",
"representation",
"of",
"a",
"reference",
"to",
"the",
"given",
"type",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/type.go#L102-L113 |
17,485 | thriftrw/thriftrw-go | gen/type.go | typeReferencePtr | func typeReferencePtr(g Generator, spec compile.TypeSpec) (string, error) {
ref, err := typeName(g, spec)
if err != nil {
return "", err
}
if !isReferenceType(spec) {
// need * prefix for everything but map, string, and list.
return "*" + ref, nil
}
return ref, nil
} | go | func typeReferencePtr(g Generator, spec compile.TypeSpec) (string, error) {
ref, err := typeName(g, spec)
if err != nil {
return "", err
}
if !isReferenceType(spec) {
// need * prefix for everything but map, string, and list.
return "*" + ref, nil
}
return ref, nil
} | [
"func",
"typeReferencePtr",
"(",
"g",
"Generator",
",",
"spec",
"compile",
".",
"TypeSpec",
")",
"(",
"string",
",",
"error",
")",
"{",
"ref",
",",
"err",
":=",
"typeName",
"(",
"g",
",",
"spec",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // typeReferencePtr returns a strung representing a reference to a pointer of
// the given type. The pointer prefix is not added for types that are already
// reference types. | [
"typeReferencePtr",
"returns",
"a",
"strung",
"representing",
"a",
"reference",
"to",
"a",
"pointer",
"of",
"the",
"given",
"type",
".",
"The",
"pointer",
"prefix",
"is",
"not",
"added",
"for",
"types",
"that",
"are",
"already",
"reference",
"types",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/type.go#L118-L128 |
17,486 | thriftrw/thriftrw-go | gen/type.go | typeName | func typeName(g Generator, spec compile.TypeSpec) (string, error) {
switch s := spec.(type) {
case *compile.BoolSpec:
return "bool", nil
case *compile.I8Spec:
return "int8", nil
case *compile.I16Spec:
return "int16", nil
case *compile.I32Spec:
return "int32", nil
case *compile.I64Spec:
return "int64", n... | go | func typeName(g Generator, spec compile.TypeSpec) (string, error) {
switch s := spec.(type) {
case *compile.BoolSpec:
return "bool", nil
case *compile.I8Spec:
return "int8", nil
case *compile.I16Spec:
return "int16", nil
case *compile.I32Spec:
return "int32", nil
case *compile.I64Spec:
return "int64", n... | [
"func",
"typeName",
"(",
"g",
"Generator",
",",
"spec",
"compile",
".",
"TypeSpec",
")",
"(",
"string",
",",
"error",
")",
"{",
"switch",
"s",
":=",
"spec",
".",
"(",
"type",
")",
"{",
"case",
"*",
"compile",
".",
"BoolSpec",
":",
"return",
"\"",
"... | // typeName returns the name of the given type, whether it's a custom type or
// native. | [
"typeName",
"returns",
"the",
"name",
"of",
"the",
"given",
"type",
"whether",
"it",
"s",
"a",
"custom",
"type",
"or",
"native",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/type.go#L132-L185 |
17,487 | thriftrw/thriftrw-go | compile/service.go | resolveService | func resolveService(src ast.ServiceReference, scope Scope) (*ServiceSpec, error) {
s, err := scope.LookupService(src.Name)
if err == nil {
err = s.Link(scope)
return s, err
}
mname, iname := splitInclude(src.Name)
if len(mname) == 0 {
return nil, referenceError{
Target: src.Name,
Line: src.Lin... | go | func resolveService(src ast.ServiceReference, scope Scope) (*ServiceSpec, error) {
s, err := scope.LookupService(src.Name)
if err == nil {
err = s.Link(scope)
return s, err
}
mname, iname := splitInclude(src.Name)
if len(mname) == 0 {
return nil, referenceError{
Target: src.Name,
Line: src.Lin... | [
"func",
"resolveService",
"(",
"src",
"ast",
".",
"ServiceReference",
",",
"scope",
"Scope",
")",
"(",
"*",
"ServiceSpec",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"scope",
".",
"LookupService",
"(",
"src",
".",
"Name",
")",
"\n",
"if",
"err",
... | // resolveService resolves a ServiceReference in the given scope. | [
"resolveService",
"resolves",
"a",
"ServiceReference",
"in",
"the",
"given",
"scope",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/service.go#L85-L113 |
17,488 | thriftrw/thriftrw-go | compile/service.go | Link | func (s *ServiceSpec) Link(scope Scope) error {
if s.linked() {
return nil
}
if s.parentSrc != nil {
parent, err := resolveService(*s.parentSrc, scope)
if err != nil {
return compileError{
Target: s.Name,
Reason: referenceError{
Target: s.parentSrc.Name,
Line: s.parentSrc.Line,
... | go | func (s *ServiceSpec) Link(scope Scope) error {
if s.linked() {
return nil
}
if s.parentSrc != nil {
parent, err := resolveService(*s.parentSrc, scope)
if err != nil {
return compileError{
Target: s.Name,
Reason: referenceError{
Target: s.parentSrc.Name,
Line: s.parentSrc.Line,
... | [
"func",
"(",
"s",
"*",
"ServiceSpec",
")",
"Link",
"(",
"scope",
"Scope",
")",
"error",
"{",
"if",
"s",
".",
"linked",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"parentSrc",
"!=",
"nil",
"{",
"parent",
",",
"err",
":=",
... | // Link resolves any references made by the given service. | [
"Link",
"resolves",
"any",
"references",
"made",
"by",
"the",
"given",
"service",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/service.go#L116-L153 |
17,489 | thriftrw/thriftrw-go | compile/service.go | Link | func (f *FunctionSpec) Link(scope Scope) error {
if f.linked() {
return nil
}
if err := f.ArgsSpec.Link(scope); err != nil {
return compileError{Target: f.Name, Reason: err}
}
if f.ResultSpec != nil {
if err := f.ResultSpec.Link(scope); err != nil {
return compileError{Target: f.Name, Reason: err}
}
... | go | func (f *FunctionSpec) Link(scope Scope) error {
if f.linked() {
return nil
}
if err := f.ArgsSpec.Link(scope); err != nil {
return compileError{Target: f.Name, Reason: err}
}
if f.ResultSpec != nil {
if err := f.ResultSpec.Link(scope); err != nil {
return compileError{Target: f.Name, Reason: err}
}
... | [
"func",
"(",
"f",
"*",
"FunctionSpec",
")",
"Link",
"(",
"scope",
"Scope",
")",
"error",
"{",
"if",
"f",
".",
"linked",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"f",
".",
"ArgsSpec",
".",
"Link",
"(",
"scope",
")",
... | // Link resolves any references made by the given function. | [
"Link",
"resolves",
"any",
"references",
"made",
"by",
"the",
"given",
"function",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/service.go#L217-L233 |
17,490 | thriftrw/thriftrw-go | compile/service.go | CallType | func (f *FunctionSpec) CallType() wire.EnvelopeType {
if f.OneWay {
return wire.OneWay
}
return wire.Call
} | go | func (f *FunctionSpec) CallType() wire.EnvelopeType {
if f.OneWay {
return wire.OneWay
}
return wire.Call
} | [
"func",
"(",
"f",
"*",
"FunctionSpec",
")",
"CallType",
"(",
")",
"wire",
".",
"EnvelopeType",
"{",
"if",
"f",
".",
"OneWay",
"{",
"return",
"wire",
".",
"OneWay",
"\n",
"}",
"\n",
"return",
"wire",
".",
"Call",
"\n",
"}"
] | // CallType returns the envelope type that is used when making enveloped
// requests for this function. | [
"CallType",
"returns",
"the",
"envelope",
"type",
"that",
"is",
"used",
"when",
"making",
"enveloped",
"requests",
"for",
"this",
"function",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/service.go#L242-L247 |
17,491 | thriftrw/thriftrw-go | compile/service.go | Link | func (as ArgsSpec) Link(scope Scope) error {
return FieldGroup(as).Link(scope)
} | go | func (as ArgsSpec) Link(scope Scope) error {
return FieldGroup(as).Link(scope)
} | [
"func",
"(",
"as",
"ArgsSpec",
")",
"Link",
"(",
"scope",
"Scope",
")",
"error",
"{",
"return",
"FieldGroup",
"(",
"as",
")",
".",
"Link",
"(",
"scope",
")",
"\n",
"}"
] | // Link resolves references made by the ArgsSpec. | [
"Link",
"resolves",
"references",
"made",
"by",
"the",
"ArgsSpec",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/service.go#L261-L263 |
17,492 | thriftrw/thriftrw-go | compile/service.go | Link | func (rs *ResultSpec) Link(scope Scope) (err error) {
if rs.ReturnType != nil {
rs.ReturnType, err = rs.ReturnType.Link(scope)
if err != nil {
return err
}
}
if err := rs.Exceptions.Link(scope); err != nil {
return err
}
// verify that everything listed under throws is an exception.
for _, exception ... | go | func (rs *ResultSpec) Link(scope Scope) (err error) {
if rs.ReturnType != nil {
rs.ReturnType, err = rs.ReturnType.Link(scope)
if err != nil {
return err
}
}
if err := rs.Exceptions.Link(scope); err != nil {
return err
}
// verify that everything listed under throws is an exception.
for _, exception ... | [
"func",
"(",
"rs",
"*",
"ResultSpec",
")",
"Link",
"(",
"scope",
"Scope",
")",
"(",
"err",
"error",
")",
"{",
"if",
"rs",
".",
"ReturnType",
"!=",
"nil",
"{",
"rs",
".",
"ReturnType",
",",
"err",
"=",
"rs",
".",
"ReturnType",
".",
"Link",
"(",
"s... | // Link resolves any references made by the return type or exceptions in the
// ResultSpec. | [
"Link",
"resolves",
"any",
"references",
"made",
"by",
"the",
"return",
"type",
"or",
"exceptions",
"in",
"the",
"ResultSpec",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/service.go#L301-L325 |
17,493 | thriftrw/thriftrw-go | internal/semver/range.go | Contains | func (r *Range) Contains(other Version) bool {
return other.Compare(&r.Begin) >= 0 && other.Compare(&r.End) < 0
} | go | func (r *Range) Contains(other Version) bool {
return other.Compare(&r.Begin) >= 0 && other.Compare(&r.End) < 0
} | [
"func",
"(",
"r",
"*",
"Range",
")",
"Contains",
"(",
"other",
"Version",
")",
"bool",
"{",
"return",
"other",
".",
"Compare",
"(",
"&",
"r",
".",
"Begin",
")",
">=",
"0",
"&&",
"other",
".",
"Compare",
"(",
"&",
"r",
".",
"End",
")",
"<",
"0",... | // Contains returns true if the given semver version number is in this range. | [
"Contains",
"returns",
"true",
"if",
"the",
"given",
"semver",
"version",
"number",
"is",
"in",
"this",
"range",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/semver/range.go#L30-L32 |
17,494 | thriftrw/thriftrw-go | gen/zap.go | zapMarshalerPtr | func (z *zapGenerator) zapMarshalerPtr(g Generator, spec compile.TypeSpec, fieldValue string) (string, error) {
if isPrimitiveType(spec) {
fieldValue = "*" + fieldValue
}
return z.zapMarshaler(g, spec, fieldValue)
} | go | func (z *zapGenerator) zapMarshalerPtr(g Generator, spec compile.TypeSpec, fieldValue string) (string, error) {
if isPrimitiveType(spec) {
fieldValue = "*" + fieldValue
}
return z.zapMarshaler(g, spec, fieldValue)
} | [
"func",
"(",
"z",
"*",
"zapGenerator",
")",
"zapMarshalerPtr",
"(",
"g",
"Generator",
",",
"spec",
"compile",
".",
"TypeSpec",
",",
"fieldValue",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"isPrimitiveType",
"(",
"spec",
")",
"{",
"field... | // zapMarshalerPtr will dereference the pointer and call zapMarshal on it. | [
"zapMarshalerPtr",
"will",
"dereference",
"the",
"pointer",
"and",
"call",
"zapMarshal",
"on",
"it",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/zap.go#L134-L139 |
17,495 | thriftrw/thriftrw-go | compile/compiler.go | Compile | func Compile(path string, opts ...Option) (*Module, error) {
c := newCompiler()
for _, opt := range opts {
opt(&c)
}
m, err := c.load(path)
if err != nil {
return nil, err
}
err = m.Walk(func(m *Module) error {
if err := c.link(m); err != nil {
return compileError{
Target: m.ThriftPath,
Reason... | go | func Compile(path string, opts ...Option) (*Module, error) {
c := newCompiler()
for _, opt := range opts {
opt(&c)
}
m, err := c.load(path)
if err != nil {
return nil, err
}
err = m.Walk(func(m *Module) error {
if err := c.link(m); err != nil {
return compileError{
Target: m.ThriftPath,
Reason... | [
"func",
"Compile",
"(",
"path",
"string",
",",
"opts",
"...",
"Option",
")",
"(",
"*",
"Module",
",",
"error",
")",
"{",
"c",
":=",
"newCompiler",
"(",
")",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"&",
"c",
")",
"\... | // Compile parses and compiles the Thrift file at the given path and any other
// Thrift file it includes. | [
"Compile",
"parses",
"and",
"compiles",
"the",
"Thrift",
"file",
"at",
"the",
"given",
"path",
"and",
"any",
"other",
"Thrift",
"file",
"it",
"includes",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/compiler.go#L32-L53 |
17,496 | thriftrw/thriftrw-go | compile/compiler.go | load | func (c compiler) load(p string) (*Module, error) {
p, err := c.fs.Abs(p)
if err != nil {
return nil, err
}
if m, ok := c.Modules[p]; ok {
// Already loaded.
return m, nil
}
s, err := c.fs.Read(p)
if err != nil {
return nil, fileReadError{Path: p, Reason: err}
}
prog, err := idl.Parse(s)
if err != ... | go | func (c compiler) load(p string) (*Module, error) {
p, err := c.fs.Abs(p)
if err != nil {
return nil, err
}
if m, ok := c.Modules[p]; ok {
// Already loaded.
return m, nil
}
s, err := c.fs.Read(p)
if err != nil {
return nil, fileReadError{Path: p, Reason: err}
}
prog, err := idl.Parse(s)
if err != ... | [
"func",
"(",
"c",
"compiler",
")",
"load",
"(",
"p",
"string",
")",
"(",
"*",
"Module",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"c",
".",
"fs",
".",
"Abs",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // load populates the compiler with information from the given Thrift file.
//
// The types aren't actually compiled in this step. | [
"load",
"populates",
"the",
"compiler",
"with",
"information",
"from",
"the",
"given",
"Thrift",
"file",
".",
"The",
"types",
"aren",
"t",
"actually",
"compiled",
"in",
"this",
"step",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/compiler.go#L119-L158 |
17,497 | thriftrw/thriftrw-go | compile/compiler.go | include | func (c compiler) include(m *Module, include *ast.Include) (*IncludedModule, error) {
if len(include.Name) > 0 {
// TODO(abg): Add support for include-as flag somewhere.
return nil, includeError{
Include: include,
Reason: includeAsDisabledError{},
}
}
ipath := filepath.Join(filepath.Dir(m.ThriftPath), ... | go | func (c compiler) include(m *Module, include *ast.Include) (*IncludedModule, error) {
if len(include.Name) > 0 {
// TODO(abg): Add support for include-as flag somewhere.
return nil, includeError{
Include: include,
Reason: includeAsDisabledError{},
}
}
ipath := filepath.Join(filepath.Dir(m.ThriftPath), ... | [
"func",
"(",
"c",
"compiler",
")",
"include",
"(",
"m",
"*",
"Module",
",",
"include",
"*",
"ast",
".",
"Include",
")",
"(",
"*",
"IncludedModule",
",",
"error",
")",
"{",
"if",
"len",
"(",
"include",
".",
"Name",
")",
">",
"0",
"{",
"// TODO(abg):... | // include loads the file specified by the given include in the given Module.
//
// The path to the file is relative to the ThriftPath of the given module. | [
"include",
"loads",
"the",
"file",
"specified",
"by",
"the",
"given",
"include",
"in",
"the",
"given",
"Module",
".",
"The",
"path",
"to",
"the",
"file",
"is",
"relative",
"to",
"the",
"ThriftPath",
"of",
"the",
"given",
"module",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/compiler.go#L245-L261 |
17,498 | thriftrw/thriftrw-go | gen/list.go | zapMarshaler | func (l *listGenerator) zapMarshaler(
g Generator,
spec *compile.ListSpec,
fieldValue string,
) (string, error) {
name := zapperName(g, spec)
if err := g.EnsureDeclared(
`
<$zapcore := import "go.uber.org/zap/zapcore">
type <.Name> <typeReference .Type>
<$l := newVar "l">
<$v := newVar "v">
<$enc... | go | func (l *listGenerator) zapMarshaler(
g Generator,
spec *compile.ListSpec,
fieldValue string,
) (string, error) {
name := zapperName(g, spec)
if err := g.EnsureDeclared(
`
<$zapcore := import "go.uber.org/zap/zapcore">
type <.Name> <typeReference .Type>
<$l := newVar "l">
<$v := newVar "v">
<$enc... | [
"func",
"(",
"l",
"*",
"listGenerator",
")",
"zapMarshaler",
"(",
"g",
"Generator",
",",
"spec",
"*",
"compile",
".",
"ListSpec",
",",
"fieldValue",
"string",
",",
")",
"(",
"string",
",",
"error",
")",
"{",
"name",
":=",
"zapperName",
"(",
"g",
",",
... | // Slices are logged as JSON arrays. | [
"Slices",
"are",
"logged",
"as",
"JSON",
"arrays",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/list.go#L186-L221 |
17,499 | thriftrw/thriftrw-go | plugin/api/servicegenerator_handler.go | Handle | func (h ServiceGeneratorHandler) Handle(name string, reqValue wire.Value) (wire.Value, error) {
switch name {
case "generate":
var args ServiceGenerator_Generate_Args
if err := args.FromWire(reqValue); err != nil {
return wire.Value{}, err
}
result, err := ServiceGenerator_Generate_Helper.WrapResponse(
... | go | func (h ServiceGeneratorHandler) Handle(name string, reqValue wire.Value) (wire.Value, error) {
switch name {
case "generate":
var args ServiceGenerator_Generate_Args
if err := args.FromWire(reqValue); err != nil {
return wire.Value{}, err
}
result, err := ServiceGenerator_Generate_Helper.WrapResponse(
... | [
"func",
"(",
"h",
"ServiceGeneratorHandler",
")",
"Handle",
"(",
"name",
"string",
",",
"reqValue",
"wire",
".",
"Value",
")",
"(",
"wire",
".",
"Value",
",",
"error",
")",
"{",
"switch",
"name",
"{",
"case",
"\"",
"\"",
":",
"var",
"args",
"ServiceGen... | // Handle receives and handles a request for the ServiceGenerator service. | [
"Handle",
"receives",
"and",
"handles",
"a",
"request",
"for",
"the",
"ServiceGenerator",
"service",
"."
] | a9a6ad793beab07cc3385954d2e8af8abfaa83e2 | https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/plugin/api/servicegenerator_handler.go#L44-L68 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.