id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,100 | alecthomas/kingpin | parser.go | Next | func (p *ParseContext) Next() *Token {
if len(p.peek) > 0 {
return p.pop()
}
// End of tokens.
if len(p.args) == 0 {
return &Token{Index: p.argi, Type: TokenEOL}
}
arg := p.args[0]
p.next()
if p.argsOnly {
return &Token{p.argi, TokenArg, arg}
}
// All remaining args are passed directly.
if arg == "... | go | func (p *ParseContext) Next() *Token {
if len(p.peek) > 0 {
return p.pop()
}
// End of tokens.
if len(p.args) == 0 {
return &Token{Index: p.argi, Type: TokenEOL}
}
arg := p.args[0]
p.next()
if p.argsOnly {
return &Token{p.argi, TokenArg, arg}
}
// All remaining args are passed directly.
if arg == "... | [
"func",
"(",
"p",
"*",
"ParseContext",
")",
"Next",
"(",
")",
"*",
"Token",
"{",
"if",
"len",
"(",
"p",
".",
"peek",
")",
">",
"0",
"{",
"return",
"p",
".",
"pop",
"(",
")",
"\n",
"}",
"\n\n",
"// End of tokens.",
"if",
"len",
"(",
"p",
".",
... | // Next token in the parse context. | [
"Next",
"token",
"in",
"the",
"parse",
"context",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parser.go#L161-L231 |
26,101 | alecthomas/kingpin | usage.go | Usage | func (a *Application) Usage(args []string) {
context, err := a.parseContext(true, args)
a.FatalIfError(err, "")
if err := a.UsageForContextWithTemplate(context, 2, a.usageTemplate); err != nil {
panic(err)
}
} | go | func (a *Application) Usage(args []string) {
context, err := a.parseContext(true, args)
a.FatalIfError(err, "")
if err := a.UsageForContextWithTemplate(context, 2, a.usageTemplate); err != nil {
panic(err)
}
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"Usage",
"(",
"args",
"[",
"]",
"string",
")",
"{",
"context",
",",
"err",
":=",
"a",
".",
"parseContext",
"(",
"true",
",",
"args",
")",
"\n",
"a",
".",
"FatalIfError",
"(",
"err",
",",
"\"",
"\"",
")",... | // Usage writes application usage to w. It parses args to determine
// appropriate help context, such as which command to show help for. | [
"Usage",
"writes",
"application",
"usage",
"to",
"w",
".",
"It",
"parses",
"args",
"to",
"determine",
"appropriate",
"help",
"context",
"such",
"as",
"which",
"command",
"to",
"show",
"help",
"for",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/usage.go#L46-L52 |
26,102 | emersion/go-imap | search.go | ParseWithCharset | func (c *SearchCriteria) ParseWithCharset(fields []interface{}, charsetReader func(io.Reader) io.Reader) error {
for len(fields) > 0 {
var err error
if fields, err = c.parseField(fields, charsetReader); err != nil {
return err
}
}
return nil
} | go | func (c *SearchCriteria) ParseWithCharset(fields []interface{}, charsetReader func(io.Reader) io.Reader) error {
for len(fields) > 0 {
var err error
if fields, err = c.parseField(fields, charsetReader); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"SearchCriteria",
")",
"ParseWithCharset",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
",",
"charsetReader",
"func",
"(",
"io",
".",
"Reader",
")",
"io",
".",
"Reader",
")",
"error",
"{",
"for",
"len",
"(",
"fields",
")",
"... | // ParseWithCharset parses a search criteria from the provided fields.
// charsetReader is an optional function that converts from the fields charset
// to UTF-8. | [
"ParseWithCharset",
"parses",
"a",
"search",
"criteria",
"from",
"the",
"provided",
"fields",
".",
"charsetReader",
"is",
"an",
"optional",
"function",
"that",
"converts",
"from",
"the",
"fields",
"charset",
"to",
"UTF",
"-",
"8",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/search.go#L264-L272 |
26,103 | emersion/go-imap | backend/backendutil/envelope.go | FetchEnvelope | func FetchEnvelope(h message.Header) (*imap.Envelope, error) {
mh := mail.Header{Header: h}
env := new(imap.Envelope)
env.Date, _ = mh.Date()
env.Subject, _ = mh.Subject()
env.From, _ = headerAddressList(mh, "From")
env.Sender, _ = headerAddressList(mh, "Sender")
env.ReplyTo, _ = headerAddressList(mh, "Reply-To... | go | func FetchEnvelope(h message.Header) (*imap.Envelope, error) {
mh := mail.Header{Header: h}
env := new(imap.Envelope)
env.Date, _ = mh.Date()
env.Subject, _ = mh.Subject()
env.From, _ = headerAddressList(mh, "From")
env.Sender, _ = headerAddressList(mh, "Sender")
env.ReplyTo, _ = headerAddressList(mh, "Reply-To... | [
"func",
"FetchEnvelope",
"(",
"h",
"message",
".",
"Header",
")",
"(",
"*",
"imap",
".",
"Envelope",
",",
"error",
")",
"{",
"mh",
":=",
"mail",
".",
"Header",
"{",
"Header",
":",
"h",
"}",
"\n\n",
"env",
":=",
"new",
"(",
"imap",
".",
"Envelope",
... | // FetchEnvelope returns a message's envelope from its header. | [
"FetchEnvelope",
"returns",
"a",
"message",
"s",
"envelope",
"from",
"its",
"header",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/envelope.go#L34-L50 |
26,104 | emersion/go-imap | backend/backendutil/flags.go | UpdateFlags | func UpdateFlags(current []string, op imap.FlagsOp, flags []string) []string {
switch op {
case imap.SetFlags:
// TODO: keep \Recent if it is present
return flags
case imap.AddFlags:
// Check for duplicates
for _, flag := range current {
for i, addFlag := range flags {
if addFlag == flag {
flags ... | go | func UpdateFlags(current []string, op imap.FlagsOp, flags []string) []string {
switch op {
case imap.SetFlags:
// TODO: keep \Recent if it is present
return flags
case imap.AddFlags:
// Check for duplicates
for _, flag := range current {
for i, addFlag := range flags {
if addFlag == flag {
flags ... | [
"func",
"UpdateFlags",
"(",
"current",
"[",
"]",
"string",
",",
"op",
"imap",
".",
"FlagsOp",
",",
"flags",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"switch",
"op",
"{",
"case",
"imap",
".",
"SetFlags",
":",
"// TODO: keep \\Recent if it is presen... | // UpdateFlags executes a flag operation on the flag set current. | [
"UpdateFlags",
"executes",
"a",
"flag",
"operation",
"on",
"the",
"flag",
"set",
"current",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/flags.go#L8-L40 |
26,105 | emersion/go-imap | mailbox.go | CanonicalMailboxName | func CanonicalMailboxName(name string) string {
if strings.ToUpper(name) == InboxName {
return InboxName
}
return name
} | go | func CanonicalMailboxName(name string) string {
if strings.ToUpper(name) == InboxName {
return InboxName
}
return name
} | [
"func",
"CanonicalMailboxName",
"(",
"name",
"string",
")",
"string",
"{",
"if",
"strings",
".",
"ToUpper",
"(",
"name",
")",
"==",
"InboxName",
"{",
"return",
"InboxName",
"\n",
"}",
"\n",
"return",
"name",
"\n",
"}"
] | // CanonicalMailboxName returns the canonical form of a mailbox name. Mailbox names can be
// case-sensitive or case-insensitive depending on the backend implementation.
// The special INBOX mailbox is case-insensitive. | [
"CanonicalMailboxName",
"returns",
"the",
"canonical",
"form",
"of",
"a",
"mailbox",
"name",
".",
"Mailbox",
"names",
"can",
"be",
"case",
"-",
"sensitive",
"or",
"case",
"-",
"insensitive",
"depending",
"on",
"the",
"backend",
"implementation",
".",
"The",
"s... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/mailbox.go#L18-L23 |
26,106 | emersion/go-imap | mailbox.go | Parse | func (info *MailboxInfo) Parse(fields []interface{}) error {
if len(fields) < 3 {
return errors.New("Mailbox info needs at least 3 fields")
}
var err error
if info.Attributes, err = ParseStringList(fields[0]); err != nil {
return err
}
var ok bool
if info.Delimiter, ok = fields[1].(string); !ok {
return ... | go | func (info *MailboxInfo) Parse(fields []interface{}) error {
if len(fields) < 3 {
return errors.New("Mailbox info needs at least 3 fields")
}
var err error
if info.Attributes, err = ParseStringList(fields[0]); err != nil {
return err
}
var ok bool
if info.Delimiter, ok = fields[1].(string); !ok {
return ... | [
"func",
"(",
"info",
"*",
"MailboxInfo",
")",
"Parse",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"fields",
")",
"<",
"3",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"... | // Parse mailbox info from fields. | [
"Parse",
"mailbox",
"info",
"from",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/mailbox.go#L52-L76 |
26,107 | emersion/go-imap | mailbox.go | Format | func (info *MailboxInfo) Format() []interface{} {
name, _ := utf7.Encoding.NewEncoder().String(info.Name)
attrs := make([]interface{}, len(info.Attributes))
for i, attr := range info.Attributes {
attrs[i] = Atom(attr)
}
// Thunderbird doesn't understand delimiters if not quoted
return []interface{}{attrs, Quote... | go | func (info *MailboxInfo) Format() []interface{} {
name, _ := utf7.Encoding.NewEncoder().String(info.Name)
attrs := make([]interface{}, len(info.Attributes))
for i, attr := range info.Attributes {
attrs[i] = Atom(attr)
}
// Thunderbird doesn't understand delimiters if not quoted
return []interface{}{attrs, Quote... | [
"func",
"(",
"info",
"*",
"MailboxInfo",
")",
"Format",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"name",
",",
"_",
":=",
"utf7",
".",
"Encoding",
".",
"NewEncoder",
"(",
")",
".",
"String",
"(",
"info",
".",
"Name",
")",
"\n",
"attrs",
":=... | // Format mailbox info to fields. | [
"Format",
"mailbox",
"info",
"to",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/mailbox.go#L79-L87 |
26,108 | emersion/go-imap | mailbox.go | Match | func (info *MailboxInfo) Match(reference, pattern string) bool {
name := info.Name
if strings.HasPrefix(pattern, info.Delimiter) {
reference = ""
pattern = strings.TrimPrefix(pattern, info.Delimiter)
}
if reference != "" {
if !strings.HasSuffix(reference, info.Delimiter) {
reference += info.Delimiter
}
... | go | func (info *MailboxInfo) Match(reference, pattern string) bool {
name := info.Name
if strings.HasPrefix(pattern, info.Delimiter) {
reference = ""
pattern = strings.TrimPrefix(pattern, info.Delimiter)
}
if reference != "" {
if !strings.HasSuffix(reference, info.Delimiter) {
reference += info.Delimiter
}
... | [
"func",
"(",
"info",
"*",
"MailboxInfo",
")",
"Match",
"(",
"reference",
",",
"pattern",
"string",
")",
"bool",
"{",
"name",
":=",
"info",
".",
"Name",
"\n\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"pattern",
",",
"info",
".",
"Delimiter",
")",
"{",
... | // Match checks if a reference and a pattern matches this mailbox name, as
// defined in RFC 3501 section 6.3.8. | [
"Match",
"checks",
"if",
"a",
"reference",
"and",
"a",
"pattern",
"matches",
"this",
"mailbox",
"name",
"as",
"defined",
"in",
"RFC",
"3501",
"section",
"6",
".",
"3",
".",
"8",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/mailbox.go#L123-L141 |
26,109 | emersion/go-imap | mailbox.go | NewMailboxStatus | func NewMailboxStatus(name string, items []StatusItem) *MailboxStatus {
status := &MailboxStatus{
Name: name,
Items: make(map[StatusItem]interface{}),
}
for _, k := range items {
status.Items[k] = nil
}
return status
} | go | func NewMailboxStatus(name string, items []StatusItem) *MailboxStatus {
status := &MailboxStatus{
Name: name,
Items: make(map[StatusItem]interface{}),
}
for _, k := range items {
status.Items[k] = nil
}
return status
} | [
"func",
"NewMailboxStatus",
"(",
"name",
"string",
",",
"items",
"[",
"]",
"StatusItem",
")",
"*",
"MailboxStatus",
"{",
"status",
":=",
"&",
"MailboxStatus",
"{",
"Name",
":",
"name",
",",
"Items",
":",
"make",
"(",
"map",
"[",
"StatusItem",
"]",
"inter... | // Create a new mailbox status that will contain the specified items. | [
"Create",
"a",
"new",
"mailbox",
"status",
"that",
"will",
"contain",
"the",
"specified",
"items",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/mailbox.go#L179-L190 |
26,110 | emersion/go-imap | backend/updates.go | NewUpdate | func NewUpdate(username, mailbox string) Update {
return &update{
username: username,
mailbox: mailbox,
}
} | go | func NewUpdate(username, mailbox string) Update {
return &update{
username: username,
mailbox: mailbox,
}
} | [
"func",
"NewUpdate",
"(",
"username",
",",
"mailbox",
"string",
")",
"Update",
"{",
"return",
"&",
"update",
"{",
"username",
":",
"username",
",",
"mailbox",
":",
"mailbox",
",",
"}",
"\n",
"}"
] | // NewUpdate creates a new update. | [
"NewUpdate",
"creates",
"a",
"new",
"update",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/updates.go#L22-L27 |
26,111 | emersion/go-imap | client/client.go | State | func (c *Client) State() imap.ConnState {
c.locker.Lock()
state := c.state
c.locker.Unlock()
return state
} | go | func (c *Client) State() imap.ConnState {
c.locker.Lock()
state := c.state
c.locker.Unlock()
return state
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"State",
"(",
")",
"imap",
".",
"ConnState",
"{",
"c",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"state",
":=",
"c",
".",
"state",
"\n",
"c",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n",
"return",
"state... | // State returns the current connection state. | [
"State",
"returns",
"the",
"current",
"connection",
"state",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L278-L283 |
26,112 | emersion/go-imap | client/client.go | Mailbox | func (c *Client) Mailbox() *imap.MailboxStatus {
// c.Mailbox fields are not supposed to change, so we can return the pointer.
c.locker.Lock()
mbox := c.mailbox
c.locker.Unlock()
return mbox
} | go | func (c *Client) Mailbox() *imap.MailboxStatus {
// c.Mailbox fields are not supposed to change, so we can return the pointer.
c.locker.Lock()
mbox := c.mailbox
c.locker.Unlock()
return mbox
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Mailbox",
"(",
")",
"*",
"imap",
".",
"MailboxStatus",
"{",
"// c.Mailbox fields are not supposed to change, so we can return the pointer.",
"c",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"mbox",
":=",
"c",
".",
"mailbox"... | // Mailbox returns the selected mailbox. It returns nil if there isn't one. | [
"Mailbox",
"returns",
"the",
"selected",
"mailbox",
".",
"It",
"returns",
"nil",
"if",
"there",
"isn",
"t",
"one",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L286-L292 |
26,113 | emersion/go-imap | client/client.go | SetState | func (c *Client) SetState(state imap.ConnState, mailbox *imap.MailboxStatus) {
c.locker.Lock()
c.state = state
c.mailbox = mailbox
c.locker.Unlock()
} | go | func (c *Client) SetState(state imap.ConnState, mailbox *imap.MailboxStatus) {
c.locker.Lock()
c.state = state
c.mailbox = mailbox
c.locker.Unlock()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetState",
"(",
"state",
"imap",
".",
"ConnState",
",",
"mailbox",
"*",
"imap",
".",
"MailboxStatus",
")",
"{",
"c",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"state",
"=",
"state",
"\n",
"c",
".... | // SetState sets this connection's internal state.
//
// This function should not be called directly, it must only be used by
// libraries implementing extensions of the IMAP protocol. | [
"SetState",
"sets",
"this",
"connection",
"s",
"internal",
"state",
".",
"This",
"function",
"should",
"not",
"be",
"called",
"directly",
"it",
"must",
"only",
"be",
"used",
"by",
"libraries",
"implementing",
"extensions",
"of",
"the",
"IMAP",
"protocol",
"."
... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L298-L303 |
26,114 | emersion/go-imap | client/client.go | Execute | func (c *Client) Execute(cmdr imap.Commander, h responses.Handler) (*imap.StatusResp, error) {
return c.execute(cmdr, h)
} | go | func (c *Client) Execute(cmdr imap.Commander, h responses.Handler) (*imap.StatusResp, error) {
return c.execute(cmdr, h)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Execute",
"(",
"cmdr",
"imap",
".",
"Commander",
",",
"h",
"responses",
".",
"Handler",
")",
"(",
"*",
"imap",
".",
"StatusResp",
",",
"error",
")",
"{",
"return",
"c",
".",
"execute",
"(",
"cmdr",
",",
"h",
... | // Execute executes a generic command. cmdr is a value that can be converted to
// a raw command and h is a response handler. The function returns when the
// command has completed or failed, in this case err is nil. A non-nil err value
// indicates a network error.
//
// This function should not be called directly, it... | [
"Execute",
"executes",
"a",
"generic",
"command",
".",
"cmdr",
"is",
"a",
"value",
"that",
"can",
"be",
"converted",
"to",
"a",
"raw",
"command",
"and",
"h",
"is",
"a",
"response",
"handler",
".",
"The",
"function",
"returns",
"when",
"the",
"command",
"... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L312-L314 |
26,115 | emersion/go-imap | client/client.go | New | func New(conn net.Conn) (*Client, error) {
continues := make(chan bool)
w := imap.NewClientWriter(nil, continues)
r := imap.NewReader(nil)
c := &Client{
conn: imap.NewConn(conn, r, w),
replies: make(chan []byte),
loggedOut: make(chan struct{}),
state: imap.ConnectingState,
ErrorLog: log.New(o... | go | func New(conn net.Conn) (*Client, error) {
continues := make(chan bool)
w := imap.NewClientWriter(nil, continues)
r := imap.NewReader(nil)
c := &Client{
conn: imap.NewConn(conn, r, w),
replies: make(chan []byte),
loggedOut: make(chan struct{}),
state: imap.ConnectingState,
ErrorLog: log.New(o... | [
"func",
"New",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"continues",
":=",
"make",
"(",
"chan",
"bool",
")",
"\n",
"w",
":=",
"imap",
".",
"NewClientWriter",
"(",
"nil",
",",
"continues",
")",
"\n",
"r",
"... | // New creates a new client from an existing connection. | [
"New",
"creates",
"a",
"new",
"client",
"from",
"an",
"existing",
"connection",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L558-L575 |
26,116 | emersion/go-imap | client/client.go | Dial | func Dial(addr string) (c *Client, err error) {
conn, err := net.Dial("tcp", addr)
if err != nil {
return
}
c, err = New(conn)
return
} | go | func Dial(addr string) (c *Client, err error) {
conn, err := net.Dial("tcp", addr)
if err != nil {
return
}
c, err = New(conn)
return
} | [
"func",
"Dial",
"(",
"addr",
"string",
")",
"(",
"c",
"*",
"Client",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n... | // Dial connects to an IMAP server using an unencrypted connection. | [
"Dial",
"connects",
"to",
"an",
"IMAP",
"server",
"using",
"an",
"unencrypted",
"connection",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L578-L586 |
26,117 | emersion/go-imap | client/client.go | DialWithDialer | func DialWithDialer(dialer *net.Dialer, address string) (c *Client, err error) {
conn, err := dialer.Dial("tcp", address)
if err != nil {
return nil, err
}
// We don't return to the caller until we try to receive a greeting. As such,
// there is no way to set the client's Timeout for that action. As a
// worka... | go | func DialWithDialer(dialer *net.Dialer, address string) (c *Client, err error) {
conn, err := dialer.Dial("tcp", address)
if err != nil {
return nil, err
}
// We don't return to the caller until we try to receive a greeting. As such,
// there is no way to set the client's Timeout for that action. As a
// worka... | [
"func",
"DialWithDialer",
"(",
"dialer",
"*",
"net",
".",
"Dialer",
",",
"address",
"string",
")",
"(",
"c",
"*",
"Client",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"dialer",
".",
"Dial",
"(",
"\"",
"\"",
",",
"address",
")",
"\n",
... | // DialWithDialer connects to an IMAP server using an unencrypted connection
// using dialer.Dial.
//
// Among other uses, this allows to apply a dial timeout. | [
"DialWithDialer",
"connects",
"to",
"an",
"IMAP",
"server",
"using",
"an",
"unencrypted",
"connection",
"using",
"dialer",
".",
"Dial",
".",
"Among",
"other",
"uses",
"this",
"allows",
"to",
"apply",
"a",
"dial",
"timeout",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L592-L611 |
26,118 | emersion/go-imap | client/client.go | DialTLS | func DialTLS(addr string, tlsConfig *tls.Config) (c *Client, err error) {
conn, err := tls.Dial("tcp", addr, tlsConfig)
if err != nil {
return
}
c, err = New(conn)
c.isTLS = true
return
} | go | func DialTLS(addr string, tlsConfig *tls.Config) (c *Client, err error) {
conn, err := tls.Dial("tcp", addr, tlsConfig)
if err != nil {
return
}
c, err = New(conn)
c.isTLS = true
return
} | [
"func",
"DialTLS",
"(",
"addr",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"(",
"c",
"*",
"Client",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"tls",
".",
"Dial",
"(",
"\"",
"\"",
",",
"addr",
",",
"tlsConfig",
")",... | // DialTLS connects to an IMAP server using an encrypted connection. | [
"DialTLS",
"connects",
"to",
"an",
"IMAP",
"server",
"using",
"an",
"encrypted",
"connection",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L614-L623 |
26,119 | emersion/go-imap | client/client.go | DialWithDialerTLS | func DialWithDialerTLS(dialer *net.Dialer, addr string,
tlsConfig *tls.Config) (c *Client, err error) {
conn, err := tls.DialWithDialer(dialer, "tcp", addr, tlsConfig)
if err != nil {
return
}
// We don't return to the caller until we try to receive a greeting. As such,
// there is no way to set the client's T... | go | func DialWithDialerTLS(dialer *net.Dialer, addr string,
tlsConfig *tls.Config) (c *Client, err error) {
conn, err := tls.DialWithDialer(dialer, "tcp", addr, tlsConfig)
if err != nil {
return
}
// We don't return to the caller until we try to receive a greeting. As such,
// there is no way to set the client's T... | [
"func",
"DialWithDialerTLS",
"(",
"dialer",
"*",
"net",
".",
"Dialer",
",",
"addr",
"string",
",",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"(",
"c",
"*",
"Client",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"tls",
".",
"DialWithDia... | // DialWithDialerTLS connects to an IMAP server using an encrypted connection
// using dialer.Dial.
//
// Among other uses, this allows to apply a dial timeout. | [
"DialWithDialerTLS",
"connects",
"to",
"an",
"IMAP",
"server",
"using",
"an",
"encrypted",
"connection",
"using",
"dialer",
".",
"Dial",
".",
"Among",
"other",
"uses",
"this",
"allows",
"to",
"apply",
"a",
"dial",
"timeout",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/client.go#L629-L650 |
26,120 | emersion/go-imap | write.go | FormatStringList | func FormatStringList(list []string) (fields []interface{}) {
fields = make([]interface{}, len(list))
for i, v := range list {
fields[i] = v
}
return
} | go | func FormatStringList(list []string) (fields []interface{}) {
fields = make([]interface{}, len(list))
for i, v := range list {
fields[i] = v
}
return
} | [
"func",
"FormatStringList",
"(",
"list",
"[",
"]",
"string",
")",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"fields",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"list",
")",
")",
"\n",
"for",
"i",
",",
"... | // Convert a string list to a field list. | [
"Convert",
"a",
"string",
"list",
"to",
"a",
"field",
"list",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/write.go#L33-L39 |
26,121 | emersion/go-imap | write.go | isAscii | func isAscii(s string) bool {
for _, c := range s {
if c > unicode.MaxASCII || unicode.IsControl(c) {
return false
}
}
return true
} | go | func isAscii(s string) bool {
for _, c := range s {
if c > unicode.MaxASCII || unicode.IsControl(c) {
return false
}
}
return true
} | [
"func",
"isAscii",
"(",
"s",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"c",
":=",
"range",
"s",
"{",
"if",
"c",
">",
"unicode",
".",
"MaxASCII",
"||",
"unicode",
".",
"IsControl",
"(",
"c",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
... | // Check if a string is 8-bit clean. | [
"Check",
"if",
"a",
"string",
"is",
"8",
"-",
"bit",
"clean",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/write.go#L42-L49 |
26,122 | emersion/go-imap | write.go | writeString | func (w *Writer) writeString(s string) error {
_, err := io.WriteString(w.Writer, s)
return err
} | go | func (w *Writer) writeString(s string) error {
_, err := io.WriteString(w.Writer, s)
return err
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"writeString",
"(",
"s",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"io",
".",
"WriteString",
"(",
"w",
".",
"Writer",
",",
"s",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Helper function to write a string to w. | [
"Helper",
"function",
"to",
"write",
"a",
"string",
"to",
"w",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/write.go#L59-L62 |
26,123 | emersion/go-imap | utf7/decoder.go | decode | func decode(b64 []byte) []byte {
var b []byte
// Allocate a single block of memory large enough to store the Base64 data
// (if padding is required), UTF-16-BE bytes, and decoded UTF-8 bytes.
// Since a 2-byte UTF-16 sequence may expand into a 3-byte UTF-8 sequence,
// double the space allocation for UTF-8.
if n... | go | func decode(b64 []byte) []byte {
var b []byte
// Allocate a single block of memory large enough to store the Base64 data
// (if padding is required), UTF-16-BE bytes, and decoded UTF-8 bytes.
// Since a 2-byte UTF-16 sequence may expand into a 3-byte UTF-8 sequence,
// double the space allocation for UTF-8.
if n... | [
"func",
"decode",
"(",
"b64",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n\n",
"// Allocate a single block of memory large enough to store the Base64 data",
"// (if padding is required), UTF-16-BE bytes, and decoded UTF-8 bytes.",
"// Since ... | // Extracts UTF-16-BE bytes from base64 data and converts them to UTF-8.
// A nil slice is returned if the encoding is invalid. | [
"Extracts",
"UTF",
"-",
"16",
"-",
"BE",
"bytes",
"from",
"base64",
"data",
"and",
"converts",
"them",
"to",
"UTF",
"-",
"8",
".",
"A",
"nil",
"slice",
"is",
"returned",
"if",
"the",
"encoding",
"is",
"invalid",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/utf7/decoder.go#L105-L148 |
26,124 | emersion/go-imap | imap.go | Expand | func (item FetchItem) Expand() []FetchItem {
switch item {
case FetchAll:
return []FetchItem{FetchFlags, FetchInternalDate, FetchRFC822Size, FetchEnvelope}
case FetchFast:
return []FetchItem{FetchFlags, FetchInternalDate, FetchRFC822Size}
case FetchFull:
return []FetchItem{FetchFlags, FetchInternalDate, Fetch... | go | func (item FetchItem) Expand() []FetchItem {
switch item {
case FetchAll:
return []FetchItem{FetchFlags, FetchInternalDate, FetchRFC822Size, FetchEnvelope}
case FetchFast:
return []FetchItem{FetchFlags, FetchInternalDate, FetchRFC822Size}
case FetchFull:
return []FetchItem{FetchFlags, FetchInternalDate, Fetch... | [
"func",
"(",
"item",
"FetchItem",
")",
"Expand",
"(",
")",
"[",
"]",
"FetchItem",
"{",
"switch",
"item",
"{",
"case",
"FetchAll",
":",
"return",
"[",
"]",
"FetchItem",
"{",
"FetchFlags",
",",
"FetchInternalDate",
",",
"FetchRFC822Size",
",",
"FetchEnvelope",... | // Expand expands the item if it's a macro. | [
"Expand",
"expands",
"the",
"item",
"if",
"it",
"s",
"a",
"macro",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/imap.go#L46-L57 |
26,125 | emersion/go-imap | imap.go | FormatFlagsOp | func FormatFlagsOp(op FlagsOp, silent bool) StoreItem {
s := string(op)
if silent {
s += silentOp
}
return StoreItem(s)
} | go | func FormatFlagsOp(op FlagsOp, silent bool) StoreItem {
s := string(op)
if silent {
s += silentOp
}
return StoreItem(s)
} | [
"func",
"FormatFlagsOp",
"(",
"op",
"FlagsOp",
",",
"silent",
"bool",
")",
"StoreItem",
"{",
"s",
":=",
"string",
"(",
"op",
")",
"\n",
"if",
"silent",
"{",
"s",
"+=",
"silentOp",
"\n",
"}",
"\n",
"return",
"StoreItem",
"(",
"s",
")",
"\n",
"}"
] | // FormatFlagsOp returns the StoreItem that executes the flags operation op. | [
"FormatFlagsOp",
"returns",
"the",
"StoreItem",
"that",
"executes",
"the",
"flags",
"operation",
"op",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/imap.go#L79-L85 |
26,126 | emersion/go-imap | imap.go | ParseFlagsOp | func ParseFlagsOp(item StoreItem) (op FlagsOp, silent bool, err error) {
itemStr := string(item)
silent = strings.HasSuffix(itemStr, silentOp)
if silent {
itemStr = strings.TrimSuffix(itemStr, silentOp)
}
op = FlagsOp(itemStr)
if op != SetFlags && op != AddFlags && op != RemoveFlags {
err = errors.New("Unsup... | go | func ParseFlagsOp(item StoreItem) (op FlagsOp, silent bool, err error) {
itemStr := string(item)
silent = strings.HasSuffix(itemStr, silentOp)
if silent {
itemStr = strings.TrimSuffix(itemStr, silentOp)
}
op = FlagsOp(itemStr)
if op != SetFlags && op != AddFlags && op != RemoveFlags {
err = errors.New("Unsup... | [
"func",
"ParseFlagsOp",
"(",
"item",
"StoreItem",
")",
"(",
"op",
"FlagsOp",
",",
"silent",
"bool",
",",
"err",
"error",
")",
"{",
"itemStr",
":=",
"string",
"(",
"item",
")",
"\n",
"silent",
"=",
"strings",
".",
"HasSuffix",
"(",
"itemStr",
",",
"sile... | // ParseFlagsOp parses a flags operation from StoreItem. | [
"ParseFlagsOp",
"parses",
"a",
"flags",
"operation",
"from",
"StoreItem",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/imap.go#L88-L100 |
26,127 | emersion/go-imap | client/cmd_any.go | Capability | func (c *Client) Capability() (map[string]bool, error) {
cmd := &commands.Capability{}
if status, err := c.execute(cmd, nil); err != nil {
return nil, err
} else if err := status.Err(); err != nil {
return nil, err
}
c.locker.Lock()
caps := c.caps
c.locker.Unlock()
return caps, nil
} | go | func (c *Client) Capability() (map[string]bool, error) {
cmd := &commands.Capability{}
if status, err := c.execute(cmd, nil); err != nil {
return nil, err
} else if err := status.Err(); err != nil {
return nil, err
}
c.locker.Lock()
caps := c.caps
c.locker.Unlock()
return caps, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Capability",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"bool",
",",
"error",
")",
"{",
"cmd",
":=",
"&",
"commands",
".",
"Capability",
"{",
"}",
"\n\n",
"if",
"status",
",",
"err",
":=",
"c",
".",
"execute"... | // Capability requests a listing of capabilities that the server supports.
// Capabilities are often returned by the server with the greeting or with the
// STARTTLS and LOGIN responses, so usually explicitly requesting capabilities
// isn't needed.
//
// Most of the time, Support should be used instead. | [
"Capability",
"requests",
"a",
"listing",
"of",
"capabilities",
"that",
"the",
"server",
"supports",
".",
"Capabilities",
"are",
"often",
"returned",
"by",
"the",
"server",
"with",
"the",
"greeting",
"or",
"with",
"the",
"STARTTLS",
"and",
"LOGIN",
"responses",
... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_any.go#L20-L33 |
26,128 | emersion/go-imap | client/cmd_any.go | Support | func (c *Client) Support(cap string) (bool, error) {
c.locker.Lock()
ok := c.caps != nil
c.locker.Unlock()
// If capabilities are not cached, request them
if !ok {
if _, err := c.Capability(); err != nil {
return false, err
}
}
c.locker.Lock()
supported := c.caps[cap]
c.locker.Unlock()
return support... | go | func (c *Client) Support(cap string) (bool, error) {
c.locker.Lock()
ok := c.caps != nil
c.locker.Unlock()
// If capabilities are not cached, request them
if !ok {
if _, err := c.Capability(); err != nil {
return false, err
}
}
c.locker.Lock()
supported := c.caps[cap]
c.locker.Unlock()
return support... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Support",
"(",
"cap",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"c",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"ok",
":=",
"c",
".",
"caps",
"!=",
"nil",
"\n",
"c",
".",
"locker",
".",
"Unloc... | // Support checks if cap is a capability supported by the server. If the server
// hasn't sent its capabilities yet, Support requests them. | [
"Support",
"checks",
"if",
"cap",
"is",
"a",
"capability",
"supported",
"by",
"the",
"server",
".",
"If",
"the",
"server",
"hasn",
"t",
"sent",
"its",
"capabilities",
"yet",
"Support",
"requests",
"them",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_any.go#L37-L53 |
26,129 | emersion/go-imap | client/cmd_any.go | Noop | func (c *Client) Noop() error {
cmd := new(commands.Noop)
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | go | func (c *Client) Noop() error {
cmd := new(commands.Noop)
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Noop",
"(",
")",
"error",
"{",
"cmd",
":=",
"new",
"(",
"commands",
".",
"Noop",
")",
"\n\n",
"status",
",",
"err",
":=",
"c",
".",
"execute",
"(",
"cmd",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Noop always succeeds and does nothing.
//
// It can be used as a periodic poll for new messages or message status updates
// during a period of inactivity. It can also be used to reset any inactivity
// autologout timer on the server. | [
"Noop",
"always",
"succeeds",
"and",
"does",
"nothing",
".",
"It",
"can",
"be",
"used",
"as",
"a",
"periodic",
"poll",
"for",
"new",
"messages",
"or",
"message",
"status",
"updates",
"during",
"a",
"period",
"of",
"inactivity",
".",
"It",
"can",
"also",
... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_any.go#L60-L68 |
26,130 | emersion/go-imap | client/cmd_any.go | Logout | func (c *Client) Logout() error {
if c.State() == imap.LogoutState {
return ErrAlreadyLoggedOut
}
cmd := new(commands.Logout)
if status, err := c.execute(cmd, nil); err == errClosed {
// Server closed connection, that's what we want anyway
return nil
} else if err != nil {
return err
} else if status !=... | go | func (c *Client) Logout() error {
if c.State() == imap.LogoutState {
return ErrAlreadyLoggedOut
}
cmd := new(commands.Logout)
if status, err := c.execute(cmd, nil); err == errClosed {
// Server closed connection, that's what we want anyway
return nil
} else if err != nil {
return err
} else if status !=... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Logout",
"(",
")",
"error",
"{",
"if",
"c",
".",
"State",
"(",
")",
"==",
"imap",
".",
"LogoutState",
"{",
"return",
"ErrAlreadyLoggedOut",
"\n",
"}",
"\n\n",
"cmd",
":=",
"new",
"(",
"commands",
".",
"Logout",
... | // Logout gracefully closes the connection. | [
"Logout",
"gracefully",
"closes",
"the",
"connection",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_any.go#L71-L87 |
26,131 | emersion/go-imap | client/cmd_selected.go | Check | func (c *Client) Check() error {
if c.State() != imap.SelectedState {
return ErrNoMailboxSelected
}
cmd := new(commands.Check)
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | go | func (c *Client) Check() error {
if c.State() != imap.SelectedState {
return ErrNoMailboxSelected
}
cmd := new(commands.Check)
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Check",
"(",
")",
"error",
"{",
"if",
"c",
".",
"State",
"(",
")",
"!=",
"imap",
".",
"SelectedState",
"{",
"return",
"ErrNoMailboxSelected",
"\n",
"}",
"\n\n",
"cmd",
":=",
"new",
"(",
"commands",
".",
"Check",... | // Check requests a checkpoint of the currently selected mailbox. A checkpoint
// refers to any implementation-dependent housekeeping associated with the
// mailbox that is not normally executed as part of each command. | [
"Check",
"requests",
"a",
"checkpoint",
"of",
"the",
"currently",
"selected",
"mailbox",
".",
"A",
"checkpoint",
"refers",
"to",
"any",
"implementation",
"-",
"dependent",
"housekeeping",
"associated",
"with",
"the",
"mailbox",
"that",
"is",
"not",
"normally",
"... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L18-L31 |
26,132 | emersion/go-imap | client/cmd_selected.go | Close | func (c *Client) Close() error {
if c.State() != imap.SelectedState {
return ErrNoMailboxSelected
}
cmd := new(commands.Close)
status, err := c.execute(cmd, nil)
if err != nil {
return err
} else if err := status.Err(); err != nil {
return err
}
c.locker.Lock()
c.state = imap.AuthenticatedState
c.mai... | go | func (c *Client) Close() error {
if c.State() != imap.SelectedState {
return ErrNoMailboxSelected
}
cmd := new(commands.Close)
status, err := c.execute(cmd, nil)
if err != nil {
return err
} else if err := status.Err(); err != nil {
return err
}
c.locker.Lock()
c.state = imap.AuthenticatedState
c.mai... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
".",
"State",
"(",
")",
"!=",
"imap",
".",
"SelectedState",
"{",
"return",
"ErrNoMailboxSelected",
"\n",
"}",
"\n\n",
"cmd",
":=",
"new",
"(",
"commands",
".",
"Close",... | // Close permanently removes all messages that have the \Deleted flag set from
// the currently selected mailbox, and returns to the authenticated state from
// the selected state. | [
"Close",
"permanently",
"removes",
"all",
"messages",
"that",
"have",
"the",
"\\",
"Deleted",
"flag",
"set",
"from",
"the",
"currently",
"selected",
"mailbox",
"and",
"returns",
"to",
"the",
"authenticated",
"state",
"from",
"the",
"selected",
"state",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L36-L55 |
26,133 | emersion/go-imap | client/cmd_selected.go | Expunge | func (c *Client) Expunge(ch chan uint32) error {
if c.State() != imap.SelectedState {
return ErrNoMailboxSelected
}
cmd := new(commands.Expunge)
var h responses.Handler
if ch != nil {
h = &responses.Expunge{SeqNums: ch}
defer close(ch)
}
status, err := c.execute(cmd, h)
if err != nil {
return err
}
... | go | func (c *Client) Expunge(ch chan uint32) error {
if c.State() != imap.SelectedState {
return ErrNoMailboxSelected
}
cmd := new(commands.Expunge)
var h responses.Handler
if ch != nil {
h = &responses.Expunge{SeqNums: ch}
defer close(ch)
}
status, err := c.execute(cmd, h)
if err != nil {
return err
}
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Expunge",
"(",
"ch",
"chan",
"uint32",
")",
"error",
"{",
"if",
"c",
".",
"State",
"(",
")",
"!=",
"imap",
".",
"SelectedState",
"{",
"return",
"ErrNoMailboxSelected",
"\n",
"}",
"\n\n",
"cmd",
":=",
"new",
"(",... | // Expunge permanently removes all messages that have the \Deleted flag set from
// the currently selected mailbox. If ch is not nil, sends sequence IDs of each
// deleted message to this channel. | [
"Expunge",
"permanently",
"removes",
"all",
"messages",
"that",
"have",
"the",
"\\",
"Deleted",
"flag",
"set",
"from",
"the",
"currently",
"selected",
"mailbox",
".",
"If",
"ch",
"is",
"not",
"nil",
"sends",
"sequence",
"IDs",
"of",
"each",
"deleted",
"messa... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L65-L83 |
26,134 | emersion/go-imap | client/cmd_selected.go | UidSearch | func (c *Client) UidSearch(criteria *imap.SearchCriteria) (uids []uint32, err error) {
return c.search(true, criteria)
} | go | func (c *Client) UidSearch(criteria *imap.SearchCriteria) (uids []uint32, err error) {
return c.search(true, criteria)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UidSearch",
"(",
"criteria",
"*",
"imap",
".",
"SearchCriteria",
")",
"(",
"uids",
"[",
"]",
"uint32",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"search",
"(",
"true",
",",
"criteria",
")",
"\n",
"}"
... | // UidSearch is identical to Search, but UIDs are returned instead of message
// sequence numbers. | [
"UidSearch",
"is",
"identical",
"to",
"Search",
"but",
"UIDs",
"are",
"returned",
"instead",
"of",
"message",
"sequence",
"numbers",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L132-L134 |
26,135 | emersion/go-imap | client/cmd_selected.go | Fetch | func (c *Client) Fetch(seqset *imap.SeqSet, items []imap.FetchItem, ch chan *imap.Message) error {
return c.fetch(false, seqset, items, ch)
} | go | func (c *Client) Fetch(seqset *imap.SeqSet, items []imap.FetchItem, ch chan *imap.Message) error {
return c.fetch(false, seqset, items, ch)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Fetch",
"(",
"seqset",
"*",
"imap",
".",
"SeqSet",
",",
"items",
"[",
"]",
"imap",
".",
"FetchItem",
",",
"ch",
"chan",
"*",
"imap",
".",
"Message",
")",
"error",
"{",
"return",
"c",
".",
"fetch",
"(",
"fals... | // Fetch retrieves data associated with a message in the mailbox. See RFC 3501
// section 6.4.5 for a list of items that can be requested. | [
"Fetch",
"retrieves",
"data",
"associated",
"with",
"a",
"message",
"in",
"the",
"mailbox",
".",
"See",
"RFC",
"3501",
"section",
"6",
".",
"4",
".",
"5",
"for",
"a",
"list",
"of",
"items",
"that",
"can",
"be",
"requested",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L162-L164 |
26,136 | emersion/go-imap | client/cmd_selected.go | UidFetch | func (c *Client) UidFetch(seqset *imap.SeqSet, items []imap.FetchItem, ch chan *imap.Message) error {
return c.fetch(true, seqset, items, ch)
} | go | func (c *Client) UidFetch(seqset *imap.SeqSet, items []imap.FetchItem, ch chan *imap.Message) error {
return c.fetch(true, seqset, items, ch)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UidFetch",
"(",
"seqset",
"*",
"imap",
".",
"SeqSet",
",",
"items",
"[",
"]",
"imap",
".",
"FetchItem",
",",
"ch",
"chan",
"*",
"imap",
".",
"Message",
")",
"error",
"{",
"return",
"c",
".",
"fetch",
"(",
"t... | // UidFetch is identical to Fetch, but seqset is interpreted as containing
// unique identifiers instead of message sequence numbers. | [
"UidFetch",
"is",
"identical",
"to",
"Fetch",
"but",
"seqset",
"is",
"interpreted",
"as",
"containing",
"unique",
"identifiers",
"instead",
"of",
"message",
"sequence",
"numbers",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L168-L170 |
26,137 | emersion/go-imap | client/cmd_selected.go | Store | func (c *Client) Store(seqset *imap.SeqSet, item imap.StoreItem, value interface{}, ch chan *imap.Message) error {
return c.store(false, seqset, item, value, ch)
} | go | func (c *Client) Store(seqset *imap.SeqSet, item imap.StoreItem, value interface{}, ch chan *imap.Message) error {
return c.store(false, seqset, item, value, ch)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Store",
"(",
"seqset",
"*",
"imap",
".",
"SeqSet",
",",
"item",
"imap",
".",
"StoreItem",
",",
"value",
"interface",
"{",
"}",
",",
"ch",
"chan",
"*",
"imap",
".",
"Message",
")",
"error",
"{",
"return",
"c",
... | // Store alters data associated with a message in the mailbox. If ch is not nil,
// the updated value of the data will be sent to this channel. See RFC 3501
// section 6.4.6 for a list of items that can be updated. | [
"Store",
"alters",
"data",
"associated",
"with",
"a",
"message",
"in",
"the",
"mailbox",
".",
"If",
"ch",
"is",
"not",
"nil",
"the",
"updated",
"value",
"of",
"the",
"data",
"will",
"be",
"sent",
"to",
"this",
"channel",
".",
"See",
"RFC",
"3501",
"sec... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L220-L222 |
26,138 | emersion/go-imap | client/cmd_selected.go | UidStore | func (c *Client) UidStore(seqset *imap.SeqSet, item imap.StoreItem, value interface{}, ch chan *imap.Message) error {
return c.store(true, seqset, item, value, ch)
} | go | func (c *Client) UidStore(seqset *imap.SeqSet, item imap.StoreItem, value interface{}, ch chan *imap.Message) error {
return c.store(true, seqset, item, value, ch)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UidStore",
"(",
"seqset",
"*",
"imap",
".",
"SeqSet",
",",
"item",
"imap",
".",
"StoreItem",
",",
"value",
"interface",
"{",
"}",
",",
"ch",
"chan",
"*",
"imap",
".",
"Message",
")",
"error",
"{",
"return",
"c... | // UidStore is identical to Store, but seqset is interpreted as containing
// unique identifiers instead of message sequence numbers. | [
"UidStore",
"is",
"identical",
"to",
"Store",
"but",
"seqset",
"is",
"interpreted",
"as",
"containing",
"unique",
"identifiers",
"instead",
"of",
"message",
"sequence",
"numbers",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L226-L228 |
26,139 | emersion/go-imap | client/cmd_selected.go | UidCopy | func (c *Client) UidCopy(seqset *imap.SeqSet, dest string) error {
return c.copy(true, seqset, dest)
} | go | func (c *Client) UidCopy(seqset *imap.SeqSet, dest string) error {
return c.copy(true, seqset, dest)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UidCopy",
"(",
"seqset",
"*",
"imap",
".",
"SeqSet",
",",
"dest",
"string",
")",
"error",
"{",
"return",
"c",
".",
"copy",
"(",
"true",
",",
"seqset",
",",
"dest",
")",
"\n",
"}"
] | // UidCopy is identical to Copy, but seqset is interpreted as containing unique
// identifiers instead of message sequence numbers. | [
"UidCopy",
"is",
"identical",
"to",
"Copy",
"but",
"seqset",
"is",
"interpreted",
"as",
"containing",
"unique",
"identifiers",
"instead",
"of",
"message",
"sequence",
"numbers",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_selected.go#L258-L260 |
26,140 | emersion/go-imap | conn.go | NewDebugWriter | func NewDebugWriter(local, remote io.Writer) io.Writer {
return &debugWriter{Writer: local, local: local, remote: remote}
} | go | func NewDebugWriter(local, remote io.Writer) io.Writer {
return &debugWriter{Writer: local, local: local, remote: remote}
} | [
"func",
"NewDebugWriter",
"(",
"local",
",",
"remote",
"io",
".",
"Writer",
")",
"io",
".",
"Writer",
"{",
"return",
"&",
"debugWriter",
"{",
"Writer",
":",
"local",
",",
"local",
":",
"local",
",",
"remote",
":",
"remote",
"}",
"\n",
"}"
] | // NewDebugWriter creates a new io.Writer that will write local network activity
// to local and remote network activity to remote. | [
"NewDebugWriter",
"creates",
"a",
"new",
"io",
".",
"Writer",
"that",
"will",
"write",
"local",
"network",
"activity",
"to",
"local",
"and",
"remote",
"network",
"activity",
"to",
"remote",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/conn.go#L117-L119 |
26,141 | emersion/go-imap | conn.go | NewConn | func NewConn(conn net.Conn, r *Reader, w *Writer) *Conn {
c := &Conn{Conn: conn, Reader: r, Writer: w}
c.init()
return c
} | go | func NewConn(conn net.Conn, r *Reader, w *Writer) *Conn {
c := &Conn{Conn: conn, Reader: r, Writer: w}
c.init()
return c
} | [
"func",
"NewConn",
"(",
"conn",
"net",
".",
"Conn",
",",
"r",
"*",
"Reader",
",",
"w",
"*",
"Writer",
")",
"*",
"Conn",
"{",
"c",
":=",
"&",
"Conn",
"{",
"Conn",
":",
"conn",
",",
"Reader",
":",
"r",
",",
"Writer",
":",
"w",
"}",
"\n\n",
"c",... | // NewConn creates a new IMAP connection. | [
"NewConn",
"creates",
"a",
"new",
"IMAP",
"connection",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/conn.go#L154-L159 |
26,142 | emersion/go-imap | seqset.go | Less | func (s Seq) Less(q uint32) bool {
return (s.Stop < q || q == 0) && s.Stop != 0
} | go | func (s Seq) Less(q uint32) bool {
return (s.Stop < q || q == 0) && s.Stop != 0
} | [
"func",
"(",
"s",
"Seq",
")",
"Less",
"(",
"q",
"uint32",
")",
"bool",
"{",
"return",
"(",
"s",
".",
"Stop",
"<",
"q",
"||",
"q",
"==",
"0",
")",
"&&",
"s",
".",
"Stop",
"!=",
"0",
"\n",
"}"
] | // Less returns true if s precedes and does not contain seq-number q. | [
"Less",
"returns",
"true",
"if",
"s",
"precedes",
"and",
"does",
"not",
"contain",
"seq",
"-",
"number",
"q",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L65-L67 |
26,143 | emersion/go-imap | seqset.go | Merge | func (s Seq) Merge(t Seq) (union Seq, ok bool) {
if union = s; s == t {
ok = true
return
}
if s.Start != 0 && t.Start != 0 {
// s and t are any combination of "n", "n:m", or "n:*"
if s.Start > t.Start {
s, t = t, s
}
// s starts at or before t, check where it ends
if (s.Stop >= t.Stop && t.Stop != 0... | go | func (s Seq) Merge(t Seq) (union Seq, ok bool) {
if union = s; s == t {
ok = true
return
}
if s.Start != 0 && t.Start != 0 {
// s and t are any combination of "n", "n:m", or "n:*"
if s.Start > t.Start {
s, t = t, s
}
// s starts at or before t, check where it ends
if (s.Stop >= t.Stop && t.Stop != 0... | [
"func",
"(",
"s",
"Seq",
")",
"Merge",
"(",
"t",
"Seq",
")",
"(",
"union",
"Seq",
",",
"ok",
"bool",
")",
"{",
"if",
"union",
"=",
"s",
";",
"s",
"==",
"t",
"{",
"ok",
"=",
"true",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"s",
".",
"Start",
... | // Merge combines sequence values s and t into a single union if the two
// intersect or one is a superset of the other. The order of s and t does not
// matter. If the values cannot be merged, s is returned unmodified and ok is
// set to false. | [
"Merge",
"combines",
"sequence",
"values",
"s",
"and",
"t",
"into",
"a",
"single",
"union",
"if",
"the",
"two",
"intersect",
"or",
"one",
"is",
"a",
"superset",
"of",
"the",
"other",
".",
"The",
"order",
"of",
"s",
"and",
"t",
"does",
"not",
"matter",
... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L73-L102 |
26,144 | emersion/go-imap | seqset.go | String | func (s Seq) String() string {
if s.Start == s.Stop {
if s.Start == 0 {
return "*"
}
return strconv.FormatUint(uint64(s.Start), 10)
}
b := strconv.AppendUint(make([]byte, 0, 24), uint64(s.Start), 10)
if s.Stop == 0 {
return string(append(b, ':', '*'))
}
return string(strconv.AppendUint(append(b, ':'), ... | go | func (s Seq) String() string {
if s.Start == s.Stop {
if s.Start == 0 {
return "*"
}
return strconv.FormatUint(uint64(s.Start), 10)
}
b := strconv.AppendUint(make([]byte, 0, 24), uint64(s.Start), 10)
if s.Stop == 0 {
return string(append(b, ':', '*'))
}
return string(strconv.AppendUint(append(b, ':'), ... | [
"func",
"(",
"s",
"Seq",
")",
"String",
"(",
")",
"string",
"{",
"if",
"s",
".",
"Start",
"==",
"s",
".",
"Stop",
"{",
"if",
"s",
".",
"Start",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"strconv",
".",
"FormatUint",
"(",
... | // String returns sequence value s as a seq-number or seq-range string. | [
"String",
"returns",
"sequence",
"value",
"s",
"as",
"a",
"seq",
"-",
"number",
"or",
"seq",
"-",
"range",
"string",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L105-L117 |
26,145 | emersion/go-imap | seqset.go | ParseSeqSet | func ParseSeqSet(set string) (s *SeqSet, err error) {
s = new(SeqSet)
return s, s.Add(set)
} | go | func ParseSeqSet(set string) (s *SeqSet, err error) {
s = new(SeqSet)
return s, s.Add(set)
} | [
"func",
"ParseSeqSet",
"(",
"set",
"string",
")",
"(",
"s",
"*",
"SeqSet",
",",
"err",
"error",
")",
"{",
"s",
"=",
"new",
"(",
"SeqSet",
")",
"\n",
"return",
"s",
",",
"s",
".",
"Add",
"(",
"set",
")",
"\n",
"}"
] | // ParseSeqSet returns a new SeqSet instance after parsing the set string. | [
"ParseSeqSet",
"returns",
"a",
"new",
"SeqSet",
"instance",
"after",
"parsing",
"the",
"set",
"string",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L126-L129 |
26,146 | emersion/go-imap | seqset.go | Add | func (s *SeqSet) Add(set string) error {
for _, sv := range strings.Split(set, ",") {
v, err := parseSeq(sv)
if err != nil {
return err
}
s.insert(v)
}
return nil
} | go | func (s *SeqSet) Add(set string) error {
for _, sv := range strings.Split(set, ",") {
v, err := parseSeq(sv)
if err != nil {
return err
}
s.insert(v)
}
return nil
} | [
"func",
"(",
"s",
"*",
"SeqSet",
")",
"Add",
"(",
"set",
"string",
")",
"error",
"{",
"for",
"_",
",",
"sv",
":=",
"range",
"strings",
".",
"Split",
"(",
"set",
",",
"\"",
"\"",
")",
"{",
"v",
",",
"err",
":=",
"parseSeq",
"(",
"sv",
")",
"\n... | // Add inserts new sequence values into the set. The string format is described
// by RFC 3501 sequence-set ABNF rule. If an error is encountered, all values
// inserted successfully prior to the error remain in the set. | [
"Add",
"inserts",
"new",
"sequence",
"values",
"into",
"the",
"set",
".",
"The",
"string",
"format",
"is",
"described",
"by",
"RFC",
"3501",
"sequence",
"-",
"set",
"ABNF",
"rule",
".",
"If",
"an",
"error",
"is",
"encountered",
"all",
"values",
"inserted",... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L134-L143 |
26,147 | emersion/go-imap | seqset.go | AddRange | func (s *SeqSet) AddRange(Start, Stop uint32) {
if (Stop < Start && Stop != 0) || Start == 0 {
s.insert(Seq{Stop, Start})
} else {
s.insert(Seq{Start, Stop})
}
} | go | func (s *SeqSet) AddRange(Start, Stop uint32) {
if (Stop < Start && Stop != 0) || Start == 0 {
s.insert(Seq{Stop, Start})
} else {
s.insert(Seq{Start, Stop})
}
} | [
"func",
"(",
"s",
"*",
"SeqSet",
")",
"AddRange",
"(",
"Start",
",",
"Stop",
"uint32",
")",
"{",
"if",
"(",
"Stop",
"<",
"Start",
"&&",
"Stop",
"!=",
"0",
")",
"||",
"Start",
"==",
"0",
"{",
"s",
".",
"insert",
"(",
"Seq",
"{",
"Stop",
",",
"... | // AddRange inserts a new sequence range into the set. | [
"AddRange",
"inserts",
"a",
"new",
"sequence",
"range",
"into",
"the",
"set",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L153-L159 |
26,148 | emersion/go-imap | seqset.go | AddSet | func (s *SeqSet) AddSet(t *SeqSet) {
for _, v := range t.Set {
s.insert(v)
}
} | go | func (s *SeqSet) AddSet(t *SeqSet) {
for _, v := range t.Set {
s.insert(v)
}
} | [
"func",
"(",
"s",
"*",
"SeqSet",
")",
"AddSet",
"(",
"t",
"*",
"SeqSet",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"t",
".",
"Set",
"{",
"s",
".",
"insert",
"(",
"v",
")",
"\n",
"}",
"\n",
"}"
] | // AddSet inserts all values from t into s. | [
"AddSet",
"inserts",
"all",
"values",
"from",
"t",
"into",
"s",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L162-L166 |
26,149 | emersion/go-imap | seqset.go | String | func (s SeqSet) String() string {
if len(s.Set) == 0 {
return ""
}
b := make([]byte, 0, 64)
for _, v := range s.Set {
b = append(b, ',')
if v.Start == 0 {
b = append(b, '*')
continue
}
b = strconv.AppendUint(b, uint64(v.Start), 10)
if v.Start != v.Stop {
if v.Stop == 0 {
b = append(b, ':', ... | go | func (s SeqSet) String() string {
if len(s.Set) == 0 {
return ""
}
b := make([]byte, 0, 64)
for _, v := range s.Set {
b = append(b, ',')
if v.Start == 0 {
b = append(b, '*')
continue
}
b = strconv.AppendUint(b, uint64(v.Start), 10)
if v.Start != v.Stop {
if v.Stop == 0 {
b = append(b, ':', ... | [
"func",
"(",
"s",
"SeqSet",
")",
"String",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"s",
".",
"Set",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"64",
")",
"\n",
"... | // String returns a sorted representation of all contained sequence values. | [
"String",
"returns",
"a",
"sorted",
"representation",
"of",
"all",
"contained",
"sequence",
"values",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L196-L217 |
26,150 | emersion/go-imap | seqset.go | insert | func (s *SeqSet) insert(v Seq) {
i, _ := s.search(v.Start)
merged := false
if i > 0 {
// try merging with the preceding entry (e.g. "1,4".insert(2), i == 1)
s.Set[i-1], merged = s.Set[i-1].Merge(v)
}
if i == len(s.Set) {
// v was either merged with the last entry or needs to be appended
if !merged {
s.i... | go | func (s *SeqSet) insert(v Seq) {
i, _ := s.search(v.Start)
merged := false
if i > 0 {
// try merging with the preceding entry (e.g. "1,4".insert(2), i == 1)
s.Set[i-1], merged = s.Set[i-1].Merge(v)
}
if i == len(s.Set) {
// v was either merged with the last entry or needs to be appended
if !merged {
s.i... | [
"func",
"(",
"s",
"*",
"SeqSet",
")",
"insert",
"(",
"v",
"Seq",
")",
"{",
"i",
",",
"_",
":=",
"s",
".",
"search",
"(",
"v",
".",
"Start",
")",
"\n",
"merged",
":=",
"false",
"\n",
"if",
"i",
">",
"0",
"{",
"// try merging with the preceding entry... | // insert adds sequence value v to the set. | [
"insert",
"adds",
"sequence",
"value",
"v",
"to",
"the",
"set",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L220-L251 |
26,151 | emersion/go-imap | seqset.go | insertAt | func (s *SeqSet) insertAt(i int, v Seq) {
if n := len(s.Set); i == n {
// insert at the end
s.Set = append(s.Set, v)
return
} else if n < cap(s.Set) {
// enough space, shift everything at and after i to the right
s.Set = s.Set[:n+1]
copy(s.Set[i+1:], s.Set[i:])
} else {
// allocate new slice and copy e... | go | func (s *SeqSet) insertAt(i int, v Seq) {
if n := len(s.Set); i == n {
// insert at the end
s.Set = append(s.Set, v)
return
} else if n < cap(s.Set) {
// enough space, shift everything at and after i to the right
s.Set = s.Set[:n+1]
copy(s.Set[i+1:], s.Set[i:])
} else {
// allocate new slice and copy e... | [
"func",
"(",
"s",
"*",
"SeqSet",
")",
"insertAt",
"(",
"i",
"int",
",",
"v",
"Seq",
")",
"{",
"if",
"n",
":=",
"len",
"(",
"s",
".",
"Set",
")",
";",
"i",
"==",
"n",
"{",
"// insert at the end",
"s",
".",
"Set",
"=",
"append",
"(",
"s",
".",
... | // insertAt inserts a new sequence value v at index i, resizing s.Set as needed. | [
"insertAt",
"inserts",
"a",
"new",
"sequence",
"value",
"v",
"at",
"index",
"i",
"resizing",
"s",
".",
"Set",
"as",
"needed",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L254-L271 |
26,152 | emersion/go-imap | seqset.go | search | func (s SeqSet) search(q uint32) (i int, ok bool) {
min, max := 0, len(s.Set)-1
for min < max {
if mid := (min + max) >> 1; s.Set[mid].Less(q) {
min = mid + 1
} else {
max = mid
}
}
if max < 0 || s.Set[min].Less(q) {
return len(s.Set), false // q is the new largest value
}
return min, s.Set[min].Con... | go | func (s SeqSet) search(q uint32) (i int, ok bool) {
min, max := 0, len(s.Set)-1
for min < max {
if mid := (min + max) >> 1; s.Set[mid].Less(q) {
min = mid + 1
} else {
max = mid
}
}
if max < 0 || s.Set[min].Less(q) {
return len(s.Set), false // q is the new largest value
}
return min, s.Set[min].Con... | [
"func",
"(",
"s",
"SeqSet",
")",
"search",
"(",
"q",
"uint32",
")",
"(",
"i",
"int",
",",
"ok",
"bool",
")",
"{",
"min",
",",
"max",
":=",
"0",
",",
"len",
"(",
"s",
".",
"Set",
")",
"-",
"1",
"\n",
"for",
"min",
"<",
"max",
"{",
"if",
"m... | // search attempts to find the index of the sequence set value that contains q.
// If no values contain q, the returned index is the position where q should be
// inserted and ok is set to false. | [
"search",
"attempts",
"to",
"find",
"the",
"index",
"of",
"the",
"sequence",
"set",
"value",
"that",
"contains",
"q",
".",
"If",
"no",
"values",
"contain",
"q",
"the",
"returned",
"index",
"is",
"the",
"position",
"where",
"q",
"should",
"be",
"inserted",
... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/seqset.go#L276-L289 |
26,153 | emersion/go-imap | status.go | Err | func (r *StatusResp) Err() error {
if r == nil {
// No status response, connection closed before we get one
return errors.New("imap: connection closed during command execution")
}
if r.Type == StatusRespNo || r.Type == StatusRespBad {
return errors.New(r.Info)
}
return nil
} | go | func (r *StatusResp) Err() error {
if r == nil {
// No status response, connection closed before we get one
return errors.New("imap: connection closed during command execution")
}
if r.Type == StatusRespNo || r.Type == StatusRespBad {
return errors.New(r.Info)
}
return nil
} | [
"func",
"(",
"r",
"*",
"StatusResp",
")",
"Err",
"(",
")",
"error",
"{",
"if",
"r",
"==",
"nil",
"{",
"// No status response, connection closed before we get one",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"r",
".",
"... | // If this status is NO or BAD, returns an error with the status info.
// Otherwise, returns nil. | [
"If",
"this",
"status",
"is",
"NO",
"or",
"BAD",
"returns",
"an",
"error",
"with",
"the",
"status",
"info",
".",
"Otherwise",
"returns",
"nil",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/status.go#L79-L89 |
26,154 | emersion/go-imap | utf7/encoder.go | encode | func encode(s []byte) []byte {
// len(s) is sufficient for UTF-8 to UTF-16 conversion if there are no
// control code points (see table below).
b := make([]byte, 0, len(s)+4)
for len(s) > 0 {
r, size := utf8.DecodeRune(s)
if r > utf8.MaxRune {
r, size = utf8.RuneError, 1 // Bug fix (issue 3785)
}
s = s[s... | go | func encode(s []byte) []byte {
// len(s) is sufficient for UTF-8 to UTF-16 conversion if there are no
// control code points (see table below).
b := make([]byte, 0, len(s)+4)
for len(s) > 0 {
r, size := utf8.DecodeRune(s)
if r > utf8.MaxRune {
r, size = utf8.RuneError, 1 // Bug fix (issue 3785)
}
s = s[s... | [
"func",
"encode",
"(",
"s",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"// len(s) is sufficient for UTF-8 to UTF-16 conversion if there are no",
"// control code points (see table below).",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"len",
"(",
"s... | // Converts string s from UTF-8 to UTF-16-BE, encodes the result as base64,
// removes the padding, and adds UTF-7 shifts. | [
"Converts",
"string",
"s",
"from",
"UTF",
"-",
"8",
"to",
"UTF",
"-",
"16",
"-",
"BE",
"encodes",
"the",
"result",
"as",
"base64",
"removes",
"the",
"padding",
"and",
"adds",
"UTF",
"-",
"7",
"shifts",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/utf7/encoder.go#L61-L91 |
26,155 | emersion/go-imap | response.go | ReadResp | func ReadResp(r *Reader) (Resp, error) {
atom, err := r.ReadAtom()
if err != nil {
return nil, err
}
tag, ok := atom.(string)
if !ok {
return nil, newParseError("response tag is not an atom")
}
if tag == "+" {
if err := r.ReadSp(); err != nil {
r.UnreadRune()
}
resp := &ContinuationReq{}
resp.In... | go | func ReadResp(r *Reader) (Resp, error) {
atom, err := r.ReadAtom()
if err != nil {
return nil, err
}
tag, ok := atom.(string)
if !ok {
return nil, newParseError("response tag is not an atom")
}
if tag == "+" {
if err := r.ReadSp(); err != nil {
r.UnreadRune()
}
resp := &ContinuationReq{}
resp.In... | [
"func",
"ReadResp",
"(",
"r",
"*",
"Reader",
")",
"(",
"Resp",
",",
"error",
")",
"{",
"atom",
",",
"err",
":=",
"r",
".",
"ReadAtom",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"tag",
",",
"o... | // ReadResp reads a single response from a Reader. | [
"ReadResp",
"reads",
"a",
"single",
"response",
"from",
"a",
"Reader",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/response.go#L14-L98 |
26,156 | emersion/go-imap | response.go | ParseNamedResp | func ParseNamedResp(resp Resp) (name string, fields []interface{}, ok bool) {
data, ok := resp.(*DataResp)
if !ok || len(data.Fields) == 0 {
return
}
// Some responses (namely EXISTS and RECENT) are formatted like so:
// [num] [name] [...]
// Which is fucking stupid. But we handle that here by checking if th... | go | func ParseNamedResp(resp Resp) (name string, fields []interface{}, ok bool) {
data, ok := resp.(*DataResp)
if !ok || len(data.Fields) == 0 {
return
}
// Some responses (namely EXISTS and RECENT) are formatted like so:
// [num] [name] [...]
// Which is fucking stupid. But we handle that here by checking if th... | [
"func",
"ParseNamedResp",
"(",
"resp",
"Resp",
")",
"(",
"name",
"string",
",",
"fields",
"[",
"]",
"interface",
"{",
"}",
",",
"ok",
"bool",
")",
"{",
"data",
",",
"ok",
":=",
"resp",
".",
"(",
"*",
"DataResp",
")",
"\n",
"if",
"!",
"ok",
"||",
... | // ParseNamedResp attempts to parse a named data response. | [
"ParseNamedResp",
"attempts",
"to",
"parse",
"a",
"named",
"data",
"response",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/response.go#L153-L181 |
26,157 | emersion/go-imap | command.go | Parse | func (cmd *Command) Parse(fields []interface{}) error {
if len(fields) < 2 {
return errors.New("imap: cannot parse command: no enough fields")
}
var ok bool
if cmd.Tag, ok = fields[0].(string); !ok {
return errors.New("imap: cannot parse command: invalid tag")
}
if cmd.Name, ok = fields[1].(string); !ok {
... | go | func (cmd *Command) Parse(fields []interface{}) error {
if len(fields) < 2 {
return errors.New("imap: cannot parse command: no enough fields")
}
var ok bool
if cmd.Tag, ok = fields[0].(string); !ok {
return errors.New("imap: cannot parse command: invalid tag")
}
if cmd.Name, ok = fields[1].(string); !ok {
... | [
"func",
"(",
"cmd",
"*",
"Command",
")",
"Parse",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"fields",
")",
"<",
"2",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",... | // Parse a command from fields. | [
"Parse",
"a",
"command",
"from",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/command.go#L41-L57 |
26,158 | emersion/go-imap | client/cmd_auth.go | Select | func (c *Client) Select(name string, readOnly bool) (*imap.MailboxStatus, error) {
if err := c.ensureAuthenticated(); err != nil {
return nil, err
}
cmd := &commands.Select{
Mailbox: name,
ReadOnly: readOnly,
}
mbox := &imap.MailboxStatus{Name: name, Items: make(map[imap.StatusItem]interface{})}
res := &... | go | func (c *Client) Select(name string, readOnly bool) (*imap.MailboxStatus, error) {
if err := c.ensureAuthenticated(); err != nil {
return nil, err
}
cmd := &commands.Select{
Mailbox: name,
ReadOnly: readOnly,
}
mbox := &imap.MailboxStatus{Name: name, Items: make(map[imap.StatusItem]interface{})}
res := &... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Select",
"(",
"name",
"string",
",",
"readOnly",
"bool",
")",
"(",
"*",
"imap",
".",
"MailboxStatus",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"ensureAuthenticated",
"(",
")",
";",
"err",
"!=",
"ni... | // Select selects a mailbox so that messages in the mailbox can be accessed. Any
// currently selected mailbox is deselected before attempting the new selection.
// Even if the readOnly parameter is set to false, the server can decide to open
// the mailbox in read-only mode. | [
"Select",
"selects",
"a",
"mailbox",
"so",
"that",
"messages",
"in",
"the",
"mailbox",
"can",
"be",
"accessed",
".",
"Any",
"currently",
"selected",
"mailbox",
"is",
"deselected",
"before",
"attempting",
"the",
"new",
"selection",
".",
"Even",
"if",
"the",
"... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_auth.go#L28-L65 |
26,159 | emersion/go-imap | client/cmd_auth.go | Rename | func (c *Client) Rename(existingName, newName string) error {
if err := c.ensureAuthenticated(); err != nil {
return err
}
cmd := &commands.Rename{
Existing: existingName,
New: newName,
}
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | go | func (c *Client) Rename(existingName, newName string) error {
if err := c.ensureAuthenticated(); err != nil {
return err
}
cmd := &commands.Rename{
Existing: existingName,
New: newName,
}
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Rename",
"(",
"existingName",
",",
"newName",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"ensureAuthenticated",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"cmd",
... | // Rename changes the name of a mailbox. | [
"Rename",
"changes",
"the",
"name",
"of",
"a",
"mailbox",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_auth.go#L102-L117 |
26,160 | emersion/go-imap | client/cmd_auth.go | Subscribe | func (c *Client) Subscribe(name string) error {
if err := c.ensureAuthenticated(); err != nil {
return err
}
cmd := &commands.Subscribe{
Mailbox: name,
}
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | go | func (c *Client) Subscribe(name string) error {
if err := c.ensureAuthenticated(); err != nil {
return err
}
cmd := &commands.Subscribe{
Mailbox: name,
}
status, err := c.execute(cmd, nil)
if err != nil {
return err
}
return status.Err()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Subscribe",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"ensureAuthenticated",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"cmd",
":=",
"&",
"commands... | // Subscribe adds the specified mailbox name to the server's set of "active" or
// "subscribed" mailboxes. | [
"Subscribe",
"adds",
"the",
"specified",
"mailbox",
"name",
"to",
"the",
"server",
"s",
"set",
"of",
"active",
"or",
"subscribed",
"mailboxes",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_auth.go#L121-L135 |
26,161 | emersion/go-imap | client/cmd_auth.go | Status | func (c *Client) Status(name string, items []imap.StatusItem) (*imap.MailboxStatus, error) {
if err := c.ensureAuthenticated(); err != nil {
return nil, err
}
cmd := &commands.Status{
Mailbox: name,
Items: items,
}
res := &responses.Status{
Mailbox: new(imap.MailboxStatus),
}
status, err := c.execute... | go | func (c *Client) Status(name string, items []imap.StatusItem) (*imap.MailboxStatus, error) {
if err := c.ensureAuthenticated(); err != nil {
return nil, err
}
cmd := &commands.Status{
Mailbox: name,
Items: items,
}
res := &responses.Status{
Mailbox: new(imap.MailboxStatus),
}
status, err := c.execute... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Status",
"(",
"name",
"string",
",",
"items",
"[",
"]",
"imap",
".",
"StatusItem",
")",
"(",
"*",
"imap",
".",
"MailboxStatus",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"ensureAuthenticated",
"(",
... | // Status requests the status of the indicated mailbox. It does not change the
// currently selected mailbox, nor does it affect the state of any messages in
// the queried mailbox.
//
// See RFC 3501 section 6.3.10 for a list of items that can be requested. | [
"Status",
"requests",
"the",
"status",
"of",
"the",
"indicated",
"mailbox",
".",
"It",
"does",
"not",
"change",
"the",
"currently",
"selected",
"mailbox",
"nor",
"does",
"it",
"affect",
"the",
"state",
"of",
"any",
"messages",
"in",
"the",
"queried",
"mailbo... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_auth.go#L213-L231 |
26,162 | emersion/go-imap | client/cmd_auth.go | Append | func (c *Client) Append(mbox string, flags []string, date time.Time, msg imap.Literal) error {
if err := c.ensureAuthenticated(); err != nil {
return err
}
cmd := &commands.Append{
Mailbox: mbox,
Flags: flags,
Date: date,
Message: msg,
}
status, err := c.execute(cmd, nil)
if err != nil {
return... | go | func (c *Client) Append(mbox string, flags []string, date time.Time, msg imap.Literal) error {
if err := c.ensureAuthenticated(); err != nil {
return err
}
cmd := &commands.Append{
Mailbox: mbox,
Flags: flags,
Date: date,
Message: msg,
}
status, err := c.execute(cmd, nil)
if err != nil {
return... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Append",
"(",
"mbox",
"string",
",",
"flags",
"[",
"]",
"string",
",",
"date",
"time",
".",
"Time",
",",
"msg",
"imap",
".",
"Literal",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"ensureAuthenticated",
"(... | // Append appends the literal argument as a new message to the end of the
// specified destination mailbox. This argument SHOULD be in the format of an
// RFC 2822 message. flags and date are optional arguments and can be set to
// nil. | [
"Append",
"appends",
"the",
"literal",
"argument",
"as",
"a",
"new",
"message",
"to",
"the",
"end",
"of",
"the",
"specified",
"destination",
"mailbox",
".",
"This",
"argument",
"SHOULD",
"be",
"in",
"the",
"format",
"of",
"an",
"RFC",
"2822",
"message",
".... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_auth.go#L237-L254 |
26,163 | emersion/go-imap | backend/backendutil/search.go | MatchFlags | func MatchFlags(flags []string, c *imap.SearchCriteria) bool {
flagsMap := make(map[string]bool)
for _, f := range flags {
flagsMap[f] = true
}
return matchFlags(flagsMap, c)
} | go | func MatchFlags(flags []string, c *imap.SearchCriteria) bool {
flagsMap := make(map[string]bool)
for _, f := range flags {
flagsMap[f] = true
}
return matchFlags(flagsMap, c)
} | [
"func",
"MatchFlags",
"(",
"flags",
"[",
"]",
"string",
",",
"c",
"*",
"imap",
".",
"SearchCriteria",
")",
"bool",
"{",
"flagsMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"flags",
"{",
... | // MatchFlags returns true if a flag list matches the provided criteria. | [
"MatchFlags",
"returns",
"true",
"if",
"a",
"flag",
"list",
"matches",
"the",
"provided",
"criteria",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/search.go#L172-L179 |
26,164 | emersion/go-imap | backend/backendutil/search.go | MatchSeqNumAndUid | func MatchSeqNumAndUid(seqNum uint32, uid uint32, c *imap.SearchCriteria) bool {
if c.SeqNum != nil && !c.SeqNum.Contains(seqNum) {
return false
}
if c.Uid != nil && !c.Uid.Contains(uid) {
return false
}
for _, not := range c.Not {
if MatchSeqNumAndUid(seqNum, uid, not) {
return false
}
}
for _, or :... | go | func MatchSeqNumAndUid(seqNum uint32, uid uint32, c *imap.SearchCriteria) bool {
if c.SeqNum != nil && !c.SeqNum.Contains(seqNum) {
return false
}
if c.Uid != nil && !c.Uid.Contains(uid) {
return false
}
for _, not := range c.Not {
if MatchSeqNumAndUid(seqNum, uid, not) {
return false
}
}
for _, or :... | [
"func",
"MatchSeqNumAndUid",
"(",
"seqNum",
"uint32",
",",
"uid",
"uint32",
",",
"c",
"*",
"imap",
".",
"SearchCriteria",
")",
"bool",
"{",
"if",
"c",
".",
"SeqNum",
"!=",
"nil",
"&&",
"!",
"c",
".",
"SeqNum",
".",
"Contains",
"(",
"seqNum",
")",
"{"... | // MatchSeqNumAndUid returns true if a sequence number and a UID matches the
// provided criteria. | [
"MatchSeqNumAndUid",
"returns",
"true",
"if",
"a",
"sequence",
"number",
"and",
"a",
"UID",
"matches",
"the",
"provided",
"criteria",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/search.go#L183-L202 |
26,165 | emersion/go-imap | backend/backendutil/search.go | MatchDate | func MatchDate(date time.Time, c *imap.SearchCriteria) bool {
date = date.Round(24 * time.Hour)
if !c.Since.IsZero() && !date.After(c.Since) {
return false
}
if !c.Before.IsZero() && !date.Before(c.Before) {
return false
}
for _, not := range c.Not {
if MatchDate(date, not) {
return false
}
}
for _,... | go | func MatchDate(date time.Time, c *imap.SearchCriteria) bool {
date = date.Round(24 * time.Hour)
if !c.Since.IsZero() && !date.After(c.Since) {
return false
}
if !c.Before.IsZero() && !date.Before(c.Before) {
return false
}
for _, not := range c.Not {
if MatchDate(date, not) {
return false
}
}
for _,... | [
"func",
"MatchDate",
"(",
"date",
"time",
".",
"Time",
",",
"c",
"*",
"imap",
".",
"SearchCriteria",
")",
"bool",
"{",
"date",
"=",
"date",
".",
"Round",
"(",
"24",
"*",
"time",
".",
"Hour",
")",
"\n",
"if",
"!",
"c",
".",
"Since",
".",
"IsZero",... | // MatchDate returns true if a date matches the provided criteria. | [
"MatchDate",
"returns",
"true",
"if",
"a",
"date",
"matches",
"the",
"provided",
"criteria",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/search.go#L205-L225 |
26,166 | emersion/go-imap | client/cmd_noauth.go | StartTLS | func (c *Client) StartTLS(tlsConfig *tls.Config) error {
if c.isTLS {
return ErrTLSAlreadyEnabled
}
cmd := new(commands.StartTLS)
err := c.Upgrade(func(conn net.Conn) (net.Conn, error) {
// Flag connection as in upgrading
c.upgrading = true
if status, err := c.execute(cmd, nil); err != nil {
return nil... | go | func (c *Client) StartTLS(tlsConfig *tls.Config) error {
if c.isTLS {
return ErrTLSAlreadyEnabled
}
cmd := new(commands.StartTLS)
err := c.Upgrade(func(conn net.Conn) (net.Conn, error) {
// Flag connection as in upgrading
c.upgrading = true
if status, err := c.execute(cmd, nil); err != nil {
return nil... | [
"func",
"(",
"c",
"*",
"Client",
")",
"StartTLS",
"(",
"tlsConfig",
"*",
"tls",
".",
"Config",
")",
"error",
"{",
"if",
"c",
".",
"isTLS",
"{",
"return",
"ErrTLSAlreadyEnabled",
"\n",
"}",
"\n\n",
"cmd",
":=",
"new",
"(",
"commands",
".",
"StartTLS",
... | // StartTLS starts TLS negotiation. | [
"StartTLS",
"starts",
"TLS",
"negotiation",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_noauth.go#L33-L69 |
26,167 | emersion/go-imap | client/cmd_noauth.go | SupportAuth | func (c *Client) SupportAuth(mech string) (bool, error) {
return c.Support("AUTH=" + mech)
} | go | func (c *Client) SupportAuth(mech string) (bool, error) {
return c.Support("AUTH=" + mech)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SupportAuth",
"(",
"mech",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"c",
".",
"Support",
"(",
"\"",
"\"",
"+",
"mech",
")",
"\n",
"}"
] | // SupportAuth checks if the server supports a given authentication mechanism. | [
"SupportAuth",
"checks",
"if",
"the",
"server",
"supports",
"a",
"given",
"authentication",
"mechanism",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_noauth.go#L72-L74 |
26,168 | emersion/go-imap | client/cmd_noauth.go | Authenticate | func (c *Client) Authenticate(auth sasl.Client) error {
if c.State() != imap.NotAuthenticatedState {
return ErrAlreadyLoggedIn
}
mech, ir, err := auth.Start()
if err != nil {
return err
}
cmd := &commands.Authenticate{
Mechanism: mech,
}
res := &responses.Authenticate{
Mechanism: auth,
Initia... | go | func (c *Client) Authenticate(auth sasl.Client) error {
if c.State() != imap.NotAuthenticatedState {
return ErrAlreadyLoggedIn
}
mech, ir, err := auth.Start()
if err != nil {
return err
}
cmd := &commands.Authenticate{
Mechanism: mech,
}
res := &responses.Authenticate{
Mechanism: auth,
Initia... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Authenticate",
"(",
"auth",
"sasl",
".",
"Client",
")",
"error",
"{",
"if",
"c",
".",
"State",
"(",
")",
"!=",
"imap",
".",
"NotAuthenticatedState",
"{",
"return",
"ErrAlreadyLoggedIn",
"\n",
"}",
"\n\n",
"mech",
... | // Authenticate indicates a SASL authentication mechanism to the server. If the
// server supports the requested authentication mechanism, it performs an
// authentication protocol exchange to authenticate and identify the client. | [
"Authenticate",
"indicates",
"a",
"SASL",
"authentication",
"mechanism",
"to",
"the",
"server",
".",
"If",
"the",
"server",
"supports",
"the",
"requested",
"authentication",
"mechanism",
"it",
"performs",
"an",
"authentication",
"protocol",
"exchange",
"to",
"authen... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_noauth.go#L79-L120 |
26,169 | emersion/go-imap | client/cmd_noauth.go | Login | func (c *Client) Login(username, password string) error {
if state := c.State(); state == imap.AuthenticatedState || state == imap.SelectedState {
return ErrAlreadyLoggedIn
}
c.locker.Lock()
loginDisabled := c.caps != nil && c.caps["LOGINDISABLED"]
c.locker.Unlock()
if loginDisabled {
return ErrLoginDisabled... | go | func (c *Client) Login(username, password string) error {
if state := c.State(); state == imap.AuthenticatedState || state == imap.SelectedState {
return ErrAlreadyLoggedIn
}
c.locker.Lock()
loginDisabled := c.caps != nil && c.caps["LOGINDISABLED"]
c.locker.Unlock()
if loginDisabled {
return ErrLoginDisabled... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Login",
"(",
"username",
",",
"password",
"string",
")",
"error",
"{",
"if",
"state",
":=",
"c",
".",
"State",
"(",
")",
";",
"state",
"==",
"imap",
".",
"AuthenticatedState",
"||",
"state",
"==",
"imap",
".",
... | // Login identifies the client to the server and carries the plaintext password
// authenticating this user. | [
"Login",
"identifies",
"the",
"client",
"to",
"the",
"server",
"and",
"carries",
"the",
"plaintext",
"password",
"authenticating",
"this",
"user",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/client/cmd_noauth.go#L124-L158 |
26,170 | emersion/go-imap | message.go | CanonicalFlag | func CanonicalFlag(flag string) string {
flag = strings.ToLower(flag)
for _, f := range flags {
if strings.ToLower(f) == flag {
return f
}
}
return flag
} | go | func CanonicalFlag(flag string) string {
flag = strings.ToLower(flag)
for _, f := range flags {
if strings.ToLower(f) == flag {
return f
}
}
return flag
} | [
"func",
"CanonicalFlag",
"(",
"flag",
"string",
")",
"string",
"{",
"flag",
"=",
"strings",
".",
"ToLower",
"(",
"flag",
")",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"flags",
"{",
"if",
"strings",
".",
"ToLower",
"(",
"f",
")",
"==",
"flag",
"{"... | // CanonicalFlag returns the canonical form of a flag. Flags are case-insensitive.
//
// If the flag is defined in RFC 3501, it returns the flag with the case of the
// RFC. Otherwise, it returns the lowercase version of the flag. | [
"CanonicalFlag",
"returns",
"the",
"canonical",
"form",
"of",
"a",
"flag",
".",
"Flags",
"are",
"case",
"-",
"insensitive",
".",
"If",
"the",
"flag",
"is",
"defined",
"in",
"RFC",
"3501",
"it",
"returns",
"the",
"flag",
"with",
"the",
"case",
"of",
"the"... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L54-L62 |
26,171 | emersion/go-imap | message.go | NewMessage | func NewMessage(seqNum uint32, items []FetchItem) *Message {
msg := &Message{
SeqNum: seqNum,
Items: make(map[FetchItem]interface{}),
Body: make(map[*BodySectionName]Literal),
itemsOrder: items,
}
for _, k := range items {
msg.Items[k] = nil
}
return msg
} | go | func NewMessage(seqNum uint32, items []FetchItem) *Message {
msg := &Message{
SeqNum: seqNum,
Items: make(map[FetchItem]interface{}),
Body: make(map[*BodySectionName]Literal),
itemsOrder: items,
}
for _, k := range items {
msg.Items[k] = nil
}
return msg
} | [
"func",
"NewMessage",
"(",
"seqNum",
"uint32",
",",
"items",
"[",
"]",
"FetchItem",
")",
"*",
"Message",
"{",
"msg",
":=",
"&",
"Message",
"{",
"SeqNum",
":",
"seqNum",
",",
"Items",
":",
"make",
"(",
"map",
"[",
"FetchItem",
"]",
"interface",
"{",
"... | // Create a new empty message that will contain the specified items. | [
"Create",
"a",
"new",
"empty",
"message",
"that",
"will",
"contain",
"the",
"specified",
"items",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L168-L181 |
26,172 | emersion/go-imap | message.go | Parse | func (m *Message) Parse(fields []interface{}) error {
m.Items = make(map[FetchItem]interface{})
m.Body = map[*BodySectionName]Literal{}
m.itemsOrder = nil
var k FetchItem
for i, f := range fields {
if i%2 == 0 { // It's a key
if kstr, ok := f.(string); !ok {
return fmt.Errorf("cannot parse message: key i... | go | func (m *Message) Parse(fields []interface{}) error {
m.Items = make(map[FetchItem]interface{})
m.Body = map[*BodySectionName]Literal{}
m.itemsOrder = nil
var k FetchItem
for i, f := range fields {
if i%2 == 0 { // It's a key
if kstr, ok := f.(string); !ok {
return fmt.Errorf("cannot parse message: key i... | [
"func",
"(",
"m",
"*",
"Message",
")",
"Parse",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"m",
".",
"Items",
"=",
"make",
"(",
"map",
"[",
"FetchItem",
"]",
"interface",
"{",
"}",
")",
"\n",
"m",
".",
"Body",
"=",
"map"... | // Parse a message from fields. | [
"Parse",
"a",
"message",
"from",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L184-L254 |
26,173 | emersion/go-imap | message.go | GetBody | func (m *Message) GetBody(section *BodySectionName) Literal {
section = section.resp()
for s, body := range m.Body {
if section.Equal(s) {
return body
}
}
return nil
} | go | func (m *Message) GetBody(section *BodySectionName) Literal {
section = section.resp()
for s, body := range m.Body {
if section.Equal(s) {
return body
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"GetBody",
"(",
"section",
"*",
"BodySectionName",
")",
"Literal",
"{",
"section",
"=",
"section",
".",
"resp",
"(",
")",
"\n\n",
"for",
"s",
",",
"body",
":=",
"range",
"m",
".",
"Body",
"{",
"if",
"section",
... | // GetBody gets the body section with the specified name. Returns nil if it's not found. | [
"GetBody",
"gets",
"the",
"body",
"section",
"with",
"the",
"specified",
"name",
".",
"Returns",
"nil",
"if",
"it",
"s",
"not",
"found",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L316-L325 |
26,174 | emersion/go-imap | message.go | Equal | func (section *BodySectionName) Equal(other *BodySectionName) bool {
if section.Peek != other.Peek {
return false
}
if len(section.Partial) != len(other.Partial) {
return false
}
if len(section.Partial) > 0 && section.Partial[0] != other.Partial[0] {
return false
}
if len(section.Partial) > 1 && section.Pa... | go | func (section *BodySectionName) Equal(other *BodySectionName) bool {
if section.Peek != other.Peek {
return false
}
if len(section.Partial) != len(other.Partial) {
return false
}
if len(section.Partial) > 0 && section.Partial[0] != other.Partial[0] {
return false
}
if len(section.Partial) > 1 && section.Pa... | [
"func",
"(",
"section",
"*",
"BodySectionName",
")",
"Equal",
"(",
"other",
"*",
"BodySectionName",
")",
"bool",
"{",
"if",
"section",
".",
"Peek",
"!=",
"other",
".",
"Peek",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"len",
"(",
"section",
".",
... | // Equal checks whether two sections are equal. | [
"Equal",
"checks",
"whether",
"two",
"sections",
"are",
"equal",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L439-L453 |
26,175 | emersion/go-imap | message.go | ExtractPartial | func (section *BodySectionName) ExtractPartial(b []byte) []byte {
if len(section.Partial) != 2 {
return b
}
from := section.Partial[0]
length := section.Partial[1]
to := from + length
if from > len(b) {
return nil
}
if to > len(b) {
to = len(b)
}
return b[from:to]
} | go | func (section *BodySectionName) ExtractPartial(b []byte) []byte {
if len(section.Partial) != 2 {
return b
}
from := section.Partial[0]
length := section.Partial[1]
to := from + length
if from > len(b) {
return nil
}
if to > len(b) {
to = len(b)
}
return b[from:to]
} | [
"func",
"(",
"section",
"*",
"BodySectionName",
")",
"ExtractPartial",
"(",
"b",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"section",
".",
"Partial",
")",
"!=",
"2",
"{",
"return",
"b",
"\n",
"}",
"\n\n",
"from",
":=",
"sectio... | // ExtractPartial returns a subset of the specified bytes matching the partial requested in the
// section name. | [
"ExtractPartial",
"returns",
"a",
"subset",
"of",
"the",
"specified",
"bytes",
"matching",
"the",
"partial",
"requested",
"in",
"the",
"section",
"name",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L469-L484 |
26,176 | emersion/go-imap | message.go | ParseBodySectionName | func ParseBodySectionName(s FetchItem) (*BodySectionName, error) {
section := new(BodySectionName)
err := section.parse(string(s))
return section, err
} | go | func ParseBodySectionName(s FetchItem) (*BodySectionName, error) {
section := new(BodySectionName)
err := section.parse(string(s))
return section, err
} | [
"func",
"ParseBodySectionName",
"(",
"s",
"FetchItem",
")",
"(",
"*",
"BodySectionName",
",",
"error",
")",
"{",
"section",
":=",
"new",
"(",
"BodySectionName",
")",
"\n",
"err",
":=",
"section",
".",
"parse",
"(",
"string",
"(",
"s",
")",
")",
"\n",
"... | // ParseBodySectionName parses a body section name. | [
"ParseBodySectionName",
"parses",
"a",
"body",
"section",
"name",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L487-L491 |
26,177 | emersion/go-imap | message.go | Equal | func (part *BodyPartName) Equal(other *BodyPartName) bool {
if part.Specifier != other.Specifier {
return false
}
if part.NotFields != other.NotFields {
return false
}
if len(part.Path) != len(other.Path) {
return false
}
for i, node := range part.Path {
if node != other.Path[i] {
return false
}
}
... | go | func (part *BodyPartName) Equal(other *BodyPartName) bool {
if part.Specifier != other.Specifier {
return false
}
if part.NotFields != other.NotFields {
return false
}
if len(part.Path) != len(other.Path) {
return false
}
for i, node := range part.Path {
if node != other.Path[i] {
return false
}
}
... | [
"func",
"(",
"part",
"*",
"BodyPartName",
")",
"Equal",
"(",
"other",
"*",
"BodyPartName",
")",
"bool",
"{",
"if",
"part",
".",
"Specifier",
"!=",
"other",
".",
"Specifier",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"part",
".",
"NotFields",
"!=",... | // Equal checks whether two body part names are equal. | [
"Equal",
"checks",
"whether",
"two",
"body",
"part",
"names",
"are",
"equal",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L590-L621 |
26,178 | emersion/go-imap | message.go | Parse | func (addr *Address) Parse(fields []interface{}) error {
if len(fields) < 4 {
return errors.New("Address doesn't contain 4 fields")
}
if s, err := ParseString(fields[0]); err == nil {
addr.PersonalName, _ = decodeHeader(s)
}
if s, err := ParseString(fields[1]); err == nil {
addr.AtDomainList, _ = decodeHead... | go | func (addr *Address) Parse(fields []interface{}) error {
if len(fields) < 4 {
return errors.New("Address doesn't contain 4 fields")
}
if s, err := ParseString(fields[0]); err == nil {
addr.PersonalName, _ = decodeHeader(s)
}
if s, err := ParseString(fields[1]); err == nil {
addr.AtDomainList, _ = decodeHead... | [
"func",
"(",
"addr",
"*",
"Address",
")",
"Parse",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"fields",
")",
"<",
"4",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",... | // Parse an address from fields. | [
"Parse",
"an",
"address",
"from",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L636-L655 |
26,179 | emersion/go-imap | message.go | Format | func (addr *Address) Format() []interface{} {
fields := make([]interface{}, 4)
if addr.PersonalName != "" {
fields[0] = encodeHeader(addr.PersonalName)
}
if addr.AtDomainList != "" {
fields[1] = addr.AtDomainList
}
if addr.MailboxName != "" {
fields[2] = addr.MailboxName
}
if addr.HostName != "" {
fiel... | go | func (addr *Address) Format() []interface{} {
fields := make([]interface{}, 4)
if addr.PersonalName != "" {
fields[0] = encodeHeader(addr.PersonalName)
}
if addr.AtDomainList != "" {
fields[1] = addr.AtDomainList
}
if addr.MailboxName != "" {
fields[2] = addr.MailboxName
}
if addr.HostName != "" {
fiel... | [
"func",
"(",
"addr",
"*",
"Address",
")",
"Format",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"fields",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"4",
")",
"\n\n",
"if",
"addr",
".",
"PersonalName",
"!=",
"\"",
"\"",
"{",
"... | // Format an address to fields. | [
"Format",
"an",
"address",
"to",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L658-L675 |
26,180 | emersion/go-imap | message.go | ParseAddressList | func ParseAddressList(fields []interface{}) (addrs []*Address) {
addrs = make([]*Address, len(fields))
for i, f := range fields {
if addrFields, ok := f.([]interface{}); ok {
addr := &Address{}
if err := addr.Parse(addrFields); err == nil {
addrs[i] = addr
}
}
}
return
} | go | func ParseAddressList(fields []interface{}) (addrs []*Address) {
addrs = make([]*Address, len(fields))
for i, f := range fields {
if addrFields, ok := f.([]interface{}); ok {
addr := &Address{}
if err := addr.Parse(addrFields); err == nil {
addrs[i] = addr
}
}
}
return
} | [
"func",
"ParseAddressList",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"addrs",
"[",
"]",
"*",
"Address",
")",
"{",
"addrs",
"=",
"make",
"(",
"[",
"]",
"*",
"Address",
",",
"len",
"(",
"fields",
")",
")",
"\n\n",
"for",
"i",
",",
... | // Parse an address list from fields. | [
"Parse",
"an",
"address",
"list",
"from",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L678-L691 |
26,181 | emersion/go-imap | message.go | FormatAddressList | func FormatAddressList(addrs []*Address) (fields []interface{}) {
fields = make([]interface{}, len(addrs))
for i, addr := range addrs {
fields[i] = addr.Format()
}
return
} | go | func FormatAddressList(addrs []*Address) (fields []interface{}) {
fields = make([]interface{}, len(addrs))
for i, addr := range addrs {
fields[i] = addr.Format()
}
return
} | [
"func",
"FormatAddressList",
"(",
"addrs",
"[",
"]",
"*",
"Address",
")",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"fields",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"addrs",
")",
")",
"\n\n",
"for",
"i... | // Format an address list to fields. | [
"Format",
"an",
"address",
"list",
"to",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L694-L702 |
26,182 | emersion/go-imap | message.go | Parse | func (e *Envelope) Parse(fields []interface{}) error {
if len(fields) < 10 {
return errors.New("ENVELOPE doesn't contain 10 fields")
}
if date, ok := fields[0].(string); ok {
e.Date, _ = parseMessageDateTime(date)
}
if subject, err := ParseString(fields[1]); err == nil {
e.Subject, _ = decodeHeader(subject)... | go | func (e *Envelope) Parse(fields []interface{}) error {
if len(fields) < 10 {
return errors.New("ENVELOPE doesn't contain 10 fields")
}
if date, ok := fields[0].(string); ok {
e.Date, _ = parseMessageDateTime(date)
}
if subject, err := ParseString(fields[1]); err == nil {
e.Subject, _ = decodeHeader(subject)... | [
"func",
"(",
"e",
"*",
"Envelope",
")",
"Parse",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"fields",
")",
"<",
"10",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
... | // Parse an envelope from fields. | [
"Parse",
"an",
"envelope",
"from",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L730-L767 |
26,183 | emersion/go-imap | message.go | Format | func (e *Envelope) Format() (fields []interface{}) {
return []interface{}{
envelopeDateTime(e.Date),
encodeHeader(e.Subject),
FormatAddressList(e.From),
FormatAddressList(e.Sender),
FormatAddressList(e.ReplyTo),
FormatAddressList(e.To),
FormatAddressList(e.Cc),
FormatAddressList(e.Bcc),
e.InReplyTo,
... | go | func (e *Envelope) Format() (fields []interface{}) {
return []interface{}{
envelopeDateTime(e.Date),
encodeHeader(e.Subject),
FormatAddressList(e.From),
FormatAddressList(e.Sender),
FormatAddressList(e.ReplyTo),
FormatAddressList(e.To),
FormatAddressList(e.Cc),
FormatAddressList(e.Bcc),
e.InReplyTo,
... | [
"func",
"(",
"e",
"*",
"Envelope",
")",
"Format",
"(",
")",
"(",
"fields",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"return",
"[",
"]",
"interface",
"{",
"}",
"{",
"envelopeDateTime",
"(",
"e",
".",
"Date",
")",
",",
"encodeHeader",
"(",
"e",
"... | // Format an envelope to fields. | [
"Format",
"an",
"envelope",
"to",
"fields",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/message.go#L770-L783 |
26,184 | emersion/go-imap | server/server.go | Serve | func (s *Server) Serve(l net.Listener) error {
s.locker.Lock()
s.listeners[l] = struct{}{}
s.locker.Unlock()
defer func() {
s.locker.Lock()
defer s.locker.Unlock()
l.Close()
delete(s.listeners, l)
}()
updater, ok := s.Backend.(backend.BackendUpdater)
if ok {
s.Updates = updater.Updates()
go s.liste... | go | func (s *Server) Serve(l net.Listener) error {
s.locker.Lock()
s.listeners[l] = struct{}{}
s.locker.Unlock()
defer func() {
s.locker.Lock()
defer s.locker.Unlock()
l.Close()
delete(s.listeners, l)
}()
updater, ok := s.Backend.(backend.BackendUpdater)
if ok {
s.Updates = updater.Updates()
go s.liste... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Serve",
"(",
"l",
"net",
".",
"Listener",
")",
"error",
"{",
"s",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"listeners",
"[",
"l",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"s",
".",
"l... | // Serve accepts incoming connections on the Listener l. | [
"Serve",
"accepts",
"incoming",
"connections",
"on",
"the",
"Listener",
"l",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/server/server.go#L198-L231 |
26,185 | emersion/go-imap | server/server.go | Command | func (s *Server) Command(name string) HandlerFactory {
// Extensions can override builtin commands
for _, ext := range s.extensions {
if h := ext.Command(name); h != nil {
return h
}
}
return s.commands[name]
} | go | func (s *Server) Command(name string) HandlerFactory {
// Extensions can override builtin commands
for _, ext := range s.extensions {
if h := ext.Command(name); h != nil {
return h
}
}
return s.commands[name]
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Command",
"(",
"name",
"string",
")",
"HandlerFactory",
"{",
"// Extensions can override builtin commands",
"for",
"_",
",",
"ext",
":=",
"range",
"s",
".",
"extensions",
"{",
"if",
"h",
":=",
"ext",
".",
"Command",
"... | // Command gets a command handler factory for the provided command name. | [
"Command",
"gets",
"a",
"command",
"handler",
"factory",
"for",
"the",
"provided",
"command",
"name",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/server/server.go#L285-L294 |
26,186 | emersion/go-imap | server/server.go | ForEachConn | func (s *Server) ForEachConn(f func(Conn)) {
s.locker.Lock()
defer s.locker.Unlock()
for conn := range s.conns {
f(conn)
}
} | go | func (s *Server) ForEachConn(f func(Conn)) {
s.locker.Lock()
defer s.locker.Unlock()
for conn := range s.conns {
f(conn)
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ForEachConn",
"(",
"f",
"func",
"(",
"Conn",
")",
")",
"{",
"s",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n",
"for",
"conn",
":=",
"range",
"s",
... | // ForEachConn iterates through all opened connections. | [
"ForEachConn",
"iterates",
"through",
"all",
"opened",
"connections",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/server/server.go#L374-L380 |
26,187 | emersion/go-imap | server/server.go | Close | func (s *Server) Close() error {
s.locker.Lock()
defer s.locker.Unlock()
for l := range s.listeners {
l.Close()
}
for conn := range s.conns {
conn.Close()
}
return nil
} | go | func (s *Server) Close() error {
s.locker.Lock()
defer s.locker.Unlock()
for l := range s.listeners {
l.Close()
}
for conn := range s.conns {
conn.Close()
}
return nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Close",
"(",
")",
"error",
"{",
"s",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"l",
":=",
"range",
"s",
".",
"listeners",
"{",
"l",
... | // Stops listening and closes all current connections. | [
"Stops",
"listening",
"and",
"closes",
"all",
"current",
"connections",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/server/server.go#L383-L396 |
26,188 | emersion/go-imap | server/server.go | Enable | func (s *Server) Enable(extensions ...Extension) {
s.extensions = append(s.extensions, extensions...)
} | go | func (s *Server) Enable(extensions ...Extension) {
s.extensions = append(s.extensions, extensions...)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Enable",
"(",
"extensions",
"...",
"Extension",
")",
"{",
"s",
".",
"extensions",
"=",
"append",
"(",
"s",
".",
"extensions",
",",
"extensions",
"...",
")",
"\n",
"}"
] | // Enable some IMAP extensions on this server.
//
// This function should not be called directly, it must only be used by
// libraries implementing extensions of the IMAP protocol. | [
"Enable",
"some",
"IMAP",
"extensions",
"on",
"this",
"server",
".",
"This",
"function",
"should",
"not",
"be",
"called",
"directly",
"it",
"must",
"only",
"be",
"used",
"by",
"libraries",
"implementing",
"extensions",
"of",
"the",
"IMAP",
"protocol",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/server/server.go#L402-L404 |
26,189 | emersion/go-imap | server/server.go | EnableAuth | func (s *Server) EnableAuth(name string, f SASLServerFactory) {
s.auths[name] = f
} | go | func (s *Server) EnableAuth(name string, f SASLServerFactory) {
s.auths[name] = f
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"EnableAuth",
"(",
"name",
"string",
",",
"f",
"SASLServerFactory",
")",
"{",
"s",
".",
"auths",
"[",
"name",
"]",
"=",
"f",
"\n",
"}"
] | // Enable an authentication mechanism on this server.
//
// This function should not be called directly, it must only be used by
// libraries implementing extensions of the IMAP protocol. | [
"Enable",
"an",
"authentication",
"mechanism",
"on",
"this",
"server",
".",
"This",
"function",
"should",
"not",
"be",
"called",
"directly",
"it",
"must",
"only",
"be",
"used",
"by",
"libraries",
"implementing",
"extensions",
"of",
"the",
"IMAP",
"protocol",
"... | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/server/server.go#L410-L412 |
26,190 | emersion/go-imap | backend/backendutil/bodystructure.go | FetchBodyStructure | func FetchBodyStructure(e *message.Entity, extended bool) (*imap.BodyStructure, error) {
bs := new(imap.BodyStructure)
mediaType, mediaParams, _ := e.Header.ContentType()
typeParts := strings.SplitN(mediaType, "/", 2)
bs.MIMEType = typeParts[0]
if len(typeParts) == 2 {
bs.MIMESubType = typeParts[1]
}
bs.Param... | go | func FetchBodyStructure(e *message.Entity, extended bool) (*imap.BodyStructure, error) {
bs := new(imap.BodyStructure)
mediaType, mediaParams, _ := e.Header.ContentType()
typeParts := strings.SplitN(mediaType, "/", 2)
bs.MIMEType = typeParts[0]
if len(typeParts) == 2 {
bs.MIMESubType = typeParts[1]
}
bs.Param... | [
"func",
"FetchBodyStructure",
"(",
"e",
"*",
"message",
".",
"Entity",
",",
"extended",
"bool",
")",
"(",
"*",
"imap",
".",
"BodyStructure",
",",
"error",
")",
"{",
"bs",
":=",
"new",
"(",
"imap",
".",
"BodyStructure",
")",
"\n\n",
"mediaType",
",",
"m... | // FetchBodyStructure computes a message's body structure from its content. | [
"FetchBodyStructure",
"computes",
"a",
"message",
"s",
"body",
"structure",
"from",
"its",
"content",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/bodystructure.go#L12-L60 |
26,191 | emersion/go-imap | backend/backendutil/body.go | FetchBodySection | func FetchBodySection(e *message.Entity, section *imap.BodySectionName) (imap.Literal, error) {
// First, find the requested part using the provided path
for i := 0; i < len(section.Path); i++ {
n := section.Path[i]
mr := e.MultipartReader()
if mr == nil {
return nil, errNoSuchPart
}
for j := 1; j <= n... | go | func FetchBodySection(e *message.Entity, section *imap.BodySectionName) (imap.Literal, error) {
// First, find the requested part using the provided path
for i := 0; i < len(section.Path); i++ {
n := section.Path[i]
mr := e.MultipartReader()
if mr == nil {
return nil, errNoSuchPart
}
for j := 1; j <= n... | [
"func",
"FetchBodySection",
"(",
"e",
"*",
"message",
".",
"Entity",
",",
"section",
"*",
"imap",
".",
"BodySectionName",
")",
"(",
"imap",
".",
"Literal",
",",
"error",
")",
"{",
"// First, find the requested part using the provided path",
"for",
"i",
":=",
"0"... | // FetchBodySection extracts a body section from a message. | [
"FetchBodySection",
"extracts",
"a",
"body",
"section",
"from",
"a",
"message",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/backend/backendutil/body.go#L15-L75 |
26,192 | emersion/go-imap | read.go | ParseNumber | func ParseNumber(f interface{}) (uint32, error) {
// Useful for tests
if n, ok := f.(uint32); ok {
return n, nil
}
s, ok := f.(string)
if !ok {
return 0, newParseError("expected a number, got a non-atom")
}
nbr, err := strconv.ParseUint(s, 10, 32)
if err != nil {
return 0, &parseError{err}
}
return u... | go | func ParseNumber(f interface{}) (uint32, error) {
// Useful for tests
if n, ok := f.(uint32); ok {
return n, nil
}
s, ok := f.(string)
if !ok {
return 0, newParseError("expected a number, got a non-atom")
}
nbr, err := strconv.ParseUint(s, 10, 32)
if err != nil {
return 0, &parseError{err}
}
return u... | [
"func",
"ParseNumber",
"(",
"f",
"interface",
"{",
"}",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"// Useful for tests",
"if",
"n",
",",
"ok",
":=",
"f",
".",
"(",
"uint32",
")",
";",
"ok",
"{",
"return",
"n",
",",
"nil",
"\n",
"}",
"\n\n",
"s"... | // ParseNumber parses a number. | [
"ParseNumber",
"parses",
"a",
"number",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/read.go#L66-L83 |
26,193 | emersion/go-imap | read.go | ParseString | func ParseString(f interface{}) (string, error) {
if s, ok := f.(string); ok {
return s, nil
}
// Useful for tests
if q, ok := f.(Quoted); ok {
return string(q), nil
}
if a, ok := f.(Atom); ok {
return string(a), nil
}
if l, ok := f.(Literal); ok {
b := make([]byte, l.Len())
if _, err := io.ReadFull... | go | func ParseString(f interface{}) (string, error) {
if s, ok := f.(string); ok {
return s, nil
}
// Useful for tests
if q, ok := f.(Quoted); ok {
return string(q), nil
}
if a, ok := f.(Atom); ok {
return string(a), nil
}
if l, ok := f.(Literal); ok {
b := make([]byte, l.Len())
if _, err := io.ReadFull... | [
"func",
"ParseString",
"(",
"f",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"s",
",",
"ok",
":=",
"f",
".",
"(",
"string",
")",
";",
"ok",
"{",
"return",
"s",
",",
"nil",
"\n",
"}",
"\n\n",
"// Useful for tests",
"if... | // ParseString parses a string, which is either a literal, a quoted string or an
// atom. | [
"ParseString",
"parses",
"a",
"string",
"which",
"is",
"either",
"a",
"literal",
"a",
"quoted",
"string",
"or",
"an",
"atom",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/read.go#L87-L109 |
26,194 | emersion/go-imap | read.go | ParseStringList | func ParseStringList(f interface{}) ([]string, error) {
fields, ok := f.([]interface{})
if !ok {
return nil, newParseError("expected a string list, got a non-list")
}
list := make([]string, len(fields))
for i, f := range fields {
var err error
if list[i], err = ParseString(f); err != nil {
return nil, ne... | go | func ParseStringList(f interface{}) ([]string, error) {
fields, ok := f.([]interface{})
if !ok {
return nil, newParseError("expected a string list, got a non-list")
}
list := make([]string, len(fields))
for i, f := range fields {
var err error
if list[i], err = ParseString(f); err != nil {
return nil, ne... | [
"func",
"ParseStringList",
"(",
"f",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"fields",
",",
"ok",
":=",
"f",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
... | // Convert a field list to a string list. | [
"Convert",
"a",
"field",
"list",
"to",
"a",
"string",
"list",
"."
] | b7db4a2bc5cc04fb568fb036a438da43ee9a9f78 | https://github.com/emersion/go-imap/blob/b7db4a2bc5cc04fb568fb036a438da43ee9a9f78/read.go#L112-L126 |
26,195 | alecthomas/chroma | formatters/api.go | Names | func Names() []string {
out := []string{}
for name := range Registry {
out = append(out, name)
}
sort.Strings(out)
return out
} | go | func Names() []string {
out := []string{}
for name := range Registry {
out = append(out, name)
}
sort.Strings(out)
return out
} | [
"func",
"Names",
"(",
")",
"[",
"]",
"string",
"{",
"out",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"name",
":=",
"range",
"Registry",
"{",
"out",
"=",
"append",
"(",
"out",
",",
"name",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"("... | // Names of registered formatters. | [
"Names",
"of",
"registered",
"formatters",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/api.go#L32-L39 |
26,196 | alecthomas/chroma | formatters/api.go | Get | func Get(name string) chroma.Formatter {
if f, ok := Registry[name]; ok {
return f
}
return Fallback
} | go | func Get(name string) chroma.Formatter {
if f, ok := Registry[name]; ok {
return f
}
return Fallback
} | [
"func",
"Get",
"(",
"name",
"string",
")",
"chroma",
".",
"Formatter",
"{",
"if",
"f",
",",
"ok",
":=",
"Registry",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"f",
"\n",
"}",
"\n",
"return",
"Fallback",
"\n",
"}"
] | // Get formatter by name.
//
// If the given formatter is not found, the Fallback formatter will be returned. | [
"Get",
"formatter",
"by",
"name",
".",
"If",
"the",
"given",
"formatter",
"is",
"not",
"found",
"the",
"Fallback",
"formatter",
"will",
"be",
"returned",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/api.go#L44-L49 |
26,197 | alecthomas/chroma | formatters/api.go | Register | func Register(name string, formatter chroma.Formatter) chroma.Formatter {
Registry[name] = formatter
return formatter
} | go | func Register(name string, formatter chroma.Formatter) chroma.Formatter {
Registry[name] = formatter
return formatter
} | [
"func",
"Register",
"(",
"name",
"string",
",",
"formatter",
"chroma",
".",
"Formatter",
")",
"chroma",
".",
"Formatter",
"{",
"Registry",
"[",
"name",
"]",
"=",
"formatter",
"\n",
"return",
"formatter",
"\n",
"}"
] | // Register a named formatter. | [
"Register",
"a",
"named",
"formatter",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/api.go#L52-L55 |
26,198 | alecthomas/chroma | style.go | Prefix | func (t Trilean) Prefix(s string) string {
if t == Yes {
return s
} else if t == No {
return "no" + s
}
return ""
} | go | func (t Trilean) Prefix(s string) string {
if t == Yes {
return s
} else if t == No {
return "no" + s
}
return ""
} | [
"func",
"(",
"t",
"Trilean",
")",
"Prefix",
"(",
"s",
"string",
")",
"string",
"{",
"if",
"t",
"==",
"Yes",
"{",
"return",
"s",
"\n",
"}",
"else",
"if",
"t",
"==",
"No",
"{",
"return",
"\"",
"\"",
"+",
"s",
"\n",
"}",
"\n",
"return",
"\"",
"\... | // Prefix returns s with "no" as a prefix if Trilean is no. | [
"Prefix",
"returns",
"s",
"with",
"no",
"as",
"a",
"prefix",
"if",
"Trilean",
"is",
"no",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L30-L37 |
26,199 | alecthomas/chroma | style.go | Sub | func (s StyleEntry) Sub(e StyleEntry) StyleEntry {
out := StyleEntry{}
if e.Colour != s.Colour {
out.Colour = s.Colour
}
if e.Background != s.Background {
out.Background = s.Background
}
if e.Bold != s.Bold {
out.Bold = s.Bold
}
if e.Italic != s.Italic {
out.Italic = s.Italic
}
if e.Underline != s.Und... | go | func (s StyleEntry) Sub(e StyleEntry) StyleEntry {
out := StyleEntry{}
if e.Colour != s.Colour {
out.Colour = s.Colour
}
if e.Background != s.Background {
out.Background = s.Background
}
if e.Bold != s.Bold {
out.Bold = s.Bold
}
if e.Italic != s.Italic {
out.Italic = s.Italic
}
if e.Underline != s.Und... | [
"func",
"(",
"s",
"StyleEntry",
")",
"Sub",
"(",
"e",
"StyleEntry",
")",
"StyleEntry",
"{",
"out",
":=",
"StyleEntry",
"{",
"}",
"\n",
"if",
"e",
".",
"Colour",
"!=",
"s",
".",
"Colour",
"{",
"out",
".",
"Colour",
"=",
"s",
".",
"Colour",
"\n",
"... | // Sub subtracts e from s where elements match. | [
"Sub",
"subtracts",
"e",
"from",
"s",
"where",
"elements",
"match",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L79-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.