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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,000 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go | readArmored | func readArmored(r io.Reader, expectedType string) (body io.Reader, err error) {
block, err := armor.Decode(r)
if err != nil {
return
}
if block.Type != expectedType {
return nil, errors.InvalidArgumentError("expected '" + expectedType + "', got: " + block.Type)
}
return block.Body, nil
} | go | func readArmored(r io.Reader, expectedType string) (body io.Reader, err error) {
block, err := armor.Decode(r)
if err != nil {
return
}
if block.Type != expectedType {
return nil, errors.InvalidArgumentError("expected '" + expectedType + "', got: " + block.Type)
}
return block.Body, nil
} | [
"func",
"readArmored",
"(",
"r",
"io",
".",
"Reader",
",",
"expectedType",
"string",
")",
"(",
"body",
"io",
".",
"Reader",
",",
"err",
"error",
")",
"{",
"block",
",",
"err",
":=",
"armor",
".",
"Decode",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
... | // readArmored reads an armored block with the given type. | [
"readArmored",
"reads",
"an",
"armored",
"block",
"with",
"the",
"given",
"type",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go#L23-L34 |
150,001 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go | readSignedMessage | func readSignedMessage(packets *packet.Reader, mdin *MessageDetails, keyring KeyRing) (md *MessageDetails, err error) {
if mdin == nil {
mdin = new(MessageDetails)
}
md = mdin
var p packet.Packet
var h hash.Hash
var wrappedHash hash.Hash
FindLiteralData:
for {
p, err = packets.Next()
if err != nil {
re... | go | func readSignedMessage(packets *packet.Reader, mdin *MessageDetails, keyring KeyRing) (md *MessageDetails, err error) {
if mdin == nil {
mdin = new(MessageDetails)
}
md = mdin
var p packet.Packet
var h hash.Hash
var wrappedHash hash.Hash
FindLiteralData:
for {
p, err = packets.Next()
if err != nil {
re... | [
"func",
"readSignedMessage",
"(",
"packets",
"*",
"packet",
".",
"Reader",
",",
"mdin",
"*",
"MessageDetails",
",",
"keyring",
"KeyRing",
")",
"(",
"md",
"*",
"MessageDetails",
",",
"err",
"error",
")",
"{",
"if",
"mdin",
"==",
"nil",
"{",
"mdin",
"=",
... | // readSignedMessage reads a possibly signed message if mdin is non-zero then
// that structure is updated and returned. Otherwise a fresh MessageDetails is
// used. | [
"readSignedMessage",
"reads",
"a",
"possibly",
"signed",
"message",
"if",
"mdin",
"is",
"non",
"-",
"zero",
"then",
"that",
"structure",
"is",
"updated",
"and",
"returned",
".",
"Otherwise",
"a",
"fresh",
"MessageDetails",
"is",
"used",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go#L223-L275 |
150,002 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go | CheckDetachedSignature | func CheckDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error) {
p, err := packet.Read(signature)
if err != nil {
return
}
var issuerKeyId uint64
var hashFunc crypto.Hash
var sigType packet.SignatureType
switch sig := p.(type) {
case *packet.Signature:
if sig.IssuerK... | go | func CheckDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error) {
p, err := packet.Read(signature)
if err != nil {
return
}
var issuerKeyId uint64
var hashFunc crypto.Hash
var sigType packet.SignatureType
switch sig := p.(type) {
case *packet.Signature:
if sig.IssuerK... | [
"func",
"CheckDetachedSignature",
"(",
"keyring",
"KeyRing",
",",
"signed",
",",
"signature",
"io",
".",
"Reader",
")",
"(",
"signer",
"*",
"Entity",
",",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"packet",
".",
"Read",
"(",
"signature",
")",
"\... | // CheckDetachedSignature takes a signed file and a detached signature and
// returns the signer if the signature is valid. If the signer isn't known,
// ErrUnknownIssuer is returned. | [
"CheckDetachedSignature",
"takes",
"a",
"signed",
"file",
"and",
"a",
"detached",
"signature",
"and",
"returns",
"the",
"signer",
"if",
"the",
"signature",
"is",
"valid",
".",
"If",
"the",
"signer",
"isn",
"t",
"known",
"ErrUnknownIssuer",
"is",
"returned",
".... | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go#L359-L416 |
150,003 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go | CheckArmoredDetachedSignature | func CheckArmoredDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error) {
body, err := readArmored(signature, SignatureType)
if err != nil {
return
}
return CheckDetachedSignature(keyring, signed, body)
} | go | func CheckArmoredDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error) {
body, err := readArmored(signature, SignatureType)
if err != nil {
return
}
return CheckDetachedSignature(keyring, signed, body)
} | [
"func",
"CheckArmoredDetachedSignature",
"(",
"keyring",
"KeyRing",
",",
"signed",
",",
"signature",
"io",
".",
"Reader",
")",
"(",
"signer",
"*",
"Entity",
",",
"err",
"error",
")",
"{",
"body",
",",
"err",
":=",
"readArmored",
"(",
"signature",
",",
"Sig... | // CheckArmoredDetachedSignature performs the same actions as
// CheckDetachedSignature but expects the signature to be armored. | [
"CheckArmoredDetachedSignature",
"performs",
"the",
"same",
"actions",
"as",
"CheckDetachedSignature",
"but",
"expects",
"the",
"signature",
"to",
"be",
"armored",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go#L420-L427 |
150,004 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/compressed.go | SerializeCompressed | func SerializeCompressed(w io.WriteCloser, algo CompressionAlgo, cc *CompressionConfig) (literaldata io.WriteCloser, err error) {
compressed, err := serializeStreamHeader(w, packetTypeCompressed)
if err != nil {
return
}
_, err = compressed.Write([]byte{uint8(algo)})
if err != nil {
return
}
level := Defau... | go | func SerializeCompressed(w io.WriteCloser, algo CompressionAlgo, cc *CompressionConfig) (literaldata io.WriteCloser, err error) {
compressed, err := serializeStreamHeader(w, packetTypeCompressed)
if err != nil {
return
}
_, err = compressed.Write([]byte{uint8(algo)})
if err != nil {
return
}
level := Defau... | [
"func",
"SerializeCompressed",
"(",
"w",
"io",
".",
"WriteCloser",
",",
"algo",
"CompressionAlgo",
",",
"cc",
"*",
"CompressionConfig",
")",
"(",
"literaldata",
"io",
".",
"WriteCloser",
",",
"err",
"error",
")",
"{",
"compressed",
",",
"err",
":=",
"seriali... | // SerializeCompressed serializes a compressed data packet to w and
// returns a WriteCloser to which the literal data packets themselves
// can be written and which MUST be closed on completion. If cc is
// nil, sensible defaults will be used to configure the compression
// algorithm. | [
"SerializeCompressed",
"serializes",
"a",
"compressed",
"data",
"packet",
"to",
"w",
"and",
"returns",
"a",
"WriteCloser",
"to",
"which",
"the",
"literal",
"data",
"packets",
"themselves",
"can",
"be",
"written",
"and",
"which",
"MUST",
"be",
"closed",
"on",
"... | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/compressed.go#L90-L123 |
150,005 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | primaryIdentity | func (e *Entity) primaryIdentity() *Identity {
var firstIdentity *Identity
for _, ident := range e.Identities {
if firstIdentity == nil {
firstIdentity = ident
}
if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
return ident
}
}
return firstIdentity
} | go | func (e *Entity) primaryIdentity() *Identity {
var firstIdentity *Identity
for _, ident := range e.Identities {
if firstIdentity == nil {
firstIdentity = ident
}
if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
return ident
}
}
return firstIdentity
} | [
"func",
"(",
"e",
"*",
"Entity",
")",
"primaryIdentity",
"(",
")",
"*",
"Identity",
"{",
"var",
"firstIdentity",
"*",
"Identity",
"\n",
"for",
"_",
",",
"ident",
":=",
"range",
"e",
".",
"Identities",
"{",
"if",
"firstIdentity",
"==",
"nil",
"{",
"firs... | // primaryIdentity returns the Identity marked as primary or the first identity
// if none are so marked. | [
"primaryIdentity",
"returns",
"the",
"Identity",
"marked",
"as",
"primary",
"or",
"the",
"first",
"identity",
"if",
"none",
"are",
"so",
"marked",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L76-L87 |
150,006 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | signingKey | func (e *Entity) signingKey(now time.Time) (Key, bool) {
candidateSubkey := -1
for i, subkey := range e.Subkeys {
if subkey.Sig.FlagsValid &&
subkey.Sig.FlagSign &&
subkey.PublicKey.PubKeyAlgo.CanSign() &&
!subkey.Sig.KeyExpired(now) {
candidateSubkey = i
break
}
}
if candidateSubkey != -1 {
... | go | func (e *Entity) signingKey(now time.Time) (Key, bool) {
candidateSubkey := -1
for i, subkey := range e.Subkeys {
if subkey.Sig.FlagsValid &&
subkey.Sig.FlagSign &&
subkey.PublicKey.PubKeyAlgo.CanSign() &&
!subkey.Sig.KeyExpired(now) {
candidateSubkey = i
break
}
}
if candidateSubkey != -1 {
... | [
"func",
"(",
"e",
"*",
"Entity",
")",
"signingKey",
"(",
"now",
"time",
".",
"Time",
")",
"(",
"Key",
",",
"bool",
")",
"{",
"candidateSubkey",
":=",
"-",
"1",
"\n\n",
"for",
"i",
",",
"subkey",
":=",
"range",
"e",
".",
"Subkeys",
"{",
"if",
"sub... | // signingKey return the best candidate Key for signing a message with this
// Entity. | [
"signingKey",
"return",
"the",
"best",
"candidate",
"Key",
"for",
"signing",
"a",
"message",
"with",
"this",
"Entity",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L129-L156 |
150,007 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | KeysById | func (el EntityList) KeysById(id uint64) (keys []Key) {
for _, e := range el {
if e.PrimaryKey.KeyId == id {
var selfSig *packet.Signature
for _, ident := range e.Identities {
if selfSig == nil {
selfSig = ident.SelfSignature
} else if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature... | go | func (el EntityList) KeysById(id uint64) (keys []Key) {
for _, e := range el {
if e.PrimaryKey.KeyId == id {
var selfSig *packet.Signature
for _, ident := range e.Identities {
if selfSig == nil {
selfSig = ident.SelfSignature
} else if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature... | [
"func",
"(",
"el",
"EntityList",
")",
"KeysById",
"(",
"id",
"uint64",
")",
"(",
"keys",
"[",
"]",
"Key",
")",
"{",
"for",
"_",
",",
"e",
":=",
"range",
"el",
"{",
"if",
"e",
".",
"PrimaryKey",
".",
"KeyId",
"==",
"id",
"{",
"var",
"selfSig",
"... | // KeysById returns the set of keys that have the given key id. | [
"KeysById",
"returns",
"the",
"set",
"of",
"keys",
"that",
"have",
"the",
"given",
"key",
"id",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L162-L184 |
150,008 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | DecryptionKeys | func (el EntityList) DecryptionKeys() (keys []Key) {
for _, e := range el {
for _, subKey := range e.Subkeys {
if subKey.PrivateKey != nil && (!subKey.Sig.FlagsValid || subKey.Sig.FlagEncryptStorage || subKey.Sig.FlagEncryptCommunications) {
keys = append(keys, Key{e, subKey.PublicKey, subKey.PrivateKey, subK... | go | func (el EntityList) DecryptionKeys() (keys []Key) {
for _, e := range el {
for _, subKey := range e.Subkeys {
if subKey.PrivateKey != nil && (!subKey.Sig.FlagsValid || subKey.Sig.FlagEncryptStorage || subKey.Sig.FlagEncryptCommunications) {
keys = append(keys, Key{e, subKey.PublicKey, subKey.PrivateKey, subK... | [
"func",
"(",
"el",
"EntityList",
")",
"DecryptionKeys",
"(",
")",
"(",
"keys",
"[",
"]",
"Key",
")",
"{",
"for",
"_",
",",
"e",
":=",
"range",
"el",
"{",
"for",
"_",
",",
"subKey",
":=",
"range",
"e",
".",
"Subkeys",
"{",
"if",
"subKey",
".",
"... | // DecryptionKeys returns all private keys that are valid for decryption. | [
"DecryptionKeys",
"returns",
"all",
"private",
"keys",
"that",
"are",
"valid",
"for",
"decryption",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L224-L233 |
150,009 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | readToNextPublicKey | func readToNextPublicKey(packets *packet.Reader) (err error) {
var p packet.Packet
for {
p, err = packets.Next()
if err == io.EOF {
return
} else if err != nil {
if _, ok := err.(errors.UnsupportedError); ok {
err = nil
continue
}
return
}
if pk, ok := p.(*packet.PublicKey); ok && !pk.I... | go | func readToNextPublicKey(packets *packet.Reader) (err error) {
var p packet.Packet
for {
p, err = packets.Next()
if err == io.EOF {
return
} else if err != nil {
if _, ok := err.(errors.UnsupportedError); ok {
err = nil
continue
}
return
}
if pk, ok := p.(*packet.PublicKey); ok && !pk.I... | [
"func",
"readToNextPublicKey",
"(",
"packets",
"*",
"packet",
".",
"Reader",
")",
"(",
"err",
"error",
")",
"{",
"var",
"p",
"packet",
".",
"Packet",
"\n",
"for",
"{",
"p",
",",
"err",
"=",
"packets",
".",
"Next",
"(",
")",
"\n",
"if",
"err",
"==",... | // readToNextPublicKey reads packets until the start of the entity and leaves
// the first packet of the new entity in the Reader. | [
"readToNextPublicKey",
"reads",
"packets",
"until",
"the",
"start",
"of",
"the",
"entity",
"and",
"leaves",
"the",
"first",
"packet",
"of",
"the",
"new",
"entity",
"in",
"the",
"Reader",
"."
] | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L291-L312 |
150,010 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | SerializePrivate | func (e *Entity) SerializePrivate(w io.Writer, config *packet.Config) (err error) {
err = e.PrivateKey.Serialize(w)
if err != nil {
return
}
for _, ident := range e.Identities {
err = ident.UserId.Serialize(w)
if err != nil {
return
}
err = ident.SelfSignature.SignUserId(ident.UserId.Id, e.PrimaryKey, ... | go | func (e *Entity) SerializePrivate(w io.Writer, config *packet.Config) (err error) {
err = e.PrivateKey.Serialize(w)
if err != nil {
return
}
for _, ident := range e.Identities {
err = ident.UserId.Serialize(w)
if err != nil {
return
}
err = ident.SelfSignature.SignUserId(ident.UserId.Id, e.PrimaryKey, ... | [
"func",
"(",
"e",
"*",
"Entity",
")",
"SerializePrivate",
"(",
"w",
"io",
".",
"Writer",
",",
"config",
"*",
"packet",
".",
"Config",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"e",
".",
"PrivateKey",
".",
"Serialize",
"(",
"w",
")",
"\n",
"... | // SerializePrivate serializes an Entity, including private key material, to
// the given Writer. For now, it must only be used on an Entity returned from
// NewEntity.
// If config is nil, sensible defaults will be used. | [
"SerializePrivate",
"serializes",
"an",
"Entity",
"including",
"private",
"key",
"material",
"to",
"the",
"given",
"Writer",
".",
"For",
"now",
"it",
"must",
"only",
"be",
"used",
"on",
"an",
"Entity",
"returned",
"from",
"NewEntity",
".",
"If",
"config",
"i... | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L527-L561 |
150,011 | lavab/mailer | Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go | SignIdentity | func (e *Entity) SignIdentity(identity string, signer *Entity, config *packet.Config) error {
if signer.PrivateKey == nil {
return errors.InvalidArgumentError("signing Entity must have a private key")
}
if signer.PrivateKey.Encrypted {
return errors.InvalidArgumentError("signing Entity's private key must be decr... | go | func (e *Entity) SignIdentity(identity string, signer *Entity, config *packet.Config) error {
if signer.PrivateKey == nil {
return errors.InvalidArgumentError("signing Entity must have a private key")
}
if signer.PrivateKey.Encrypted {
return errors.InvalidArgumentError("signing Entity's private key must be decr... | [
"func",
"(",
"e",
"*",
"Entity",
")",
"SignIdentity",
"(",
"identity",
"string",
",",
"signer",
"*",
"Entity",
",",
"config",
"*",
"packet",
".",
"Config",
")",
"error",
"{",
"if",
"signer",
".",
"PrivateKey",
"==",
"nil",
"{",
"return",
"errors",
".",... | // SignIdentity adds a signature to e, from signer, attesting that identity is
// associated with e. The provided identity must already be an element of
// e.Identities and the private key of signer must have been decrypted if
// necessary.
// If config is nil, sensible defaults will be used. | [
"SignIdentity",
"adds",
"a",
"signature",
"to",
"e",
"from",
"signer",
"attesting",
"that",
"identity",
"is",
"associated",
"with",
"e",
".",
"The",
"provided",
"identity",
"must",
"already",
"be",
"an",
"element",
"of",
"e",
".",
"Identities",
"and",
"the",... | a0901ff739bb9a5599f40133deaadb250ec834db | https://github.com/lavab/mailer/blob/a0901ff739bb9a5599f40133deaadb250ec834db/Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go#L604-L628 |
150,012 | cloudfoundry-attic/garden-linux | process_tracker/process.go | runLinker | func (p *Process) runLinker() {
processSock := path.Join(p.containerPath, "processes", fmt.Sprintf("%s.sock", p.ID()))
link, err := link.Create(processSock, p.stdout, p.stderr)
if err != nil {
p.completed(-1, err)
return
}
p.stdin.AddSink(link)
p.link = link
close(p.linked)
p.completed(p.link.Wait())
... | go | func (p *Process) runLinker() {
processSock := path.Join(p.containerPath, "processes", fmt.Sprintf("%s.sock", p.ID()))
link, err := link.Create(processSock, p.stdout, p.stderr)
if err != nil {
p.completed(-1, err)
return
}
p.stdin.AddSink(link)
p.link = link
close(p.linked)
p.completed(p.link.Wait())
... | [
"func",
"(",
"p",
"*",
"Process",
")",
"runLinker",
"(",
")",
"{",
"processSock",
":=",
"path",
".",
"Join",
"(",
"p",
".",
"containerPath",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
".",
"ID",
"(",
")",
")",
")",
... | // This is guarded by runningLink so will only run once per Process per garden. | [
"This",
"is",
"guarded",
"by",
"runningLink",
"so",
"will",
"only",
"run",
"once",
"per",
"Process",
"per",
"garden",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/process_tracker/process.go#L222-L240 |
150,013 | cloudfoundry-attic/garden-linux | iodaemon/iodaemon.go | Spawn | func Spawn(
socketPath string,
argv []string,
timeout time.Duration,
notifyStream io.WriteCloser,
wirer *Wirer,
daemon *Daemon,
) error {
listener, err := listen(socketPath)
if err != nil {
return err
}
defer listener.Close()
executablePath, err := exec.LookPath(argv[0])
if err != nil {
return fmt.Er... | go | func Spawn(
socketPath string,
argv []string,
timeout time.Duration,
notifyStream io.WriteCloser,
wirer *Wirer,
daemon *Daemon,
) error {
listener, err := listen(socketPath)
if err != nil {
return err
}
defer listener.Close()
executablePath, err := exec.LookPath(argv[0])
if err != nil {
return fmt.Er... | [
"func",
"Spawn",
"(",
"socketPath",
"string",
",",
"argv",
"[",
"]",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"notifyStream",
"io",
".",
"WriteCloser",
",",
"wirer",
"*",
"Wirer",
",",
"daemon",
"*",
"Daemon",
",",
")",
"error",
"{",
"li... | // spawn listens on a unix socket at the given socketPath and when the first connection
// is received, starts a child process. | [
"spawn",
"listens",
"on",
"a",
"unix",
"socket",
"at",
"the",
"given",
"socketPath",
"and",
"when",
"the",
"first",
"connection",
"is",
"received",
"starts",
"a",
"child",
"process",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/iodaemon/iodaemon.go#L18-L96 |
150,014 | cloudfoundry-attic/garden-linux | container_daemon/unix_socket/listener.go | NewListenerFromPath | func NewListenerFromPath(socketPath string) (*Listener, error) {
l := &Listener{}
var err error
l.listener, err = net.Listen("unix", socketPath)
if err != nil {
return nil, fmt.Errorf("unix_socket: error creating socket: %v", err)
}
return l, nil
} | go | func NewListenerFromPath(socketPath string) (*Listener, error) {
l := &Listener{}
var err error
l.listener, err = net.Listen("unix", socketPath)
if err != nil {
return nil, fmt.Errorf("unix_socket: error creating socket: %v", err)
}
return l, nil
} | [
"func",
"NewListenerFromPath",
"(",
"socketPath",
"string",
")",
"(",
"*",
"Listener",
",",
"error",
")",
"{",
"l",
":=",
"&",
"Listener",
"{",
"}",
"\n",
"var",
"err",
"error",
"\n\n",
"l",
".",
"listener",
",",
"err",
"=",
"net",
".",
"Listen",
"("... | // This function should be called from the host namespace, to open the socket file in the right file system. | [
"This",
"function",
"should",
"be",
"called",
"from",
"the",
"host",
"namespace",
"to",
"open",
"the",
"socket",
"file",
"in",
"the",
"right",
"file",
"system",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/container_daemon/unix_socket/listener.go#L25-L35 |
150,015 | cloudfoundry-attic/garden-linux | container_daemon/initd/start.go | start | func start() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "initd: panicked: %s\n", r)
os.Exit(4)
}
}()
flag.String("title", "", "")
dropCaps := flag.Bool("dropCapabilities", false, "drop capabilities before running processes")
flag.Parse()
container_daemon.Detach("/dev/null", ... | go | func start() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "initd: panicked: %s\n", r)
os.Exit(4)
}
}()
flag.String("title", "", "")
dropCaps := flag.Bool("dropCapabilities", false, "drop capabilities before running processes")
flag.Parse()
container_daemon.Detach("/dev/null", ... | [
"func",
"start",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\\n",
"\"",
",",
"r",
")",
"\n",
"os",
".",
"Exit... | // initd listens on a socket, spawns requested processes and reaps their
// exit statuses. | [
"initd",
"listens",
"on",
"a",
"socket",
"spawns",
"requested",
"processes",
"and",
"reaps",
"their",
"exit",
"statuses",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/container_daemon/initd/start.go#L27-L89 |
150,016 | cloudfoundry-attic/garden-linux | network/devices/bridge.go | Create | func (Bridge) Create(name string, ip net.IP, subnet *net.IPNet) (intf *net.Interface, err error) {
netlinkMu.Lock()
defer netlinkMu.Unlock()
if intf, err = idempotentlyCreateBridge(name); err != nil {
return nil, err
}
if err = netlink.NetworkLinkAddIp(intf, ip, subnet); err != nil && err.Error() != "file exis... | go | func (Bridge) Create(name string, ip net.IP, subnet *net.IPNet) (intf *net.Interface, err error) {
netlinkMu.Lock()
defer netlinkMu.Unlock()
if intf, err = idempotentlyCreateBridge(name); err != nil {
return nil, err
}
if err = netlink.NetworkLinkAddIp(intf, ip, subnet); err != nil && err.Error() != "file exis... | [
"func",
"(",
"Bridge",
")",
"Create",
"(",
"name",
"string",
",",
"ip",
"net",
".",
"IP",
",",
"subnet",
"*",
"net",
".",
"IPNet",
")",
"(",
"intf",
"*",
"net",
".",
"Interface",
",",
"err",
"error",
")",
"{",
"netlinkMu",
".",
"Lock",
"(",
")",
... | // Create creates a bridge device and returns the interface.
// If the device already exists, returns the existing interface. | [
"Create",
"creates",
"a",
"bridge",
"device",
"and",
"returns",
"the",
"interface",
".",
"If",
"the",
"device",
"already",
"exists",
"returns",
"the",
"existing",
"interface",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/devices/bridge.go#L22-L35 |
150,017 | cloudfoundry-attic/garden-linux | container_daemon/proc_starter/start.go | start | func start() {
rlimits := flag.String("rlimits", "", "encoded rlimits")
dropCapabilities := flag.Bool("dropCapabilities", true, "drop capabilities before starting process")
uid := flag.Int("uid", -1, "user id to run the process as")
gid := flag.Int("gid", -1, "group id to run the process as")
workDir := flag.Strin... | go | func start() {
rlimits := flag.String("rlimits", "", "encoded rlimits")
dropCapabilities := flag.Bool("dropCapabilities", true, "drop capabilities before starting process")
uid := flag.Int("uid", -1, "user id to run the process as")
gid := flag.Int("gid", -1, "group id to run the process as")
workDir := flag.Strin... | [
"func",
"start",
"(",
")",
"{",
"rlimits",
":=",
"flag",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"dropCapabilities",
":=",
"flag",
".",
"Bool",
"(",
"\"",
"\"",
",",
"true",
",",
"\"",
"\"",
")",
"\n",
"uid"... | // proc_starter starts a user process with the correct rlimits and after
// closing any open FDs. | [
"proc_starter",
"starts",
"a",
"user",
"process",
"with",
"the",
"correct",
"rlimits",
"and",
"after",
"closing",
"any",
"open",
"FDs",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/container_daemon/proc_starter/start.go#L25-L51 |
150,018 | cloudfoundry-attic/garden-linux | resource_pool/resource_pool.go | pruneEntry | func (p *LinuxResourcePool) pruneEntry(id string) {
pLog := p.logger.Session("prune", lager.Data{"id": id})
pLog.Info("prune")
err := p.releaseSystemResources(pLog, id)
if err != nil {
pLog.Error("release-system-resources-error", err)
}
pLog.Info("end of prune")
} | go | func (p *LinuxResourcePool) pruneEntry(id string) {
pLog := p.logger.Session("prune", lager.Data{"id": id})
pLog.Info("prune")
err := p.releaseSystemResources(pLog, id)
if err != nil {
pLog.Error("release-system-resources-error", err)
}
pLog.Info("end of prune")
} | [
"func",
"(",
"p",
"*",
"LinuxResourcePool",
")",
"pruneEntry",
"(",
"id",
"string",
")",
"{",
"pLog",
":=",
"p",
".",
"logger",
".",
"Session",
"(",
"\"",
"\"",
",",
"lager",
".",
"Data",
"{",
"\"",
"\"",
":",
"id",
"}",
")",
"\n\n",
"pLog",
".",... | // pruneEntry does not report errors, only log them | [
"pruneEntry",
"does",
"not",
"report",
"errors",
"only",
"log",
"them"
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/resource_pool/resource_pool.go#L254-L265 |
150,019 | cloudfoundry-attic/garden-linux | network/subnets/subnets.go | NewSubnets | func NewSubnets(ipNet *net.IPNet) (Subnets, error) {
return &pool{dynamicRange: ipNet, allocated: make(map[string][]net.IP)}, nil
} | go | func NewSubnets(ipNet *net.IPNet) (Subnets, error) {
return &pool{dynamicRange: ipNet, allocated: make(map[string][]net.IP)}, nil
} | [
"func",
"NewSubnets",
"(",
"ipNet",
"*",
"net",
".",
"IPNet",
")",
"(",
"Subnets",
",",
"error",
")",
"{",
"return",
"&",
"pool",
"{",
"dynamicRange",
":",
"ipNet",
",",
"allocated",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"net",
"."... | // New creates a Subnets implementation from a dynamic allocation range.
// All dynamic allocations come from the range, static allocations are prohibited
// from the dynamic range. | [
"New",
"creates",
"a",
"Subnets",
"implementation",
"from",
"a",
"dynamic",
"allocation",
"range",
".",
"All",
"dynamic",
"allocations",
"come",
"from",
"the",
"range",
"static",
"allocations",
"are",
"prohibited",
"from",
"the",
"dynamic",
"range",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/subnets/subnets.go#L64-L66 |
150,020 | cloudfoundry-attic/garden-linux | network/subnets/subnets.go | Acquire | func (p *pool) Acquire(sn SubnetSelector, i IPSelector, logger lager.Logger) (network *linux_backend.Network, err error) {
p.mu.Lock()
defer p.mu.Unlock()
logger = logger.Session("acquire")
network = &linux_backend.Network{}
allocatedSubnets := subnets(p.allocated)
logger.Info("subnet-selecting", lager.Data{"a... | go | func (p *pool) Acquire(sn SubnetSelector, i IPSelector, logger lager.Logger) (network *linux_backend.Network, err error) {
p.mu.Lock()
defer p.mu.Unlock()
logger = logger.Session("acquire")
network = &linux_backend.Network{}
allocatedSubnets := subnets(p.allocated)
logger.Info("subnet-selecting", lager.Data{"a... | [
"func",
"(",
"p",
"*",
"pool",
")",
"Acquire",
"(",
"sn",
"SubnetSelector",
",",
"i",
"IPSelector",
",",
"logger",
"lager",
".",
"Logger",
")",
"(",
"network",
"*",
"linux_backend",
".",
"Network",
",",
"err",
"error",
")",
"{",
"p",
".",
"mu",
".",
... | // Acquire uses the given subnet and IP selectors to request a subnet, container IP address combination
// from the pool. | [
"Acquire",
"uses",
"the",
"given",
"subnet",
"and",
"IP",
"selectors",
"to",
"request",
"a",
"subnet",
"container",
"IP",
"address",
"combination",
"from",
"the",
"pool",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/subnets/subnets.go#L70-L99 |
150,021 | cloudfoundry-attic/garden-linux | network/subnets/subnets.go | Remove | func (p *pool) Remove(network *linux_backend.Network, logger lager.Logger) error {
p.mu.Lock()
defer p.mu.Unlock()
logger = logger.Session("remove")
logger.Info("allocating-ips", lager.Data{"allocated-subnets": subnetsStr(subnets(p.allocated)), "allocated-ips": ipsStr(p.allocated[network.Subnet.String()])})
if ... | go | func (p *pool) Remove(network *linux_backend.Network, logger lager.Logger) error {
p.mu.Lock()
defer p.mu.Unlock()
logger = logger.Session("remove")
logger.Info("allocating-ips", lager.Data{"allocated-subnets": subnetsStr(subnets(p.allocated)), "allocated-ips": ipsStr(p.allocated[network.Subnet.String()])})
if ... | [
"func",
"(",
"p",
"*",
"pool",
")",
"Remove",
"(",
"network",
"*",
"linux_backend",
".",
"Network",
",",
"logger",
"lager",
".",
"Logger",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"("... | // Remove re-allocates a given subnet and ip address combination in the pool. It returns
// an error if the combination is already allocated. | [
"Remove",
"re",
"-",
"allocates",
"a",
"given",
"subnet",
"and",
"ip",
"address",
"combination",
"in",
"the",
"pool",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"combination",
"is",
"already",
"allocated",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/subnets/subnets.go#L103-L125 |
150,022 | cloudfoundry-attic/garden-linux | network/subnets/subnets.go | subnets | func subnets(m map[string][]net.IP) (result []*net.IPNet) {
for k, v := range m {
if len(v) > 0 {
_, ipn, err := net.ParseCIDR(k)
if err != nil {
panic(fmt.Sprintf("failed to parse a CIDR in the subnet pool: %s", err))
}
result = append(result, ipn)
}
}
return result
} | go | func subnets(m map[string][]net.IP) (result []*net.IPNet) {
for k, v := range m {
if len(v) > 0 {
_, ipn, err := net.ParseCIDR(k)
if err != nil {
panic(fmt.Sprintf("failed to parse a CIDR in the subnet pool: %s", err))
}
result = append(result, ipn)
}
}
return result
} | [
"func",
"subnets",
"(",
"m",
"map",
"[",
"string",
"]",
"[",
"]",
"net",
".",
"IP",
")",
"(",
"result",
"[",
"]",
"*",
"net",
".",
"IPNet",
")",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"if",
"len",
"(",
"v",
")",
">",
"0",
"{"... | // returns the keys in the given map whose values are non-empty slices | [
"returns",
"the",
"keys",
"in",
"the",
"given",
"map",
"whose",
"values",
"are",
"non",
"-",
"empty",
"slices"
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/subnets/subnets.go#L176-L189 |
150,023 | cloudfoundry-attic/garden-linux | network/subnets/subnets.go | removeIPAtIndex | func removeIPAtIndex(ips []net.IP, i int) ([]net.IP, bool) {
l := len(ips)
ips[i] = ips[l-1]
ips = ips[:l-1]
return ips, l == 1
} | go | func removeIPAtIndex(ips []net.IP, i int) ([]net.IP, bool) {
l := len(ips)
ips[i] = ips[l-1]
ips = ips[:l-1]
return ips, l == 1
} | [
"func",
"removeIPAtIndex",
"(",
"ips",
"[",
"]",
"net",
".",
"IP",
",",
"i",
"int",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"bool",
")",
"{",
"l",
":=",
"len",
"(",
"ips",
")",
"\n",
"ips",
"[",
"i",
"]",
"=",
"ips",
"[",
"l",
"-",
"1"... | // removeAtIndex removes from a slice at the given index,
// and returns the new slice and boolean, true iff the new slice is empty. | [
"removeAtIndex",
"removes",
"from",
"a",
"slice",
"at",
"the",
"given",
"index",
"and",
"returns",
"the",
"new",
"slice",
"and",
"boolean",
"true",
"iff",
"the",
"new",
"slice",
"is",
"empty",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/subnets/subnets.go#L223-L228 |
150,024 | cloudfoundry-attic/garden-linux | network/iptables/iptables.go | NewLoggingChain | func NewLoggingChain(name string, useKernelLogging bool, runner command_runner.CommandRunner, logger lager.Logger) Chain {
logger = logger.Session("logging-chain", lager.Data{
"name": name,
"useKernelLogging": useKernelLogging,
})
return &chain{
name: name,
logChainName: name + "-... | go | func NewLoggingChain(name string, useKernelLogging bool, runner command_runner.CommandRunner, logger lager.Logger) Chain {
logger = logger.Session("logging-chain", lager.Data{
"name": name,
"useKernelLogging": useKernelLogging,
})
return &chain{
name: name,
logChainName: name + "-... | [
"func",
"NewLoggingChain",
"(",
"name",
"string",
",",
"useKernelLogging",
"bool",
",",
"runner",
"command_runner",
".",
"CommandRunner",
",",
"logger",
"lager",
".",
"Logger",
")",
"Chain",
"{",
"logger",
"=",
"logger",
".",
"Session",
"(",
"\"",
"\"",
",",... | // NewLoggingChain creates a chain with an associated log chain.
// This allows NetOut calls with the 'log' parameter to succesfully log. | [
"NewLoggingChain",
"creates",
"a",
"chain",
"with",
"an",
"associated",
"log",
"chain",
".",
"This",
"allows",
"NetOut",
"calls",
"with",
"the",
"log",
"parameter",
"to",
"succesfully",
"log",
"."
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/network/iptables/iptables.go#L37-L50 |
150,025 | cloudfoundry-attic/garden-linux | process_tracker/writer/fan_in.go | AddSink | func (fw *fanIn) AddSink(sink io.WriteCloser) {
fw.w = sink
// Allow Write and Close to proceed.
close(fw.hasSink)
} | go | func (fw *fanIn) AddSink(sink io.WriteCloser) {
fw.w = sink
// Allow Write and Close to proceed.
close(fw.hasSink)
} | [
"func",
"(",
"fw",
"*",
"fanIn",
")",
"AddSink",
"(",
"sink",
"io",
".",
"WriteCloser",
")",
"{",
"fw",
".",
"w",
"=",
"sink",
"\n\n",
"// Allow Write and Close to proceed.",
"close",
"(",
"fw",
".",
"hasSink",
")",
"\n",
"}"
] | //AddSink can only be called once | [
"AddSink",
"can",
"only",
"be",
"called",
"once"
] | f00e7916300726e04c757af746e878be9734b386 | https://github.com/cloudfoundry-attic/garden-linux/blob/f00e7916300726e04c757af746e878be9734b386/process_tracker/writer/fan_in.go#L57-L62 |
150,026 | ericchiang/go-acme | certificate.go | Bundle | func (c *Client) Bundle(certResp *CertificateResponse) (bundledPEM []byte, err error) {
if !certResp.IsAvailable() {
return nil, errors.New("Cannot bundle without certificate")
}
if certResp.Issuer == "" {
return nil, errors.New("Could not bundle certificates. Issuer not found")
}
resp, err := c.client.Get(c... | go | func (c *Client) Bundle(certResp *CertificateResponse) (bundledPEM []byte, err error) {
if !certResp.IsAvailable() {
return nil, errors.New("Cannot bundle without certificate")
}
if certResp.Issuer == "" {
return nil, errors.New("Could not bundle certificates. Issuer not found")
}
resp, err := c.client.Get(c... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Bundle",
"(",
"certResp",
"*",
"CertificateResponse",
")",
"(",
"bundledPEM",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"!",
"certResp",
".",
"IsAvailable",
"(",
")",
"{",
"return",
"nil",
",",
"err... | // Bundle bundles the certificate with the issuer certificate. | [
"Bundle",
"bundles",
"the",
"certificate",
"with",
"the",
"issuer",
"certificate",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/certificate.go#L23-L47 |
150,027 | ericchiang/go-acme | challenge.go | HTTP | func (chal Challenge) HTTP(accountKey interface{}) (urlPath, resource string, err error) {
if chal.Type != ChallengeHTTP {
return "", "", fmt.Errorf("challenge type is %s not %s", chal.Type, ChallengeHTTP)
}
urlPath = path.Join("/.well-known/acme-challenge", chal.Token)
resource, err = keyAuth(accountKey, chal.T... | go | func (chal Challenge) HTTP(accountKey interface{}) (urlPath, resource string, err error) {
if chal.Type != ChallengeHTTP {
return "", "", fmt.Errorf("challenge type is %s not %s", chal.Type, ChallengeHTTP)
}
urlPath = path.Join("/.well-known/acme-challenge", chal.Token)
resource, err = keyAuth(accountKey, chal.T... | [
"func",
"(",
"chal",
"Challenge",
")",
"HTTP",
"(",
"accountKey",
"interface",
"{",
"}",
")",
"(",
"urlPath",
",",
"resource",
"string",
",",
"err",
"error",
")",
"{",
"if",
"chal",
".",
"Type",
"!=",
"ChallengeHTTP",
"{",
"return",
"\"",
"\"",
",",
... | // HTTP returns a URL path and HTTP response body that the ACME server will
// check when verifying the challenge. | [
"HTTP",
"returns",
"a",
"URL",
"path",
"and",
"HTTP",
"response",
"body",
"that",
"the",
"ACME",
"server",
"will",
"check",
"when",
"verifying",
"the",
"challenge",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/challenge.go#L32-L40 |
150,028 | ericchiang/go-acme | challenge.go | TLSSNI | func (chal Challenge) TLSSNI(accountKey interface{}) (map[string]*tls.Certificate, error) {
if chal.Type != ChallengeTLSSNI {
return nil, fmt.Errorf("challenge type is %s not %s", chal.Type, ChallengeTLSSNI)
}
auth, err := keyAuth(accountKey, chal.Token)
if err != nil {
return nil, err
}
// private key for ... | go | func (chal Challenge) TLSSNI(accountKey interface{}) (map[string]*tls.Certificate, error) {
if chal.Type != ChallengeTLSSNI {
return nil, fmt.Errorf("challenge type is %s not %s", chal.Type, ChallengeTLSSNI)
}
auth, err := keyAuth(accountKey, chal.Token)
if err != nil {
return nil, err
}
// private key for ... | [
"func",
"(",
"chal",
"Challenge",
")",
"TLSSNI",
"(",
"accountKey",
"interface",
"{",
"}",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"if",
"chal",
".",
"Type",
"!=",
"ChallengeTLSSNI",
"{",
"return",
... | // TLSSNI returns TLS certificates for a set of server names.
// The ACME server will make a TLS Server Name Indication handshake with the
// given domain. The domain must present the returned certifiate for each name. | [
"TLSSNI",
"returns",
"TLS",
"certificates",
"for",
"a",
"set",
"of",
"server",
"names",
".",
"The",
"ACME",
"server",
"will",
"make",
"a",
"TLS",
"Server",
"Name",
"Indication",
"handshake",
"with",
"the",
"given",
"domain",
".",
"The",
"domain",
"must",
"... | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/challenge.go#L45-L103 |
150,029 | ericchiang/go-acme | challenge.go | ProofOfPossession | func (chal Challenge) ProofOfPossession(accountKey, certKey interface{}) (Challenge, error) {
return Challenge{}, errors.New("proof of possession not implemented")
} | go | func (chal Challenge) ProofOfPossession(accountKey, certKey interface{}) (Challenge, error) {
return Challenge{}, errors.New("proof of possession not implemented")
} | [
"func",
"(",
"chal",
"Challenge",
")",
"ProofOfPossession",
"(",
"accountKey",
",",
"certKey",
"interface",
"{",
"}",
")",
"(",
"Challenge",
",",
"error",
")",
"{",
"return",
"Challenge",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",... | // Not yet implemented | [
"Not",
"yet",
"implemented"
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/challenge.go#L126-L128 |
150,030 | ericchiang/go-acme | challenge.go | ChallengeReady | func (c *Client) ChallengeReady(accountKey interface{}, chal Challenge) error {
switch chal.Type {
case ChallengeHTTP, ChallengeTLSSNI, ChallengeDNS:
default:
return fmt.Errorf("unsupported challenge type '%s'", chal.Type)
}
auth, err := keyAuth(accountKey, chal.Token)
if err != nil {
return err
}
data := s... | go | func (c *Client) ChallengeReady(accountKey interface{}, chal Challenge) error {
switch chal.Type {
case ChallengeHTTP, ChallengeTLSSNI, ChallengeDNS:
default:
return fmt.Errorf("unsupported challenge type '%s'", chal.Type)
}
auth, err := keyAuth(accountKey, chal.Token)
if err != nil {
return err
}
data := s... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ChallengeReady",
"(",
"accountKey",
"interface",
"{",
"}",
",",
"chal",
"Challenge",
")",
"error",
"{",
"switch",
"chal",
".",
"Type",
"{",
"case",
"ChallengeHTTP",
",",
"ChallengeTLSSNI",
",",
"ChallengeDNS",
":",
"d... | // ChallengeReady informs the server that the provided challenge is ready
// for verification.
//
// The client then begins polling the server for confirmation on the
// result of the status. | [
"ChallengeReady",
"informs",
"the",
"server",
"that",
"the",
"provided",
"challenge",
"is",
"ready",
"for",
"verification",
".",
"The",
"client",
"then",
"begins",
"polling",
"the",
"server",
"for",
"confirmation",
"on",
"the",
"result",
"of",
"the",
"status",
... | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/challenge.go#L135-L208 |
150,031 | ericchiang/go-acme | internal/base64/base64.go | WithPadding | func (enc Encoding) WithPadding(padding rune) *Encoding {
enc.padChar = padding
return &enc
} | go | func (enc Encoding) WithPadding(padding rune) *Encoding {
enc.padChar = padding
return &enc
} | [
"func",
"(",
"enc",
"Encoding",
")",
"WithPadding",
"(",
"padding",
"rune",
")",
"*",
"Encoding",
"{",
"enc",
".",
"padChar",
"=",
"padding",
"\n",
"return",
"&",
"enc",
"\n",
"}"
] | // WithPadding creates a new encoding identical to enc except
// with a specified padding character, or NoPadding to disable padding. | [
"WithPadding",
"creates",
"a",
"new",
"encoding",
"identical",
"to",
"enc",
"except",
"with",
"a",
"specified",
"padding",
"character",
"or",
"NoPadding",
"to",
"disable",
"padding",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/internal/base64/base64.go#L60-L63 |
150,032 | ericchiang/go-acme | internal/base64/base64.go | EncodedLen | func (enc *Encoding) EncodedLen(n int) int {
if enc.padChar == NoPadding {
return (n*8 + 5) / 6 // minimum # chars at 6 bits per char
}
return (n + 2) / 3 * 4 // minimum # 4-char quanta, 3 bytes each
} | go | func (enc *Encoding) EncodedLen(n int) int {
if enc.padChar == NoPadding {
return (n*8 + 5) / 6 // minimum # chars at 6 bits per char
}
return (n + 2) / 3 * 4 // minimum # 4-char quanta, 3 bytes each
} | [
"func",
"(",
"enc",
"*",
"Encoding",
")",
"EncodedLen",
"(",
"n",
"int",
")",
"int",
"{",
"if",
"enc",
".",
"padChar",
"==",
"NoPadding",
"{",
"return",
"(",
"n",
"*",
"8",
"+",
"5",
")",
"/",
"6",
"// minimum # chars at 6 bits per char",
"\n",
"}",
... | // EncodedLen returns the length in bytes of the base64 encoding
// of an input buffer of length n. | [
"EncodedLen",
"returns",
"the",
"length",
"in",
"bytes",
"of",
"the",
"base64",
"encoding",
"of",
"an",
"input",
"buffer",
"of",
"length",
"n",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/internal/base64/base64.go#L227-L232 |
150,033 | ericchiang/go-acme | internal/base64/base64.go | decode | func (enc *Encoding) decode(dst, src []byte) (n int, end bool, err error) {
si := 0
// skip over newlines
for si < len(src) && (src[si] == '\n' || src[si] == '\r') {
si++
}
for si < len(src) && !end {
// Decode quantum using the base64 alphabet
var dbuf [4]byte
dinc, dlen := 3, 4
for j := range dbuf {... | go | func (enc *Encoding) decode(dst, src []byte) (n int, end bool, err error) {
si := 0
// skip over newlines
for si < len(src) && (src[si] == '\n' || src[si] == '\r') {
si++
}
for si < len(src) && !end {
// Decode quantum using the base64 alphabet
var dbuf [4]byte
dinc, dlen := 3, 4
for j := range dbuf {... | [
"func",
"(",
"enc",
"*",
"Encoding",
")",
"decode",
"(",
"dst",
",",
"src",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"end",
"bool",
",",
"err",
"error",
")",
"{",
"si",
":=",
"0",
"\n\n",
"// skip over newlines",
"for",
"si",
"<",
"len",
"(",... | // decode is like Decode but returns an additional 'end' value, which
// indicates if end-of-message padding or a partial quantum was encountered
// and thus any additional data is an error. | [
"decode",
"is",
"like",
"Decode",
"but",
"returns",
"an",
"additional",
"end",
"value",
"which",
"indicates",
"if",
"end",
"-",
"of",
"-",
"message",
"padding",
"or",
"a",
"partial",
"quantum",
"was",
"encountered",
"and",
"thus",
"any",
"additional",
"data"... | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/internal/base64/base64.go#L247-L329 |
150,034 | ericchiang/go-acme | internal/base64/base64.go | DecodeString | func (enc *Encoding) DecodeString(s string) ([]byte, error) {
dbuf := make([]byte, enc.DecodedLen(len(s)))
n, _, err := enc.decode(dbuf, []byte(s))
return dbuf[:n], err
} | go | func (enc *Encoding) DecodeString(s string) ([]byte, error) {
dbuf := make([]byte, enc.DecodedLen(len(s)))
n, _, err := enc.decode(dbuf, []byte(s))
return dbuf[:n], err
} | [
"func",
"(",
"enc",
"*",
"Encoding",
")",
"DecodeString",
"(",
"s",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"dbuf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"enc",
".",
"DecodedLen",
"(",
"len",
"(",
"s",
")",
")",
")",
... | // DecodeString returns the bytes represented by the base64 string s. | [
"DecodeString",
"returns",
"the",
"bytes",
"represented",
"by",
"the",
"base64",
"string",
"s",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/internal/base64/base64.go#L342-L346 |
150,035 | ericchiang/go-acme | internal/base64/base64.go | DecodedLen | func (enc *Encoding) DecodedLen(n int) int {
if enc.padChar == NoPadding {
// Unpadded data may end with partial block of 2-3 characters.
return (n*6 + 7) / 8
}
// Padded base64 should always be a multiple of 4 characters in length.
return n / 4 * 3
} | go | func (enc *Encoding) DecodedLen(n int) int {
if enc.padChar == NoPadding {
// Unpadded data may end with partial block of 2-3 characters.
return (n*6 + 7) / 8
}
// Padded base64 should always be a multiple of 4 characters in length.
return n / 4 * 3
} | [
"func",
"(",
"enc",
"*",
"Encoding",
")",
"DecodedLen",
"(",
"n",
"int",
")",
"int",
"{",
"if",
"enc",
".",
"padChar",
"==",
"NoPadding",
"{",
"// Unpadded data may end with partial block of 2-3 characters.",
"return",
"(",
"n",
"*",
"6",
"+",
"7",
")",
"/",... | // DecodedLen returns the maximum length in bytes of the decoded data
// corresponding to n bytes of base64-encoded data. | [
"DecodedLen",
"returns",
"the",
"maximum",
"length",
"in",
"bytes",
"of",
"the",
"decoded",
"data",
"corresponding",
"to",
"n",
"bytes",
"of",
"base64",
"-",
"encoded",
"data",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/internal/base64/base64.go#L441-L448 |
150,036 | ericchiang/go-acme | objects.go | Combinations | func (a Authorization) Combinations(supportedChallenges ...string) [][]Challenge {
supported := func(chal Challenge) bool {
for _, c := range supportedChallenges {
if c == chal.Type {
return true
}
}
return false
}
chals := [][]Challenge{}
for _, comb := range a.Combs {
chalList := make([]Challen... | go | func (a Authorization) Combinations(supportedChallenges ...string) [][]Challenge {
supported := func(chal Challenge) bool {
for _, c := range supportedChallenges {
if c == chal.Type {
return true
}
}
return false
}
chals := [][]Challenge{}
for _, comb := range a.Combs {
chalList := make([]Challen... | [
"func",
"(",
"a",
"Authorization",
")",
"Combinations",
"(",
"supportedChallenges",
"...",
"string",
")",
"[",
"]",
"[",
"]",
"Challenge",
"{",
"supported",
":=",
"func",
"(",
"chal",
"Challenge",
")",
"bool",
"{",
"for",
"_",
",",
"c",
":=",
"range",
... | // Combinations returns the set of challenges which the client supports.
// Completing one of these sets is enough to prove ownership of an identifier. | [
"Combinations",
"returns",
"the",
"set",
"of",
"challenges",
"which",
"the",
"client",
"supports",
".",
"Completing",
"one",
"of",
"these",
"sets",
"is",
"enough",
"to",
"prove",
"ownership",
"of",
"an",
"identifier",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/objects.go#L55-L82 |
150,037 | ericchiang/go-acme | acme.go | NewClientWithTransport | func NewClientWithTransport(directoryURL string, t http.RoundTripper) (*Client, error) {
u, err := url.Parse(directoryURL)
if err != nil {
return nil, fmt.Errorf("could not parse URL %s: %v", directoryURL, err)
}
if u.Path == "" {
u.Path = boulderDirectoryPath
}
nrt := newNonceRoundTripper(t)
c := &Client{
... | go | func NewClientWithTransport(directoryURL string, t http.RoundTripper) (*Client, error) {
u, err := url.Parse(directoryURL)
if err != nil {
return nil, fmt.Errorf("could not parse URL %s: %v", directoryURL, err)
}
if u.Path == "" {
u.Path = boulderDirectoryPath
}
nrt := newNonceRoundTripper(t)
c := &Client{
... | [
"func",
"NewClientWithTransport",
"(",
"directoryURL",
"string",
",",
"t",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"directoryURL",
")",
"\n",
"if",
"err",
"!=",
"nil... | // NewClientWithTransport creates a client of a ACME server by querying the server's
// resource directory and attempting to resolve the URL of the terms of service. | [
"NewClientWithTransport",
"creates",
"a",
"client",
"of",
"a",
"ACME",
"server",
"by",
"querying",
"the",
"server",
"s",
"resource",
"directory",
"and",
"attempting",
"to",
"resolve",
"the",
"URL",
"of",
"the",
"terms",
"of",
"service",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L131-L172 |
150,038 | ericchiang/go-acme | acme.go | UpdateRegistration | func (c *Client) UpdateRegistration(accountKey interface{}, reg Registration) (Registration, error) {
url := c.resources.Registration + strconv.Itoa(reg.Id)
return c.registration(accountKey, reg, resourceRegistration, url)
} | go | func (c *Client) UpdateRegistration(accountKey interface{}, reg Registration) (Registration, error) {
url := c.resources.Registration + strconv.Itoa(reg.Id)
return c.registration(accountKey, reg, resourceRegistration, url)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateRegistration",
"(",
"accountKey",
"interface",
"{",
"}",
",",
"reg",
"Registration",
")",
"(",
"Registration",
",",
"error",
")",
"{",
"url",
":=",
"c",
".",
"resources",
".",
"Registration",
"+",
"strconv",
"... | // UpdateRegistration sends the updated registration object to the server. | [
"UpdateRegistration",
"sends",
"the",
"updated",
"registration",
"object",
"to",
"the",
"server",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L175-L178 |
150,039 | ericchiang/go-acme | acme.go | NewRegistration | func (c *Client) NewRegistration(accountKey interface{}) (reg Registration, err error) {
reg, err = c.registration(accountKey, Registration{}, resourceNewRegistration, c.resources.NewRegistration)
if err != nil || reg.Agreement == c.Terms() {
return
}
reg.Agreement = c.Terms()
reg, err = c.UpdateRegistration(acc... | go | func (c *Client) NewRegistration(accountKey interface{}) (reg Registration, err error) {
reg, err = c.registration(accountKey, Registration{}, resourceNewRegistration, c.resources.NewRegistration)
if err != nil || reg.Agreement == c.Terms() {
return
}
reg.Agreement = c.Terms()
reg, err = c.UpdateRegistration(acc... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewRegistration",
"(",
"accountKey",
"interface",
"{",
"}",
")",
"(",
"reg",
"Registration",
",",
"err",
"error",
")",
"{",
"reg",
",",
"err",
"=",
"c",
".",
"registration",
"(",
"accountKey",
",",
"Registration",
... | // NewRegistration registers a key pair with the ACME server.
// If the key pair is already registered, the registration object is recovered. | [
"NewRegistration",
"registers",
"a",
"key",
"pair",
"with",
"the",
"ACME",
"server",
".",
"If",
"the",
"key",
"pair",
"is",
"already",
"registered",
"the",
"registration",
"object",
"is",
"recovered",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L182-L190 |
150,040 | ericchiang/go-acme | acme.go | Authorization | func (c *Client) Authorization(authURI string) (Authorization, error) {
var auth Authorization
resp, err := c.client.Get(authURI)
if err != nil {
return auth, err
}
defer resp.Body.Close()
if err = checkHTTPError(resp, http.StatusOK); err != nil {
return auth, err
}
if err := json.NewDecoder(resp.Body).Dec... | go | func (c *Client) Authorization(authURI string) (Authorization, error) {
var auth Authorization
resp, err := c.client.Get(authURI)
if err != nil {
return auth, err
}
defer resp.Body.Close()
if err = checkHTTPError(resp, http.StatusOK); err != nil {
return auth, err
}
if err := json.NewDecoder(resp.Body).Dec... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Authorization",
"(",
"authURI",
"string",
")",
"(",
"Authorization",
",",
"error",
")",
"{",
"var",
"auth",
"Authorization",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"client",
".",
"Get",
"(",
"authURI",
")",
"... | // Authorization returns the authorization object associated with
// the given authorization URI. | [
"Authorization",
"returns",
"the",
"authorization",
"object",
"associated",
"with",
"the",
"given",
"authorization",
"URI",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L268-L283 |
150,041 | ericchiang/go-acme | acme.go | Challenge | func (c *Client) Challenge(chalURI string) (Challenge, error) {
var chal Challenge
resp, err := c.client.Get(chalURI)
if err != nil {
return chal, err
}
defer resp.Body.Close()
if err = checkHTTPError(resp, http.StatusAccepted); err != nil {
return chal, err
}
if err := json.NewDecoder(resp.Body).Decode(&c... | go | func (c *Client) Challenge(chalURI string) (Challenge, error) {
var chal Challenge
resp, err := c.client.Get(chalURI)
if err != nil {
return chal, err
}
defer resp.Body.Close()
if err = checkHTTPError(resp, http.StatusAccepted); err != nil {
return chal, err
}
if err := json.NewDecoder(resp.Body).Decode(&c... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Challenge",
"(",
"chalURI",
"string",
")",
"(",
"Challenge",
",",
"error",
")",
"{",
"var",
"chal",
"Challenge",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"client",
".",
"Get",
"(",
"chalURI",
")",
"\n",
"if",... | // Challenge returns the challenge object associated with the
// given challenge URI. | [
"Challenge",
"returns",
"the",
"challenge",
"object",
"associated",
"with",
"the",
"given",
"challenge",
"URI",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L287-L302 |
150,042 | ericchiang/go-acme | acme.go | NewCertificate | func (c *Client) NewCertificate(accountKey interface{}, csr *x509.CertificateRequest) (*CertificateResponse, error) {
if csr == nil || csr.Raw == nil {
return nil, errors.New("invalid certificate request object")
}
payload := struct {
Resource string `json:"resource"`
CSR string `json:"csr"`
}{
resourc... | go | func (c *Client) NewCertificate(accountKey interface{}, csr *x509.CertificateRequest) (*CertificateResponse, error) {
if csr == nil || csr.Raw == nil {
return nil, errors.New("invalid certificate request object")
}
payload := struct {
Resource string `json:"resource"`
CSR string `json:"csr"`
}{
resourc... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewCertificate",
"(",
"accountKey",
"interface",
"{",
"}",
",",
"csr",
"*",
"x509",
".",
"CertificateRequest",
")",
"(",
"*",
"CertificateResponse",
",",
"error",
")",
"{",
"if",
"csr",
"==",
"nil",
"||",
"csr",
"... | // NewCertificate requests a certificate from the ACME server.
//
// csr must have already been signed by a private key. | [
"NewCertificate",
"requests",
"a",
"certificate",
"from",
"the",
"ACME",
"server",
".",
"csr",
"must",
"have",
"already",
"been",
"signed",
"by",
"a",
"private",
"key",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L307-L333 |
150,043 | ericchiang/go-acme | acme.go | RevokeCertificate | func (c *Client) RevokeCertificate(accountKey interface{}, pemBytes []byte) error {
certificates, err := parsePEMBundle(pemBytes)
if err != nil {
return err
}
cert := certificates[0]
if cert.IsCA {
return errors.New("Certificate bundle starts with a CA certificate")
}
// cert.Raw holds DERbytes, which need... | go | func (c *Client) RevokeCertificate(accountKey interface{}, pemBytes []byte) error {
certificates, err := parsePEMBundle(pemBytes)
if err != nil {
return err
}
cert := certificates[0]
if cert.IsCA {
return errors.New("Certificate bundle starts with a CA certificate")
}
// cert.Raw holds DERbytes, which need... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RevokeCertificate",
"(",
"accountKey",
"interface",
"{",
"}",
",",
"pemBytes",
"[",
"]",
"byte",
")",
"error",
"{",
"certificates",
",",
"err",
":=",
"parsePEMBundle",
"(",
"pemBytes",
")",
"\n",
"if",
"err",
"!=",
... | // RevokeCertificate takes a PEM encoded certificate or bundle and
// attempts to revoke it. | [
"RevokeCertificate",
"takes",
"a",
"PEM",
"encoded",
"certificate",
"or",
"bundle",
"and",
"attempts",
"to",
"revoke",
"it",
"."
] | 0367c87bed388f106eef6c358ec0cfbd3c72239a | https://github.com/ericchiang/go-acme/blob/0367c87bed388f106eef6c358ec0cfbd3c72239a/acme.go#L362-L398 |
150,044 | tmc/graphql | executor/tracer/tracer.go | NewContext | func NewContext(ctx context.Context, t *Tracer) context.Context {
return context.WithValue(ctx, tracerKey, t)
} | go | func NewContext(ctx context.Context, t *Tracer) context.Context {
return context.WithValue(ctx, tracerKey, t)
} | [
"func",
"NewContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"t",
"*",
"Tracer",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"tracerKey",
",",
"t",
")",
"\n",
"}"
] | // NewContext returns a new Context carrying tracer. | [
"NewContext",
"returns",
"a",
"new",
"Context",
"carrying",
"tracer",
"."
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/executor/tracer/tracer.go#L71-L73 |
150,045 | tmc/graphql | executor/tracer/tracer.go | FromContext | func FromContext(ctx context.Context) (*Tracer, bool) {
// ctx.Value returns nil if ctx has no value for the key;
// the net.IP type assertion returns ok=false for nil.
t, ok := ctx.Value(tracerKey).(*Tracer)
return t, ok
} | go | func FromContext(ctx context.Context) (*Tracer, bool) {
// ctx.Value returns nil if ctx has no value for the key;
// the net.IP type assertion returns ok=false for nil.
t, ok := ctx.Value(tracerKey).(*Tracer)
return t, ok
} | [
"func",
"FromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"Tracer",
",",
"bool",
")",
"{",
"// ctx.Value returns nil if ctx has no value for the key;",
"// the net.IP type assertion returns ok=false for nil.",
"t",
",",
"ok",
":=",
"ctx",
".",
"Value"... | // FromContext extracts the tracer from ctx, if present. | [
"FromContext",
"extracts",
"the",
"tracer",
"from",
"ctx",
"if",
"present",
"."
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/executor/tracer/tracer.go#L76-L81 |
150,046 | tmc/graphql | types.go | Get | func (a Arguments) Get(name string) (interface{}, bool) {
for _, arg := range a {
if arg.Name == name {
return arg.Value, true
}
}
return nil, false
} | go | func (a Arguments) Get(name string) (interface{}, bool) {
for _, arg := range a {
if arg.Name == name {
return arg.Value, true
}
}
return nil, false
} | [
"func",
"(",
"a",
"Arguments",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"for",
"_",
",",
"arg",
":=",
"range",
"a",
"{",
"if",
"arg",
".",
"Name",
"==",
"name",
"{",
"return",
"arg",
".",
"Value... | // Get is a helper to fetch a particular argument by name. | [
"Get",
"is",
"a",
"helper",
"to",
"fetch",
"a",
"particular",
"argument",
"by",
"name",
"."
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/types.go#L84-L91 |
150,047 | tmc/graphql | schema/schema.go | New | func New() *Schema {
s := &Schema{
registeredTypes: map[string]GraphQLTypeInfo{},
rootFields: map[string]*GraphQLFieldSpec{},
}
// self-register
s.Register(s)
return s
} | go | func New() *Schema {
s := &Schema{
registeredTypes: map[string]GraphQLTypeInfo{},
rootFields: map[string]*GraphQLFieldSpec{},
}
// self-register
s.Register(s)
return s
} | [
"func",
"New",
"(",
")",
"*",
"Schema",
"{",
"s",
":=",
"&",
"Schema",
"{",
"registeredTypes",
":",
"map",
"[",
"string",
"]",
"GraphQLTypeInfo",
"{",
"}",
",",
"rootFields",
":",
"map",
"[",
"string",
"]",
"*",
"GraphQLFieldSpec",
"{",
"}",
",",
"}"... | // New prepares a new Schema. | [
"New",
"prepares",
"a",
"new",
"Schema",
"."
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/schema/schema.go#L19-L27 |
150,048 | tmc/graphql | schema/schema.go | Register | func (s *Schema) Register(t GraphQLType) {
typeInfo := t.GraphQLTypeInfo()
s.registeredTypes[t.GraphQLTypeInfo().Name] = typeInfo
// TODO(tmc): collision handling
for name, fieldSpec := range typeInfo.Fields {
if fieldSpec.IsRoot {
s.rootFields[name] = fieldSpec
}
}
} | go | func (s *Schema) Register(t GraphQLType) {
typeInfo := t.GraphQLTypeInfo()
s.registeredTypes[t.GraphQLTypeInfo().Name] = typeInfo
// TODO(tmc): collision handling
for name, fieldSpec := range typeInfo.Fields {
if fieldSpec.IsRoot {
s.rootFields[name] = fieldSpec
}
}
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Register",
"(",
"t",
"GraphQLType",
")",
"{",
"typeInfo",
":=",
"t",
".",
"GraphQLTypeInfo",
"(",
")",
"\n",
"s",
".",
"registeredTypes",
"[",
"t",
".",
"GraphQLTypeInfo",
"(",
")",
".",
"Name",
"]",
"=",
"typeI... | // Register registers a new type | [
"Register",
"registers",
"a",
"new",
"type"
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/schema/schema.go#L30-L39 |
150,049 | tmc/graphql | schema/schema.go | GraphQLTypeInfo | func (s *Schema) GraphQLTypeInfo() GraphQLTypeInfo {
return GraphQLTypeInfo{
Name: "Schema",
Description: "Root schema object",
Fields: map[string]*GraphQLFieldSpec{
"__schema": {"__schema", "Schema entry root field", s.handleSchemaCall, nil, true},
"__type": {"__type", "Query registered typ... | go | func (s *Schema) GraphQLTypeInfo() GraphQLTypeInfo {
return GraphQLTypeInfo{
Name: "Schema",
Description: "Root schema object",
Fields: map[string]*GraphQLFieldSpec{
"__schema": {"__schema", "Schema entry root field", s.handleSchemaCall, nil, true},
"__type": {"__type", "Query registered typ... | [
"func",
"(",
"s",
"*",
"Schema",
")",
"GraphQLTypeInfo",
"(",
")",
"GraphQLTypeInfo",
"{",
"return",
"GraphQLTypeInfo",
"{",
"Name",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"Fields",
":",
"map",
"[",
"string",
"]",
"*",
"GraphQLFieldSp... | // The below makes Schema itsself a GraphQLType and provides the root field of 'schema' | [
"The",
"below",
"makes",
"Schema",
"itsself",
"a",
"GraphQLType",
"and",
"provides",
"the",
"root",
"field",
"of",
"schema"
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/schema/schema.go#L71-L82 |
150,050 | tmc/graphql | handler/handler.go | ServeHTTP | func (h *ExecutorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Headers", r.Header.Get("Access-Control-Request-Headers"))
if r.Method == "OPTIONS" {
w.WriteHeade... | go | func (h *ExecutorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Headers", r.Header.Get("Access-Control-Request-Headers"))
if r.Method == "OPTIONS" {
w.WriteHeade... | [
"func",
"(",
"h",
"*",
"ExecutorHandler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"w",
".... | // ServeHTTP provides an entrypoint into a graphql executor. It pulls the query from
// the 'q' GET parameter. | [
"ServeHTTP",
"provides",
"an",
"entrypoint",
"into",
"a",
"graphql",
"executor",
".",
"It",
"pulls",
"the",
"query",
"from",
"the",
"q",
"GET",
"parameter",
"."
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/handler/handler.go#L62-L106 |
150,051 | tmc/graphql | parser/parser.go | ParseOperation | func ParseOperation(query []byte) (*graphql.Operation, error) {
result, err := parser.Parse("", query)
if err != nil {
return nil, ErrMalformedOperation{err}
}
doc, ok := result.(graphql.Document)
if !ok {
return nil, ErrMalformedOperation{err}
}
switch len(doc.Operations) {
case 1:
return &doc.Operations... | go | func ParseOperation(query []byte) (*graphql.Operation, error) {
result, err := parser.Parse("", query)
if err != nil {
return nil, ErrMalformedOperation{err}
}
doc, ok := result.(graphql.Document)
if !ok {
return nil, ErrMalformedOperation{err}
}
switch len(doc.Operations) {
case 1:
return &doc.Operations... | [
"func",
"ParseOperation",
"(",
"query",
"[",
"]",
"byte",
")",
"(",
"*",
"graphql",
".",
"Operation",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"parser",
".",
"Parse",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // ParseOperation attempts to parse a graphql.Operation from a byte slice. | [
"ParseOperation",
"attempts",
"to",
"parse",
"a",
"graphql",
".",
"Operation",
"from",
"a",
"byte",
"slice",
"."
] | 08ddf3728865df179c87c250f9b6066e3fbb9c8e | https://github.com/tmc/graphql/blob/08ddf3728865df179c87c250f9b6066e3fbb9c8e/parser/parser.go#L31-L48 |
150,052 | tideland/golib | sml/writer.go | NewWriterContext | func NewWriterContext(wp WriterProcessor, w io.Writer, pretty bool, indentStr string) *WriterContext {
ctx := &WriterContext{
plugins: WriterProcessors{"": wp},
writer: w,
prettyPrint: pretty,
indentStr: indentStr,
}
wp.SetContext(ctx)
return ctx
} | go | func NewWriterContext(wp WriterProcessor, w io.Writer, pretty bool, indentStr string) *WriterContext {
ctx := &WriterContext{
plugins: WriterProcessors{"": wp},
writer: w,
prettyPrint: pretty,
indentStr: indentStr,
}
wp.SetContext(ctx)
return ctx
} | [
"func",
"NewWriterContext",
"(",
"wp",
"WriterProcessor",
",",
"w",
"io",
".",
"Writer",
",",
"pretty",
"bool",
",",
"indentStr",
"string",
")",
"*",
"WriterContext",
"{",
"ctx",
":=",
"&",
"WriterContext",
"{",
"plugins",
":",
"WriterProcessors",
"{",
"\"",... | // NewWriterContext creates a new writer context. | [
"NewWriterContext",
"creates",
"a",
"new",
"writer",
"context",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L51-L60 |
150,053 | tideland/golib | sml/writer.go | Register | func (ctx *WriterContext) Register(tag string, wp WriterProcessor) error {
if _, ok := ctx.plugins[tag]; ok {
return errors.New(ErrRegisteredPlugin, errorMessages, tag)
}
wp.SetContext(ctx)
ctx.plugins[tag] = wp
return nil
} | go | func (ctx *WriterContext) Register(tag string, wp WriterProcessor) error {
if _, ok := ctx.plugins[tag]; ok {
return errors.New(ErrRegisteredPlugin, errorMessages, tag)
}
wp.SetContext(ctx)
ctx.plugins[tag] = wp
return nil
} | [
"func",
"(",
"ctx",
"*",
"WriterContext",
")",
"Register",
"(",
"tag",
"string",
",",
"wp",
"WriterProcessor",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"ctx",
".",
"plugins",
"[",
"tag",
"]",
";",
"ok",
"{",
"return",
"errors",
".",
"New",
"(... | // Register adds a writer processor which will be responsible for
// processing if the tag is matching. | [
"Register",
"adds",
"a",
"writer",
"processor",
"which",
"will",
"be",
"responsible",
"for",
"processing",
"if",
"the",
"tag",
"is",
"matching",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L64-L71 |
150,054 | tideland/golib | sml/writer.go | Writef | func (ctx *WriterContext) Writef(format string, args ...interface{}) error {
_, err := fmt.Fprintf(ctx.writer, format, args...)
return err
} | go | func (ctx *WriterContext) Writef(format string, args ...interface{}) error {
_, err := fmt.Fprintf(ctx.writer, format, args...)
return err
} | [
"func",
"(",
"ctx",
"*",
"WriterContext",
")",
"Writef",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"_",
",",
"err",
":=",
"fmt",
".",
"Fprintf",
"(",
"ctx",
".",
"writer",
",",
"format",
",",
"args",
"..... | // Writef writes a formatted string to the writer. | [
"Writef",
"writes",
"a",
"formatted",
"string",
"to",
"the",
"writer",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L74-L77 |
150,055 | tideland/golib | sml/writer.go | WriteSML | func WriteSML(node Node, ctx *WriterContext) error {
wp := ctx.plugins[""]
if wp == nil {
return errors.New(ErrNoRootProcessor, errorMessages)
}
w := &mlWriter{
context: ctx,
stack: []WriterProcessor{wp},
indent: 0,
}
// Process the node with the new writer.
if err := node.ProcessWith(w); err != nil {... | go | func WriteSML(node Node, ctx *WriterContext) error {
wp := ctx.plugins[""]
if wp == nil {
return errors.New(ErrNoRootProcessor, errorMessages)
}
w := &mlWriter{
context: ctx,
stack: []WriterProcessor{wp},
indent: 0,
}
// Process the node with the new writer.
if err := node.ProcessWith(w); err != nil {... | [
"func",
"WriteSML",
"(",
"node",
"Node",
",",
"ctx",
"*",
"WriterContext",
")",
"error",
"{",
"wp",
":=",
"ctx",
".",
"plugins",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"wp",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"ErrNoRootProcessor",
",",... | // WriteSML uses one WriterProcessor and possible more as plugins to write the
// SML node to the passed writer. The prettyPrint flag controls if the writing
// is in a more beautiful formatted way. | [
"WriteSML",
"uses",
"one",
"WriterProcessor",
"and",
"possible",
"more",
"as",
"plugins",
"to",
"write",
"the",
"SML",
"node",
"to",
"the",
"passed",
"writer",
".",
"The",
"prettyPrint",
"flag",
"controls",
"if",
"the",
"writing",
"is",
"in",
"a",
"more",
... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L89-L104 |
150,056 | tideland/golib | sml/writer.go | activatePlugin | func (w *mlWriter) activatePlugin(tag string) {
if p := w.context.plugins[tag]; p != nil {
w.stack = append(w.stack, p)
}
} | go | func (w *mlWriter) activatePlugin(tag string) {
if p := w.context.plugins[tag]; p != nil {
w.stack = append(w.stack, p)
}
} | [
"func",
"(",
"w",
"*",
"mlWriter",
")",
"activatePlugin",
"(",
"tag",
"string",
")",
"{",
"if",
"p",
":=",
"w",
".",
"context",
".",
"plugins",
"[",
"tag",
"]",
";",
"p",
"!=",
"nil",
"{",
"w",
".",
"stack",
"=",
"append",
"(",
"w",
".",
"stack... | // activatePlugin activates a new one of the
// registered plugins. | [
"activatePlugin",
"activates",
"a",
"new",
"one",
"of",
"the",
"registered",
"plugins",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L165-L169 |
150,057 | tideland/golib | sml/writer.go | deactivatePlugin | func (w *mlWriter) deactivatePlugin() {
w.stack = w.stack[:len(w.stack)-1]
} | go | func (w *mlWriter) deactivatePlugin() {
w.stack = w.stack[:len(w.stack)-1]
} | [
"func",
"(",
"w",
"*",
"mlWriter",
")",
"deactivatePlugin",
"(",
")",
"{",
"w",
".",
"stack",
"=",
"w",
".",
"stack",
"[",
":",
"len",
"(",
"w",
".",
"stack",
")",
"-",
"1",
"]",
"\n",
"}"
] | // deactivatePlugin deactivates the top plugin. | [
"deactivatePlugin",
"deactivates",
"the",
"top",
"plugin",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L172-L174 |
150,058 | tideland/golib | sml/writer.go | writeIndent | func (w *mlWriter) writeIndent(open bool) {
if w.context.prettyPrint {
for i := 0; i < w.indent; i++ {
w.context.Writef(w.context.indentStr)
}
} else if open {
w.context.Writef(" ")
}
} | go | func (w *mlWriter) writeIndent(open bool) {
if w.context.prettyPrint {
for i := 0; i < w.indent; i++ {
w.context.Writef(w.context.indentStr)
}
} else if open {
w.context.Writef(" ")
}
} | [
"func",
"(",
"w",
"*",
"mlWriter",
")",
"writeIndent",
"(",
"open",
"bool",
")",
"{",
"if",
"w",
".",
"context",
".",
"prettyPrint",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"w",
".",
"indent",
";",
"i",
"++",
"{",
"w",
".",
"context",
".",
... | // writeIndent writes an indentation if wanted. | [
"writeIndent",
"writes",
"an",
"indentation",
"if",
"wanted",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/writer.go#L182-L190 |
150,059 | tideland/golib | redis/resultset.go | nextResultSet | func (rs *ResultSet) nextResultSet() *ResultSet {
if !rs.allReceived() {
return rs
}
if rs.parent == nil {
return nil
}
return rs.parent.nextResultSet()
} | go | func (rs *ResultSet) nextResultSet() *ResultSet {
if !rs.allReceived() {
return rs
}
if rs.parent == nil {
return nil
}
return rs.parent.nextResultSet()
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"nextResultSet",
"(",
")",
"*",
"ResultSet",
"{",
"if",
"!",
"rs",
".",
"allReceived",
"(",
")",
"{",
"return",
"rs",
"\n",
"}",
"\n",
"if",
"rs",
".",
"parent",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"... | // nextResultSet returns the parent stack upwards as long as all expected
// items are received. | [
"nextResultSet",
"returns",
"the",
"parent",
"stack",
"upwards",
"as",
"long",
"as",
"all",
"expected",
"items",
"are",
"received",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L59-L67 |
150,060 | tideland/golib | redis/resultset.go | ValueAt | func (rs *ResultSet) ValueAt(index int) (Value, error) {
if len(rs.items) < index+1 {
return nil, errors.New(ErrIllegalItemIndex, errorMessages, index, len(rs.items))
}
value, ok := rs.items[index].(Value)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "value")
}
return value, nil
} | go | func (rs *ResultSet) ValueAt(index int) (Value, error) {
if len(rs.items) < index+1 {
return nil, errors.New(ErrIllegalItemIndex, errorMessages, index, len(rs.items))
}
value, ok := rs.items[index].(Value)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "value")
}
return value, nil
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"ValueAt",
"(",
"index",
"int",
")",
"(",
"Value",
",",
"error",
")",
"{",
"if",
"len",
"(",
"rs",
".",
"items",
")",
"<",
"index",
"+",
"1",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"ErrIl... | // ValueAt returns the value at index. | [
"ValueAt",
"returns",
"the",
"value",
"at",
"index",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L75-L84 |
150,061 | tideland/golib | redis/resultset.go | BoolAt | func (rs *ResultSet) BoolAt(index int) (bool, error) {
value, err := rs.ValueAt(index)
if err != nil {
return false, err
}
return value.Bool()
} | go | func (rs *ResultSet) BoolAt(index int) (bool, error) {
value, err := rs.ValueAt(index)
if err != nil {
return false, err
}
return value.Bool()
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"BoolAt",
"(",
"index",
"int",
")",
"(",
"bool",
",",
"error",
")",
"{",
"value",
",",
"err",
":=",
"rs",
".",
"ValueAt",
"(",
"index",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
... | // BoolAt returns the value at index as bool. This is a convenience
// method as the bool is needed very often. | [
"BoolAt",
"returns",
"the",
"value",
"at",
"index",
"as",
"bool",
".",
"This",
"is",
"a",
"convenience",
"method",
"as",
"the",
"bool",
"is",
"needed",
"very",
"often",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L88-L94 |
150,062 | tideland/golib | redis/resultset.go | IntAt | func (rs *ResultSet) IntAt(index int) (int, error) {
value, err := rs.ValueAt(index)
if err != nil {
return 0, err
}
return value.Int()
} | go | func (rs *ResultSet) IntAt(index int) (int, error) {
value, err := rs.ValueAt(index)
if err != nil {
return 0, err
}
return value.Int()
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"IntAt",
"(",
"index",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"value",
",",
"err",
":=",
"rs",
".",
"ValueAt",
"(",
"index",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",... | // IntAt returns the value at index as int. This is a convenience
// method as the integer is needed very often. | [
"IntAt",
"returns",
"the",
"value",
"at",
"index",
"as",
"int",
".",
"This",
"is",
"a",
"convenience",
"method",
"as",
"the",
"integer",
"is",
"needed",
"very",
"often",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L98-L104 |
150,063 | tideland/golib | redis/resultset.go | StringAt | func (rs *ResultSet) StringAt(index int) (string, error) {
value, err := rs.ValueAt(index)
if err != nil {
return "", err
}
return value.String(), nil
} | go | func (rs *ResultSet) StringAt(index int) (string, error) {
value, err := rs.ValueAt(index)
if err != nil {
return "", err
}
return value.String(), nil
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"StringAt",
"(",
"index",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"value",
",",
"err",
":=",
"rs",
".",
"ValueAt",
"(",
"index",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
... | // StringAt returns the value at index as string. This is a convenience
// method as the string is needed very often. | [
"StringAt",
"returns",
"the",
"value",
"at",
"index",
"as",
"string",
".",
"This",
"is",
"a",
"convenience",
"method",
"as",
"the",
"string",
"is",
"needed",
"very",
"often",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L108-L114 |
150,064 | tideland/golib | redis/resultset.go | ResultSetAt | func (rs *ResultSet) ResultSetAt(index int) (*ResultSet, error) {
if len(rs.items) < index-1 {
return nil, errors.New(ErrIllegalItemIndex, errorMessages, index, len(rs.items))
}
resultSet, ok := rs.items[index].(*ResultSet)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "result set")
... | go | func (rs *ResultSet) ResultSetAt(index int) (*ResultSet, error) {
if len(rs.items) < index-1 {
return nil, errors.New(ErrIllegalItemIndex, errorMessages, index, len(rs.items))
}
resultSet, ok := rs.items[index].(*ResultSet)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "result set")
... | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"ResultSetAt",
"(",
"index",
"int",
")",
"(",
"*",
"ResultSet",
",",
"error",
")",
"{",
"if",
"len",
"(",
"rs",
".",
"items",
")",
"<",
"index",
"-",
"1",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
... | // ResultSetAt returns the nested result set at index. | [
"ResultSetAt",
"returns",
"the",
"nested",
"result",
"set",
"at",
"index",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L117-L126 |
150,065 | tideland/golib | redis/resultset.go | Values | func (rs *ResultSet) Values() Values {
values := []Value{}
for _, item := range rs.items {
switch i := item.(type) {
case Value:
values = append(values, i)
case *ResultSet:
values = append(values, i.Values()...)
}
}
return values
} | go | func (rs *ResultSet) Values() Values {
values := []Value{}
for _, item := range rs.items {
switch i := item.(type) {
case Value:
values = append(values, i)
case *ResultSet:
values = append(values, i.Values()...)
}
}
return values
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"Values",
"(",
")",
"Values",
"{",
"values",
":=",
"[",
"]",
"Value",
"{",
"}",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"rs",
".",
"items",
"{",
"switch",
"i",
":=",
"item",
".",
"(",
"type",
")",... | // Values returnes a flattened list of all values. | [
"Values",
"returnes",
"a",
"flattened",
"list",
"of",
"all",
"values",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L129-L140 |
150,066 | tideland/golib | redis/resultset.go | ScoredValues | func (rs *ResultSet) ScoredValues(withscores bool) (ScoredValues, error) {
svs := ScoredValues{}
sv := ScoredValue{}
for index, item := range rs.items {
value, ok := item.(Value)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "value")
}
if withscores {
// With scores, so alte... | go | func (rs *ResultSet) ScoredValues(withscores bool) (ScoredValues, error) {
svs := ScoredValues{}
sv := ScoredValue{}
for index, item := range rs.items {
value, ok := item.(Value)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "value")
}
if withscores {
// With scores, so alte... | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"ScoredValues",
"(",
"withscores",
"bool",
")",
"(",
"ScoredValues",
",",
"error",
")",
"{",
"svs",
":=",
"ScoredValues",
"{",
"}",
"\n",
"sv",
":=",
"ScoredValue",
"{",
"}",
"\n",
"for",
"index",
",",
"item",
... | // ScoredValues returns the alternating values as scored values slice. If
// withscores is false the result set contains no scores and so they are
// set to 0.0 in the returned scored values. | [
"ScoredValues",
"returns",
"the",
"alternating",
"values",
"as",
"scored",
"values",
"slice",
".",
"If",
"withscores",
"is",
"false",
"the",
"result",
"set",
"contains",
"no",
"scores",
"and",
"so",
"they",
"are",
"set",
"to",
"0",
".",
"0",
"in",
"the",
... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L163-L192 |
150,067 | tideland/golib | redis/resultset.go | Hash | func (rs *ResultSet) Hash() (Hash, error) {
hash := make(Hash)
key := ""
for index, item := range rs.items {
value, ok := item.(Value)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "value")
}
if index%2 == 0 {
key = value.String()
} else {
hash.Set(key, value.Bytes())
... | go | func (rs *ResultSet) Hash() (Hash, error) {
hash := make(Hash)
key := ""
for index, item := range rs.items {
value, ok := item.(Value)
if !ok {
return nil, errors.New(ErrIllegalItemType, errorMessages, index, "value")
}
if index%2 == 0 {
key = value.String()
} else {
hash.Set(key, value.Bytes())
... | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"Hash",
"(",
")",
"(",
"Hash",
",",
"error",
")",
"{",
"hash",
":=",
"make",
"(",
"Hash",
")",
"\n",
"key",
":=",
"\"",
"\"",
"\n",
"for",
"index",
",",
"item",
":=",
"range",
"rs",
".",
"items",
"{",
... | // Hash returns the values of the result set as hash. | [
"Hash",
"returns",
"the",
"values",
"of",
"the",
"result",
"set",
"as",
"hash",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L195-L210 |
150,068 | tideland/golib | redis/resultset.go | Scanned | func (rs *ResultSet) Scanned() (int, *ResultSet, error) {
cursor, err := rs.IntAt(0)
if err != nil {
return 0, nil, err
}
result, err := rs.ResultSetAt(1)
return cursor, result, err
} | go | func (rs *ResultSet) Scanned() (int, *ResultSet, error) {
cursor, err := rs.IntAt(0)
if err != nil {
return 0, nil, err
}
result, err := rs.ResultSetAt(1)
return cursor, result, err
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"Scanned",
"(",
")",
"(",
"int",
",",
"*",
"ResultSet",
",",
"error",
")",
"{",
"cursor",
",",
"err",
":=",
"rs",
".",
"IntAt",
"(",
"0",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
... | // Scanned returns the cursor and the keys or values of a
// scan operation. | [
"Scanned",
"returns",
"the",
"cursor",
"and",
"the",
"keys",
"or",
"values",
"of",
"a",
"scan",
"operation",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L214-L221 |
150,069 | tideland/golib | redis/resultset.go | String | func (rs *ResultSet) String() string {
out := "RESULT SET ("
ss := rs.Strings()
return out + strings.Join(ss, " / ") + ")"
} | go | func (rs *ResultSet) String() string {
out := "RESULT SET ("
ss := rs.Strings()
return out + strings.Join(ss, " / ") + ")"
} | [
"func",
"(",
"rs",
"*",
"ResultSet",
")",
"String",
"(",
")",
"string",
"{",
"out",
":=",
"\"",
"\"",
"\n",
"ss",
":=",
"rs",
".",
"Strings",
"(",
")",
"\n",
"return",
"out",
"+",
"strings",
".",
"Join",
"(",
"ss",
",",
"\"",
"\"",
")",
"+",
... | // String returns the result set in a human readable form. | [
"String",
"returns",
"the",
"result",
"set",
"in",
"a",
"human",
"readable",
"form",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/resultset.go#L238-L242 |
150,070 | tideland/golib | timex/timex.go | YearInRange | func YearInRange(t time.Time, minYear, maxYear int) bool {
return (minYear <= t.Year()) && (t.Year() <= maxYear)
} | go | func YearInRange(t time.Time, minYear, maxYear int) bool {
return (minYear <= t.Year()) && (t.Year() <= maxYear)
} | [
"func",
"YearInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minYear",
",",
"maxYear",
"int",
")",
"bool",
"{",
"return",
"(",
"minYear",
"<=",
"t",
".",
"Year",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Year",
"(",
")",
"<=",
"maxYear",
")",
"\n",
"... | // YearInRange tests if a year of a time is in a given range. | [
"YearInRange",
"tests",
"if",
"a",
"year",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L34-L36 |
150,071 | tideland/golib | timex/timex.go | MonthInList | func MonthInList(t time.Time, months []time.Month) bool {
for _, month := range months {
if t.Month() == month {
return true
}
}
return false
} | go | func MonthInList(t time.Time, months []time.Month) bool {
for _, month := range months {
if t.Month() == month {
return true
}
}
return false
} | [
"func",
"MonthInList",
"(",
"t",
"time",
".",
"Time",
",",
"months",
"[",
"]",
"time",
".",
"Month",
")",
"bool",
"{",
"for",
"_",
",",
"month",
":=",
"range",
"months",
"{",
"if",
"t",
".",
"Month",
"(",
")",
"==",
"month",
"{",
"return",
"true"... | // MonthInList tests if the month of a time is in a given list. | [
"MonthInList",
"tests",
"if",
"the",
"month",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"list",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L39-L46 |
150,072 | tideland/golib | timex/timex.go | MonthInRange | func MonthInRange(t time.Time, minMonth, maxMonth time.Month) bool {
return (minMonth <= t.Month()) && (t.Month() <= maxMonth)
} | go | func MonthInRange(t time.Time, minMonth, maxMonth time.Month) bool {
return (minMonth <= t.Month()) && (t.Month() <= maxMonth)
} | [
"func",
"MonthInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minMonth",
",",
"maxMonth",
"time",
".",
"Month",
")",
"bool",
"{",
"return",
"(",
"minMonth",
"<=",
"t",
".",
"Month",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Month",
"(",
")",
"<=",
"max... | // MonthInRange tests if a month of a time is in a given range. | [
"MonthInRange",
"tests",
"if",
"a",
"month",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L49-L51 |
150,073 | tideland/golib | timex/timex.go | DayInList | func DayInList(t time.Time, days []int) bool {
for _, day := range days {
if t.Day() == day {
return true
}
}
return false
} | go | func DayInList(t time.Time, days []int) bool {
for _, day := range days {
if t.Day() == day {
return true
}
}
return false
} | [
"func",
"DayInList",
"(",
"t",
"time",
".",
"Time",
",",
"days",
"[",
"]",
"int",
")",
"bool",
"{",
"for",
"_",
",",
"day",
":=",
"range",
"days",
"{",
"if",
"t",
".",
"Day",
"(",
")",
"==",
"day",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",... | // DayInList tests if the day of a time is in a given list. | [
"DayInList",
"tests",
"if",
"the",
"day",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"list",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L54-L61 |
150,074 | tideland/golib | timex/timex.go | DayInRange | func DayInRange(t time.Time, minDay, maxDay int) bool {
return (minDay <= t.Day()) && (t.Day() <= maxDay)
} | go | func DayInRange(t time.Time, minDay, maxDay int) bool {
return (minDay <= t.Day()) && (t.Day() <= maxDay)
} | [
"func",
"DayInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minDay",
",",
"maxDay",
"int",
")",
"bool",
"{",
"return",
"(",
"minDay",
"<=",
"t",
".",
"Day",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Day",
"(",
")",
"<=",
"maxDay",
")",
"\n",
"}"
] | // DayInRange tests if a day of a time is in a given range. | [
"DayInRange",
"tests",
"if",
"a",
"day",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L64-L66 |
150,075 | tideland/golib | timex/timex.go | HourInList | func HourInList(t time.Time, hours []int) bool {
for _, hour := range hours {
if t.Hour() == hour {
return true
}
}
return false
} | go | func HourInList(t time.Time, hours []int) bool {
for _, hour := range hours {
if t.Hour() == hour {
return true
}
}
return false
} | [
"func",
"HourInList",
"(",
"t",
"time",
".",
"Time",
",",
"hours",
"[",
"]",
"int",
")",
"bool",
"{",
"for",
"_",
",",
"hour",
":=",
"range",
"hours",
"{",
"if",
"t",
".",
"Hour",
"(",
")",
"==",
"hour",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // HourInList tests if the hour of a time is in a given list. | [
"HourInList",
"tests",
"if",
"the",
"hour",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"list",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L69-L76 |
150,076 | tideland/golib | timex/timex.go | HourInRange | func HourInRange(t time.Time, minHour, maxHour int) bool {
return (minHour <= t.Hour()) && (t.Hour() <= maxHour)
} | go | func HourInRange(t time.Time, minHour, maxHour int) bool {
return (minHour <= t.Hour()) && (t.Hour() <= maxHour)
} | [
"func",
"HourInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minHour",
",",
"maxHour",
"int",
")",
"bool",
"{",
"return",
"(",
"minHour",
"<=",
"t",
".",
"Hour",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Hour",
"(",
")",
"<=",
"maxHour",
")",
"\n",
"... | // HourInRange tests if a hour of a time is in a given range. | [
"HourInRange",
"tests",
"if",
"a",
"hour",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L79-L81 |
150,077 | tideland/golib | timex/timex.go | MinuteInList | func MinuteInList(t time.Time, minutes []int) bool {
for _, minute := range minutes {
if t.Minute() == minute {
return true
}
}
return false
} | go | func MinuteInList(t time.Time, minutes []int) bool {
for _, minute := range minutes {
if t.Minute() == minute {
return true
}
}
return false
} | [
"func",
"MinuteInList",
"(",
"t",
"time",
".",
"Time",
",",
"minutes",
"[",
"]",
"int",
")",
"bool",
"{",
"for",
"_",
",",
"minute",
":=",
"range",
"minutes",
"{",
"if",
"t",
".",
"Minute",
"(",
")",
"==",
"minute",
"{",
"return",
"true",
"\n",
"... | // MinuteInList tests if the minute of a time is in a given list. | [
"MinuteInList",
"tests",
"if",
"the",
"minute",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"list",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L84-L91 |
150,078 | tideland/golib | timex/timex.go | MinuteInRange | func MinuteInRange(t time.Time, minMinute, maxMinute int) bool {
return (minMinute <= t.Minute()) && (t.Minute() <= maxMinute)
} | go | func MinuteInRange(t time.Time, minMinute, maxMinute int) bool {
return (minMinute <= t.Minute()) && (t.Minute() <= maxMinute)
} | [
"func",
"MinuteInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minMinute",
",",
"maxMinute",
"int",
")",
"bool",
"{",
"return",
"(",
"minMinute",
"<=",
"t",
".",
"Minute",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Minute",
"(",
")",
"<=",
"maxMinute",
")... | // MinuteInRange tests if a minute of a time is in a given range. | [
"MinuteInRange",
"tests",
"if",
"a",
"minute",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L94-L96 |
150,079 | tideland/golib | timex/timex.go | SecondInList | func SecondInList(t time.Time, seconds []int) bool {
for _, second := range seconds {
if t.Second() == second {
return true
}
}
return false
} | go | func SecondInList(t time.Time, seconds []int) bool {
for _, second := range seconds {
if t.Second() == second {
return true
}
}
return false
} | [
"func",
"SecondInList",
"(",
"t",
"time",
".",
"Time",
",",
"seconds",
"[",
"]",
"int",
")",
"bool",
"{",
"for",
"_",
",",
"second",
":=",
"range",
"seconds",
"{",
"if",
"t",
".",
"Second",
"(",
")",
"==",
"second",
"{",
"return",
"true",
"\n",
"... | // SecondInList tests if the second of a time is in a given list. | [
"SecondInList",
"tests",
"if",
"the",
"second",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"list",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L99-L106 |
150,080 | tideland/golib | timex/timex.go | SecondInRange | func SecondInRange(t time.Time, minSecond, maxSecond int) bool {
return (minSecond <= t.Second()) && (t.Second() <= maxSecond)
} | go | func SecondInRange(t time.Time, minSecond, maxSecond int) bool {
return (minSecond <= t.Second()) && (t.Second() <= maxSecond)
} | [
"func",
"SecondInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minSecond",
",",
"maxSecond",
"int",
")",
"bool",
"{",
"return",
"(",
"minSecond",
"<=",
"t",
".",
"Second",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Second",
"(",
")",
"<=",
"maxSecond",
")... | // SecondInRange tests if a second of a time is in a given range. | [
"SecondInRange",
"tests",
"if",
"a",
"second",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L109-L111 |
150,081 | tideland/golib | timex/timex.go | WeekdayInList | func WeekdayInList(t time.Time, weekdays []time.Weekday) bool {
for _, weekday := range weekdays {
if t.Weekday() == weekday {
return true
}
}
return false
} | go | func WeekdayInList(t time.Time, weekdays []time.Weekday) bool {
for _, weekday := range weekdays {
if t.Weekday() == weekday {
return true
}
}
return false
} | [
"func",
"WeekdayInList",
"(",
"t",
"time",
".",
"Time",
",",
"weekdays",
"[",
"]",
"time",
".",
"Weekday",
")",
"bool",
"{",
"for",
"_",
",",
"weekday",
":=",
"range",
"weekdays",
"{",
"if",
"t",
".",
"Weekday",
"(",
")",
"==",
"weekday",
"{",
"ret... | // WeekdayInList tests if the weekday of a time is in a given list. | [
"WeekdayInList",
"tests",
"if",
"the",
"weekday",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"list",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L114-L121 |
150,082 | tideland/golib | timex/timex.go | WeekdayInRange | func WeekdayInRange(t time.Time, minWeekday, maxWeekday time.Weekday) bool {
return (minWeekday <= t.Weekday()) && (t.Weekday() <= maxWeekday)
} | go | func WeekdayInRange(t time.Time, minWeekday, maxWeekday time.Weekday) bool {
return (minWeekday <= t.Weekday()) && (t.Weekday() <= maxWeekday)
} | [
"func",
"WeekdayInRange",
"(",
"t",
"time",
".",
"Time",
",",
"minWeekday",
",",
"maxWeekday",
"time",
".",
"Weekday",
")",
"bool",
"{",
"return",
"(",
"minWeekday",
"<=",
"t",
".",
"Weekday",
"(",
")",
")",
"&&",
"(",
"t",
".",
"Weekday",
"(",
")",
... | // WeekdayInRange tests if a weekday of a time is in a given range. | [
"WeekdayInRange",
"tests",
"if",
"a",
"weekday",
"of",
"a",
"time",
"is",
"in",
"a",
"given",
"range",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L124-L126 |
150,083 | tideland/golib | timex/timex.go | BeginOf | func BeginOf(t time.Time, unit UnitOfTime) time.Time {
// Retrieve the individual parts of the given time.
year := t.Year()
month := t.Month()
day := t.Day()
hour := t.Hour()
minute := t.Minute()
second := t.Second()
loc := t.Location()
// Build new time.
switch unit {
case Second:
return time.Date(year, m... | go | func BeginOf(t time.Time, unit UnitOfTime) time.Time {
// Retrieve the individual parts of the given time.
year := t.Year()
month := t.Month()
day := t.Day()
hour := t.Hour()
minute := t.Minute()
second := t.Second()
loc := t.Location()
// Build new time.
switch unit {
case Second:
return time.Date(year, m... | [
"func",
"BeginOf",
"(",
"t",
"time",
".",
"Time",
",",
"unit",
"UnitOfTime",
")",
"time",
".",
"Time",
"{",
"// Retrieve the individual parts of the given time.",
"year",
":=",
"t",
".",
"Year",
"(",
")",
"\n",
"month",
":=",
"t",
".",
"Month",
"(",
")",
... | // BeginOf returns the begin of the passed unit for the given time. | [
"BeginOf",
"returns",
"the",
"begin",
"of",
"the",
"passed",
"unit",
"for",
"the",
"given",
"time",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L146-L172 |
150,084 | tideland/golib | timex/timex.go | EndOf | func EndOf(t time.Time, unit UnitOfTime) time.Time {
// Retrieve the individual parts of the given time.
year := t.Year()
month := t.Month()
day := t.Day()
hour := t.Hour()
minute := t.Minute()
second := t.Second()
loc := t.Location()
// Build new time.
switch unit {
case Second:
return time.Date(year, mon... | go | func EndOf(t time.Time, unit UnitOfTime) time.Time {
// Retrieve the individual parts of the given time.
year := t.Year()
month := t.Month()
day := t.Day()
hour := t.Hour()
minute := t.Minute()
second := t.Second()
loc := t.Location()
// Build new time.
switch unit {
case Second:
return time.Date(year, mon... | [
"func",
"EndOf",
"(",
"t",
"time",
".",
"Time",
",",
"unit",
"UnitOfTime",
")",
"time",
".",
"Time",
"{",
"// Retrieve the individual parts of the given time.",
"year",
":=",
"t",
".",
"Year",
"(",
")",
"\n",
"month",
":=",
"t",
".",
"Month",
"(",
")",
"... | // EndOf returns the end of the passed unit for the given time. | [
"EndOf",
"returns",
"the",
"end",
"of",
"the",
"passed",
"unit",
"for",
"the",
"given",
"time",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/timex.go#L175-L203 |
150,085 | tideland/golib | gjp/diff.go | Compare | func Compare(first, second []byte, separator string) (Diff, error) {
fd, err := Parse(first, separator)
if err != nil {
return nil, err
}
sd, err := Parse(second, separator)
if err != nil {
return nil, err
}
d := &diff{
first: fd,
second: sd,
}
err = d.compare()
if err != nil {
return nil, err
}
... | go | func Compare(first, second []byte, separator string) (Diff, error) {
fd, err := Parse(first, separator)
if err != nil {
return nil, err
}
sd, err := Parse(second, separator)
if err != nil {
return nil, err
}
d := &diff{
first: fd,
second: sd,
}
err = d.compare()
if err != nil {
return nil, err
}
... | [
"func",
"Compare",
"(",
"first",
",",
"second",
"[",
"]",
"byte",
",",
"separator",
"string",
")",
"(",
"Diff",
",",
"error",
")",
"{",
"fd",
",",
"err",
":=",
"Parse",
"(",
"first",
",",
"separator",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // Compare parses and compares the documents and returns their differences. | [
"Compare",
"parses",
"and",
"compares",
"the",
"documents",
"and",
"returns",
"their",
"differences",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/diff.go#L45-L63 |
150,086 | tideland/golib | gjp/diff.go | CompareDocuments | func CompareDocuments(first, second Document, separator string) (Diff, error) {
fd, ok := first.(*document)
if !ok {
return nil, errors.New(ErrInvalidDocument, errorMessages, "first")
}
fd.separator = separator
sd, ok := second.(*document)
if !ok {
return nil, errors.New(ErrInvalidDocument, errorMessages, "se... | go | func CompareDocuments(first, second Document, separator string) (Diff, error) {
fd, ok := first.(*document)
if !ok {
return nil, errors.New(ErrInvalidDocument, errorMessages, "first")
}
fd.separator = separator
sd, ok := second.(*document)
if !ok {
return nil, errors.New(ErrInvalidDocument, errorMessages, "se... | [
"func",
"CompareDocuments",
"(",
"first",
",",
"second",
"Document",
",",
"separator",
"string",
")",
"(",
"Diff",
",",
"error",
")",
"{",
"fd",
",",
"ok",
":=",
"first",
".",
"(",
"*",
"document",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
... | // CompareDocuments compares the documents and returns their differences. | [
"CompareDocuments",
"compares",
"the",
"documents",
"and",
"returns",
"their",
"differences",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/diff.go#L66-L86 |
150,087 | tideland/golib | audit/generators.go | BuildEMail | func BuildEMail(first, last, domain string) string {
valid := make(map[rune]bool)
for _, r := range "abcdefghijklmnopqrstuvwxyz0123456789-" {
valid[r] = true
}
name := func(in string) string {
out := []rune{}
for _, r := range strings.ToLower(in) {
if valid[r] {
out = append(out, r)
}
}
return s... | go | func BuildEMail(first, last, domain string) string {
valid := make(map[rune]bool)
for _, r := range "abcdefghijklmnopqrstuvwxyz0123456789-" {
valid[r] = true
}
name := func(in string) string {
out := []rune{}
for _, r := range strings.ToLower(in) {
if valid[r] {
out = append(out, r)
}
}
return s... | [
"func",
"BuildEMail",
"(",
"first",
",",
"last",
",",
"domain",
"string",
")",
"string",
"{",
"valid",
":=",
"make",
"(",
"map",
"[",
"rune",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"\"",
"\"",
"{",
"valid",
"[",
"r",
"]",
... | // BuildEMail creates an e-mail address out of first and last
// name and the domain. | [
"BuildEMail",
"creates",
"an",
"e",
"-",
"mail",
"address",
"out",
"of",
"first",
"and",
"last",
"name",
"and",
"the",
"domain",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L78-L93 |
150,088 | tideland/golib | audit/generators.go | BuildTime | func BuildTime(layout string, offset time.Duration) (string, time.Time) {
t := time.Now().Add(offset)
ts := t.Format(layout)
tp, err := time.Parse(layout, ts)
if err != nil {
panic("cannot build time: " + err.Error())
}
return ts, tp
} | go | func BuildTime(layout string, offset time.Duration) (string, time.Time) {
t := time.Now().Add(offset)
ts := t.Format(layout)
tp, err := time.Parse(layout, ts)
if err != nil {
panic("cannot build time: " + err.Error())
}
return ts, tp
} | [
"func",
"BuildTime",
"(",
"layout",
"string",
",",
"offset",
"time",
".",
"Duration",
")",
"(",
"string",
",",
"time",
".",
"Time",
")",
"{",
"t",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"offset",
")",
"\n",
"ts",
":=",
"t",
".",
"... | // BuildTime returns the current time plus or minus the passed
// offset formatted as string and as Time. The returned time is
// the parsed formatted one to avoid parsing troubles in tests. | [
"BuildTime",
"returns",
"the",
"current",
"time",
"plus",
"or",
"minus",
"the",
"passed",
"offset",
"formatted",
"as",
"string",
"and",
"as",
"Time",
".",
"The",
"returned",
"time",
"is",
"the",
"parsed",
"formatted",
"one",
"to",
"avoid",
"parsing",
"troubl... | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L98-L106 |
150,089 | tideland/golib | audit/generators.go | Int | func (g *Generator) Int(lo, hi int) int {
if lo == hi {
return lo
}
if lo > hi {
lo, hi = hi, lo
}
n := g.rand.Intn(hi - lo + 1)
return lo + n
} | go | func (g *Generator) Int(lo, hi int) int {
if lo == hi {
return lo
}
if lo > hi {
lo, hi = hi, lo
}
n := g.rand.Intn(hi - lo + 1)
return lo + n
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"Int",
"(",
"lo",
",",
"hi",
"int",
")",
"int",
"{",
"if",
"lo",
"==",
"hi",
"{",
"return",
"lo",
"\n",
"}",
"\n",
"if",
"lo",
">",
"hi",
"{",
"lo",
",",
"hi",
"=",
"hi",
",",
"lo",
"\n",
"}",
"\n"... | // Int generates an int between lo and hi including
// those values. | [
"Int",
"generates",
"an",
"int",
"between",
"lo",
"and",
"hi",
"including",
"those",
"values",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L126-L135 |
150,090 | tideland/golib | audit/generators.go | Ints | func (g *Generator) Ints(lo, hi, count int) []int {
ints := make([]int, count)
for i := 0; i < count; i++ {
ints[i] = g.Int(lo, hi)
}
return ints
} | go | func (g *Generator) Ints(lo, hi, count int) []int {
ints := make([]int, count)
for i := 0; i < count; i++ {
ints[i] = g.Int(lo, hi)
}
return ints
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"Ints",
"(",
"lo",
",",
"hi",
",",
"count",
"int",
")",
"[",
"]",
"int",
"{",
"ints",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"count",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"count",
";",
... | // Ints generates a slice of random ints. | [
"Ints",
"generates",
"a",
"slice",
"of",
"random",
"ints",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L138-L144 |
150,091 | tideland/golib | audit/generators.go | FlipCoin | func (g *Generator) FlipCoin(percent int) bool {
switch {
case percent > 100:
percent = 100
case percent < 0:
percent = 0
}
return g.Percent() >= percent
} | go | func (g *Generator) FlipCoin(percent int) bool {
switch {
case percent > 100:
percent = 100
case percent < 0:
percent = 0
}
return g.Percent() >= percent
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"FlipCoin",
"(",
"percent",
"int",
")",
"bool",
"{",
"switch",
"{",
"case",
"percent",
">",
"100",
":",
"percent",
"=",
"100",
"\n",
"case",
"percent",
"<",
"0",
":",
"percent",
"=",
"0",
"\n",
"}",
"\n",
... | // FlipCoin returns true if the internal generated percentage is
// equal or greater than the passed percentage. | [
"FlipCoin",
"returns",
"true",
"if",
"the",
"internal",
"generated",
"percentage",
"is",
"equal",
"or",
"greater",
"than",
"the",
"passed",
"percentage",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L153-L161 |
150,092 | tideland/golib | audit/generators.go | OneByteOf | func (g *Generator) OneByteOf(values ...byte) byte {
i := g.Int(0, len(values)-1)
return values[i]
} | go | func (g *Generator) OneByteOf(values ...byte) byte {
i := g.Int(0, len(values)-1)
return values[i]
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"OneByteOf",
"(",
"values",
"...",
"byte",
")",
"byte",
"{",
"i",
":=",
"g",
".",
"Int",
"(",
"0",
",",
"len",
"(",
"values",
")",
"-",
"1",
")",
"\n",
"return",
"values",
"[",
"i",
"]",
"\n",
"}"
] | // OneByteOf returns one of the passed bytes. | [
"OneByteOf",
"returns",
"one",
"of",
"the",
"passed",
"bytes",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L164-L167 |
150,093 | tideland/golib | audit/generators.go | OneRuneOf | func (g *Generator) OneRuneOf(values string) rune {
runes := []rune(values)
i := g.Int(0, len(runes)-1)
return runes[i]
} | go | func (g *Generator) OneRuneOf(values string) rune {
runes := []rune(values)
i := g.Int(0, len(runes)-1)
return runes[i]
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"OneRuneOf",
"(",
"values",
"string",
")",
"rune",
"{",
"runes",
":=",
"[",
"]",
"rune",
"(",
"values",
")",
"\n",
"i",
":=",
"g",
".",
"Int",
"(",
"0",
",",
"len",
"(",
"runes",
")",
"-",
"1",
")",
"\... | // OneRuneOf returns one of the runes of the passed string. | [
"OneRuneOf",
"returns",
"one",
"of",
"the",
"runes",
"of",
"the",
"passed",
"string",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L170-L174 |
150,094 | tideland/golib | audit/generators.go | OneIntOf | func (g *Generator) OneIntOf(values ...int) int {
i := g.Int(0, len(values)-1)
return values[i]
} | go | func (g *Generator) OneIntOf(values ...int) int {
i := g.Int(0, len(values)-1)
return values[i]
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"OneIntOf",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"i",
":=",
"g",
".",
"Int",
"(",
"0",
",",
"len",
"(",
"values",
")",
"-",
"1",
")",
"\n",
"return",
"values",
"[",
"i",
"]",
"\n",
"}"
] | // OneIntOf returns one of the passed ints. | [
"OneIntOf",
"returns",
"one",
"of",
"the",
"passed",
"ints",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L177-L180 |
150,095 | tideland/golib | audit/generators.go | OneStringOf | func (g *Generator) OneStringOf(values ...string) string {
i := g.Int(0, len(values)-1)
return values[i]
} | go | func (g *Generator) OneStringOf(values ...string) string {
i := g.Int(0, len(values)-1)
return values[i]
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"OneStringOf",
"(",
"values",
"...",
"string",
")",
"string",
"{",
"i",
":=",
"g",
".",
"Int",
"(",
"0",
",",
"len",
"(",
"values",
")",
"-",
"1",
")",
"\n",
"return",
"values",
"[",
"i",
"]",
"\n",
"}"
... | // OneStringOf returns one of the passed strings. | [
"OneStringOf",
"returns",
"one",
"of",
"the",
"passed",
"strings",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L183-L186 |
150,096 | tideland/golib | audit/generators.go | OneDurationOf | func (g *Generator) OneDurationOf(values ...time.Duration) time.Duration {
i := g.Int(0, len(values)-1)
return values[i]
} | go | func (g *Generator) OneDurationOf(values ...time.Duration) time.Duration {
i := g.Int(0, len(values)-1)
return values[i]
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"OneDurationOf",
"(",
"values",
"...",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"i",
":=",
"g",
".",
"Int",
"(",
"0",
",",
"len",
"(",
"values",
")",
"-",
"1",
")",
"\n",
"return",
"valu... | // OneDurationOf returns one of the passed durations. | [
"OneDurationOf",
"returns",
"one",
"of",
"the",
"passed",
"durations",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L189-L192 |
150,097 | tideland/golib | audit/generators.go | Words | func (g *Generator) Words(count int) []string {
words := make([]string, count)
for i := 0; i < count; i++ {
words[i] = g.Word()
}
return words
} | go | func (g *Generator) Words(count int) []string {
words := make([]string, count)
for i := 0; i < count; i++ {
words[i] = g.Word()
}
return words
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"Words",
"(",
"count",
"int",
")",
"[",
"]",
"string",
"{",
"words",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"count",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
"{",
... | // Words generates a slice of random words | [
"Words",
"generates",
"a",
"slice",
"of",
"random",
"words"
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L200-L206 |
150,098 | tideland/golib | audit/generators.go | LimitedWord | func (g *Generator) LimitedWord(lo, hi int) string {
length := g.Int(lo, hi)
if length < MinWordLen {
length = MinWordLen
}
if length > MaxWordLen {
length = MaxWordLen
}
// Start anywhere in the list.
pos := g.Int(0, wordsLen)
for {
if pos >= wordsLen {
pos = 0
}
if len(words[pos]) == length {
... | go | func (g *Generator) LimitedWord(lo, hi int) string {
length := g.Int(lo, hi)
if length < MinWordLen {
length = MinWordLen
}
if length > MaxWordLen {
length = MaxWordLen
}
// Start anywhere in the list.
pos := g.Int(0, wordsLen)
for {
if pos >= wordsLen {
pos = 0
}
if len(words[pos]) == length {
... | [
"func",
"(",
"g",
"*",
"Generator",
")",
"LimitedWord",
"(",
"lo",
",",
"hi",
"int",
")",
"string",
"{",
"length",
":=",
"g",
".",
"Int",
"(",
"lo",
",",
"hi",
")",
"\n",
"if",
"length",
"<",
"MinWordLen",
"{",
"length",
"=",
"MinWordLen",
"\n",
... | // LimitedWord generates a random word with a length between
// lo and hi. | [
"LimitedWord",
"generates",
"a",
"random",
"word",
"with",
"a",
"length",
"between",
"lo",
"and",
"hi",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L210-L229 |
150,099 | tideland/golib | audit/generators.go | Sentence | func (g *Generator) Sentence() string {
count := g.Int(2, 15)
words := g.Words(count)
words[0] = ToUpperFirst(words[0])
for i := 2; i < count-1; i++ {
if g.FlipCoin(80) {
words[i] += ","
}
}
return strings.Join(words, " ") + "."
} | go | func (g *Generator) Sentence() string {
count := g.Int(2, 15)
words := g.Words(count)
words[0] = ToUpperFirst(words[0])
for i := 2; i < count-1; i++ {
if g.FlipCoin(80) {
words[i] += ","
}
}
return strings.Join(words, " ") + "."
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"Sentence",
"(",
")",
"string",
"{",
"count",
":=",
"g",
".",
"Int",
"(",
"2",
",",
"15",
")",
"\n",
"words",
":=",
"g",
".",
"Words",
"(",
"count",
")",
"\n",
"words",
"[",
"0",
"]",
"=",
"ToUpperFirst"... | // Sentence generates a sentence between 2 and 15 words
// and possibly containing commas. | [
"Sentence",
"generates",
"a",
"sentence",
"between",
"2",
"and",
"15",
"words",
"and",
"possibly",
"containing",
"commas",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L274-L284 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.