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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,300 | cenkalti/backoff | context.go | WithContext | func WithContext(b BackOff, ctx context.Context) BackOffContext {
if ctx == nil {
panic("nil context")
}
if b, ok := b.(*backOffContext); ok {
return &backOffContext{
BackOff: b.BackOff,
ctx: ctx,
}
}
return &backOffContext{
BackOff: b,
ctx: ctx,
}
} | go | func WithContext(b BackOff, ctx context.Context) BackOffContext {
if ctx == nil {
panic("nil context")
}
if b, ok := b.(*backOffContext); ok {
return &backOffContext{
BackOff: b.BackOff,
ctx: ctx,
}
}
return &backOffContext{
BackOff: b,
ctx: ctx,
}
} | [
"func",
"WithContext",
"(",
"b",
"BackOff",
",",
"ctx",
"context",
".",
"Context",
")",
"BackOffContext",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"b",
",",
"ok",
":=",
"b",
".",
"(",
"*",
"backO... | // WithContext returns a BackOffContext with context ctx
//
// ctx must not be nil | [
"WithContext",
"returns",
"a",
"BackOffContext",
"with",
"context",
"ctx",
"ctx",
"must",
"not",
"be",
"nil"
] | 1e4cf3da559842a91afcb6ea6141451e6c30c618 | https://github.com/cenkalti/backoff/blob/1e4cf3da559842a91afcb6ea6141451e6c30c618/context.go#L23-L39 |
150,301 | sideshow/apns2 | notification.go | MarshalJSON | func (n *Notification) MarshalJSON() ([]byte, error) {
switch n.Payload.(type) {
case string:
return []byte(n.Payload.(string)), nil
case []byte:
return n.Payload.([]byte), nil
default:
return json.Marshal(n.Payload)
}
} | go | func (n *Notification) MarshalJSON() ([]byte, error) {
switch n.Payload.(type) {
case string:
return []byte(n.Payload.(string)), nil
case []byte:
return n.Payload.([]byte), nil
default:
return json.Marshal(n.Payload)
}
} | [
"func",
"(",
"n",
"*",
"Notification",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"n",
".",
"Payload",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"return",
"[",
"]",
"byte",
"(",
"n",
".",
"Pa... | // MarshalJSON converts the notification payload to JSON. | [
"MarshalJSON",
"converts",
"the",
"notification",
"payload",
"to",
"JSON",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/notification.go#L71-L80 |
150,302 | sideshow/apns2 | token/token.go | GenerateIfExpired | func (t *Token) GenerateIfExpired() {
t.Lock()
defer t.Unlock()
if t.Expired() {
t.Generate()
}
} | go | func (t *Token) GenerateIfExpired() {
t.Lock()
defer t.Unlock()
if t.Expired() {
t.Generate()
}
} | [
"func",
"(",
"t",
"*",
"Token",
")",
"GenerateIfExpired",
"(",
")",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"Unlock",
"(",
")",
"\n",
"if",
"t",
".",
"Expired",
"(",
")",
"{",
"t",
".",
"Generate",
"(",
")",
"\n",
"}",
"\n",... | // GenerateIfExpired checks to see if the token is about to expire and
// generates a new token. | [
"GenerateIfExpired",
"checks",
"to",
"see",
"if",
"the",
"token",
"is",
"about",
"to",
"expire",
"and",
"generates",
"a",
"new",
"token",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/token/token.go#L71-L77 |
150,303 | sideshow/apns2 | token/token.go | Expired | func (t *Token) Expired() bool {
return time.Now().Unix() >= (t.IssuedAt + TokenTimeout)
} | go | func (t *Token) Expired() bool {
return time.Now().Unix() >= (t.IssuedAt + TokenTimeout)
} | [
"func",
"(",
"t",
"*",
"Token",
")",
"Expired",
"(",
")",
"bool",
"{",
"return",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
">=",
"(",
"t",
".",
"IssuedAt",
"+",
"TokenTimeout",
")",
"\n",
"}"
] | // Expired checks to see if the token has expired. | [
"Expired",
"checks",
"to",
"see",
"if",
"the",
"token",
"has",
"expired",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/token/token.go#L80-L82 |
150,304 | sideshow/apns2 | token/token.go | Generate | func (t *Token) Generate() (bool, error) {
if t.AuthKey == nil {
return false, ErrAuthKeyNil
}
issuedAt := time.Now().Unix()
jwtToken := &jwt.Token{
Header: map[string]interface{}{
"alg": "ES256",
"kid": t.KeyID,
},
Claims: jwt.MapClaims{
"iss": t.TeamID,
"iat": issuedAt,
},
Method: jwt.Sign... | go | func (t *Token) Generate() (bool, error) {
if t.AuthKey == nil {
return false, ErrAuthKeyNil
}
issuedAt := time.Now().Unix()
jwtToken := &jwt.Token{
Header: map[string]interface{}{
"alg": "ES256",
"kid": t.KeyID,
},
Claims: jwt.MapClaims{
"iss": t.TeamID,
"iat": issuedAt,
},
Method: jwt.Sign... | [
"func",
"(",
"t",
"*",
"Token",
")",
"Generate",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"t",
".",
"AuthKey",
"==",
"nil",
"{",
"return",
"false",
",",
"ErrAuthKeyNil",
"\n",
"}",
"\n",
"issuedAt",
":=",
"time",
".",
"Now",
"(",
")",... | // Generate creates a new token. | [
"Generate",
"creates",
"a",
"new",
"token",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/token/token.go#L85-L108 |
150,305 | sideshow/apns2 | client.go | Push | func (c *Client) Push(n *Notification) (*Response, error) {
return c.PushWithContext(nil, n)
} | go | func (c *Client) Push(n *Notification) (*Response, error) {
return c.PushWithContext(nil, n)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Push",
"(",
"n",
"*",
"Notification",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"PushWithContext",
"(",
"nil",
",",
"n",
")",
"\n",
"}"
] | // Push sends a Notification to the APNs gateway. If the underlying http.Client
// is not currently connected, this method will attempt to reconnect
// transparently before sending the notification. It will return a Response
// indicating whether the notification was accepted or rejected by the APNs
// gateway, or an e... | [
"Push",
"sends",
"a",
"Notification",
"to",
"the",
"APNs",
"gateway",
".",
"If",
"the",
"underlying",
"http",
".",
"Client",
"is",
"not",
"currently",
"connected",
"this",
"method",
"will",
"attempt",
"to",
"reconnect",
"transparently",
"before",
"sending",
"t... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client.go#L137-L139 |
150,306 | sideshow/apns2 | client.go | PushWithContext | func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error) {
payload, err := json.Marshal(n)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%v/3/device/%v", c.Host, n.DeviceToken)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if c.Token != nil {
c.setTokenHea... | go | func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error) {
payload, err := json.Marshal(n)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%v/3/device/%v", c.Host, n.DeviceToken)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if c.Token != nil {
c.setTokenHea... | [
"func",
"(",
"c",
"*",
"Client",
")",
"PushWithContext",
"(",
"ctx",
"Context",
",",
"n",
"*",
"Notification",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"payload",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"n",
")",
"\n",
"if",
"err",... | // PushWithContext sends a Notification to the APNs gateway. Context carries a
// deadline and a cancellation signal and allows you to close long running
// requests when the context timeout is exceeded. Context can be nil, for
// backwards compatibility.
//
// If the underlying http.Client is not currently connected, ... | [
"PushWithContext",
"sends",
"a",
"Notification",
"to",
"the",
"APNs",
"gateway",
".",
"Context",
"carries",
"a",
"deadline",
"and",
"a",
"cancellation",
"signal",
"and",
"allows",
"you",
"to",
"close",
"long",
"running",
"requests",
"when",
"the",
"context",
"... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client.go#L150-L180 |
150,307 | sideshow/apns2 | client_manager.go | NewClientManager | func NewClientManager() *ClientManager {
manager := &ClientManager{
MaxSize: 64,
MaxAge: 10 * time.Minute,
Factory: NewClient,
}
manager.initInternals()
return manager
} | go | func NewClientManager() *ClientManager {
manager := &ClientManager{
MaxSize: 64,
MaxAge: 10 * time.Minute,
Factory: NewClient,
}
manager.initInternals()
return manager
} | [
"func",
"NewClientManager",
"(",
")",
"*",
"ClientManager",
"{",
"manager",
":=",
"&",
"ClientManager",
"{",
"MaxSize",
":",
"64",
",",
"MaxAge",
":",
"10",
"*",
"time",
".",
"Minute",
",",
"Factory",
":",
"NewClient",
",",
"}",
"\n\n",
"manager",
".",
... | // NewClientManager returns a new ClientManager for prolonged, concurrent usage
// of multiple APNs clients. ClientManager is flexible enough to work best for
// your use case. When a client is not found in the manager, Get will return
// the result of calling Factory, which can be a Client or nil.
//
// Having multipl... | [
"NewClientManager",
"returns",
"a",
"new",
"ClientManager",
"for",
"prolonged",
"concurrent",
"usage",
"of",
"multiple",
"APNs",
"clients",
".",
"ClientManager",
"is",
"flexible",
"enough",
"to",
"work",
"best",
"for",
"your",
"use",
"case",
".",
"When",
"a",
... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L49-L59 |
150,308 | sideshow/apns2 | client_manager.go | Add | func (m *ClientManager) Add(client *Client) {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(client.Certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
item.client = client
item.lastUsed = now
m.ll.MoveToFront(ele)
return
}
ele := m.ll... | go | func (m *ClientManager) Add(client *Client) {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(client.Certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
item.client = client
item.lastUsed = now
m.ll.MoveToFront(ele)
return
}
ele := m.ll... | [
"func",
"(",
"m",
"*",
"ClientManager",
")",
"Add",
"(",
"client",
"*",
"Client",
")",
"{",
"m",
".",
"initInternals",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"key",... | // Add adds a Client to the manager. You can use this to individually configure
// Clients in the manager. | [
"Add",
"adds",
"a",
"Client",
"to",
"the",
"manager",
".",
"You",
"can",
"use",
"this",
"to",
"individually",
"configure",
"Clients",
"in",
"the",
"manager",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L63-L84 |
150,309 | sideshow/apns2 | client_manager.go | Get | func (m *ClientManager) Get(certificate tls.Certificate) *Client {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
if m.MaxAge != 0 && item.lastUsed.Before(now.Add(-m.MaxAge)) {
c := m.Fact... | go | func (m *ClientManager) Get(certificate tls.Certificate) *Client {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
if m.MaxAge != 0 && item.lastUsed.Before(now.Add(-m.MaxAge)) {
c := m.Fact... | [
"func",
"(",
"m",
"*",
"ClientManager",
")",
"Get",
"(",
"certificate",
"tls",
".",
"Certificate",
")",
"*",
"Client",
"{",
"m",
".",
"initInternals",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unl... | // Get gets a Client from the manager. If a Client is not found in the manager
// or if a Client has remained in the manager longer than MaxAge, Get will call
// the ClientManager's Factory function, store the result in the manager if
// non-nil, and return it. | [
"Get",
"gets",
"a",
"Client",
"from",
"the",
"manager",
".",
"If",
"a",
"Client",
"is",
"not",
"found",
"in",
"the",
"manager",
"or",
"if",
"a",
"Client",
"has",
"remained",
"in",
"the",
"manager",
"longer",
"than",
"MaxAge",
"Get",
"will",
"call",
"th... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L90-L119 |
150,310 | sideshow/apns2 | client_manager.go | Len | func (m *ClientManager) Len() int {
if m.cache == nil {
return 0
}
m.mu.Lock()
defer m.mu.Unlock()
return m.ll.Len()
} | go | func (m *ClientManager) Len() int {
if m.cache == nil {
return 0
}
m.mu.Lock()
defer m.mu.Unlock()
return m.ll.Len()
} | [
"func",
"(",
"m",
"*",
"ClientManager",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"m",
".",
"cache",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
"... | // Len returns the current size of the ClientManager. | [
"Len",
"returns",
"the",
"current",
"size",
"of",
"the",
"ClientManager",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L122-L129 |
150,311 | google/zoekt | gitindex/submodule.go | ParseGitModules | func ParseGitModules(content []byte) (map[string]*SubmoduleEntry, error) {
dec := config.NewDecoder(bytes.NewBuffer(content))
cfg := &config.Config{}
if err := dec.Decode(cfg); err != nil {
return nil, err
}
result := map[string]*SubmoduleEntry{}
for _, s := range cfg.Sections {
if s.Name != "submodule" {
... | go | func ParseGitModules(content []byte) (map[string]*SubmoduleEntry, error) {
dec := config.NewDecoder(bytes.NewBuffer(content))
cfg := &config.Config{}
if err := dec.Decode(cfg); err != nil {
return nil, err
}
result := map[string]*SubmoduleEntry{}
for _, s := range cfg.Sections {
if s.Name != "submodule" {
... | [
"func",
"ParseGitModules",
"(",
"content",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"SubmoduleEntry",
",",
"error",
")",
"{",
"dec",
":=",
"config",
".",
"NewDecoder",
"(",
"bytes",
".",
"NewBuffer",
"(",
"content",
")",
")",
"\n",
... | // ParseGitModules parses the contents of a .gitmodules file. | [
"ParseGitModules",
"parses",
"the",
"contents",
"of",
"a",
".",
"gitmodules",
"file",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/submodule.go#L31-L64 |
150,312 | google/zoekt | bits.go | caseFoldingEqualsRunes | func caseFoldingEqualsRunes(lower, mixed []byte) (int, bool) {
matchTotal := 0
for len(lower) > 0 && len(mixed) > 0 {
lr, lsz := utf8.DecodeRune(lower)
lower = lower[lsz:]
mr, msz := utf8.DecodeRune(mixed)
mixed = mixed[msz:]
matchTotal += msz
if lr != unicode.ToLower(mr) {
return 0, false
}
}
r... | go | func caseFoldingEqualsRunes(lower, mixed []byte) (int, bool) {
matchTotal := 0
for len(lower) > 0 && len(mixed) > 0 {
lr, lsz := utf8.DecodeRune(lower)
lower = lower[lsz:]
mr, msz := utf8.DecodeRune(mixed)
mixed = mixed[msz:]
matchTotal += msz
if lr != unicode.ToLower(mr) {
return 0, false
}
}
r... | [
"func",
"caseFoldingEqualsRunes",
"(",
"lower",
",",
"mixed",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"bool",
")",
"{",
"matchTotal",
":=",
"0",
"\n",
"for",
"len",
"(",
"lower",
")",
">",
"0",
"&&",
"len",
"(",
"mixed",
")",
">",
"0",
"{",
"lr",... | // compare 'lower' and 'mixed', where lower is the needle. 'mixed' may
// be larger than 'lower'. Returns whether there was a match, and if
// yes, the byte size of the match. | [
"compare",
"lower",
"and",
"mixed",
"where",
"lower",
"is",
"the",
"needle",
".",
"mixed",
"may",
"be",
"larger",
"than",
"lower",
".",
"Returns",
"whether",
"there",
"was",
"a",
"match",
"and",
"if",
"yes",
"the",
"byte",
"size",
"of",
"the",
"match",
... | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/bits.go#L59-L75 |
150,313 | google/zoekt | query/parse.go | parseStringLiteral | func parseStringLiteral(in []byte) (lit []byte, n int, err error) {
left := in[1:]
found := false
loop:
for len(left) > 0 {
c := left[0]
left = left[1:]
switch c {
case '"':
found = true
break loop
case '\\':
// TODO - other escape sequences.
if len(left) == 0 {
return nil, 0, fmt.Errorf("... | go | func parseStringLiteral(in []byte) (lit []byte, n int, err error) {
left := in[1:]
found := false
loop:
for len(left) > 0 {
c := left[0]
left = left[1:]
switch c {
case '"':
found = true
break loop
case '\\':
// TODO - other escape sequences.
if len(left) == 0 {
return nil, 0, fmt.Errorf("... | [
"func",
"parseStringLiteral",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"lit",
"[",
"]",
"byte",
",",
"n",
"int",
",",
"err",
"error",
")",
"{",
"left",
":=",
"in",
"[",
"1",
":",
"]",
"\n",
"found",
":=",
"false",
"\n\n",
"loop",
":",
"for",
"len... | // parseStringLiteral parses a string literal, consumes the starting
// quote too. | [
"parseStringLiteral",
"parses",
"a",
"string",
"literal",
"consumes",
"the",
"starting",
"quote",
"too",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L37-L66 |
150,314 | google/zoekt | query/parse.go | Parse | func Parse(qStr string) (Q, error) {
b := []byte(qStr)
qs, _, err := parseExprList(b)
if err != nil {
return nil, err
}
q, err := parseOperators(qs)
if err != nil {
return nil, err
}
return Simplify(q), nil
} | go | func Parse(qStr string) (Q, error) {
b := []byte(qStr)
qs, _, err := parseExprList(b)
if err != nil {
return nil, err
}
q, err := parseOperators(qs)
if err != nil {
return nil, err
}
return Simplify(q), nil
} | [
"func",
"Parse",
"(",
"qStr",
"string",
")",
"(",
"Q",
",",
"error",
")",
"{",
"b",
":=",
"[",
"]",
"byte",
"(",
"qStr",
")",
"\n\n",
"qs",
",",
"_",
",",
"err",
":=",
"parseExprList",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // Parse parses a string into a query. | [
"Parse",
"parses",
"a",
"string",
"into",
"a",
"query",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L81-L95 |
150,315 | google/zoekt | query/parse.go | regexpQuery | func regexpQuery(text string, content, file bool) (Q, error) {
var expr Q
r, err := syntax.Parse(text, syntax.ClassNL|syntax.PerlX|syntax.UnicodeGroups)
if err != nil {
return nil, err
}
if r.Op == syntax.OpLiteral {
expr = &Substring{
Pattern: string(r.Rune),
FileName: file,
Content: content,
}... | go | func regexpQuery(text string, content, file bool) (Q, error) {
var expr Q
r, err := syntax.Parse(text, syntax.ClassNL|syntax.PerlX|syntax.UnicodeGroups)
if err != nil {
return nil, err
}
if r.Op == syntax.OpLiteral {
expr = &Substring{
Pattern: string(r.Rune),
FileName: file,
Content: content,
}... | [
"func",
"regexpQuery",
"(",
"text",
"string",
",",
"content",
",",
"file",
"bool",
")",
"(",
"Q",
",",
"error",
")",
"{",
"var",
"expr",
"Q",
"\n\n",
"r",
",",
"err",
":=",
"syntax",
".",
"Parse",
"(",
"text",
",",
"syntax",
".",
"ClassNL",
"|",
... | // regexpQuery parses an atom into either a regular expression, or a
// simple substring atom. | [
"regexpQuery",
"parses",
"an",
"atom",
"into",
"either",
"a",
"regular",
"expression",
"or",
"a",
"simple",
"substring",
"atom",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L197-L220 |
150,316 | google/zoekt | query/parse.go | parseOperators | func parseOperators(in []Q) (Q, error) {
top := &Or{}
cur := &And{}
seenOr := false
for _, q := range in {
if _, ok := q.(*orOperator); ok {
seenOr = true
if len(cur.Children) == 0 {
return nil, fmt.Errorf("query: OR operator should have operand")
}
top.Children = append(top.Children, cur)
cur... | go | func parseOperators(in []Q) (Q, error) {
top := &Or{}
cur := &And{}
seenOr := false
for _, q := range in {
if _, ok := q.(*orOperator); ok {
seenOr = true
if len(cur.Children) == 0 {
return nil, fmt.Errorf("query: OR operator should have operand")
}
top.Children = append(top.Children, cur)
cur... | [
"func",
"parseOperators",
"(",
"in",
"[",
"]",
"Q",
")",
"(",
"Q",
",",
"error",
")",
"{",
"top",
":=",
"&",
"Or",
"{",
"}",
"\n",
"cur",
":=",
"&",
"And",
"{",
"}",
"\n\n",
"seenOr",
":=",
"false",
"\n",
"for",
"_",
",",
"q",
":=",
"range",
... | // parseOperators interprets the orOperator in a list of queries. | [
"parseOperators",
"interprets",
"the",
"orOperator",
"in",
"a",
"list",
"of",
"queries",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L223-L246 |
150,317 | google/zoekt | query/parse.go | parseExprList | func parseExprList(in []byte) ([]Q, int, error) {
b := in[:]
var qs []Q
for len(b) > 0 {
for len(b) > 0 && isSpace(b[0]) {
b = b[1:]
}
tok, _ := nextToken(b)
if tok != nil && tok.Type == tokParenClose {
break
} else if tok != nil && tok.Type == tokOr {
qs = append(qs, &orOperator{})
b = b[len(t... | go | func parseExprList(in []byte) ([]Q, int, error) {
b := in[:]
var qs []Q
for len(b) > 0 {
for len(b) > 0 && isSpace(b[0]) {
b = b[1:]
}
tok, _ := nextToken(b)
if tok != nil && tok.Type == tokParenClose {
break
} else if tok != nil && tok.Type == tokOr {
qs = append(qs, &orOperator{})
b = b[len(t... | [
"func",
"parseExprList",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"Q",
",",
"int",
",",
"error",
")",
"{",
"b",
":=",
"in",
"[",
":",
"]",
"\n",
"var",
"qs",
"[",
"]",
"Q",
"\n",
"for",
"len",
"(",
"b",
")",
">",
"0",
"{",
"for",
... | // parseExprList parses a list of query expressions. It is the
// workhorse of the Parse function. | [
"parseExprList",
"parses",
"a",
"list",
"of",
"query",
"expressions",
".",
"It",
"is",
"the",
"workhorse",
"of",
"the",
"Parse",
"function",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L250-L295 |
150,318 | google/zoekt | query/parse.go | nextToken | func nextToken(in []byte) (*token, error) {
left := in[:]
parenCount := 0
var cur token
if len(left) == 0 {
return nil, nil
}
if left[0] == '-' {
return &token{
Type: tokNegate,
Text: []byte{'-'},
Input: in[:1],
}, nil
}
foundSpace := false
loop:
for len(left) > 0 {
c := left[0]
switch ... | go | func nextToken(in []byte) (*token, error) {
left := in[:]
parenCount := 0
var cur token
if len(left) == 0 {
return nil, nil
}
if left[0] == '-' {
return &token{
Type: tokNegate,
Text: []byte{'-'},
Input: in[:1],
}, nil
}
foundSpace := false
loop:
for len(left) > 0 {
c := left[0]
switch ... | [
"func",
"nextToken",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"*",
"token",
",",
"error",
")",
"{",
"left",
":=",
"in",
"[",
":",
"]",
"\n",
"parenCount",
":=",
"0",
"\n",
"var",
"cur",
"token",
"\n",
"if",
"len",
"(",
"left",
")",
"==",
"0",
"... | // nextToken returns the next token from the given input. | [
"nextToken",
"returns",
"the",
"next",
"token",
"from",
"the",
"given",
"input",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L393-L471 |
150,319 | google/zoekt | gitindex/repocache.go | NewRepoCache | func NewRepoCache(dir string) *RepoCache {
return &RepoCache{
baseDir: dir,
repos: make(map[string]*git.Repository),
}
} | go | func NewRepoCache(dir string) *RepoCache {
return &RepoCache{
baseDir: dir,
repos: make(map[string]*git.Repository),
}
} | [
"func",
"NewRepoCache",
"(",
"dir",
"string",
")",
"*",
"RepoCache",
"{",
"return",
"&",
"RepoCache",
"{",
"baseDir",
":",
"dir",
",",
"repos",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"git",
".",
"Repository",
")",
",",
"}",
"\n",
"}"
] | // NewRepoCache creates a new RepoCache rooted at the given directory. | [
"NewRepoCache",
"creates",
"a",
"new",
"RepoCache",
"rooted",
"at",
"the",
"given",
"directory",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L37-L42 |
150,320 | google/zoekt | gitindex/repocache.go | Path | func Path(baseDir string, name string) string {
key := repoKeyStr(name)
return filepath.Join(baseDir, key)
} | go | func Path(baseDir string, name string) string {
key := repoKeyStr(name)
return filepath.Join(baseDir, key)
} | [
"func",
"Path",
"(",
"baseDir",
"string",
",",
"name",
"string",
")",
"string",
"{",
"key",
":=",
"repoKeyStr",
"(",
"name",
")",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"baseDir",
",",
"key",
")",
"\n",
"}"
] | // Path returns the absolute path of the bare repository. | [
"Path",
"returns",
"the",
"absolute",
"path",
"of",
"the",
"bare",
"repository",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L56-L59 |
150,321 | google/zoekt | gitindex/repocache.go | Open | func (rc *RepoCache) Open(u *url.URL) (*git.Repository, error) {
dir := rc.Path(u)
rc.reposMu.Lock()
defer rc.reposMu.Unlock()
key := repoKey(u)
r := rc.repos[key]
if r != nil {
return r, nil
}
repo, err := git.PlainOpen(dir)
if err == nil {
rc.repos[key] = repo
}
return repo, err
} | go | func (rc *RepoCache) Open(u *url.URL) (*git.Repository, error) {
dir := rc.Path(u)
rc.reposMu.Lock()
defer rc.reposMu.Unlock()
key := repoKey(u)
r := rc.repos[key]
if r != nil {
return r, nil
}
repo, err := git.PlainOpen(dir)
if err == nil {
rc.repos[key] = repo
}
return repo, err
} | [
"func",
"(",
"rc",
"*",
"RepoCache",
")",
"Open",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"(",
"*",
"git",
".",
"Repository",
",",
"error",
")",
"{",
"dir",
":=",
"rc",
".",
"Path",
"(",
"u",
")",
"\n",
"rc",
".",
"reposMu",
".",
"Lock",
"(",
... | // Open opens a git repository. The cache retains a pointer to the
// repository. | [
"Open",
"opens",
"a",
"git",
"repository",
".",
"The",
"cache",
"retains",
"a",
"pointer",
"to",
"the",
"repository",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L68-L84 |
150,322 | google/zoekt | gitindex/repocache.go | ListRepos | func ListRepos(baseDir string, u *url.URL) ([]string, error) {
key := filepath.Join(u.Host, u.Path)
var paths []string
walk := func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
return nil
}
if strings.HasSuffix(path, ".git") && !strings.HasSuffix(... | go | func ListRepos(baseDir string, u *url.URL) ([]string, error) {
key := filepath.Join(u.Host, u.Path)
var paths []string
walk := func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
return nil
}
if strings.HasSuffix(path, ".git") && !strings.HasSuffix(... | [
"func",
"ListRepos",
"(",
"baseDir",
"string",
",",
"u",
"*",
"url",
".",
"URL",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"key",
":=",
"filepath",
".",
"Join",
"(",
"u",
".",
"Host",
",",
"u",
".",
"Path",
")",
"\n\n",
"var",
"path... | // ListRepos returns paths to repos on disk that start with the given
// URL prefix. The paths are relative to baseDir, and typically
// include a ".git" suffix. | [
"ListRepos",
"returns",
"paths",
"to",
"repos",
"on",
"disk",
"that",
"start",
"with",
"the",
"given",
"URL",
"prefix",
".",
"The",
"paths",
"are",
"relative",
"to",
"baseDir",
"and",
"typically",
"include",
"a",
".",
"git",
"suffix",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L89-L117 |
150,323 | google/zoekt | cmd/zoekt-mirror-gitiles/cgit.go | getCGitRepos | func getCGitRepos(u *url.URL, filter func(string) bool) (map[string]*crawlTarget, error) {
c, err := normalizedGet(u)
if err != nil {
return nil, err
}
pages := map[string]*crawlTarget{}
for _, m := range cgitRepoEntryRE.FindAllSubmatch(c, -1) {
nm := strings.TrimSuffix(string(m[1]), ".git")
if !filter(nm)... | go | func getCGitRepos(u *url.URL, filter func(string) bool) (map[string]*crawlTarget, error) {
c, err := normalizedGet(u)
if err != nil {
return nil, err
}
pages := map[string]*crawlTarget{}
for _, m := range cgitRepoEntryRE.FindAllSubmatch(c, -1) {
nm := strings.TrimSuffix(string(m[1]), ".git")
if !filter(nm)... | [
"func",
"getCGitRepos",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"filter",
"func",
"(",
"string",
")",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"crawlTarget",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"normalizedGet",
"(",
"u",
")",
"... | // getCGitRepos finds repo names from the CGit index page hosted at
// URL `u`. | [
"getCGitRepos",
"finds",
"repo",
"names",
"from",
"the",
"CGit",
"index",
"page",
"hosted",
"at",
"URL",
"u",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-mirror-gitiles/cgit.go#L54-L93 |
150,324 | google/zoekt | indexfile_linux.go | NewIndexFile | func NewIndexFile(f *os.File) (IndexFile, error) {
defer f.Close()
fi, err := f.Stat()
if err != nil {
return nil, err
}
sz := fi.Size()
if sz >= maxUInt32 {
return nil, fmt.Errorf("file %s too large: %d", f.Name(), sz)
}
r := &mmapedIndexFile{
name: f.Name(),
size: uint32(sz),
}
rounded := (r.size... | go | func NewIndexFile(f *os.File) (IndexFile, error) {
defer f.Close()
fi, err := f.Stat()
if err != nil {
return nil, err
}
sz := fi.Size()
if sz >= maxUInt32 {
return nil, fmt.Errorf("file %s too large: %d", f.Name(), sz)
}
r := &mmapedIndexFile{
name: f.Name(),
size: uint32(sz),
}
rounded := (r.size... | [
"func",
"NewIndexFile",
"(",
"f",
"*",
"os",
".",
"File",
")",
"(",
"IndexFile",
",",
"error",
")",
"{",
"defer",
"f",
".",
"Close",
"(",
")",
"\n\n",
"fi",
",",
"err",
":=",
"f",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // NewIndexFile returns a new index file. The index file takes
// ownership of the passed in file, and may close it. | [
"NewIndexFile",
"returns",
"a",
"new",
"index",
"file",
".",
"The",
"index",
"file",
"takes",
"ownership",
"of",
"the",
"passed",
"in",
"file",
"and",
"may",
"close",
"it",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexfile_linux.go#L50-L74 |
150,325 | google/zoekt | gitindex/filter.go | Include | func (f *Filter) Include(name string) bool {
if f.inc != nil {
if !f.inc.MatchString(name) {
return false
}
}
if f.exc != nil {
if f.exc.MatchString(name) {
return false
}
}
return true
} | go | func (f *Filter) Include(name string) bool {
if f.inc != nil {
if !f.inc.MatchString(name) {
return false
}
}
if f.exc != nil {
if f.exc.MatchString(name) {
return false
}
}
return true
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Include",
"(",
"name",
"string",
")",
"bool",
"{",
"if",
"f",
".",
"inc",
"!=",
"nil",
"{",
"if",
"!",
"f",
".",
"inc",
".",
"MatchString",
"(",
"name",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
... | // Include returns true if the name passes the filter. | [
"Include",
"returns",
"true",
"if",
"the",
"name",
"passes",
"the",
"filter",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/filter.go#L25-L37 |
150,326 | google/zoekt | gitindex/filter.go | NewFilter | func NewFilter(includeRegex, excludeRegex string) (*Filter, error) {
f := &Filter{}
var err error
if includeRegex != "" {
f.inc, err = regexp.Compile(includeRegex)
if err != nil {
return nil, err
}
}
if excludeRegex != "" {
f.exc, err = regexp.Compile(excludeRegex)
if err != nil {
return nil, err
... | go | func NewFilter(includeRegex, excludeRegex string) (*Filter, error) {
f := &Filter{}
var err error
if includeRegex != "" {
f.inc, err = regexp.Compile(includeRegex)
if err != nil {
return nil, err
}
}
if excludeRegex != "" {
f.exc, err = regexp.Compile(excludeRegex)
if err != nil {
return nil, err
... | [
"func",
"NewFilter",
"(",
"includeRegex",
",",
"excludeRegex",
"string",
")",
"(",
"*",
"Filter",
",",
"error",
")",
"{",
"f",
":=",
"&",
"Filter",
"{",
"}",
"\n",
"var",
"err",
"error",
"\n",
"if",
"includeRegex",
"!=",
"\"",
"\"",
"{",
"f",
".",
... | // NewFilter creates a new filter. | [
"NewFilter",
"creates",
"a",
"new",
"filter",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/filter.go#L40-L58 |
150,327 | google/zoekt | matchiter.go | matchContent | func (m *candidateMatch) matchContent(content []byte) bool {
if m.caseSensitive {
comp := bytes.Equal(m.substrBytes, content[m.byteOffset:m.byteOffset+uint32(len(m.substrBytes))])
m.byteMatchSz = uint32(len(m.substrBytes))
return comp
} else {
// It is tempting to try a simple ASCII based
// comparison if ... | go | func (m *candidateMatch) matchContent(content []byte) bool {
if m.caseSensitive {
comp := bytes.Equal(m.substrBytes, content[m.byteOffset:m.byteOffset+uint32(len(m.substrBytes))])
m.byteMatchSz = uint32(len(m.substrBytes))
return comp
} else {
// It is tempting to try a simple ASCII based
// comparison if ... | [
"func",
"(",
"m",
"*",
"candidateMatch",
")",
"matchContent",
"(",
"content",
"[",
"]",
"byte",
")",
"bool",
"{",
"if",
"m",
".",
"caseSensitive",
"{",
"comp",
":=",
"bytes",
".",
"Equal",
"(",
"m",
".",
"substrBytes",
",",
"content",
"[",
"m",
".",
... | // Matches content against the substring, and populates byteMatchSz on success | [
"Matches",
"content",
"against",
"the",
"substring",
"and",
"populates",
"byteMatchSz",
"on",
"success"
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/matchiter.go#L43-L61 |
150,328 | google/zoekt | eval.go | gatherBranches | func (d *indexData) gatherBranches(docID uint32, mt matchTree, known map[matchTree]bool) []string {
foundBranchQuery := false
var branches []string
visitMatches(mt, known, func(mt matchTree) {
bq, ok := mt.(*branchQueryMatchTree)
if ok {
foundBranchQuery = true
branches = append(branches,
d.branchName... | go | func (d *indexData) gatherBranches(docID uint32, mt matchTree, known map[matchTree]bool) []string {
foundBranchQuery := false
var branches []string
visitMatches(mt, known, func(mt matchTree) {
bq, ok := mt.(*branchQueryMatchTree)
if ok {
foundBranchQuery = true
branches = append(branches,
d.branchName... | [
"func",
"(",
"d",
"*",
"indexData",
")",
"gatherBranches",
"(",
"docID",
"uint32",
",",
"mt",
"matchTree",
",",
"known",
"map",
"[",
"matchTree",
"]",
"bool",
")",
"[",
"]",
"string",
"{",
"foundBranchQuery",
":=",
"false",
"\n",
"var",
"branches",
"[",
... | // gatherBranches returns a list of branch names. | [
"gatherBranches",
"returns",
"a",
"list",
"of",
"branch",
"names",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/eval.go#L366-L391 |
150,329 | google/zoekt | gitindex/clone.go | CloneRepo | func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (string, error) {
parent := filepath.Join(destDir, filepath.Dir(name))
if err := os.MkdirAll(parent, 0755); err != nil {
return "", err
}
repoDest := filepath.Join(parent, filepath.Base(name)+".git")
if _, err := os.Lstat(repoDest); err ... | go | func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (string, error) {
parent := filepath.Join(destDir, filepath.Dir(name))
if err := os.MkdirAll(parent, 0755); err != nil {
return "", err
}
repoDest := filepath.Join(parent, filepath.Base(name)+".git")
if _, err := os.Lstat(repoDest); err ... | [
"func",
"CloneRepo",
"(",
"destDir",
",",
"name",
",",
"cloneURL",
"string",
",",
"settings",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"parent",
":=",
"filepath",
".",
"Join",
"(",
"destDir",
",",
"filepath",
"."... | // CloneRepo clones one repository, adding the given config
// settings. It returns the bare repo directory. The `name` argument
// determines where the repo is stored relative to `destDir`. Returns
// the directory of the repository. | [
"CloneRepo",
"clones",
"one",
"repository",
"adding",
"the",
"given",
"config",
"settings",
".",
"It",
"returns",
"the",
"bare",
"repo",
"directory",
".",
"The",
"name",
"argument",
"determines",
"where",
"the",
"repo",
"is",
"stored",
"relative",
"to",
"destD... | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/clone.go#L30-L68 |
150,330 | google/zoekt | build/builder.go | HashOptions | func (o *Options) HashOptions() string {
hasher := sha1.New()
hasher.Write([]byte(o.CTags))
hasher.Write([]byte(fmt.Sprintf("%t", o.CTagsMustSucceed)))
hasher.Write([]byte(fmt.Sprintf("%d", o.SizeMax)))
hasher.Write([]byte(fmt.Sprintf("%q", o.LargeFiles)))
return fmt.Sprintf("%x", hasher.Sum(nil))
} | go | func (o *Options) HashOptions() string {
hasher := sha1.New()
hasher.Write([]byte(o.CTags))
hasher.Write([]byte(fmt.Sprintf("%t", o.CTagsMustSucceed)))
hasher.Write([]byte(fmt.Sprintf("%d", o.SizeMax)))
hasher.Write([]byte(fmt.Sprintf("%q", o.LargeFiles)))
return fmt.Sprintf("%x", hasher.Sum(nil))
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"HashOptions",
"(",
")",
"string",
"{",
"hasher",
":=",
"sha1",
".",
"New",
"(",
")",
"\n\n",
"hasher",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"o",
".",
"CTags",
")",
")",
"\n",
"hasher",
".",
"Write",
... | // HashOptions creates a hash of the options that affect an index. | [
"HashOptions",
"creates",
"a",
"hash",
"of",
"the",
"options",
"that",
"affect",
"an",
"index",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L84-L93 |
150,331 | google/zoekt | build/builder.go | SetDefaults | func (o *Options) SetDefaults() {
if o.CTags == "" {
ctags, err := exec.LookPath("universal-ctags")
if err == nil {
o.CTags = ctags
}
}
if o.CTags == "" {
ctags, err := exec.LookPath("ctags-exuberant")
if err == nil {
o.CTags = ctags
}
}
if o.Parallelism == 0 {
o.Parallelism = 1
}
if o.SizeM... | go | func (o *Options) SetDefaults() {
if o.CTags == "" {
ctags, err := exec.LookPath("universal-ctags")
if err == nil {
o.CTags = ctags
}
}
if o.CTags == "" {
ctags, err := exec.LookPath("ctags-exuberant")
if err == nil {
o.CTags = ctags
}
}
if o.Parallelism == 0 {
o.Parallelism = 1
}
if o.SizeM... | [
"func",
"(",
"o",
"*",
"Options",
")",
"SetDefaults",
"(",
")",
"{",
"if",
"o",
".",
"CTags",
"==",
"\"",
"\"",
"{",
"ctags",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"o",
".",
"CTa... | // SetDefaults sets reasonable default options. | [
"SetDefaults",
"sets",
"reasonable",
"default",
"options",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L123-L153 |
150,332 | google/zoekt | build/builder.go | shardName | func (o *Options) shardName(n int) string {
abs := url.QueryEscape(o.RepositoryDescription.Name)
if len(abs) > 200 {
abs = abs[:200] + hashString(abs)[:8]
}
return filepath.Join(o.IndexDir,
fmt.Sprintf("%s_v%d.%05d.zoekt", abs, zoekt.IndexFormatVersion, n))
} | go | func (o *Options) shardName(n int) string {
abs := url.QueryEscape(o.RepositoryDescription.Name)
if len(abs) > 200 {
abs = abs[:200] + hashString(abs)[:8]
}
return filepath.Join(o.IndexDir,
fmt.Sprintf("%s_v%d.%05d.zoekt", abs, zoekt.IndexFormatVersion, n))
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"shardName",
"(",
"n",
"int",
")",
"string",
"{",
"abs",
":=",
"url",
".",
"QueryEscape",
"(",
"o",
".",
"RepositoryDescription",
".",
"Name",
")",
"\n",
"if",
"len",
"(",
"abs",
")",
">",
"200",
"{",
"abs",
... | // ShardName returns the name the given index shard. | [
"ShardName",
"returns",
"the",
"name",
"the",
"given",
"index",
"shard",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L162-L169 |
150,333 | google/zoekt | build/builder.go | IndexVersions | func (o *Options) IndexVersions() []zoekt.RepositoryBranch {
fn := o.shardName(0)
f, err := os.Open(fn)
if err != nil {
return nil
}
iFile, err := zoekt.NewIndexFile(f)
if err != nil {
return nil
}
defer iFile.Close()
repo, index, err := zoekt.ReadMetadata(iFile)
if err != nil {
return nil
}
if in... | go | func (o *Options) IndexVersions() []zoekt.RepositoryBranch {
fn := o.shardName(0)
f, err := os.Open(fn)
if err != nil {
return nil
}
iFile, err := zoekt.NewIndexFile(f)
if err != nil {
return nil
}
defer iFile.Close()
repo, index, err := zoekt.ReadMetadata(iFile)
if err != nil {
return nil
}
if in... | [
"func",
"(",
"o",
"*",
"Options",
")",
"IndexVersions",
"(",
")",
"[",
"]",
"zoekt",
".",
"RepositoryBranch",
"{",
"fn",
":=",
"o",
".",
"shardName",
"(",
"0",
")",
"\n\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fn",
")",
"\n",
"if",
"... | // IndexVersions returns the versions as present in the index, for
// implementing incremental indexing. | [
"IndexVersions",
"returns",
"the",
"versions",
"as",
"present",
"in",
"the",
"index",
"for",
"implementing",
"incremental",
"indexing",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L173-L201 |
150,334 | google/zoekt | build/builder.go | IgnoreSizeMax | func (o *Options) IgnoreSizeMax(name string) bool {
for _, pattern := range o.LargeFiles {
pattern = strings.TrimSpace(pattern)
m, _ := filepath.Match(pattern, name)
if m {
return true
}
}
return false
} | go | func (o *Options) IgnoreSizeMax(name string) bool {
for _, pattern := range o.LargeFiles {
pattern = strings.TrimSpace(pattern)
m, _ := filepath.Match(pattern, name)
if m {
return true
}
}
return false
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"IgnoreSizeMax",
"(",
"name",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"pattern",
":=",
"range",
"o",
".",
"LargeFiles",
"{",
"pattern",
"=",
"strings",
".",
"TrimSpace",
"(",
"pattern",
")",
"\n",
"m",
",",... | // IgnoreSizeMax determines whether the max size should be ignored. | [
"IgnoreSizeMax",
"determines",
"whether",
"the",
"max",
"size",
"should",
"be",
"ignored",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L204-L214 |
150,335 | google/zoekt | build/builder.go | NewBuilder | func NewBuilder(opts Options) (*Builder, error) {
opts.SetDefaults()
if opts.RepositoryDescription.Name == "" {
return nil, fmt.Errorf("builder: must set Name")
}
b := &Builder{
opts: opts,
throttle: make(chan int, opts.Parallelism),
finishedShards: map[string]string{},
}
if b.opts.CTags... | go | func NewBuilder(opts Options) (*Builder, error) {
opts.SetDefaults()
if opts.RepositoryDescription.Name == "" {
return nil, fmt.Errorf("builder: must set Name")
}
b := &Builder{
opts: opts,
throttle: make(chan int, opts.Parallelism),
finishedShards: map[string]string{},
}
if b.opts.CTags... | [
"func",
"NewBuilder",
"(",
"opts",
"Options",
")",
"(",
"*",
"Builder",
",",
"error",
")",
"{",
"opts",
".",
"SetDefaults",
"(",
")",
"\n",
"if",
"opts",
".",
"RepositoryDescription",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
"... | // NewBuilder creates a new Builder instance. | [
"NewBuilder",
"creates",
"a",
"new",
"Builder",
"instance",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L217-L246 |
150,336 | google/zoekt | build/builder.go | AddFile | func (b *Builder) AddFile(name string, content []byte) error {
return b.Add(zoekt.Document{Name: name, Content: content})
} | go | func (b *Builder) AddFile(name string, content []byte) error {
return b.Add(zoekt.Document{Name: name, Content: content})
} | [
"func",
"(",
"b",
"*",
"Builder",
")",
"AddFile",
"(",
"name",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"b",
".",
"Add",
"(",
"zoekt",
".",
"Document",
"{",
"Name",
":",
"name",
",",
"Content",
":",
"content",
"}",
... | // AddFile is a convenience wrapper for the Add method | [
"AddFile",
"is",
"a",
"convenience",
"wrapper",
"for",
"the",
"Add",
"method"
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L249-L251 |
150,337 | google/zoekt | build/builder.go | Finish | func (b *Builder) Finish() error {
b.flush()
b.building.Wait()
if b.buildError != nil {
for tmp := range b.finishedShards {
os.Remove(tmp)
}
return b.buildError
}
for tmp, final := range b.finishedShards {
if err := os.Rename(tmp, final); err != nil {
b.buildError = err
}
}
if b.nextShardNum >... | go | func (b *Builder) Finish() error {
b.flush()
b.building.Wait()
if b.buildError != nil {
for tmp := range b.finishedShards {
os.Remove(tmp)
}
return b.buildError
}
for tmp, final := range b.finishedShards {
if err := os.Rename(tmp, final); err != nil {
b.buildError = err
}
}
if b.nextShardNum >... | [
"func",
"(",
"b",
"*",
"Builder",
")",
"Finish",
"(",
")",
"error",
"{",
"b",
".",
"flush",
"(",
")",
"\n",
"b",
".",
"building",
".",
"Wait",
"(",
")",
"\n\n",
"if",
"b",
".",
"buildError",
"!=",
"nil",
"{",
"for",
"tmp",
":=",
"range",
"b",
... | // Finish creates a last shard from the buffered documents, and clears
// stale shards from previous runs | [
"Finish",
"creates",
"a",
"last",
"shard",
"from",
"the",
"buffered",
"documents",
"and",
"clears",
"stale",
"shards",
"from",
"previous",
"runs"
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L276-L297 |
150,338 | google/zoekt | shards/shards.go | NewDirectorySearcher | func NewDirectorySearcher(dir string) (zoekt.Searcher, error) {
ss := newShardedSearcher(int64(runtime.NumCPU()))
tl := &throttledLoader{
ss: ss,
throttle: make(chan struct{}, runtime.NumCPU()),
}
_, err := NewDirectoryWatcher(dir, tl)
if err != nil {
return nil, err
}
return ss, nil
} | go | func NewDirectorySearcher(dir string) (zoekt.Searcher, error) {
ss := newShardedSearcher(int64(runtime.NumCPU()))
tl := &throttledLoader{
ss: ss,
throttle: make(chan struct{}, runtime.NumCPU()),
}
_, err := NewDirectoryWatcher(dir, tl)
if err != nil {
return nil, err
}
return ss, nil
} | [
"func",
"NewDirectorySearcher",
"(",
"dir",
"string",
")",
"(",
"zoekt",
".",
"Searcher",
",",
"error",
")",
"{",
"ss",
":=",
"newShardedSearcher",
"(",
"int64",
"(",
"runtime",
".",
"NumCPU",
"(",
")",
")",
")",
"\n",
"tl",
":=",
"&",
"throttledLoader",... | // NewDirectorySearcher returns a searcher instance that loads all
// shards corresponding to a glob into memory. | [
"NewDirectorySearcher",
"returns",
"a",
"searcher",
"instance",
"that",
"loads",
"all",
"shards",
"corresponding",
"to",
"a",
"glob",
"into",
"memory",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/shards/shards.go#L61-L73 |
150,339 | google/zoekt | shards/shards.go | Close | func (ss *shardedSearcher) Close() {
ss.lock(context.Background())
defer ss.unlock()
for _, s := range ss.shards {
s.Close()
}
} | go | func (ss *shardedSearcher) Close() {
ss.lock(context.Background())
defer ss.unlock()
for _, s := range ss.shards {
s.Close()
}
} | [
"func",
"(",
"ss",
"*",
"shardedSearcher",
")",
"Close",
"(",
")",
"{",
"ss",
".",
"lock",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"defer",
"ss",
".",
"unlock",
"(",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"ss",
".",
"sh... | // Close closes references to open files. It may be called only once. | [
"Close",
"closes",
"references",
"to",
"open",
"files",
".",
"It",
"may",
"be",
"called",
"only",
"once",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/shards/shards.go#L102-L108 |
150,340 | google/zoekt | shards/shards.go | getShards | func (s *shardedSearcher) getShards() []rankedShard {
var res []rankedShard
for _, sh := range s.shards {
res = append(res, sh)
}
// TODO: precompute this.
sort.Slice(res, func(i, j int) bool {
return res[i].rank > res[j].rank
})
return res
} | go | func (s *shardedSearcher) getShards() []rankedShard {
var res []rankedShard
for _, sh := range s.shards {
res = append(res, sh)
}
// TODO: precompute this.
sort.Slice(res, func(i, j int) bool {
return res[i].rank > res[j].rank
})
return res
} | [
"func",
"(",
"s",
"*",
"shardedSearcher",
")",
"getShards",
"(",
")",
"[",
"]",
"rankedShard",
"{",
"var",
"res",
"[",
"]",
"rankedShard",
"\n",
"for",
"_",
",",
"sh",
":=",
"range",
"s",
".",
"shards",
"{",
"res",
"=",
"append",
"(",
"res",
",",
... | // getShards returns the currently loaded shards. The shards must be
// accessed under a rlock call. The shards are sorted by decreasing
// rank. | [
"getShards",
"returns",
"the",
"currently",
"loaded",
"shards",
".",
"The",
"shards",
"must",
"be",
"accessed",
"under",
"a",
"rlock",
"call",
".",
"The",
"shards",
"are",
"sorted",
"by",
"decreasing",
"rank",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/shards/shards.go#L322-L332 |
150,341 | google/zoekt | gitindex/index.go | RepoModTime | func RepoModTime(dir string) (time.Time, error) {
var last time.Time
refDir := filepath.Join(dir, "refs")
if _, err := os.Lstat(refDir); err == nil {
if err := filepath.Walk(refDir,
func(name string, fi os.FileInfo, err error) error {
if !fi.IsDir() && last.Before(fi.ModTime()) {
last = fi.ModTime()
... | go | func RepoModTime(dir string) (time.Time, error) {
var last time.Time
refDir := filepath.Join(dir, "refs")
if _, err := os.Lstat(refDir); err == nil {
if err := filepath.Walk(refDir,
func(name string, fi os.FileInfo, err error) error {
if !fi.IsDir() && last.Before(fi.ModTime()) {
last = fi.ModTime()
... | [
"func",
"RepoModTime",
"(",
"dir",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"var",
"last",
"time",
".",
"Time",
"\n",
"refDir",
":=",
"filepath",
".",
"Join",
"(",
"dir",
",",
"\"",
"\"",
")",
"\n",
"if",
"_",
",",
"err",
... | // RepoModTime returns the time of last fetch of a git repository. | [
"RepoModTime",
"returns",
"the",
"time",
"of",
"last",
"fetch",
"of",
"a",
"git",
"repository",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L45-L68 |
150,342 | google/zoekt | gitindex/index.go | setTemplates | func setTemplates(repo *zoekt.Repository, u *url.URL, typ string) error {
repo.URL = u.String()
switch typ {
case "gitiles":
/// eg. https://gerrit.googlesource.com/gitiles/+/master/tools/run_dev.sh#20
repo.CommitURLTemplate = u.String() + "/+/{{.Version}}"
repo.FileURLTemplate = u.String() + "/+/{{.Version}}/... | go | func setTemplates(repo *zoekt.Repository, u *url.URL, typ string) error {
repo.URL = u.String()
switch typ {
case "gitiles":
/// eg. https://gerrit.googlesource.com/gitiles/+/master/tools/run_dev.sh#20
repo.CommitURLTemplate = u.String() + "/+/{{.Version}}"
repo.FileURLTemplate = u.String() + "/+/{{.Version}}/... | [
"func",
"setTemplates",
"(",
"repo",
"*",
"zoekt",
".",
"Repository",
",",
"u",
"*",
"url",
".",
"URL",
",",
"typ",
"string",
")",
"error",
"{",
"repo",
".",
"URL",
"=",
"u",
".",
"String",
"(",
")",
"\n",
"switch",
"typ",
"{",
"case",
"\"",
"\""... | // setTemplates fills in URL templates for known git hosting
// sites. | [
"setTemplates",
"fills",
"in",
"URL",
"templates",
"for",
"known",
"git",
"hosting",
"sites",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L111-L154 |
150,343 | google/zoekt | gitindex/index.go | getCommit | func getCommit(repo *git.Repository, prefix, ref string) (*object.Commit, error) {
sha1, err := repo.ResolveRevision(plumbing.Revision(ref))
// ref might be a branch name (e.g. "master") add branch prefix and try again.
if err != nil {
sha1, err = repo.ResolveRevision(plumbing.Revision(filepath.Join(prefix, ref)))... | go | func getCommit(repo *git.Repository, prefix, ref string) (*object.Commit, error) {
sha1, err := repo.ResolveRevision(plumbing.Revision(ref))
// ref might be a branch name (e.g. "master") add branch prefix and try again.
if err != nil {
sha1, err = repo.ResolveRevision(plumbing.Revision(filepath.Join(prefix, ref)))... | [
"func",
"getCommit",
"(",
"repo",
"*",
"git",
".",
"Repository",
",",
"prefix",
",",
"ref",
"string",
")",
"(",
"*",
"object",
".",
"Commit",
",",
"error",
")",
"{",
"sha1",
",",
"err",
":=",
"repo",
".",
"ResolveRevision",
"(",
"plumbing",
".",
"Rev... | // getCommit returns a tree object for the given reference. | [
"getCommit",
"returns",
"a",
"tree",
"object",
"for",
"the",
"given",
"reference",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L157-L172 |
150,344 | google/zoekt | gitindex/index.go | SetTemplatesFromOrigin | func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error {
desc.Name = filepath.Join(u.Host, strings.TrimSuffix(u.Path, ".git"))
if strings.HasSuffix(u.Host, ".googlesource.com") {
return setTemplates(desc, u, "gitiles")
} else if u.Host == "github.com" {
u.Path = strings.TrimSuffix(u.Path, ".git")... | go | func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error {
desc.Name = filepath.Join(u.Host, strings.TrimSuffix(u.Path, ".git"))
if strings.HasSuffix(u.Host, ".googlesource.com") {
return setTemplates(desc, u, "gitiles")
} else if u.Host == "github.com" {
u.Path = strings.TrimSuffix(u.Path, ".git")... | [
"func",
"SetTemplatesFromOrigin",
"(",
"desc",
"*",
"zoekt",
".",
"Repository",
",",
"u",
"*",
"url",
".",
"URL",
")",
"error",
"{",
"desc",
".",
"Name",
"=",
"filepath",
".",
"Join",
"(",
"u",
".",
"Host",
",",
"strings",
".",
"TrimSuffix",
"(",
"u"... | // SetTemplates fills in templates based on the origin URL. | [
"SetTemplates",
"fills",
"in",
"templates",
"based",
"on",
"the",
"origin",
"URL",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L273-L284 |
150,345 | google/zoekt | matchtree.go | prepare | func (t *bruteForceMatchTree) prepare(doc uint32) {
t.docID = doc
t.firstDone = true
} | go | func (t *bruteForceMatchTree) prepare(doc uint32) {
t.docID = doc
t.firstDone = true
} | [
"func",
"(",
"t",
"*",
"bruteForceMatchTree",
")",
"prepare",
"(",
"doc",
"uint32",
")",
"{",
"t",
".",
"docID",
"=",
"doc",
"\n",
"t",
".",
"firstDone",
"=",
"true",
"\n",
"}"
] | // all prepare methods | [
"all",
"prepare",
"methods"
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/matchtree.go#L146-L149 |
150,346 | google/zoekt | ctags/parse.go | Parse | func Parse(in string) (*Entry, error) {
fields := strings.Split(in, "\t")
e := Entry{}
if len(fields) < 3 {
return nil, fmt.Errorf("too few fields: %q", in)
}
e.Sym = fields[0]
e.Path = fields[1]
lstr := fields[2]
if len(lstr) < 2 {
return nil, fmt.Errorf("got %q for linenum field", lstr)
}
l, err := ... | go | func Parse(in string) (*Entry, error) {
fields := strings.Split(in, "\t")
e := Entry{}
if len(fields) < 3 {
return nil, fmt.Errorf("too few fields: %q", in)
}
e.Sym = fields[0]
e.Path = fields[1]
lstr := fields[2]
if len(lstr) < 2 {
return nil, fmt.Errorf("got %q for linenum field", lstr)
}
l, err := ... | [
"func",
"Parse",
"(",
"in",
"string",
")",
"(",
"*",
"Entry",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"in",
",",
"\"",
"\\t",
"\"",
")",
"\n",
"e",
":=",
"Entry",
"{",
"}",
"\n\n",
"if",
"len",
"(",
"fields",
")",
... | // Parse parses a single line of exuberant "ctags -n" output. | [
"Parse",
"parses",
"a",
"single",
"line",
"of",
"exuberant",
"ctags",
"-",
"n",
"output",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/ctags/parse.go#L36-L73 |
150,347 | google/zoekt | query/query.go | Map | func Map(q Q, f func(q Q) Q) Q {
switch s := q.(type) {
case *And:
q = &And{Children: mapQueryList(s.Children, f)}
case *Or:
q = &Or{Children: mapQueryList(s.Children, f)}
case *Not:
q = &Not{Child: Map(s.Child, f)}
}
return f(q)
} | go | func Map(q Q, f func(q Q) Q) Q {
switch s := q.(type) {
case *And:
q = &And{Children: mapQueryList(s.Children, f)}
case *Or:
q = &Or{Children: mapQueryList(s.Children, f)}
case *Not:
q = &Not{Child: Map(s.Child, f)}
}
return f(q)
} | [
"func",
"Map",
"(",
"q",
"Q",
",",
"f",
"func",
"(",
"q",
"Q",
")",
"Q",
")",
"Q",
"{",
"switch",
"s",
":=",
"q",
".",
"(",
"type",
")",
"{",
"case",
"*",
"And",
":",
"q",
"=",
"&",
"And",
"{",
"Children",
":",
"mapQueryList",
"(",
"s",
"... | // Map runs f over the q. | [
"Map",
"runs",
"f",
"over",
"the",
"q",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/query.go#L346-L356 |
150,348 | google/zoekt | query/query.go | VisitAtoms | func VisitAtoms(q Q, v func(q Q)) {
Map(q, func(iQ Q) Q {
switch iQ.(type) {
case *And:
case *Or:
case *Not:
default:
v(iQ)
}
return iQ
})
} | go | func VisitAtoms(q Q, v func(q Q)) {
Map(q, func(iQ Q) Q {
switch iQ.(type) {
case *And:
case *Or:
case *Not:
default:
v(iQ)
}
return iQ
})
} | [
"func",
"VisitAtoms",
"(",
"q",
"Q",
",",
"v",
"func",
"(",
"q",
"Q",
")",
")",
"{",
"Map",
"(",
"q",
",",
"func",
"(",
"iQ",
"Q",
")",
"Q",
"{",
"switch",
"iQ",
".",
"(",
"type",
")",
"{",
"case",
"*",
"And",
":",
"case",
"*",
"Or",
":",... | // VisitAtoms runs `v` on all atom queries within `q`. | [
"VisitAtoms",
"runs",
"v",
"on",
"all",
"atom",
"queries",
"within",
"q",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/query.go#L383-L394 |
150,349 | google/zoekt | indexbuilder.go | ContentSize | func (b *IndexBuilder) ContentSize() uint32 {
// Add the name too so we don't skip building index if we have
// lots of empty files.
return b.contentPostings.endByte + b.namePostings.endByte
} | go | func (b *IndexBuilder) ContentSize() uint32 {
// Add the name too so we don't skip building index if we have
// lots of empty files.
return b.contentPostings.endByte + b.namePostings.endByte
} | [
"func",
"(",
"b",
"*",
"IndexBuilder",
")",
"ContentSize",
"(",
")",
"uint32",
"{",
"// Add the name too so we don't skip building index if we have",
"// lots of empty files.",
"return",
"b",
".",
"contentPostings",
".",
"endByte",
"+",
"b",
".",
"namePostings",
".",
... | // ContentSize returns the number of content bytes so far ingested. | [
"ContentSize",
"returns",
"the",
"number",
"of",
"content",
"bytes",
"so",
"far",
"ingested",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L186-L190 |
150,350 | google/zoekt | indexbuilder.go | NewIndexBuilder | func NewIndexBuilder(r *Repository) (*IndexBuilder, error) {
b := &IndexBuilder{
contentPostings: newPostingsBuilder(),
namePostings: newPostingsBuilder(),
languageMap: map[string]byte{},
}
if r == nil {
r = &Repository{}
}
if err := b.setRepository(r); err != nil {
return nil, err
}
return b, ... | go | func NewIndexBuilder(r *Repository) (*IndexBuilder, error) {
b := &IndexBuilder{
contentPostings: newPostingsBuilder(),
namePostings: newPostingsBuilder(),
languageMap: map[string]byte{},
}
if r == nil {
r = &Repository{}
}
if err := b.setRepository(r); err != nil {
return nil, err
}
return b, ... | [
"func",
"NewIndexBuilder",
"(",
"r",
"*",
"Repository",
")",
"(",
"*",
"IndexBuilder",
",",
"error",
")",
"{",
"b",
":=",
"&",
"IndexBuilder",
"{",
"contentPostings",
":",
"newPostingsBuilder",
"(",
")",
",",
"namePostings",
":",
"newPostingsBuilder",
"(",
"... | // NewIndexBuilder creates a fresh IndexBuilder. The passed in
// Repository contains repo metadata, and may be set to nil. | [
"NewIndexBuilder",
"creates",
"a",
"fresh",
"IndexBuilder",
".",
"The",
"passed",
"in",
"Repository",
"contains",
"repo",
"metadata",
"and",
"may",
"be",
"set",
"to",
"nil",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L194-L208 |
150,351 | google/zoekt | indexbuilder.go | AddFile | func (b *IndexBuilder) AddFile(name string, content []byte) error {
return b.Add(Document{Name: name, Content: content})
} | go | func (b *IndexBuilder) AddFile(name string, content []byte) error {
return b.Add(Document{Name: name, Content: content})
} | [
"func",
"(",
"b",
"*",
"IndexBuilder",
")",
"AddFile",
"(",
"name",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"b",
".",
"Add",
"(",
"Document",
"{",
"Name",
":",
"name",
",",
"Content",
":",
"content",
"}",
")",
"\n",... | // AddFile is a convenience wrapper for Add | [
"AddFile",
"is",
"a",
"convenience",
"wrapper",
"for",
"Add"
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L271-L273 |
150,352 | google/zoekt | indexbuilder.go | CheckText | func CheckText(content []byte) error {
if len(content) == 0 {
return nil
}
if len(content) < ngramSize {
return fmt.Errorf("file size smaller than %d", ngramSize)
}
trigrams := map[ngram]struct{}{}
var cur [3]rune
byteCount := 0
for len(content) > 0 {
if content[0] == 0 {
return fmt.Errorf("binary d... | go | func CheckText(content []byte) error {
if len(content) == 0 {
return nil
}
if len(content) < ngramSize {
return fmt.Errorf("file size smaller than %d", ngramSize)
}
trigrams := map[ngram]struct{}{}
var cur [3]rune
byteCount := 0
for len(content) > 0 {
if content[0] == 0 {
return fmt.Errorf("binary d... | [
"func",
"CheckText",
"(",
"content",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"content",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"content",
")",
"<",
"ngramSize",
"{",
"return",
"fmt",
".",
"Errorf",... | // CheckText returns a reason why the given contents are probably not source texts. | [
"CheckText",
"returns",
"a",
"reason",
"why",
"the",
"given",
"contents",
"are",
"probably",
"not",
"source",
"texts",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L278-L313 |
150,353 | google/zoekt | read.go | ReadMetadata | func ReadMetadata(inf IndexFile) (*Repository, *IndexMetadata, error) {
rd := &reader{r: inf}
var toc indexTOC
if err := rd.readTOC(&toc); err != nil {
return nil, nil, err
}
var md IndexMetadata
if err := rd.readJSON(&md, &toc.metaData); err != nil {
return nil, nil, err
}
var repo Repository
if err := ... | go | func ReadMetadata(inf IndexFile) (*Repository, *IndexMetadata, error) {
rd := &reader{r: inf}
var toc indexTOC
if err := rd.readTOC(&toc); err != nil {
return nil, nil, err
}
var md IndexMetadata
if err := rd.readJSON(&md, &toc.metaData); err != nil {
return nil, nil, err
}
var repo Repository
if err := ... | [
"func",
"ReadMetadata",
"(",
"inf",
"IndexFile",
")",
"(",
"*",
"Repository",
",",
"*",
"IndexMetadata",
",",
"error",
")",
"{",
"rd",
":=",
"&",
"reader",
"{",
"r",
":",
"inf",
"}",
"\n",
"var",
"toc",
"indexTOC",
"\n",
"if",
"err",
":=",
"rd",
".... | // ReadMetadata returns the metadata of index shard without reading
// the index data. The IndexFile is not closed. | [
"ReadMetadata",
"returns",
"the",
"metadata",
"of",
"index",
"shard",
"without",
"reading",
"the",
"index",
"data",
".",
"The",
"IndexFile",
"is",
"not",
"closed",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/read.go#L364-L382 |
150,354 | google/zoekt | gitindex/tree.go | subURL | func (w *repoWalker) subURL(relURL string) (*url.URL, error) {
if w.repoURL == nil {
return nil, fmt.Errorf("no URL for base repo")
}
if strings.HasPrefix(relURL, "../") {
u := *w.repoURL
u.Path = path.Join(u.Path, relURL)
return &u, nil
}
return url.Parse(relURL)
} | go | func (w *repoWalker) subURL(relURL string) (*url.URL, error) {
if w.repoURL == nil {
return nil, fmt.Errorf("no URL for base repo")
}
if strings.HasPrefix(relURL, "../") {
u := *w.repoURL
u.Path = path.Join(u.Path, relURL)
return &u, nil
}
return url.Parse(relURL)
} | [
"func",
"(",
"w",
"*",
"repoWalker",
")",
"subURL",
"(",
"relURL",
"string",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"if",
"w",
".",
"repoURL",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")"... | // subURL returns the URL for a submodule. | [
"subURL",
"returns",
"the",
"URL",
"for",
"a",
"submodule",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L52-L63 |
150,355 | google/zoekt | gitindex/tree.go | newRepoWalker | func newRepoWalker(r *git.Repository, repoURL string, repoCache *RepoCache) *repoWalker {
u, _ := url.Parse(repoURL)
return &repoWalker{
repo: r,
repoURL: u,
tree: map[fileKey]BlobLocation{},
repoCache: repoCache,
subRepoVersions: m... | go | func newRepoWalker(r *git.Repository, repoURL string, repoCache *RepoCache) *repoWalker {
u, _ := url.Parse(repoURL)
return &repoWalker{
repo: r,
repoURL: u,
tree: map[fileKey]BlobLocation{},
repoCache: repoCache,
subRepoVersions: m... | [
"func",
"newRepoWalker",
"(",
"r",
"*",
"git",
".",
"Repository",
",",
"repoURL",
"string",
",",
"repoCache",
"*",
"RepoCache",
")",
"*",
"repoWalker",
"{",
"u",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"repoURL",
")",
"\n",
"return",
"&",
"repoWalker... | // newRepoWalker creates a new repoWalker. | [
"newRepoWalker",
"creates",
"a",
"new",
"repoWalker",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L66-L76 |
150,356 | google/zoekt | gitindex/tree.go | parseModuleMap | func (rw *repoWalker) parseModuleMap(t *object.Tree) error {
modEntry, _ := t.File(".gitmodules")
if modEntry != nil {
c, err := blobContents(&modEntry.Blob)
if err != nil {
return err
}
mods, err := ParseGitModules(c)
if err != nil {
return err
}
rw.submodules = map[string]*SubmoduleEntry{}
for... | go | func (rw *repoWalker) parseModuleMap(t *object.Tree) error {
modEntry, _ := t.File(".gitmodules")
if modEntry != nil {
c, err := blobContents(&modEntry.Blob)
if err != nil {
return err
}
mods, err := ParseGitModules(c)
if err != nil {
return err
}
rw.submodules = map[string]*SubmoduleEntry{}
for... | [
"func",
"(",
"rw",
"*",
"repoWalker",
")",
"parseModuleMap",
"(",
"t",
"*",
"object",
".",
"Tree",
")",
"error",
"{",
"modEntry",
",",
"_",
":=",
"t",
".",
"File",
"(",
"\"",
"\"",
")",
"\n",
"if",
"modEntry",
"!=",
"nil",
"{",
"c",
",",
"err",
... | // parseModuleMap initializes rw.submodules. | [
"parseModuleMap",
"initializes",
"rw",
".",
"submodules",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L79-L96 |
150,357 | google/zoekt | gitindex/tree.go | TreeToFiles | func TreeToFiles(r *git.Repository, t *object.Tree,
repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error) {
rw := newRepoWalker(r, repoURL, repoCache)
if err := rw.parseModuleMap(t); err != nil {
return nil, nil, err
}
tw := object.NewTreeWalker(t, true, make(map[plu... | go | func TreeToFiles(r *git.Repository, t *object.Tree,
repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error) {
rw := newRepoWalker(r, repoURL, repoCache)
if err := rw.parseModuleMap(t); err != nil {
return nil, nil, err
}
tw := object.NewTreeWalker(t, true, make(map[plu... | [
"func",
"TreeToFiles",
"(",
"r",
"*",
"git",
".",
"Repository",
",",
"t",
"*",
"object",
".",
"Tree",
",",
"repoURL",
"string",
",",
"repoCache",
"*",
"RepoCache",
")",
"(",
"map",
"[",
"fileKey",
"]",
"BlobLocation",
",",
"map",
"[",
"string",
"]",
... | // TreeToFiles fetches the blob SHA1s for a tree. If repoCache is
// non-nil, recurse into submodules. In addition, it returns a mapping
// that indicates in which repo each SHA1 can be found. | [
"TreeToFiles",
"fetches",
"the",
"blob",
"SHA1s",
"for",
"a",
"tree",
".",
"If",
"repoCache",
"is",
"non",
"-",
"nil",
"recurse",
"into",
"submodules",
".",
"In",
"addition",
"it",
"returns",
"a",
"mapping",
"that",
"indicates",
"in",
"which",
"repo",
"eac... | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L101-L121 |
150,358 | google/zoekt | cmd/zoekt-archive-index/main.go | stripComponents | func stripComponents(path string, count int) string {
for i := 0; path != "" && i < count; i++ {
i := strings.Index(path, "/")
if i < 0 {
return ""
}
path = path[i+1:]
}
return path
} | go | func stripComponents(path string, count int) string {
for i := 0; path != "" && i < count; i++ {
i := strings.Index(path, "/")
if i < 0 {
return ""
}
path = path[i+1:]
}
return path
} | [
"func",
"stripComponents",
"(",
"path",
"string",
",",
"count",
"int",
")",
"string",
"{",
"for",
"i",
":=",
"0",
";",
"path",
"!=",
"\"",
"\"",
"&&",
"i",
"<",
"count",
";",
"i",
"++",
"{",
"i",
":=",
"strings",
".",
"Index",
"(",
"path",
",",
... | // stripComponents removes the specified number of leading path
// elements. Pathnames with fewer elements will return the empty string. | [
"stripComponents",
"removes",
"the",
"specified",
"number",
"of",
"leading",
"path",
"elements",
".",
"Pathnames",
"with",
"fewer",
"elements",
"will",
"return",
"the",
"empty",
"string",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-archive-index/main.go#L29-L38 |
150,359 | google/zoekt | cmd/zoekt-archive-index/archive.go | openArchive | func openArchive(u string) (Archive, error) {
var (
r io.Reader
closer io.Closer
)
if strings.HasPrefix(u, "https://") || strings.HasPrefix(u, "http://") {
resp, err := http.Get(u)
if err != nil {
return nil, err
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
b, err := ioutil.ReadAll(... | go | func openArchive(u string) (Archive, error) {
var (
r io.Reader
closer io.Closer
)
if strings.HasPrefix(u, "https://") || strings.HasPrefix(u, "http://") {
resp, err := http.Get(u)
if err != nil {
return nil, err
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
b, err := ioutil.ReadAll(... | [
"func",
"openArchive",
"(",
"u",
"string",
")",
"(",
"Archive",
",",
"error",
")",
"{",
"var",
"(",
"r",
"io",
".",
"Reader",
"\n",
"closer",
"io",
".",
"Closer",
"\n",
")",
"\n\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"u",
",",
"\"",
"\"",
")... | // openArchive opens the tar at the URL or filepath u. Also supported is tgz
// files over http. | [
"openArchive",
"opens",
"the",
"tar",
"at",
"the",
"URL",
"or",
"filepath",
"u",
".",
"Also",
"supported",
"is",
"tgz",
"files",
"over",
"http",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-archive-index/archive.go#L60-L107 |
150,360 | google/zoekt | cmd/zoekt-repo-index/main.go | iterateManifest | func iterateManifest(mf *manifest.Manifest,
baseURL url.URL, revPrefix string,
cache *gitindex.RepoCache) (map[fileKey]gitindex.BlobLocation, map[string]plumbing.Hash, error) {
allFiles := map[fileKey]gitindex.BlobLocation{}
allVersions := map[string]plumbing.Hash{}
for _, p := range mf.Project {
rev := mf.Proje... | go | func iterateManifest(mf *manifest.Manifest,
baseURL url.URL, revPrefix string,
cache *gitindex.RepoCache) (map[fileKey]gitindex.BlobLocation, map[string]plumbing.Hash, error) {
allFiles := map[fileKey]gitindex.BlobLocation{}
allVersions := map[string]plumbing.Hash{}
for _, p := range mf.Project {
rev := mf.Proje... | [
"func",
"iterateManifest",
"(",
"mf",
"*",
"manifest",
".",
"Manifest",
",",
"baseURL",
"url",
".",
"URL",
",",
"revPrefix",
"string",
",",
"cache",
"*",
"gitindex",
".",
"RepoCache",
")",
"(",
"map",
"[",
"fileKey",
"]",
"gitindex",
".",
"BlobLocation",
... | // iterateManifest constructs a complete tree from the given Manifest. | [
"iterateManifest",
"constructs",
"a",
"complete",
"tree",
"from",
"the",
"given",
"Manifest",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-repo-index/main.go#L325-L380 |
150,361 | google/zoekt | ctags/json.go | NewParser | func NewParser(bin string) (Parser, error) {
if strings.Contains(bin, "universal-ctags") {
// todo: restart, parallelization.
proc, err := newProcess(bin)
if err != nil {
return nil, err
}
return &lockedParser{p: proc}, nil
}
log.Fatal("not implemented")
return nil, nil
} | go | func NewParser(bin string) (Parser, error) {
if strings.Contains(bin, "universal-ctags") {
// todo: restart, parallelization.
proc, err := newProcess(bin)
if err != nil {
return nil, err
}
return &lockedParser{p: proc}, nil
}
log.Fatal("not implemented")
return nil, nil
} | [
"func",
"NewParser",
"(",
"bin",
"string",
")",
"(",
"Parser",
",",
"error",
")",
"{",
"if",
"strings",
".",
"Contains",
"(",
"bin",
",",
"\"",
"\"",
")",
"{",
"// todo: restart, parallelization.",
"proc",
",",
"err",
":=",
"newProcess",
"(",
"bin",
")",... | // NewParser creates a parser that is implemented by the given
// universal-ctags binary. The parser is safe for concurrent use. | [
"NewParser",
"creates",
"a",
"parser",
"that",
"is",
"implemented",
"by",
"the",
"given",
"universal",
"-",
"ctags",
"binary",
".",
"The",
"parser",
"is",
"safe",
"for",
"concurrent",
"use",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/ctags/json.go#L207-L219 |
150,362 | google/zoekt | contentprovider.go | setDocument | func (p *contentProvider) setDocument(docID uint32) {
fileStart := p.id.boundaries[docID]
p.idx = docID
p.fileSize = p.id.boundaries[docID+1] - fileStart
p._nl = nil
p._sects = nil
p._data = nil
} | go | func (p *contentProvider) setDocument(docID uint32) {
fileStart := p.id.boundaries[docID]
p.idx = docID
p.fileSize = p.id.boundaries[docID+1] - fileStart
p._nl = nil
p._sects = nil
p._data = nil
} | [
"func",
"(",
"p",
"*",
"contentProvider",
")",
"setDocument",
"(",
"docID",
"uint32",
")",
"{",
"fileStart",
":=",
"p",
".",
"id",
".",
"boundaries",
"[",
"docID",
"]",
"\n\n",
"p",
".",
"idx",
"=",
"docID",
"\n",
"p",
".",
"fileSize",
"=",
"p",
".... | // setDocument skips to the given document. | [
"setDocument",
"skips",
"to",
"the",
"given",
"document",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/contentprovider.go#L44-L53 |
150,363 | google/zoekt | query/regexp.go | RegexpToQuery | func RegexpToQuery(r *syntax.Regexp, minTextSize int) Q {
q := regexpToQueryRecursive(r, minTextSize)
q = Simplify(q)
return q
} | go | func RegexpToQuery(r *syntax.Regexp, minTextSize int) Q {
q := regexpToQueryRecursive(r, minTextSize)
q = Simplify(q)
return q
} | [
"func",
"RegexpToQuery",
"(",
"r",
"*",
"syntax",
".",
"Regexp",
",",
"minTextSize",
"int",
")",
"Q",
"{",
"q",
":=",
"regexpToQueryRecursive",
"(",
"r",
",",
"minTextSize",
")",
"\n",
"q",
"=",
"Simplify",
"(",
"q",
")",
"\n",
"return",
"q",
"\n",
"... | // RegexpToQuery tries to distill a substring search query that
// matches a superset of the regexp. | [
"RegexpToQuery",
"tries",
"to",
"distill",
"a",
"substring",
"search",
"query",
"that",
"matches",
"a",
"superset",
"of",
"the",
"regexp",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/regexp.go#L48-L52 |
150,364 | google/zoekt | cmd/zoekt-indexserver/main.go | periodicFetch | func periodicFetch(repoDir, indexDir string, opts *Options, pendingRepos chan<- string) {
t := time.NewTicker(opts.fetchInterval)
for {
repos, err := gitindex.FindGitRepos(repoDir)
if err != nil {
log.Println(err)
continue
}
if len(repos) == 0 {
log.Printf("no repos found under %s", repoDir)
}
/... | go | func periodicFetch(repoDir, indexDir string, opts *Options, pendingRepos chan<- string) {
t := time.NewTicker(opts.fetchInterval)
for {
repos, err := gitindex.FindGitRepos(repoDir)
if err != nil {
log.Println(err)
continue
}
if len(repos) == 0 {
log.Printf("no repos found under %s", repoDir)
}
/... | [
"func",
"periodicFetch",
"(",
"repoDir",
",",
"indexDir",
"string",
",",
"opts",
"*",
"Options",
",",
"pendingRepos",
"chan",
"<-",
"string",
")",
"{",
"t",
":=",
"time",
".",
"NewTicker",
"(",
"opts",
".",
"fetchInterval",
")",
"\n",
"for",
"{",
"repos"... | // periodicFetch runs git-fetch every once in a while. Results are
// posted on pendingRepos. | [
"periodicFetch",
"runs",
"git",
"-",
"fetch",
"every",
"once",
"in",
"a",
"while",
".",
"Results",
"are",
"posted",
"on",
"pendingRepos",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L95-L124 |
150,365 | google/zoekt | cmd/zoekt-indexserver/main.go | fetchGitRepo | func fetchGitRepo(dir string) bool {
cmd := exec.Command("git", "--git-dir", dir, "fetch", "origin")
outBuf := &bytes.Buffer{}
errBuf := &bytes.Buffer{}
// Prevent prompting
cmd.Stdin = &bytes.Buffer{}
cmd.Stderr = errBuf
cmd.Stdout = outBuf
if err := cmd.Run(); err != nil {
log.Printf("command %s failed: %v... | go | func fetchGitRepo(dir string) bool {
cmd := exec.Command("git", "--git-dir", dir, "fetch", "origin")
outBuf := &bytes.Buffer{}
errBuf := &bytes.Buffer{}
// Prevent prompting
cmd.Stdin = &bytes.Buffer{}
cmd.Stderr = errBuf
cmd.Stdout = outBuf
if err := cmd.Run(); err != nil {
log.Printf("command %s failed: %v... | [
"func",
"fetchGitRepo",
"(",
"dir",
"string",
")",
"bool",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"dir",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"outBuf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}... | // fetchGitRepo runs git-fetch, and returns true if there was an
// update. | [
"fetchGitRepo",
"runs",
"git",
"-",
"fetch",
"and",
"returns",
"true",
"if",
"there",
"was",
"an",
"update",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L128-L144 |
150,366 | google/zoekt | cmd/zoekt-indexserver/main.go | indexPendingRepos | func indexPendingRepos(indexDir, repoDir string, opts *Options, repos <-chan string) {
for dir := range repos {
args := []string{
"-require_ctags",
fmt.Sprintf("-parallelism=%d", opts.cpuCount),
"-repo_cache", repoDir,
"-index", indexDir,
"-incremental",
}
args = append(args, opts.indexFlags...)
... | go | func indexPendingRepos(indexDir, repoDir string, opts *Options, repos <-chan string) {
for dir := range repos {
args := []string{
"-require_ctags",
fmt.Sprintf("-parallelism=%d", opts.cpuCount),
"-repo_cache", repoDir,
"-index", indexDir,
"-incremental",
}
args = append(args, opts.indexFlags...)
... | [
"func",
"indexPendingRepos",
"(",
"indexDir",
",",
"repoDir",
"string",
",",
"opts",
"*",
"Options",
",",
"repos",
"<-",
"chan",
"string",
")",
"{",
"for",
"dir",
":=",
"range",
"repos",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"f... | // indexPendingRepos consumes the directories on the repos channel and
// indexes them, sequentially. | [
"indexPendingRepos",
"consumes",
"the",
"directories",
"on",
"the",
"repos",
"channel",
"and",
"indexes",
"them",
"sequentially",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L148-L162 |
150,367 | google/zoekt | cmd/zoekt-indexserver/main.go | deleteLogs | func deleteLogs(logDir string, maxAge time.Duration) {
fs, err := filepath.Glob(filepath.Join(logDir, "*"))
if err != nil {
log.Fatalf("filepath.Glob(%s): %v", logDir, err)
}
threshold := time.Now().Add(-maxAge)
for _, fn := range fs {
if fi, err := os.Lstat(fn); err == nil && fi.ModTime().Before(threshold) {... | go | func deleteLogs(logDir string, maxAge time.Duration) {
fs, err := filepath.Glob(filepath.Join(logDir, "*"))
if err != nil {
log.Fatalf("filepath.Glob(%s): %v", logDir, err)
}
threshold := time.Now().Add(-maxAge)
for _, fn := range fs {
if fi, err := os.Lstat(fn); err == nil && fi.ModTime().Before(threshold) {... | [
"func",
"deleteLogs",
"(",
"logDir",
"string",
",",
"maxAge",
"time",
".",
"Duration",
")",
"{",
"fs",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"filepath",
".",
"Join",
"(",
"logDir",
",",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // deleteLogs deletes old logs. | [
"deleteLogs",
"deletes",
"old",
"logs",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L165-L177 |
150,368 | google/zoekt | cmd/zoekt-indexserver/main.go | deleteIfOrphan | func deleteIfOrphan(repoDir string, fn string) error {
f, err := os.Open(fn)
if err != nil {
return nil
}
defer f.Close()
ifile, err := zoekt.NewIndexFile(f)
if err != nil {
return nil
}
defer ifile.Close()
repo, _, err := zoekt.ReadMetadata(ifile)
if err != nil {
return nil
}
_, err = os.Stat(repo... | go | func deleteIfOrphan(repoDir string, fn string) error {
f, err := os.Open(fn)
if err != nil {
return nil
}
defer f.Close()
ifile, err := zoekt.NewIndexFile(f)
if err != nil {
return nil
}
defer ifile.Close()
repo, _, err := zoekt.ReadMetadata(ifile)
if err != nil {
return nil
}
_, err = os.Stat(repo... | [
"func",
"deleteIfOrphan",
"(",
"repoDir",
"string",
",",
"fn",
"string",
")",
"error",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"defer",
"f",
".",
"Close... | // Delete the shard if its corresponding git repo can't be found. | [
"Delete",
"the",
"shard",
"if",
"its",
"corresponding",
"git",
"repo",
"can",
"t",
"be",
"found",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L188-L213 |
150,369 | derekparker/trie | trie.go | New | func New() *Trie {
return &Trie{
root: &Node{children: make(map[rune]*Node), depth: 0},
size: 0,
}
} | go | func New() *Trie {
return &Trie{
root: &Node{children: make(map[rune]*Node), depth: 0},
size: 0,
}
} | [
"func",
"New",
"(",
")",
"*",
"Trie",
"{",
"return",
"&",
"Trie",
"{",
"root",
":",
"&",
"Node",
"{",
"children",
":",
"make",
"(",
"map",
"[",
"rune",
"]",
"*",
"Node",
")",
",",
"depth",
":",
"0",
"}",
",",
"size",
":",
"0",
",",
"}",
"\n... | // Creates a new Trie with an initialized root Node. | [
"Creates",
"a",
"new",
"Trie",
"with",
"an",
"initialized",
"root",
"Node",
"."
] | 1ce4922c7ad906a094c6298977755068ba76ad31 | https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L38-L43 |
150,370 | derekparker/trie | trie.go | Find | func (t *Trie) Find(key string) (*Node, bool) {
node := findNode(t.Root(), []rune(key))
if node == nil {
return nil, false
}
node, ok := node.Children()[nul]
if !ok || !node.term {
return nil, false
}
return node, true
} | go | func (t *Trie) Find(key string) (*Node, bool) {
node := findNode(t.Root(), []rune(key))
if node == nil {
return nil, false
}
node, ok := node.Children()[nul]
if !ok || !node.term {
return nil, false
}
return node, true
} | [
"func",
"(",
"t",
"*",
"Trie",
")",
"Find",
"(",
"key",
"string",
")",
"(",
"*",
"Node",
",",
"bool",
")",
"{",
"node",
":=",
"findNode",
"(",
"t",
".",
"Root",
"(",
")",
",",
"[",
"]",
"rune",
"(",
"key",
")",
")",
"\n",
"if",
"node",
"=="... | // Finds and returns meta data associated
// with `key`. | [
"Finds",
"and",
"returns",
"meta",
"data",
"associated",
"with",
"key",
"."
] | 1ce4922c7ad906a094c6298977755068ba76ad31 | https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L78-L90 |
150,371 | derekparker/trie | trie.go | Remove | func (t *Trie) Remove(key string) {
var (
i int
rs = []rune(key)
node = findNode(t.Root(), []rune(key))
)
t.mu.Lock()
defer t.mu.Unlock()
t.size--
for n := node.Parent(); n != nil; n = n.Parent() {
i++
if len(n.Children()) > 1 {
r := rs[len(rs)-i]
n.RemoveChild(r)
break
}
}
} | go | func (t *Trie) Remove(key string) {
var (
i int
rs = []rune(key)
node = findNode(t.Root(), []rune(key))
)
t.mu.Lock()
defer t.mu.Unlock()
t.size--
for n := node.Parent(); n != nil; n = n.Parent() {
i++
if len(n.Children()) > 1 {
r := rs[len(rs)-i]
n.RemoveChild(r)
break
}
}
} | [
"func",
"(",
"t",
"*",
"Trie",
")",
"Remove",
"(",
"key",
"string",
")",
"{",
"var",
"(",
"i",
"int",
"\n",
"rs",
"=",
"[",
"]",
"rune",
"(",
"key",
")",
"\n",
"node",
"=",
"findNode",
"(",
"t",
".",
"Root",
"(",
")",
",",
"[",
"]",
"rune",... | // Removes a key from the trie, ensuring that
// all bitmasks up to root are appropriately recalculated. | [
"Removes",
"a",
"key",
"from",
"the",
"trie",
"ensuring",
"that",
"all",
"bitmasks",
"up",
"to",
"root",
"are",
"appropriately",
"recalculated",
"."
] | 1ce4922c7ad906a094c6298977755068ba76ad31 | https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L99-L118 |
150,372 | derekparker/trie | trie.go | FuzzySearch | func (t Trie) FuzzySearch(pre string) []string {
keys := fuzzycollect(t.Root(), []rune(pre))
sort.Sort(ByKeys(keys))
return keys
} | go | func (t Trie) FuzzySearch(pre string) []string {
keys := fuzzycollect(t.Root(), []rune(pre))
sort.Sort(ByKeys(keys))
return keys
} | [
"func",
"(",
"t",
"Trie",
")",
"FuzzySearch",
"(",
"pre",
"string",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"fuzzycollect",
"(",
"t",
".",
"Root",
"(",
")",
",",
"[",
"]",
"rune",
"(",
"pre",
")",
")",
"\n",
"sort",
".",
"Sort",
"(",
"ByKey... | // Performs a fuzzy search against the keys in the trie. | [
"Performs",
"a",
"fuzzy",
"search",
"against",
"the",
"keys",
"in",
"the",
"trie",
"."
] | 1ce4922c7ad906a094c6298977755068ba76ad31 | https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L126-L130 |
150,373 | derekparker/trie | trie.go | PrefixSearch | func (t Trie) PrefixSearch(pre string) []string {
node := findNode(t.Root(), []rune(pre))
if node == nil {
return nil
}
return collect(node)
} | go | func (t Trie) PrefixSearch(pre string) []string {
node := findNode(t.Root(), []rune(pre))
if node == nil {
return nil
}
return collect(node)
} | [
"func",
"(",
"t",
"Trie",
")",
"PrefixSearch",
"(",
"pre",
"string",
")",
"[",
"]",
"string",
"{",
"node",
":=",
"findNode",
"(",
"t",
".",
"Root",
"(",
")",
",",
"[",
"]",
"rune",
"(",
"pre",
")",
")",
"\n",
"if",
"node",
"==",
"nil",
"{",
"... | // Performs a prefix search against the keys in the trie. | [
"Performs",
"a",
"prefix",
"search",
"against",
"the",
"keys",
"in",
"the",
"trie",
"."
] | 1ce4922c7ad906a094c6298977755068ba76ad31 | https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L133-L140 |
150,374 | derekparker/trie | trie.go | NewChild | func (n *Node) NewChild(val rune, bitmask uint64, meta interface{}, term bool) *Node {
node := &Node{
val: val,
mask: bitmask,
term: term,
meta: meta,
parent: n,
children: make(map[rune]*Node),
depth: n.depth + 1,
}
n.children[val] = node
n.mask |= bitmask
return node
} | go | func (n *Node) NewChild(val rune, bitmask uint64, meta interface{}, term bool) *Node {
node := &Node{
val: val,
mask: bitmask,
term: term,
meta: meta,
parent: n,
children: make(map[rune]*Node),
depth: n.depth + 1,
}
n.children[val] = node
n.mask |= bitmask
return node
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"NewChild",
"(",
"val",
"rune",
",",
"bitmask",
"uint64",
",",
"meta",
"interface",
"{",
"}",
",",
"term",
"bool",
")",
"*",
"Node",
"{",
"node",
":=",
"&",
"Node",
"{",
"val",
":",
"val",
",",
"mask",
":",
"... | // Creates and returns a pointer to a new child for the node. | [
"Creates",
"and",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"child",
"for",
"the",
"node",
"."
] | 1ce4922c7ad906a094c6298977755068ba76ad31 | https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L143-L156 |
150,375 | tidwall/sjson | sjson.go | appendStringify | func appendStringify(buf []byte, s string) []byte {
if mustMarshalString(s) {
b, _ := jsongo.Marshal(s)
return append(buf, b...)
}
buf = append(buf, '"')
buf = append(buf, s...)
buf = append(buf, '"')
return buf
} | go | func appendStringify(buf []byte, s string) []byte {
if mustMarshalString(s) {
b, _ := jsongo.Marshal(s)
return append(buf, b...)
}
buf = append(buf, '"')
buf = append(buf, s...)
buf = append(buf, '"')
return buf
} | [
"func",
"appendStringify",
"(",
"buf",
"[",
"]",
"byte",
",",
"s",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"mustMarshalString",
"(",
"s",
")",
"{",
"b",
",",
"_",
":=",
"jsongo",
".",
"Marshal",
"(",
"s",
")",
"\n",
"return",
"append",
"(",
"... | // appendStringify makes a json string and appends to buf. | [
"appendStringify",
"makes",
"a",
"json",
"string",
"and",
"appends",
"to",
"buf",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L119-L128 |
150,376 | tidwall/sjson | sjson.go | appendBuild | func appendBuild(buf []byte, array bool, paths []pathResult, raw string,
stringify bool) []byte {
if !array {
buf = appendStringify(buf, paths[0].part)
buf = append(buf, ':')
}
if len(paths) > 1 {
n, numeric := atoui(paths[1])
if numeric || (!paths[1].force && paths[1].part == "-1") {
buf = append(buf, '... | go | func appendBuild(buf []byte, array bool, paths []pathResult, raw string,
stringify bool) []byte {
if !array {
buf = appendStringify(buf, paths[0].part)
buf = append(buf, ':')
}
if len(paths) > 1 {
n, numeric := atoui(paths[1])
if numeric || (!paths[1].force && paths[1].part == "-1") {
buf = append(buf, '... | [
"func",
"appendBuild",
"(",
"buf",
"[",
"]",
"byte",
",",
"array",
"bool",
",",
"paths",
"[",
"]",
"pathResult",
",",
"raw",
"string",
",",
"stringify",
"bool",
")",
"[",
"]",
"byte",
"{",
"if",
"!",
"array",
"{",
"buf",
"=",
"appendStringify",
"(",
... | // appendBuild builds a json block from a json path. | [
"appendBuild",
"builds",
"a",
"json",
"block",
"from",
"a",
"json",
"path",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L131-L157 |
150,377 | tidwall/sjson | sjson.go | atoui | func atoui(r pathResult) (n int, ok bool) {
if r.force {
return 0, false
}
for i := 0; i < len(r.part); i++ {
if r.part[i] < '0' || r.part[i] > '9' {
return 0, false
}
n = n*10 + int(r.part[i]-'0')
}
return n, true
} | go | func atoui(r pathResult) (n int, ok bool) {
if r.force {
return 0, false
}
for i := 0; i < len(r.part); i++ {
if r.part[i] < '0' || r.part[i] > '9' {
return 0, false
}
n = n*10 + int(r.part[i]-'0')
}
return n, true
} | [
"func",
"atoui",
"(",
"r",
"pathResult",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"r",
".",
"force",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"r",
".",
"part",
")",... | // atoui does a rip conversion of string -> unigned int. | [
"atoui",
"does",
"a",
"rip",
"conversion",
"of",
"string",
"-",
">",
"unigned",
"int",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L160-L171 |
150,378 | tidwall/sjson | sjson.go | appendRepeat | func appendRepeat(buf []byte, s string, n int) []byte {
for i := 0; i < n; i++ {
buf = append(buf, s...)
}
return buf
} | go | func appendRepeat(buf []byte, s string, n int) []byte {
for i := 0; i < n; i++ {
buf = append(buf, s...)
}
return buf
} | [
"func",
"appendRepeat",
"(",
"buf",
"[",
"]",
"byte",
",",
"s",
"string",
",",
"n",
"int",
")",
"[",
"]",
"byte",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"buf",
"=",
"append",
"(",
"buf",
",",
"s",
"...",
")",
... | // appendRepeat repeats string "n" times and appends to buf. | [
"appendRepeat",
"repeats",
"string",
"n",
"times",
"and",
"appends",
"to",
"buf",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L174-L179 |
150,379 | tidwall/sjson | sjson.go | trim | func trim(s string) string {
for len(s) > 0 {
if s[0] <= ' ' {
s = s[1:]
continue
}
break
}
for len(s) > 0 {
if s[len(s)-1] <= ' ' {
s = s[:len(s)-1]
continue
}
break
}
return s
} | go | func trim(s string) string {
for len(s) > 0 {
if s[0] <= ' ' {
s = s[1:]
continue
}
break
}
for len(s) > 0 {
if s[len(s)-1] <= ' ' {
s = s[:len(s)-1]
continue
}
break
}
return s
} | [
"func",
"trim",
"(",
"s",
"string",
")",
"string",
"{",
"for",
"len",
"(",
"s",
")",
">",
"0",
"{",
"if",
"s",
"[",
"0",
"]",
"<=",
"' '",
"{",
"s",
"=",
"s",
"[",
"1",
":",
"]",
"\n",
"continue",
"\n",
"}",
"\n",
"break",
"\n",
"}",
"\n"... | // trim does a rip trim | [
"trim",
"does",
"a",
"rip",
"trim"
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L182-L198 |
150,380 | tidwall/sjson | sjson.go | deleteTailItem | func deleteTailItem(buf []byte) ([]byte, bool) {
loop:
for i := len(buf) - 1; i >= 0; i-- {
// look for either a ',',':','['
switch buf[i] {
case '[':
return buf, true
case ',':
return buf[:i], false
case ':':
// delete tail string
i--
for ; i >= 0; i-- {
if buf[i] == '"' {
i--
f... | go | func deleteTailItem(buf []byte) ([]byte, bool) {
loop:
for i := len(buf) - 1; i >= 0; i-- {
// look for either a ',',':','['
switch buf[i] {
case '[':
return buf, true
case ',':
return buf[:i], false
case ':':
// delete tail string
i--
for ; i >= 0; i-- {
if buf[i] == '"' {
i--
f... | [
"func",
"deleteTailItem",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
")",
"{",
"loop",
":",
"for",
"i",
":=",
"len",
"(",
"buf",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"// look for either a ',',':','[... | // deleteTailItem deletes the previous key or comma. | [
"deleteTailItem",
"deletes",
"the",
"previous",
"key",
"or",
"comma",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L201-L241 |
150,381 | tidwall/sjson | sjson.go | SetRaw | func SetRaw(json, path, value string) (string, error) {
return SetRawOptions(json, path, value, nil)
} | go | func SetRaw(json, path, value string) (string, error) {
return SetRawOptions(json, path, value, nil)
} | [
"func",
"SetRaw",
"(",
"json",
",",
"path",
",",
"value",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"SetRawOptions",
"(",
"json",
",",
"path",
",",
"value",
",",
"nil",
")",
"\n",
"}"
] | // SetRaw sets a raw json value for the specified path.
// This function works the same as Set except that the value is set as a
// raw block of json. This allows for setting premarshalled json objects. | [
"SetRaw",
"sets",
"a",
"raw",
"json",
"value",
"for",
"the",
"specified",
"path",
".",
"This",
"function",
"works",
"the",
"same",
"as",
"Set",
"except",
"that",
"the",
"value",
"is",
"set",
"as",
"a",
"raw",
"block",
"of",
"json",
".",
"This",
"allows... | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L446-L448 |
150,382 | tidwall/sjson | sjson.go | SetRawOptions | func SetRawOptions(json, path, value string, opts *Options) (string, error) {
var optimistic bool
if opts != nil {
optimistic = opts.Optimistic
}
res, err := set(json, path, value, false, false, optimistic, false)
if err == errNoChange {
return json, nil
}
return string(res), err
} | go | func SetRawOptions(json, path, value string, opts *Options) (string, error) {
var optimistic bool
if opts != nil {
optimistic = opts.Optimistic
}
res, err := set(json, path, value, false, false, optimistic, false)
if err == errNoChange {
return json, nil
}
return string(res), err
} | [
"func",
"SetRawOptions",
"(",
"json",
",",
"path",
",",
"value",
"string",
",",
"opts",
"*",
"Options",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"optimistic",
"bool",
"\n",
"if",
"opts",
"!=",
"nil",
"{",
"optimistic",
"=",
"opts",
".",
"Op... | // SetRawOptions sets a raw json value for the specified path with options.
// This furnction works the same as SetOptions except that the value is set
// as a raw block of json. This allows for setting premarshalled json objects. | [
"SetRawOptions",
"sets",
"a",
"raw",
"json",
"value",
"for",
"the",
"specified",
"path",
"with",
"options",
".",
"This",
"furnction",
"works",
"the",
"same",
"as",
"SetOptions",
"except",
"that",
"the",
"value",
"is",
"set",
"as",
"a",
"raw",
"block",
"of"... | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L453-L463 |
150,383 | tidwall/sjson | sjson.go | Delete | func Delete(json, path string) (string, error) {
return Set(json, path, dtype{})
} | go | func Delete(json, path string) (string, error) {
return Set(json, path, dtype{})
} | [
"func",
"Delete",
"(",
"json",
",",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"Set",
"(",
"json",
",",
"path",
",",
"dtype",
"{",
"}",
")",
"\n",
"}"
] | // Delete deletes a value from json for the specified path. | [
"Delete",
"deletes",
"a",
"value",
"from",
"json",
"for",
"the",
"specified",
"path",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L475-L477 |
150,384 | tidwall/sjson | sjson.go | DeleteBytes | func DeleteBytes(json []byte, path string) ([]byte, error) {
return SetBytes(json, path, dtype{})
} | go | func DeleteBytes(json []byte, path string) ([]byte, error) {
return SetBytes(json, path, dtype{})
} | [
"func",
"DeleteBytes",
"(",
"json",
"[",
"]",
"byte",
",",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"SetBytes",
"(",
"json",
",",
"path",
",",
"dtype",
"{",
"}",
")",
"\n",
"}"
] | // DeleteBytes deletes a value from json for the specified path. | [
"DeleteBytes",
"deletes",
"a",
"value",
"from",
"json",
"for",
"the",
"specified",
"path",
"."
] | 25fb082a20e29e83fb7b7ef5f5919166aad1f084 | https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L480-L482 |
150,385 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | NewPageReader | func NewPageReader(input io.Reader) *PageReader {
return &PageReader{
Input: input,
PageOptions: NewPageOptions(),
}
} | go | func NewPageReader(input io.Reader) *PageReader {
return &PageReader{
Input: input,
PageOptions: NewPageOptions(),
}
} | [
"func",
"NewPageReader",
"(",
"input",
"io",
".",
"Reader",
")",
"*",
"PageReader",
"{",
"return",
"&",
"PageReader",
"{",
"Input",
":",
"input",
",",
"PageOptions",
":",
"NewPageOptions",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewPageReader creates a new PageReader from an io.Reader | [
"NewPageReader",
"creates",
"a",
"new",
"PageReader",
"from",
"an",
"io",
".",
"Reader"
] | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L99-L104 |
150,386 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | Args | func (po *PageOptions) Args() []string {
return append(append([]string{}, po.pageOptions.Args()...), po.headerAndFooterOptions.Args()...)
} | go | func (po *PageOptions) Args() []string {
return append(append([]string{}, po.pageOptions.Args()...), po.headerAndFooterOptions.Args()...)
} | [
"func",
"(",
"po",
"*",
"PageOptions",
")",
"Args",
"(",
")",
"[",
"]",
"string",
"{",
"return",
"append",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"}",
",",
"po",
".",
"pageOptions",
".",
"Args",
"(",
")",
"...",
")",
",",
"po",
".",
"head... | // Args returns the argument slice | [
"Args",
"returns",
"the",
"argument",
"slice"
] | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L119-L121 |
150,387 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | Args | func (pdfg *PDFGenerator) Args() []string {
args := append([]string{}, pdfg.globalOptions.Args()...)
args = append(args, pdfg.outlineOptions.Args()...)
if pdfg.Cover.Input != "" {
args = append(args, "cover")
args = append(args, pdfg.Cover.Input)
args = append(args, pdfg.Cover.pageOptions.Args()...)
}
if pdf... | go | func (pdfg *PDFGenerator) Args() []string {
args := append([]string{}, pdfg.globalOptions.Args()...)
args = append(args, pdfg.outlineOptions.Args()...)
if pdfg.Cover.Input != "" {
args = append(args, "cover")
args = append(args, pdfg.Cover.Input)
args = append(args, pdfg.Cover.pageOptions.Args()...)
}
if pdf... | [
"func",
"(",
"pdfg",
"*",
"PDFGenerator",
")",
"Args",
"(",
")",
"[",
"]",
"string",
"{",
"args",
":=",
"append",
"(",
"[",
"]",
"string",
"{",
"}",
",",
"pdfg",
".",
"globalOptions",
".",
"Args",
"(",
")",
"...",
")",
"\n",
"args",
"=",
"append"... | //Args returns the commandline arguments as a string slice | [
"Args",
"returns",
"the",
"commandline",
"arguments",
"as",
"a",
"string",
"slice"
] | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L164-L188 |
150,388 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | AddPage | func (pdfg *PDFGenerator) AddPage(p page) {
pdfg.pages = append(pdfg.pages, p)
} | go | func (pdfg *PDFGenerator) AddPage(p page) {
pdfg.pages = append(pdfg.pages, p)
} | [
"func",
"(",
"pdfg",
"*",
"PDFGenerator",
")",
"AddPage",
"(",
"p",
"page",
")",
"{",
"pdfg",
".",
"pages",
"=",
"append",
"(",
"pdfg",
".",
"pages",
",",
"p",
")",
"\n",
"}"
] | // AddPage adds a new input page to the document.
// A page is an input HTML page, it can span multiple pages in the output document.
// It is a Page when read from file or URL or a PageReader when read from memory. | [
"AddPage",
"adds",
"a",
"new",
"input",
"page",
"to",
"the",
"document",
".",
"A",
"page",
"is",
"an",
"input",
"HTML",
"page",
"it",
"can",
"span",
"multiple",
"pages",
"in",
"the",
"output",
"document",
".",
"It",
"is",
"a",
"Page",
"when",
"read",
... | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L198-L200 |
150,389 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | WriteFile | func (pdfg *PDFGenerator) WriteFile(filename string) error {
return ioutil.WriteFile(filename, pdfg.Bytes(), 0666)
} | go | func (pdfg *PDFGenerator) WriteFile(filename string) error {
return ioutil.WriteFile(filename, pdfg.Bytes(), 0666)
} | [
"func",
"(",
"pdfg",
"*",
"PDFGenerator",
")",
"WriteFile",
"(",
"filename",
"string",
")",
"error",
"{",
"return",
"ioutil",
".",
"WriteFile",
"(",
"filename",
",",
"pdfg",
".",
"Bytes",
"(",
")",
",",
"0666",
")",
"\n",
"}"
] | // WriteFile writes the contents of the output buffer to a file | [
"WriteFile",
"writes",
"the",
"contents",
"of",
"the",
"output",
"buffer",
"to",
"a",
"file"
] | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L230-L232 |
150,390 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | findPath | func (pdfg *PDFGenerator) findPath() error {
const exe = "wkhtmltopdf"
pdfg.binPath = GetPath()
if pdfg.binPath != "" {
// wkhtmltopdf has already already found, return
return nil
}
exeDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
return err
}
path, err := exec.LookPath(filepath.Join(... | go | func (pdfg *PDFGenerator) findPath() error {
const exe = "wkhtmltopdf"
pdfg.binPath = GetPath()
if pdfg.binPath != "" {
// wkhtmltopdf has already already found, return
return nil
}
exeDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
return err
}
path, err := exec.LookPath(filepath.Join(... | [
"func",
"(",
"pdfg",
"*",
"PDFGenerator",
")",
"findPath",
"(",
")",
"error",
"{",
"const",
"exe",
"=",
"\"",
"\"",
"\n",
"pdfg",
".",
"binPath",
"=",
"GetPath",
"(",
")",
"\n",
"if",
"pdfg",
".",
"binPath",
"!=",
"\"",
"\"",
"{",
"// wkhtmltopdf has... | //findPath finds the path to wkhtmltopdf by
//- first looking in the current dir
//- looking in the PATH and PATHEXT environment dirs
//- using the WKHTMLTOPDF_PATH environment dir
//The path is cached, meaning you can not change the location of wkhtmltopdf in
//a running program once it has been found | [
"findPath",
"finds",
"the",
"path",
"to",
"wkhtmltopdf",
"by",
"-",
"first",
"looking",
"in",
"the",
"current",
"dir",
"-",
"looking",
"in",
"the",
"PATH",
"and",
"PATHEXT",
"environment",
"dirs",
"-",
"using",
"the",
"WKHTMLTOPDF_PATH",
"environment",
"dir",
... | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L240-L274 |
150,391 | SebastiaanKlippert/go-wkhtmltopdf | wkhtmltopdf.go | NewPDFGenerator | func NewPDFGenerator() (*PDFGenerator, error) {
pdfg := &PDFGenerator{
globalOptions: newGlobalOptions(),
outlineOptions: newOutlineOptions(),
Cover: cover{
pageOptions: newPageOptions(),
},
TOC: toc{
allTocOptions: allTocOptions{
tocOptions: newTocOptions(),
pageOptions: newPageOptions(),
... | go | func NewPDFGenerator() (*PDFGenerator, error) {
pdfg := &PDFGenerator{
globalOptions: newGlobalOptions(),
outlineOptions: newOutlineOptions(),
Cover: cover{
pageOptions: newPageOptions(),
},
TOC: toc{
allTocOptions: allTocOptions{
tocOptions: newTocOptions(),
pageOptions: newPageOptions(),
... | [
"func",
"NewPDFGenerator",
"(",
")",
"(",
"*",
"PDFGenerator",
",",
"error",
")",
"{",
"pdfg",
":=",
"&",
"PDFGenerator",
"{",
"globalOptions",
":",
"newGlobalOptions",
"(",
")",
",",
"outlineOptions",
":",
"newOutlineOptions",
"(",
")",
",",
"Cover",
":",
... | // NewPDFGenerator returns a new PDFGenerator struct with all options created and
// checks if wkhtmltopdf can be found on the system | [
"NewPDFGenerator",
"returns",
"a",
"new",
"PDFGenerator",
"struct",
"with",
"all",
"options",
"created",
"and",
"checks",
"if",
"wkhtmltopdf",
"can",
"be",
"found",
"on",
"the",
"system"
] | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L316-L332 |
150,392 | SebastiaanKlippert/go-wkhtmltopdf | json.go | ToJSON | func (pdfg *PDFGenerator) ToJSON() ([]byte, error) {
jpdf := &jsonPDFGenerator{
TOC: pdfg.TOC,
Cover: pdfg.Cover,
GlobalOptions: pdfg.globalOptions,
OutlineOptions: pdfg.outlineOptions,
}
for _, p := range pdfg.pages {
jp := jsonPage{
InputFile: p.InputFile(),
}
switch tp := p... | go | func (pdfg *PDFGenerator) ToJSON() ([]byte, error) {
jpdf := &jsonPDFGenerator{
TOC: pdfg.TOC,
Cover: pdfg.Cover,
GlobalOptions: pdfg.globalOptions,
OutlineOptions: pdfg.outlineOptions,
}
for _, p := range pdfg.pages {
jp := jsonPage{
InputFile: p.InputFile(),
}
switch tp := p... | [
"func",
"(",
"pdfg",
"*",
"PDFGenerator",
")",
"ToJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"jpdf",
":=",
"&",
"jsonPDFGenerator",
"{",
"TOC",
":",
"pdfg",
".",
"TOC",
",",
"Cover",
":",
"pdfg",
".",
"Cover",
",",
"GlobalOptio... | // ToJSON creates JSON of the complete representation of the PDFGenerator.
// It also saves all pages, for a PageReader page, the content is stored as a Base64 string in the JSON. | [
"ToJSON",
"creates",
"JSON",
"of",
"the",
"complete",
"representation",
"of",
"the",
"PDFGenerator",
".",
"It",
"also",
"saves",
"all",
"pages",
"for",
"a",
"PageReader",
"page",
"the",
"content",
"is",
"stored",
"as",
"a",
"Base64",
"string",
"in",
"the",
... | 72a7793efd38728796273861bb27d590cc33d9d4 | https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/json.go#L28-L57 |
150,393 | matcornic/hermes | examples/main.go | send | func send(smtpConfig smtpAuthentication, options sendOptions, htmlBody string, txtBody string) error {
if smtpConfig.Server == "" {
return errors.New("SMTP server config is empty")
}
if smtpConfig.Port == 0 {
return errors.New("SMTP port config is empty")
}
if smtpConfig.SMTPUser == "" {
return errors.New(... | go | func send(smtpConfig smtpAuthentication, options sendOptions, htmlBody string, txtBody string) error {
if smtpConfig.Server == "" {
return errors.New("SMTP server config is empty")
}
if smtpConfig.Port == 0 {
return errors.New("SMTP port config is empty")
}
if smtpConfig.SMTPUser == "" {
return errors.New(... | [
"func",
"send",
"(",
"smtpConfig",
"smtpAuthentication",
",",
"options",
"sendOptions",
",",
"htmlBody",
"string",
",",
"txtBody",
"string",
")",
"error",
"{",
"if",
"smtpConfig",
".",
"Server",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"... | // send sends the email | [
"send",
"sends",
"the",
"email"
] | 2f49bb14de85f0ec4940c93252d0e3289a59d5bd | https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/examples/main.go#L136-L177 |
150,394 | matcornic/hermes | hermes.go | ToHTML | func (c Markdown) ToHTML() template.HTML {
return template.HTML(blackfriday.Run([]byte(string(c))))
} | go | func (c Markdown) ToHTML() template.HTML {
return template.HTML(blackfriday.Run([]byte(string(c))))
} | [
"func",
"(",
"c",
"Markdown",
")",
"ToHTML",
"(",
")",
"template",
".",
"HTML",
"{",
"return",
"template",
".",
"HTML",
"(",
"blackfriday",
".",
"Run",
"(",
"[",
"]",
"byte",
"(",
"string",
"(",
"c",
")",
")",
")",
")",
"\n",
"}"
] | // ToHTML converts Markdown to HTML | [
"ToHTML",
"converts",
"Markdown",
"to",
"HTML"
] | 2f49bb14de85f0ec4940c93252d0e3289a59d5bd | https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L76-L78 |
150,395 | matcornic/hermes | hermes.go | setDefaultHermesValues | func setDefaultHermesValues(h *Hermes) error {
defaultTextDirection := TDLeftToRight
defaultHermes := Hermes{
Theme: new(Default),
TextDirection: defaultTextDirection,
Product: Product{
Name: "Hermes",
Copyright: "Copyright © 2019 Hermes. All rights reserved.",
TroubleText: "If you’re ... | go | func setDefaultHermesValues(h *Hermes) error {
defaultTextDirection := TDLeftToRight
defaultHermes := Hermes{
Theme: new(Default),
TextDirection: defaultTextDirection,
Product: Product{
Name: "Hermes",
Copyright: "Copyright © 2019 Hermes. All rights reserved.",
TroubleText: "If you’re ... | [
"func",
"setDefaultHermesValues",
"(",
"h",
"*",
"Hermes",
")",
"error",
"{",
"defaultTextDirection",
":=",
"TDLeftToRight",
"\n",
"defaultHermes",
":=",
"Hermes",
"{",
"Theme",
":",
"new",
"(",
"Default",
")",
",",
"TextDirection",
":",
"defaultTextDirection",
... | // default values of the engine | [
"default",
"values",
"of",
"the",
"engine"
] | 2f49bb14de85f0ec4940c93252d0e3289a59d5bd | https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L138-L159 |
150,396 | matcornic/hermes | hermes.go | GenerateHTML | func (h *Hermes) GenerateHTML(email Email) (string, error) {
err := setDefaultHermesValues(h)
if err != nil {
return "", err
}
return h.generateTemplate(email, h.Theme.HTMLTemplate())
} | go | func (h *Hermes) GenerateHTML(email Email) (string, error) {
err := setDefaultHermesValues(h)
if err != nil {
return "", err
}
return h.generateTemplate(email, h.Theme.HTMLTemplate())
} | [
"func",
"(",
"h",
"*",
"Hermes",
")",
"GenerateHTML",
"(",
"email",
"Email",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"setDefaultHermesValues",
"(",
"h",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\... | // GenerateHTML generates the email body from data to an HTML Reader
// This is for modern email clients | [
"GenerateHTML",
"generates",
"the",
"email",
"body",
"from",
"data",
"to",
"an",
"HTML",
"Reader",
"This",
"is",
"for",
"modern",
"email",
"clients"
] | 2f49bb14de85f0ec4940c93252d0e3289a59d5bd | https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L163-L169 |
150,397 | matcornic/hermes | hermes.go | GeneratePlainText | func (h *Hermes) GeneratePlainText(email Email) (string, error) {
err := setDefaultHermesValues(h)
if err != nil {
return "", err
}
template, err := h.generateTemplate(email, h.Theme.PlainTextTemplate())
if err != nil {
return "", err
}
return html2text.FromString(template, html2text.Options{PrettyTables: tr... | go | func (h *Hermes) GeneratePlainText(email Email) (string, error) {
err := setDefaultHermesValues(h)
if err != nil {
return "", err
}
template, err := h.generateTemplate(email, h.Theme.PlainTextTemplate())
if err != nil {
return "", err
}
return html2text.FromString(template, html2text.Options{PrettyTables: tr... | [
"func",
"(",
"h",
"*",
"Hermes",
")",
"GeneratePlainText",
"(",
"email",
"Email",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"setDefaultHermesValues",
"(",
"h",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",... | // GeneratePlainText generates the email body from data
// This is for old email clients | [
"GeneratePlainText",
"generates",
"the",
"email",
"body",
"from",
"data",
"This",
"is",
"for",
"old",
"email",
"clients"
] | 2f49bb14de85f0ec4940c93252d0e3289a59d5bd | https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L173-L183 |
150,398 | jordan-wright/email | pool.go | Send | func (p *Pool) Send(e *Email, timeout time.Duration) (err error) {
start := time.Now()
c := p.get(timeout)
if c == nil {
return p.failedToGet(start)
}
defer func() {
p.maybeReplace(err, c)
}()
recipients, err := addressLists(e.To, e.Cc, e.Bcc)
if err != nil {
return
}
msg, err := e.Bytes()
if err !=... | go | func (p *Pool) Send(e *Email, timeout time.Duration) (err error) {
start := time.Now()
c := p.get(timeout)
if c == nil {
return p.failedToGet(start)
}
defer func() {
p.maybeReplace(err, c)
}()
recipients, err := addressLists(e.To, e.Cc, e.Bcc)
if err != nil {
return
}
msg, err := e.Bytes()
if err !=... | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Send",
"(",
"e",
"*",
"Email",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"err",
"error",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"c",
":=",
"p",
".",
"get",
"(",
"timeout",
")... | // Send sends an email via a connection pulled from the Pool. The timeout may
// be <0 to indicate no timeout. Otherwise reaching the timeout will produce
// and error building a connection that occurred while we were waiting, or
// otherwise ErrTimeout. | [
"Send",
"sends",
"an",
"email",
"via",
"a",
"connection",
"pulled",
"from",
"the",
"Pool",
".",
"The",
"timeout",
"may",
"be",
"<0",
"to",
"indicate",
"no",
"timeout",
".",
"Otherwise",
"reaching",
"the",
"timeout",
"will",
"produce",
"and",
"error",
"buil... | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/pool.go#L266-L312 |
150,399 | jordan-wright/email | pool.go | Close | func (p *Pool) Close() {
close(p.closing)
for p.created > 0 {
c := <-p.clients
c.Quit()
p.dec()
}
} | go | func (p *Pool) Close() {
close(p.closing)
for p.created > 0 {
c := <-p.clients
c.Quit()
p.dec()
}
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Close",
"(",
")",
"{",
"close",
"(",
"p",
".",
"closing",
")",
"\n\n",
"for",
"p",
".",
"created",
">",
"0",
"{",
"c",
":=",
"<-",
"p",
".",
"clients",
"\n",
"c",
".",
"Quit",
"(",
")",
"\n",
"p",
".",
... | // Close immediately changes the pool's state so no new connections will be
// created, then gets and closes the existing ones as they become available. | [
"Close",
"immediately",
"changes",
"the",
"pool",
"s",
"state",
"so",
"no",
"new",
"connections",
"will",
"be",
"created",
"then",
"gets",
"and",
"closes",
"the",
"existing",
"ones",
"as",
"they",
"become",
"available",
"."
] | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/pool.go#L344-L352 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.