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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,600 | keybase/go-updater | process/process.go | findProcessesWithFn | func findProcessesWithFn(fn processesFn, matchFn MatchFn, max int) ([]ps.Process, error) {
processes, err := fn()
if err != nil {
return nil, fmt.Errorf("Error listing processes: %s", err)
}
if processes == nil {
return nil, nil
}
procs := []ps.Process{}
for _, p := range processes {
if matchFn(p) {
pro... | go | func findProcessesWithFn(fn processesFn, matchFn MatchFn, max int) ([]ps.Process, error) {
processes, err := fn()
if err != nil {
return nil, fmt.Errorf("Error listing processes: %s", err)
}
if processes == nil {
return nil, nil
}
procs := []ps.Process{}
for _, p := range processes {
if matchFn(p) {
pro... | [
"func",
"findProcessesWithFn",
"(",
"fn",
"processesFn",
",",
"matchFn",
"MatchFn",
",",
"max",
"int",
")",
"(",
"[",
"]",
"ps",
".",
"Process",
",",
"error",
")",
"{",
"processes",
",",
"err",
":=",
"fn",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // findProcessesWithFn finds processes using match function.
// If max is != 0, then we will return that max number of processes. | [
"findProcessesWithFn",
"finds",
"processes",
"using",
"match",
"function",
".",
"If",
"max",
"is",
"!",
"=",
"0",
"then",
"we",
"will",
"return",
"that",
"max",
"number",
"of",
"processes",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/process.go#L82-L100 |
145,601 | keybase/go-updater | process/process.go | FindPIDsWithMatchFn | func FindPIDsWithMatchFn(matchFn MatchFn, log Log) ([]int, error) {
return findPIDsWithFn(ps.Processes, matchFn, log)
} | go | func FindPIDsWithMatchFn(matchFn MatchFn, log Log) ([]int, error) {
return findPIDsWithFn(ps.Processes, matchFn, log)
} | [
"func",
"FindPIDsWithMatchFn",
"(",
"matchFn",
"MatchFn",
",",
"log",
"Log",
")",
"(",
"[",
"]",
"int",
",",
"error",
")",
"{",
"return",
"findPIDsWithFn",
"(",
"ps",
".",
"Processes",
",",
"matchFn",
",",
"log",
")",
"\n",
"}"
] | // FindPIDsWithMatchFn returns pids for processes matching function | [
"FindPIDsWithMatchFn",
"returns",
"pids",
"for",
"processes",
"matching",
"function"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/process.go#L103-L105 |
145,602 | keybase/go-updater | process/process.go | TerminateAll | func TerminateAll(matcher Matcher, killDelay time.Duration, log Log) []int {
return TerminateAllWithProcessesFn(ps.Processes, matcher.Fn(), killDelay, log)
} | go | func TerminateAll(matcher Matcher, killDelay time.Duration, log Log) []int {
return TerminateAllWithProcessesFn(ps.Processes, matcher.Fn(), killDelay, log)
} | [
"func",
"TerminateAll",
"(",
"matcher",
"Matcher",
",",
"killDelay",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"[",
"]",
"int",
"{",
"return",
"TerminateAllWithProcessesFn",
"(",
"ps",
".",
"Processes",
",",
"matcher",
".",
"Fn",
"(",
")",
",",
"k... | // TerminateAll stops all processes with executable names that contains the matching string.
// It returns the pids that were terminated.
// This method only logs errors, if you need error handling, you can should use a different implementation. | [
"TerminateAll",
"stops",
"all",
"processes",
"with",
"executable",
"names",
"that",
"contains",
"the",
"matching",
"string",
".",
"It",
"returns",
"the",
"pids",
"that",
"were",
"terminated",
".",
"This",
"method",
"only",
"logs",
"errors",
"if",
"you",
"need"... | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/process.go#L122-L124 |
145,603 | keybase/go-updater | process/process.go | TerminateAllWithProcessesFn | func TerminateAllWithProcessesFn(fn processesFn, matchFn MatchFn, killDelay time.Duration, log Log) (pids []int) {
pids, err := findPIDsWithFn(fn, matchFn, log)
if err != nil {
log.Errorf("Error finding process: %s", err)
return
}
if len(pids) == 0 {
return
}
for _, pid := range pids {
if err := Terminate... | go | func TerminateAllWithProcessesFn(fn processesFn, matchFn MatchFn, killDelay time.Duration, log Log) (pids []int) {
pids, err := findPIDsWithFn(fn, matchFn, log)
if err != nil {
log.Errorf("Error finding process: %s", err)
return
}
if len(pids) == 0 {
return
}
for _, pid := range pids {
if err := Terminate... | [
"func",
"TerminateAllWithProcessesFn",
"(",
"fn",
"processesFn",
",",
"matchFn",
"MatchFn",
",",
"killDelay",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"(",
"pids",
"[",
"]",
"int",
")",
"{",
"pids",
",",
"err",
":=",
"findPIDsWithFn",
"(",
"fn",
... | // TerminateAllWithProcessesFn stops processes processesFn that satify the matchFn.
// It returns the pids that were terminated.
// This method only logs errors, if you need error handling, you can should use a different implementation. | [
"TerminateAllWithProcessesFn",
"stops",
"processes",
"processesFn",
"that",
"satify",
"the",
"matchFn",
".",
"It",
"returns",
"the",
"pids",
"that",
"were",
"terminated",
".",
"This",
"method",
"only",
"logs",
"errors",
"if",
"you",
"need",
"error",
"handling",
... | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/process.go#L129-L144 |
145,604 | keybase/go-updater | process/process.go | TerminatePID | func TerminatePID(pid int, killDelay time.Duration, log Log) error {
log.Debugf("Searching OS for %d", pid)
process, err := os.FindProcess(pid)
if err != nil {
return fmt.Errorf("Error finding OS process: %s", err)
}
if process == nil {
return fmt.Errorf("No process found with pid %d", pid)
}
// Sending SIG... | go | func TerminatePID(pid int, killDelay time.Duration, log Log) error {
log.Debugf("Searching OS for %d", pid)
process, err := os.FindProcess(pid)
if err != nil {
return fmt.Errorf("Error finding OS process: %s", err)
}
if process == nil {
return fmt.Errorf("No process found with pid %d", pid)
}
// Sending SIG... | [
"func",
"TerminatePID",
"(",
"pid",
"int",
",",
"killDelay",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"error",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"pid",
")",
"\n",
"process",
",",
"err",
":=",
"os",
".",
"FindProcess",
"(",
"p... | // TerminatePID is an overly simple way to terminate a PID.
// On darwin and linux, it calls SIGTERM, then waits a killDelay and then calls
// SIGKILL. We don't mind if we call SIGKILL on an already terminated process,
// since there could be a race anyway where the process exits right after we
// check if it's still r... | [
"TerminatePID",
"is",
"an",
"overly",
"simple",
"way",
"to",
"terminate",
"a",
"PID",
".",
"On",
"darwin",
"and",
"linux",
"it",
"calls",
"SIGTERM",
"then",
"waits",
"a",
"killDelay",
"and",
"then",
"calls",
"SIGKILL",
".",
"We",
"don",
"t",
"mind",
"if"... | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/process.go#L152-L181 |
145,605 | keybase/go-updater | process/process.go | KillAll | func KillAll(matcher Matcher, log Log) (pids []int) {
pids, err := findPIDsWithFn(ps.Processes, matcher.Fn(), log)
if err != nil {
log.Errorf("Error finding process: %s", err)
return
}
if len(pids) == 0 {
return
}
for _, pid := range pids {
if err := KillPID(pid, log); err != nil {
log.Errorf("Error ki... | go | func KillAll(matcher Matcher, log Log) (pids []int) {
pids, err := findPIDsWithFn(ps.Processes, matcher.Fn(), log)
if err != nil {
log.Errorf("Error finding process: %s", err)
return
}
if len(pids) == 0 {
return
}
for _, pid := range pids {
if err := KillPID(pid, log); err != nil {
log.Errorf("Error ki... | [
"func",
"KillAll",
"(",
"matcher",
"Matcher",
",",
"log",
"Log",
")",
"(",
"pids",
"[",
"]",
"int",
")",
"{",
"pids",
",",
"err",
":=",
"findPIDsWithFn",
"(",
"ps",
".",
"Processes",
",",
"matcher",
".",
"Fn",
"(",
")",
",",
"log",
")",
"\n",
"if... | // KillAll kills all processes that match | [
"KillAll",
"kills",
"all",
"processes",
"that",
"match"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/process.go#L184-L199 |
145,606 | keybase/go-updater | saltpack/saltpack.go | VerifyDetachedFileAtPath | func VerifyDetachedFileAtPath(path string, signature string, validKIDs map[string]bool, log Log) error {
file, err := os.Open(path)
defer util.Close(file)
if err != nil {
return err
}
err = VerifyDetached(file, signature, validKIDs, log)
if err != nil {
return fmt.Errorf("Error verifying signature: %s", err)
... | go | func VerifyDetachedFileAtPath(path string, signature string, validKIDs map[string]bool, log Log) error {
file, err := os.Open(path)
defer util.Close(file)
if err != nil {
return err
}
err = VerifyDetached(file, signature, validKIDs, log)
if err != nil {
return fmt.Errorf("Error verifying signature: %s", err)
... | [
"func",
"VerifyDetachedFileAtPath",
"(",
"path",
"string",
",",
"signature",
"string",
",",
"validKIDs",
"map",
"[",
"string",
"]",
"bool",
",",
"log",
"Log",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"defe... | // VerifyDetachedFileAtPath verifies a file | [
"VerifyDetachedFileAtPath",
"verifies",
"a",
"file"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/saltpack/saltpack.go#L24-L35 |
145,607 | keybase/go-updater | saltpack/saltpack.go | VerifyDetached | func VerifyDetached(reader io.Reader, signature string, validKIDs map[string]bool, log Log) error {
if reader == nil {
return fmt.Errorf("No reader")
}
check := func(key sp.BasePublicKey) error {
return checkSender(key, validKIDs, log)
}
return VerifyDetachedCheckSender(reader, []byte(signature), check)
} | go | func VerifyDetached(reader io.Reader, signature string, validKIDs map[string]bool, log Log) error {
if reader == nil {
return fmt.Errorf("No reader")
}
check := func(key sp.BasePublicKey) error {
return checkSender(key, validKIDs, log)
}
return VerifyDetachedCheckSender(reader, []byte(signature), check)
} | [
"func",
"VerifyDetached",
"(",
"reader",
"io",
".",
"Reader",
",",
"signature",
"string",
",",
"validKIDs",
"map",
"[",
"string",
"]",
"bool",
",",
"log",
"Log",
")",
"error",
"{",
"if",
"reader",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // VerifyDetached verifies a message signature | [
"VerifyDetached",
"verifies",
"a",
"message",
"signature"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/saltpack/saltpack.go#L55-L63 |
145,608 | keybase/go-updater | saltpack/saltpack.go | VerifyDetachedCheckSender | func VerifyDetachedCheckSender(message io.Reader, signature []byte, checkSender func(sp.BasePublicKey) error) error {
kr := basic.NewKeyring()
var skey sp.SigningPublicKey
var err error
skey, _, err = sp.Dearmor62VerifyDetachedReader(sp.CheckKnownMajorVersion, message, string(signature), kr)
if err != nil {
retu... | go | func VerifyDetachedCheckSender(message io.Reader, signature []byte, checkSender func(sp.BasePublicKey) error) error {
kr := basic.NewKeyring()
var skey sp.SigningPublicKey
var err error
skey, _, err = sp.Dearmor62VerifyDetachedReader(sp.CheckKnownMajorVersion, message, string(signature), kr)
if err != nil {
retu... | [
"func",
"VerifyDetachedCheckSender",
"(",
"message",
"io",
".",
"Reader",
",",
"signature",
"[",
"]",
"byte",
",",
"checkSender",
"func",
"(",
"sp",
".",
"BasePublicKey",
")",
"error",
")",
"error",
"{",
"kr",
":=",
"basic",
".",
"NewKeyring",
"(",
")",
... | // VerifyDetachedCheckSender verifies a message signature | [
"VerifyDetachedCheckSender",
"verifies",
"a",
"message",
"signature"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/saltpack/saltpack.go#L66-L80 |
145,609 | keybase/go-updater | util/error.go | removeNilErrors | func removeNilErrors(errs []error) []error {
if len(errs) == 0 {
return nil
}
var r []error
for _, err := range errs {
if err != nil {
r = append(r, err)
}
}
return r
} | go | func removeNilErrors(errs []error) []error {
if len(errs) == 0 {
return nil
}
var r []error
for _, err := range errs {
if err != nil {
r = append(r, err)
}
}
return r
} | [
"func",
"removeNilErrors",
"(",
"errs",
"[",
"]",
"error",
")",
"[",
"]",
"error",
"{",
"if",
"len",
"(",
"errs",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"var",
"r",
"[",
"]",
"error",
"\n",
"for",
"_",
",",
"err",
":=",
"range",... | // removeNilErrors returns error slice with nil errors removed | [
"removeNilErrors",
"returns",
"error",
"slice",
"with",
"nil",
"errors",
"removed"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/error.go#L12-L23 |
145,610 | keybase/go-updater | error.go | NewError | func NewError(errorType ErrorType, err error) Error {
return Error{errorType: errorType, source: err}
} | go | func NewError(errorType ErrorType, err error) Error {
return Error{errorType: errorType, source: err}
} | [
"func",
"NewError",
"(",
"errorType",
"ErrorType",
",",
"err",
"error",
")",
"Error",
"{",
"return",
"Error",
"{",
"errorType",
":",
"errorType",
",",
"source",
":",
"err",
"}",
"\n",
"}"
] | // NewError constructs an Error from a source error | [
"NewError",
"constructs",
"an",
"Error",
"from",
"a",
"source",
"error"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/error.go#L47-L49 |
145,611 | keybase/go-updater | error.go | Error | func (e Error) Error() string {
if e.source == nil {
return fmt.Sprintf("Update Error (%s)", e.TypeString())
}
return fmt.Sprintf("Update Error (%s): %s", e.TypeString(), e.source.Error())
} | go | func (e Error) Error() string {
if e.source == nil {
return fmt.Sprintf("Update Error (%s)", e.TypeString())
}
return fmt.Sprintf("Update Error (%s): %s", e.TypeString(), e.source.Error())
} | [
"func",
"(",
"e",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"if",
"e",
".",
"source",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"TypeString",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
... | // Error returns description for an UpdateError | [
"Error",
"returns",
"description",
"for",
"an",
"UpdateError"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/error.go#L67-L72 |
145,612 | keybase/go-updater | sources/remote.go | NewRemoteUpdateSource | func NewRemoteUpdateSource(defaultURI string, log Log) RemoteUpdateSource {
return RemoteUpdateSource{
defaultURI: defaultURI,
log: log,
}
} | go | func NewRemoteUpdateSource(defaultURI string, log Log) RemoteUpdateSource {
return RemoteUpdateSource{
defaultURI: defaultURI,
log: log,
}
} | [
"func",
"NewRemoteUpdateSource",
"(",
"defaultURI",
"string",
",",
"log",
"Log",
")",
"RemoteUpdateSource",
"{",
"return",
"RemoteUpdateSource",
"{",
"defaultURI",
":",
"defaultURI",
",",
"log",
":",
"log",
",",
"}",
"\n",
"}"
] | // NewRemoteUpdateSource builds remote update source without defaults. The url used is passed
// via options instead. | [
"NewRemoteUpdateSource",
"builds",
"remote",
"update",
"source",
"without",
"defaults",
".",
"The",
"url",
"used",
"is",
"passed",
"via",
"options",
"instead",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/sources/remote.go#L25-L30 |
145,613 | xyproto/simplebolt | creator.go | NewList | func (b *BoltCreator) NewList(id string) (pinterface.IList, error) {
return NewList(b.db, id)
} | go | func (b *BoltCreator) NewList(id string) (pinterface.IList, error) {
return NewList(b.db, id)
} | [
"func",
"(",
"b",
"*",
"BoltCreator",
")",
"NewList",
"(",
"id",
"string",
")",
"(",
"pinterface",
".",
"IList",
",",
"error",
")",
"{",
"return",
"NewList",
"(",
"b",
".",
"db",
",",
"id",
")",
"\n",
"}"
] | // NewList can create a new List with the given ID | [
"NewList",
"can",
"create",
"a",
"new",
"List",
"with",
"the",
"given",
"ID"
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/creator.go#L20-L22 |
145,614 | xyproto/simplebolt | creator.go | NewSet | func (b *BoltCreator) NewSet(id string) (pinterface.ISet, error) {
return NewSet(b.db, id)
} | go | func (b *BoltCreator) NewSet(id string) (pinterface.ISet, error) {
return NewSet(b.db, id)
} | [
"func",
"(",
"b",
"*",
"BoltCreator",
")",
"NewSet",
"(",
"id",
"string",
")",
"(",
"pinterface",
".",
"ISet",
",",
"error",
")",
"{",
"return",
"NewSet",
"(",
"b",
".",
"db",
",",
"id",
")",
"\n",
"}"
] | // NewSet can create a new Set with the given ID | [
"NewSet",
"can",
"create",
"a",
"new",
"Set",
"with",
"the",
"given",
"ID"
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/creator.go#L25-L27 |
145,615 | xyproto/simplebolt | creator.go | NewHashMap | func (b *BoltCreator) NewHashMap(id string) (pinterface.IHashMap, error) {
return NewHashMap(b.db, id)
} | go | func (b *BoltCreator) NewHashMap(id string) (pinterface.IHashMap, error) {
return NewHashMap(b.db, id)
} | [
"func",
"(",
"b",
"*",
"BoltCreator",
")",
"NewHashMap",
"(",
"id",
"string",
")",
"(",
"pinterface",
".",
"IHashMap",
",",
"error",
")",
"{",
"return",
"NewHashMap",
"(",
"b",
".",
"db",
",",
"id",
")",
"\n",
"}"
] | // NewHashMap can create a new HashMap with the given ID.
// The HashMap elements have a name and then a key+value. For example a
// username for the name, then "password" as the key and a password hash as
// the value. | [
"NewHashMap",
"can",
"create",
"a",
"new",
"HashMap",
"with",
"the",
"given",
"ID",
".",
"The",
"HashMap",
"elements",
"have",
"a",
"name",
"and",
"then",
"a",
"key",
"+",
"value",
".",
"For",
"example",
"a",
"username",
"for",
"the",
"name",
"then",
"... | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/creator.go#L33-L35 |
145,616 | xyproto/simplebolt | creator.go | NewKeyValue | func (b *BoltCreator) NewKeyValue(id string) (pinterface.IKeyValue, error) {
return NewKeyValue(b.db, id)
} | go | func (b *BoltCreator) NewKeyValue(id string) (pinterface.IKeyValue, error) {
return NewKeyValue(b.db, id)
} | [
"func",
"(",
"b",
"*",
"BoltCreator",
")",
"NewKeyValue",
"(",
"id",
"string",
")",
"(",
"pinterface",
".",
"IKeyValue",
",",
"error",
")",
"{",
"return",
"NewKeyValue",
"(",
"b",
".",
"db",
",",
"id",
")",
"\n",
"}"
] | // NewKeyValue can create a new KeyValue with the given ID.
// The KeyValue elements have a key with a corresponding value. | [
"NewKeyValue",
"can",
"create",
"a",
"new",
"KeyValue",
"with",
"the",
"given",
"ID",
".",
"The",
"KeyValue",
"elements",
"have",
"a",
"key",
"with",
"a",
"corresponding",
"value",
"."
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/creator.go#L39-L41 |
145,617 | keybase/go-updater | util/http.go | SaveHTTPResponse | func SaveHTTPResponse(resp *http.Response, savePath string, mode os.FileMode, log Log) error {
if resp == nil {
return fmt.Errorf("No response")
}
file, err := os.OpenFile(savePath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, mode)
if err != nil {
return err
}
defer Close(file)
log.Infof("Downloading to %s", savePat... | go | func SaveHTTPResponse(resp *http.Response, savePath string, mode os.FileMode, log Log) error {
if resp == nil {
return fmt.Errorf("No response")
}
file, err := os.OpenFile(savePath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, mode)
if err != nil {
return err
}
defer Close(file)
log.Infof("Downloading to %s", savePat... | [
"func",
"SaveHTTPResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"savePath",
"string",
",",
"mode",
"os",
".",
"FileMode",
",",
"log",
"Log",
")",
"error",
"{",
"if",
"resp",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"... | // SaveHTTPResponse saves an http.Response to path | [
"SaveHTTPResponse",
"saves",
"an",
"http",
".",
"Response",
"to",
"path"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/http.go#L49-L65 |
145,618 | keybase/go-updater | util/http.go | parseURL | func parseURL(urlString string) (*url.URL, error) {
url, parseErr := url.Parse(urlString)
if parseErr != nil {
return nil, parseErr
}
if url == nil {
return nil, fmt.Errorf("No URL")
}
return url, nil
} | go | func parseURL(urlString string) (*url.URL, error) {
url, parseErr := url.Parse(urlString)
if parseErr != nil {
return nil, parseErr
}
if url == nil {
return nil, fmt.Errorf("No URL")
}
return url, nil
} | [
"func",
"parseURL",
"(",
"urlString",
"string",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"url",
",",
"parseErr",
":=",
"url",
".",
"Parse",
"(",
"urlString",
")",
"\n",
"if",
"parseErr",
"!=",
"nil",
"{",
"return",
"nil",
",",
"par... | // parseURL ensures error if parse error or no url was returned from url.Parse | [
"parseURL",
"ensures",
"error",
"if",
"parse",
"error",
"or",
"no",
"url",
"was",
"returned",
"from",
"url",
".",
"Parse"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/http.go#L77-L86 |
145,619 | keybase/go-updater | util/http.go | URLExists | func URLExists(urlString string, timeout time.Duration, log Log) (bool, error) {
url, err := parseURL(urlString)
if err != nil {
return false, err
}
// Handle local files
if url.Scheme == "file" {
return FileExists(PathFromURL(url))
}
log.Debugf("Checking URL exists: %s", urlString)
req, err := http.NewRe... | go | func URLExists(urlString string, timeout time.Duration, log Log) (bool, error) {
url, err := parseURL(urlString)
if err != nil {
return false, err
}
// Handle local files
if url.Scheme == "file" {
return FileExists(PathFromURL(url))
}
log.Debugf("Checking URL exists: %s", urlString)
req, err := http.NewRe... | [
"func",
"URLExists",
"(",
"urlString",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"(",
"bool",
",",
"error",
")",
"{",
"url",
",",
"err",
":=",
"parseURL",
"(",
"urlString",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // URLExists returns error if URL doesn't exist | [
"URLExists",
"returns",
"error",
"if",
"URL",
"doesn",
"t",
"exist"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/http.go#L89-L120 |
145,620 | keybase/go-updater | util/http.go | DownloadURL | func DownloadURL(urlString string, destinationPath string, options DownloadURLOptions) error {
_, err := downloadURL(urlString, destinationPath, options)
return err
} | go | func DownloadURL(urlString string, destinationPath string, options DownloadURLOptions) error {
_, err := downloadURL(urlString, destinationPath, options)
return err
} | [
"func",
"DownloadURL",
"(",
"urlString",
"string",
",",
"destinationPath",
"string",
",",
"options",
"DownloadURLOptions",
")",
"error",
"{",
"_",
",",
"err",
":=",
"downloadURL",
"(",
"urlString",
",",
"destinationPath",
",",
"options",
")",
"\n",
"return",
"... | // DownloadURL downloads a URL to a path. | [
"DownloadURL",
"downloads",
"a",
"URL",
"to",
"a",
"path",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/http.go#L132-L135 |
145,621 | keybase/go-updater | keybase/source.go | NewUpdateSource | func NewUpdateSource(cfg *config, log Log) UpdateSource {
return newUpdateSource(cfg, defaultEndpoints.update, log)
} | go | func NewUpdateSource(cfg *config, log Log) UpdateSource {
return newUpdateSource(cfg, defaultEndpoints.update, log)
} | [
"func",
"NewUpdateSource",
"(",
"cfg",
"*",
"config",
",",
"log",
"Log",
")",
"UpdateSource",
"{",
"return",
"newUpdateSource",
"(",
"cfg",
",",
"defaultEndpoints",
".",
"update",
",",
"log",
")",
"\n",
"}"
] | // NewUpdateSource contructs an update source for keybase.io | [
"NewUpdateSource",
"contructs",
"an",
"update",
"source",
"for",
"keybase",
".",
"io"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/source.go#L26-L28 |
145,622 | keybase/go-updater | keybase/source.go | FindUpdate | func (k UpdateSource) FindUpdate(options updater.UpdateOptions) (*updater.Update, error) {
return k.findUpdate(options, time.Minute)
} | go | func (k UpdateSource) FindUpdate(options updater.UpdateOptions) (*updater.Update, error) {
return k.findUpdate(options, time.Minute)
} | [
"func",
"(",
"k",
"UpdateSource",
")",
"FindUpdate",
"(",
"options",
"updater",
".",
"UpdateOptions",
")",
"(",
"*",
"updater",
".",
"Update",
",",
"error",
")",
"{",
"return",
"k",
".",
"findUpdate",
"(",
"options",
",",
"time",
".",
"Minute",
")",
"\... | // FindUpdate returns update for updater and options | [
"FindUpdate",
"returns",
"update",
"for",
"updater",
"and",
"options"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/source.go#L44-L46 |
145,623 | xyproto/simplebolt | simplebolt.go | All | func (l *List) All() (results []string, err error) {
if l.name == nil {
return nil, ErrDoesNotExist
}
return results, (*bbolt.DB)(l.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(l.name)
if bucket == nil {
return ErrBucketNotFound
}
return bucket.ForEach(func(_, value []byte) error {
results... | go | func (l *List) All() (results []string, err error) {
if l.name == nil {
return nil, ErrDoesNotExist
}
return results, (*bbolt.DB)(l.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(l.name)
if bucket == nil {
return ErrBucketNotFound
}
return bucket.ForEach(func(_, value []byte) error {
results... | [
"func",
"(",
"l",
"*",
"List",
")",
"All",
"(",
")",
"(",
"results",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"if",
"l",
".",
"name",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrDoesNotExist",
"\n",
"}",
"\n",
"return",
"results",
",",
... | // All returns all elements in the list | [
"All",
"returns",
"all",
"elements",
"in",
"the",
"list"
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/simplebolt.go#L123-L137 |
145,624 | xyproto/simplebolt | simplebolt.go | All | func (s *Set) All() (values []string, err error) {
if s.name == nil {
return nil, ErrDoesNotExist
}
return values, (*bbolt.DB)(s.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(s.name)
if bucket == nil {
return ErrBucketNotFound
}
return bucket.ForEach(func(_, value []byte) error {
values = a... | go | func (s *Set) All() (values []string, err error) {
if s.name == nil {
return nil, ErrDoesNotExist
}
return values, (*bbolt.DB)(s.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(s.name)
if bucket == nil {
return ErrBucketNotFound
}
return bucket.ForEach(func(_, value []byte) error {
values = a... | [
"func",
"(",
"s",
"*",
"Set",
")",
"All",
"(",
")",
"(",
"values",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"if",
"s",
".",
"name",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrDoesNotExist",
"\n",
"}",
"\n",
"return",
"values",
",",
"... | // All returns all elements in the set | [
"All",
"returns",
"all",
"elements",
"in",
"the",
"set"
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/simplebolt.go#L296-L310 |
145,625 | xyproto/simplebolt | simplebolt.go | All | func (h *HashMap) All() (results []string, err error) {
if h.name == nil {
return nil, ErrDoesNotExist
}
return results, (*bbolt.DB)(h.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(h.name)
if bucket == nil {
return ErrBucketNotFound
}
return bucket.ForEach(func(byteKey, _ []byte) error {
co... | go | func (h *HashMap) All() (results []string, err error) {
if h.name == nil {
return nil, ErrDoesNotExist
}
return results, (*bbolt.DB)(h.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(h.name)
if bucket == nil {
return ErrBucketNotFound
}
return bucket.ForEach(func(byteKey, _ []byte) error {
co... | [
"func",
"(",
"h",
"*",
"HashMap",
")",
"All",
"(",
")",
"(",
"results",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"if",
"h",
".",
"name",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrDoesNotExist",
"\n",
"}",
"\n",
"return",
"results",
",... | // All returns all ID's, for all hash elements | [
"All",
"returns",
"all",
"ID",
"s",
"for",
"all",
"hash",
"elements"
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/simplebolt.go#L401-L426 |
145,626 | xyproto/simplebolt | simplebolt.go | Keys | func (h *HashMap) Keys(owner string) ([]string, error) {
var props []string
return props, (*bbolt.DB)(h.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(h.name)
if bucket == nil {
return ErrBucketNotFound
}
// Loop through the keys
return bucket.ForEach(func(byteKey, _ []byte) error {
combinedK... | go | func (h *HashMap) Keys(owner string) ([]string, error) {
var props []string
return props, (*bbolt.DB)(h.db).View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(h.name)
if bucket == nil {
return ErrBucketNotFound
}
// Loop through the keys
return bucket.ForEach(func(byteKey, _ []byte) error {
combinedK... | [
"func",
"(",
"h",
"*",
"HashMap",
")",
"Keys",
"(",
"owner",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"props",
"[",
"]",
"string",
"\n",
"return",
"props",
",",
"(",
"*",
"bbolt",
".",
"DB",
")",
"(",
"h",
".",
"... | // Keys returns all names of all keys of a given owner. | [
"Keys",
"returns",
"all",
"names",
"of",
"all",
"keys",
"of",
"a",
"given",
"owner",
"."
] | 752add4550da8682eff4fb24488c806158acacf7 | https://github.com/xyproto/simplebolt/blob/752add4550da8682eff4fb24488c806158acacf7/simplebolt.go#L472-L490 |
145,627 | keybase/go-updater | keybase/platform_darwin.go | execPath | func (c config) execPath() string {
path, err := osext.Executable()
if err != nil {
c.log.Warningf("Error trying to determine our executable path: %s", err)
return ""
}
return path
} | go | func (c config) execPath() string {
path, err := osext.Executable()
if err != nil {
c.log.Warningf("Error trying to determine our executable path: %s", err)
return ""
}
return path
} | [
"func",
"(",
"c",
"config",
")",
"execPath",
"(",
")",
"string",
"{",
"path",
",",
"err",
":=",
"osext",
".",
"Executable",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",... | // execPath returns the app bundle path where this executable is located | [
"execPath",
"returns",
"the",
"app",
"bundle",
"path",
"where",
"this",
"executable",
"is",
"located"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L25-L32 |
145,628 | keybase/go-updater | keybase/platform_darwin.go | Dir | func Dir(appName string) (string, error) {
if appName == "" {
return "", fmt.Errorf("No app name for dir")
}
libDir, err := libraryDir()
if err != nil {
return "", err
}
return filepath.Join(libDir, "Application Support", appName), nil
} | go | func Dir(appName string) (string, error) {
if appName == "" {
return "", fmt.Errorf("No app name for dir")
}
libDir, err := libraryDir()
if err != nil {
return "", err
}
return filepath.Join(libDir, "Application Support", appName), nil
} | [
"func",
"Dir",
"(",
"appName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"appName",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"libDir",
",",
"err",
":=",
"li... | // Dir returns where to store config | [
"Dir",
"returns",
"where",
"to",
"store",
"config"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L60-L69 |
145,629 | keybase/go-updater | keybase/platform_darwin.go | CacheDir | func CacheDir(appName string) (string, error) {
if appName == "" {
return "", fmt.Errorf("No app name for dir")
}
return filepath.Join(os.TempDir(), appName), nil
} | go | func CacheDir(appName string) (string, error) {
if appName == "" {
return "", fmt.Errorf("No app name for dir")
}
return filepath.Join(os.TempDir(), appName), nil
} | [
"func",
"CacheDir",
"(",
"appName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"appName",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"filepath",
".",
"... | // CacheDir returns where to store temporary files | [
"CacheDir",
"returns",
"where",
"to",
"store",
"temporary",
"files"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L72-L77 |
145,630 | keybase/go-updater | keybase/platform_darwin.go | LogDir | func LogDir(appName string) (string, error) {
libDir, err := libraryDir()
if err != nil {
return "", err
}
return filepath.Join(libDir, "Logs"), nil
} | go | func LogDir(appName string) (string, error) {
libDir, err := libraryDir()
if err != nil {
return "", err
}
return filepath.Join(libDir, "Logs"), nil
} | [
"func",
"LogDir",
"(",
"appName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"libDir",
",",
"err",
":=",
"libraryDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"filepath"... | // LogDir is where to log | [
"LogDir",
"is",
"where",
"to",
"log"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L80-L86 |
145,631 | keybase/go-updater | keybase/platform_darwin.go | UpdatePrompt | func (c context) UpdatePrompt(update updater.Update, options updater.UpdateOptions, promptOptions updater.UpdatePromptOptions) (*updater.UpdatePromptResponse, error) {
promptProgram, err := c.config.promptProgram()
if err != nil {
return nil, err
}
return c.updatePrompt(promptProgram, update, options, promptOptio... | go | func (c context) UpdatePrompt(update updater.Update, options updater.UpdateOptions, promptOptions updater.UpdatePromptOptions) (*updater.UpdatePromptResponse, error) {
promptProgram, err := c.config.promptProgram()
if err != nil {
return nil, err
}
return c.updatePrompt(promptProgram, update, options, promptOptio... | [
"func",
"(",
"c",
"context",
")",
"UpdatePrompt",
"(",
"update",
"updater",
".",
"Update",
",",
"options",
"updater",
".",
"UpdateOptions",
",",
"promptOptions",
"updater",
".",
"UpdatePromptOptions",
")",
"(",
"*",
"updater",
".",
"UpdatePromptResponse",
",",
... | // UpdatePrompt is called when the user needs to accept an update | [
"UpdatePrompt",
"is",
"called",
"when",
"the",
"user",
"needs",
"to",
"accept",
"an",
"update"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L128-L134 |
145,632 | keybase/go-updater | keybase/platform_darwin.go | PausedPrompt | func (c context) PausedPrompt() bool {
promptProgram, err := c.config.promptProgram()
if err != nil {
c.log.Warningf("Error trying to get prompt path: %s", err)
return false
}
cancelUpdate, err := c.pausedPrompt(promptProgram, 5*time.Minute)
if err != nil {
c.log.Warningf("Error in paused prompt: %s", err)
... | go | func (c context) PausedPrompt() bool {
promptProgram, err := c.config.promptProgram()
if err != nil {
c.log.Warningf("Error trying to get prompt path: %s", err)
return false
}
cancelUpdate, err := c.pausedPrompt(promptProgram, 5*time.Minute)
if err != nil {
c.log.Warningf("Error in paused prompt: %s", err)
... | [
"func",
"(",
"c",
"context",
")",
"PausedPrompt",
"(",
")",
"bool",
"{",
"promptProgram",
",",
"err",
":=",
"c",
".",
"config",
".",
"promptProgram",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
... | // PausedPrompt is called when the we can't update cause the app is in use.
// We return true if the use wants to cancel the update. | [
"PausedPrompt",
"is",
"called",
"when",
"the",
"we",
"can",
"t",
"update",
"cause",
"the",
"app",
"is",
"in",
"use",
".",
"We",
"return",
"true",
"if",
"the",
"use",
"wants",
"to",
"cancel",
"the",
"update",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L138-L150 |
145,633 | keybase/go-updater | keybase/platform_darwin.go | stop | func (c context) stop() error {
// Stop app
appExitResult, appExitErr := command.Exec(c.config.keybasePath(), []string{"ctl", "app-exit"}, 30*time.Second, c.log)
c.log.Infof("Stop output: %s", appExitResult.CombinedOutput())
if appExitErr != nil {
c.log.Warningf("Error requesting app exit: %s", appExitErr)
}
/... | go | func (c context) stop() error {
// Stop app
appExitResult, appExitErr := command.Exec(c.config.keybasePath(), []string{"ctl", "app-exit"}, 30*time.Second, c.log)
c.log.Infof("Stop output: %s", appExitResult.CombinedOutput())
if appExitErr != nil {
c.log.Warningf("Error requesting app exit: %s", appExitErr)
}
/... | [
"func",
"(",
"c",
"context",
")",
"stop",
"(",
")",
"error",
"{",
"// Stop app",
"appExitResult",
",",
"appExitErr",
":=",
"command",
".",
"Exec",
"(",
"c",
".",
"config",
".",
"keybasePath",
"(",
")",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
... | // stop will quit the app and any services | [
"stop",
"will",
"quit",
"the",
"app",
"and",
"any",
"services"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L187-L218 |
145,634 | keybase/go-updater | keybase/platform_darwin.go | AfterApply | func (c context) AfterApply(update updater.Update) error {
if err := c.stop(); err != nil {
c.log.Warningf("Error trying to stop: %s", err)
}
if err := c.start(10*time.Second, time.Second); err != nil {
c.log.Warningf("Error trying to start the app: %s", err)
}
return nil
} | go | func (c context) AfterApply(update updater.Update) error {
if err := c.stop(); err != nil {
c.log.Warningf("Error trying to stop: %s", err)
}
if err := c.start(10*time.Second, time.Second); err != nil {
c.log.Warningf("Error trying to start the app: %s", err)
}
return nil
} | [
"func",
"(",
"c",
"context",
")",
"AfterApply",
"(",
"update",
"updater",
".",
"Update",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"stop",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"er... | // AfterApply is called after an update is applied | [
"AfterApply",
"is",
"called",
"after",
"an",
"update",
"is",
"applied"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L221-L230 |
145,635 | keybase/go-updater | keybase/platform_darwin.go | start | func (c context) start(wait time.Duration, delay time.Duration) error {
procPaths, err := c.lookupProcessPaths()
if err != nil {
return err
}
if err := OpenAppDarwin(procPaths.appPath, c.log); err != nil {
c.log.Warningf("Error opening app: %s", err)
}
// Check to make sure processes started
c.log.Debugf("... | go | func (c context) start(wait time.Duration, delay time.Duration) error {
procPaths, err := c.lookupProcessPaths()
if err != nil {
return err
}
if err := OpenAppDarwin(procPaths.appPath, c.log); err != nil {
c.log.Warningf("Error opening app: %s", err)
}
// Check to make sure processes started
c.log.Debugf("... | [
"func",
"(",
"c",
"context",
")",
"start",
"(",
"wait",
"time",
".",
"Duration",
",",
"delay",
"time",
".",
"Duration",
")",
"error",
"{",
"procPaths",
",",
"err",
":=",
"c",
".",
"lookupProcessPaths",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Start the app.
// The wait is how log to wait for processes and the app to start before
// reporting that an error occurred. | [
"Start",
"the",
"app",
".",
"The",
"wait",
"is",
"how",
"log",
"to",
"wait",
"for",
"processes",
"and",
"the",
"app",
"to",
"start",
"before",
"reporting",
"that",
"an",
"error",
"occurred",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L235-L252 |
145,636 | keybase/go-updater | keybase/platform_darwin.go | OpenAppDarwin | func OpenAppDarwin(appPath string, log process.Log) error {
return openAppDarwin("/usr/bin/open", appPath, time.Second, log)
} | go | func OpenAppDarwin(appPath string, log process.Log) error {
return openAppDarwin("/usr/bin/open", appPath, time.Second, log)
} | [
"func",
"OpenAppDarwin",
"(",
"appPath",
"string",
",",
"log",
"process",
".",
"Log",
")",
"error",
"{",
"return",
"openAppDarwin",
"(",
"\"",
"\"",
",",
"appPath",
",",
"time",
".",
"Second",
",",
"log",
")",
"\n",
"}"
] | // OpenAppDarwin starts an app | [
"OpenAppDarwin",
"starts",
"an",
"app"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_darwin.go#L267-L269 |
145,637 | keybase/go-updater | command/command.go | ArgsWith | func (p Program) ArgsWith(args []string) []string {
if p.Args == nil || len(p.Args) == 0 {
return args
}
if len(args) == 0 {
return p.Args
}
return append(p.Args, args...)
} | go | func (p Program) ArgsWith(args []string) []string {
if p.Args == nil || len(p.Args) == 0 {
return args
}
if len(args) == 0 {
return p.Args
}
return append(p.Args, args...)
} | [
"func",
"(",
"p",
"Program",
")",
"ArgsWith",
"(",
"args",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"p",
".",
"Args",
"==",
"nil",
"||",
"len",
"(",
"p",
".",
"Args",
")",
"==",
"0",
"{",
"return",
"args",
"\n",
"}",
"\n",
"if"... | // ArgsWith returns program args with passed in args | [
"ArgsWith",
"returns",
"program",
"args",
"with",
"passed",
"in",
"args"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/command/command.go#L32-L40 |
145,638 | keybase/go-updater | command/command.go | CombinedOutput | func (r Result) CombinedOutput() string {
strs := []string{}
if sout := r.Stdout.String(); sout != "" {
strs = append(strs, fmt.Sprintf("[stdout]: %s", sout))
}
if serr := r.Stderr.String(); serr != "" {
strs = append(strs, fmt.Sprintf("[stderr]: %s", serr))
}
return strings.Join(strs, ", ")
} | go | func (r Result) CombinedOutput() string {
strs := []string{}
if sout := r.Stdout.String(); sout != "" {
strs = append(strs, fmt.Sprintf("[stdout]: %s", sout))
}
if serr := r.Stderr.String(); serr != "" {
strs = append(strs, fmt.Sprintf("[stderr]: %s", serr))
}
return strings.Join(strs, ", ")
} | [
"func",
"(",
"r",
"Result",
")",
"CombinedOutput",
"(",
")",
"string",
"{",
"strs",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"sout",
":=",
"r",
".",
"Stdout",
".",
"String",
"(",
")",
";",
"sout",
"!=",
"\"",
"\"",
"{",
"strs",
"=",
"app... | // CombinedOutput returns Stdout and Stderr as a single string. | [
"CombinedOutput",
"returns",
"Stdout",
"and",
"Stderr",
"as",
"a",
"single",
"string",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/command/command.go#L50-L59 |
145,639 | keybase/go-updater | command/command.go | execWithFunc | func execWithFunc(name string, args []string, env []string, execCmd execCmd, timeout time.Duration, log Log) (Result, error) {
var result Result
log.Debugf("Execute: %s %s", name, args)
if name == "" {
return result, fmt.Errorf("No command")
}
if timeout < 0 {
return result, fmt.Errorf("Invalid timeout: %s", t... | go | func execWithFunc(name string, args []string, env []string, execCmd execCmd, timeout time.Duration, log Log) (Result, error) {
var result Result
log.Debugf("Execute: %s %s", name, args)
if name == "" {
return result, fmt.Errorf("No command")
}
if timeout < 0 {
return result, fmt.Errorf("Invalid timeout: %s", t... | [
"func",
"execWithFunc",
"(",
"name",
"string",
",",
"args",
"[",
"]",
"string",
",",
"env",
"[",
"]",
"string",
",",
"execCmd",
"execCmd",
",",
"timeout",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"(",
"Result",
",",
"error",
")",
"{",
"var",
... | // exec runs a command and returns a Result and error if any.
// We will send TERM signal and wait 1 second or timeout, whichever is less,
// before calling KILL. | [
"exec",
"runs",
"a",
"command",
"and",
"returns",
"a",
"Result",
"and",
"error",
"if",
"any",
".",
"We",
"will",
"send",
"TERM",
"signal",
"and",
"wait",
"1",
"second",
"or",
"timeout",
"whichever",
"is",
"less",
"before",
"calling",
"KILL",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/command/command.go#L76-L142 |
145,640 | keybase/go-updater | sources/local.go | NewLocalUpdateSource | func NewLocalUpdateSource(path string, jsonPath string, log Log) LocalUpdateSource {
return LocalUpdateSource{
path: path,
jsonPath: jsonPath,
log: log,
}
} | go | func NewLocalUpdateSource(path string, jsonPath string, log Log) LocalUpdateSource {
return LocalUpdateSource{
path: path,
jsonPath: jsonPath,
log: log,
}
} | [
"func",
"NewLocalUpdateSource",
"(",
"path",
"string",
",",
"jsonPath",
"string",
",",
"log",
"Log",
")",
"LocalUpdateSource",
"{",
"return",
"LocalUpdateSource",
"{",
"path",
":",
"path",
",",
"jsonPath",
":",
"jsonPath",
",",
"log",
":",
"log",
",",
"}",
... | // NewLocalUpdateSource returns local update source | [
"NewLocalUpdateSource",
"returns",
"local",
"update",
"source"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/sources/local.go#L23-L29 |
145,641 | keybase/go-updater | util/env.go | EnvDuration | func EnvDuration(envVar string, defaultValue time.Duration) time.Duration {
return envDuration(os.Getenv, envVar, defaultValue)
} | go | func EnvDuration(envVar string, defaultValue time.Duration) time.Duration {
return envDuration(os.Getenv, envVar, defaultValue)
} | [
"func",
"EnvDuration",
"(",
"envVar",
"string",
",",
"defaultValue",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"return",
"envDuration",
"(",
"os",
".",
"Getenv",
",",
"envVar",
",",
"defaultValue",
")",
"\n",
"}"
] | // EnvDuration returns a duration from an environment variable or default if
// invalid or not specified | [
"EnvDuration",
"returns",
"a",
"duration",
"from",
"an",
"environment",
"variable",
"or",
"default",
"if",
"invalid",
"or",
"not",
"specified"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/env.go#L16-L18 |
145,642 | keybase/go-updater | util/env.go | EnvBool | func EnvBool(envVar string, defaultValue bool) bool {
return envBool(os.Getenv, envVar, defaultValue)
} | go | func EnvBool(envVar string, defaultValue bool) bool {
return envBool(os.Getenv, envVar, defaultValue)
} | [
"func",
"EnvBool",
"(",
"envVar",
"string",
",",
"defaultValue",
"bool",
")",
"bool",
"{",
"return",
"envBool",
"(",
"os",
".",
"Getenv",
",",
"envVar",
",",
"defaultValue",
")",
"\n",
"}"
] | // EnvBool returns a bool from an environment variable or default if invalid or
// not specified | [
"EnvBool",
"returns",
"a",
"bool",
"from",
"an",
"environment",
"variable",
"or",
"default",
"if",
"invalid",
"or",
"not",
"specified"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/env.go#L34-L36 |
145,643 | keybase/go-updater | keybase/report.go | ReportError | func (c context) ReportError(err error, update *updater.Update, options updater.UpdateOptions) {
if reportErr := c.reportError(err, update, options, defaultEndpoints.err, time.Minute); reportErr != nil {
c.log.Warningf("Error notifying about an error: %s", reportErr)
}
} | go | func (c context) ReportError(err error, update *updater.Update, options updater.UpdateOptions) {
if reportErr := c.reportError(err, update, options, defaultEndpoints.err, time.Minute); reportErr != nil {
c.log.Warningf("Error notifying about an error: %s", reportErr)
}
} | [
"func",
"(",
"c",
"context",
")",
"ReportError",
"(",
"err",
"error",
",",
"update",
"*",
"updater",
".",
"Update",
",",
"options",
"updater",
".",
"UpdateOptions",
")",
"{",
"if",
"reportErr",
":=",
"c",
".",
"reportError",
"(",
"err",
",",
"update",
... | // ReportError notifies the API server of a client updater error | [
"ReportError",
"notifies",
"the",
"API",
"server",
"of",
"a",
"client",
"updater",
"error"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/report.go#L18-L22 |
145,644 | keybase/go-updater | keybase/report.go | ReportAction | func (c context) ReportAction(actionResponse updater.UpdatePromptResponse, update *updater.Update, options updater.UpdateOptions) {
if err := c.reportAction(actionResponse, update, options, defaultEndpoints.action, time.Minute); err != nil {
c.log.Warningf("Error notifying about an action (%s): %s", actionResponse.A... | go | func (c context) ReportAction(actionResponse updater.UpdatePromptResponse, update *updater.Update, options updater.UpdateOptions) {
if err := c.reportAction(actionResponse, update, options, defaultEndpoints.action, time.Minute); err != nil {
c.log.Warningf("Error notifying about an action (%s): %s", actionResponse.A... | [
"func",
"(",
"c",
"context",
")",
"ReportAction",
"(",
"actionResponse",
"updater",
".",
"UpdatePromptResponse",
",",
"update",
"*",
"updater",
".",
"Update",
",",
"options",
"updater",
".",
"UpdateOptions",
")",
"{",
"if",
"err",
":=",
"c",
".",
"reportActi... | // ReportAction notifies the API server of a client updater action | [
"ReportAction",
"notifies",
"the",
"API",
"server",
"of",
"a",
"client",
"updater",
"action"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/report.go#L40-L44 |
145,645 | keybase/go-updater | updater.go | NewUpdater | func NewUpdater(source UpdateSource, config Config, log Log) *Updater {
return &Updater{
source: source,
config: config,
log: log,
}
} | go | func NewUpdater(source UpdateSource, config Config, log Log) *Updater {
return &Updater{
source: source,
config: config,
log: log,
}
} | [
"func",
"NewUpdater",
"(",
"source",
"UpdateSource",
",",
"config",
"Config",
",",
"log",
"Log",
")",
"*",
"Updater",
"{",
"return",
"&",
"Updater",
"{",
"source",
":",
"source",
",",
"config",
":",
"config",
",",
"log",
":",
"log",
",",
"}",
"\n",
"... | // NewUpdater constructs an Updater | [
"NewUpdater",
"constructs",
"an",
"Updater"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L82-L88 |
145,646 | keybase/go-updater | updater.go | Update | func (u *Updater) Update(ctx Context) (*Update, error) {
options := ctx.UpdateOptions()
update, err := u.update(ctx, options)
report(ctx, err, update, options)
return update, err
} | go | func (u *Updater) Update(ctx Context) (*Update, error) {
options := ctx.UpdateOptions()
update, err := u.update(ctx, options)
report(ctx, err, update, options)
return update, err
} | [
"func",
"(",
"u",
"*",
"Updater",
")",
"Update",
"(",
"ctx",
"Context",
")",
"(",
"*",
"Update",
",",
"error",
")",
"{",
"options",
":=",
"ctx",
".",
"UpdateOptions",
"(",
")",
"\n",
"update",
",",
"err",
":=",
"u",
".",
"update",
"(",
"ctx",
","... | // Update checks, downloads and performs an update | [
"Update",
"checks",
"downloads",
"and",
"performs",
"an",
"update"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L91-L96 |
145,647 | keybase/go-updater | updater.go | NeedUpdate | func (u *Updater) NeedUpdate(ctx Context) (upToDate bool, err error) {
update, err := u.checkForUpdate(ctx, ctx.UpdateOptions())
if err != nil {
return false, err
}
return update.NeedUpdate, nil
} | go | func (u *Updater) NeedUpdate(ctx Context) (upToDate bool, err error) {
update, err := u.checkForUpdate(ctx, ctx.UpdateOptions())
if err != nil {
return false, err
}
return update.NeedUpdate, nil
} | [
"func",
"(",
"u",
"*",
"Updater",
")",
"NeedUpdate",
"(",
"ctx",
"Context",
")",
"(",
"upToDate",
"bool",
",",
"err",
"error",
")",
"{",
"update",
",",
"err",
":=",
"u",
".",
"checkForUpdate",
"(",
"ctx",
",",
"ctx",
".",
"UpdateOptions",
"(",
")",
... | // NeedUpdate returns true if we are out-of-date. | [
"NeedUpdate",
"returns",
"true",
"if",
"we",
"are",
"out",
"-",
"of",
"-",
"date",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L242-L248 |
145,648 | keybase/go-updater | updater.go | promptForUpdateAction | func (u *Updater) promptForUpdateAction(ctx Context, update Update, options UpdateOptions) (UpdatePromptResponse, error) {
u.log.Debug("Prompt for update")
auto, autoSet := u.config.GetUpdateAuto()
autoOverride := u.config.GetUpdateAutoOverride()
u.log.Debugf("Auto update: %s (set=%s autoOverride=%s)", strconv.For... | go | func (u *Updater) promptForUpdateAction(ctx Context, update Update, options UpdateOptions) (UpdatePromptResponse, error) {
u.log.Debug("Prompt for update")
auto, autoSet := u.config.GetUpdateAuto()
autoOverride := u.config.GetUpdateAutoOverride()
u.log.Debugf("Auto update: %s (set=%s autoOverride=%s)", strconv.For... | [
"func",
"(",
"u",
"*",
"Updater",
")",
"promptForUpdateAction",
"(",
"ctx",
"Context",
",",
"update",
"Update",
",",
"options",
"UpdateOptions",
")",
"(",
"UpdatePromptResponse",
",",
"error",
")",
"{",
"u",
".",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")"... | // promptForUpdateAction prompts the user for permission to apply an update | [
"promptForUpdateAction",
"prompts",
"the",
"user",
"for",
"permission",
"to",
"apply",
"an",
"update"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L251-L291 |
145,649 | keybase/go-updater | updater.go | tempDir | func (u *Updater) tempDir() string {
tmpDir := util.TempPath("", "KeybaseUpdater.")
if err := util.MakeDirs(tmpDir, 0700, u.log); err != nil {
u.log.Warningf("Error trying to create temp dir: %s", err)
return ""
}
return tmpDir
} | go | func (u *Updater) tempDir() string {
tmpDir := util.TempPath("", "KeybaseUpdater.")
if err := util.MakeDirs(tmpDir, 0700, u.log); err != nil {
u.log.Warningf("Error trying to create temp dir: %s", err)
return ""
}
return tmpDir
} | [
"func",
"(",
"u",
"*",
"Updater",
")",
"tempDir",
"(",
")",
"string",
"{",
"tmpDir",
":=",
"util",
".",
"TempPath",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"util",
".",
"MakeDirs",
"(",
"tmpDir",
",",
"0700",
",",
"u",
"... | // tempDir, if specified, will contain files that were replaced during an update
// and will be removed after an update. The temp dir should already exist. | [
"tempDir",
"if",
"specified",
"will",
"contain",
"files",
"that",
"were",
"replaced",
"during",
"an",
"update",
"and",
"will",
"be",
"removed",
"after",
"an",
"update",
".",
"The",
"temp",
"dir",
"should",
"already",
"exist",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L342-L349 |
145,650 | keybase/go-updater | updater.go | CleanupPreviousUpdates | func (u *Updater) CleanupPreviousUpdates() (err error) {
parent := os.TempDir()
if parent == "" || parent == "." {
return fmt.Errorf("temp directory is '%v'", parent)
}
files, err := ioutil.ReadDir(parent)
if err != nil {
return fmt.Errorf("listing parent directory: %v", err)
}
for _, fi := range files {
i... | go | func (u *Updater) CleanupPreviousUpdates() (err error) {
parent := os.TempDir()
if parent == "" || parent == "." {
return fmt.Errorf("temp directory is '%v'", parent)
}
files, err := ioutil.ReadDir(parent)
if err != nil {
return fmt.Errorf("listing parent directory: %v", err)
}
for _, fi := range files {
i... | [
"func",
"(",
"u",
"*",
"Updater",
")",
"CleanupPreviousUpdates",
"(",
")",
"(",
"err",
"error",
")",
"{",
"parent",
":=",
"os",
".",
"TempDir",
"(",
")",
"\n",
"if",
"parent",
"==",
"\"",
"\"",
"||",
"parent",
"==",
"\"",
"\"",
"{",
"return",
"fmt"... | // CleanupPreviousUpdates removes temporary files from previous updates. | [
"CleanupPreviousUpdates",
"removes",
"temporary",
"files",
"from",
"previous",
"updates",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L354-L377 |
145,651 | keybase/go-updater | updater.go | Cleanup | func (u *Updater) Cleanup(tmpDir string) {
if tmpDir != "" {
u.log.Debugf("Remove temporary directory: %q", tmpDir)
if err := os.RemoveAll(tmpDir); err != nil {
u.log.Warningf("Error removing temporary directory %q: %s", tmpDir, err)
}
}
} | go | func (u *Updater) Cleanup(tmpDir string) {
if tmpDir != "" {
u.log.Debugf("Remove temporary directory: %q", tmpDir)
if err := os.RemoveAll(tmpDir); err != nil {
u.log.Warningf("Error removing temporary directory %q: %s", tmpDir, err)
}
}
} | [
"func",
"(",
"u",
"*",
"Updater",
")",
"Cleanup",
"(",
"tmpDir",
"string",
")",
"{",
"if",
"tmpDir",
"!=",
"\"",
"\"",
"{",
"u",
".",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"tmpDir",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"RemoveAll",
"(... | // Cleanup removes temporary files from this update | [
"Cleanup",
"removes",
"temporary",
"files",
"from",
"this",
"update"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/updater.go#L380-L387 |
145,652 | keybase/go-updater | service/logger.go | Warningf | func (l logger) Warningf(s string, args ...interface{}) {
log.Printf("WARN %s\n", fmt.Sprintf(s, args...))
} | go | func (l logger) Warningf(s string, args ...interface{}) {
log.Printf("WARN %s\n", fmt.Sprintf(s, args...))
} | [
"func",
"(",
"l",
"logger",
")",
"Warningf",
"(",
"s",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"s",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // Warningf is log implementation | [
"Warningf",
"is",
"log",
"implementation"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/service/logger.go#L43-L45 |
145,653 | keybase/go-updater | keybase/platform_windows.go | updaterPromptResultFromFile | func (c context) updaterPromptResultFromFile(path string) (*updaterPromptInputResult, error) {
resultRaw, err := util.ReadFile(path)
if err != nil {
return nil, err
}
var result updaterPromptInputResult
if err := json.Unmarshal(resultRaw, &result); err != nil {
return nil, err
}
return &result, nil
} | go | func (c context) updaterPromptResultFromFile(path string) (*updaterPromptInputResult, error) {
resultRaw, err := util.ReadFile(path)
if err != nil {
return nil, err
}
var result updaterPromptInputResult
if err := json.Unmarshal(resultRaw, &result); err != nil {
return nil, err
}
return &result, nil
} | [
"func",
"(",
"c",
"context",
")",
"updaterPromptResultFromFile",
"(",
"path",
"string",
")",
"(",
"*",
"updaterPromptInputResult",
",",
"error",
")",
"{",
"resultRaw",
",",
"err",
":=",
"util",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
... | // updaterPromptResultFromFile gets the result from path decodes it | [
"updaterPromptResultFromFile",
"gets",
"the",
"result",
"from",
"path",
"decodes",
"it"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_windows.go#L198-L209 |
145,654 | keybase/go-updater | keybase/platform_windows.go | checkRegistryComponents | func (c *ComponentsChecker) checkRegistryComponents() (result bool) {
// e.g.
// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-21-2398092721-582601651-115936829-1001\Components\024E69EF1A837C752BFB37F494D86925]
// "D6A082CFDEED2984C8688664C76174BC"="C:\\Users\\chris\\AppData\... | go | func (c *ComponentsChecker) checkRegistryComponents() (result bool) {
// e.g.
// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-21-2398092721-582601651-115936829-1001\Components\024E69EF1A837C752BFB37F494D86925]
// "D6A082CFDEED2984C8688664C76174BC"="C:\\Users\\chris\\AppData\... | [
"func",
"(",
"c",
"*",
"ComponentsChecker",
")",
"checkRegistryComponents",
"(",
")",
"(",
"result",
"bool",
")",
"{",
"// e.g.",
"// [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-21-2398092721-582601651-115936829-1001\\Components\\024E69... | // checkRegistryComponents returns true if any component has more than one keybase product code | [
"checkRegistryComponents",
"returns",
"true",
"if",
"any",
"component",
"has",
"more",
"than",
"one",
"keybase",
"product",
"code"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_windows.go#L233-L301 |
145,655 | keybase/go-updater | keybase/platform_windows.go | DeepClean | func (c context) DeepClean() {
i := &ComponentsChecker{context: c, RegAccess: registry.SET_VALUE}
i.PerComponent = i.deleteProductsFunc
i.checkRegistryComponents()
i.RegWow = registry.WOW64_32KEY
i.checkRegistryComponents()
c.deleteProductFiles()
} | go | func (c context) DeepClean() {
i := &ComponentsChecker{context: c, RegAccess: registry.SET_VALUE}
i.PerComponent = i.deleteProductsFunc
i.checkRegistryComponents()
i.RegWow = registry.WOW64_32KEY
i.checkRegistryComponents()
c.deleteProductFiles()
} | [
"func",
"(",
"c",
"context",
")",
"DeepClean",
"(",
")",
"{",
"i",
":=",
"&",
"ComponentsChecker",
"{",
"context",
":",
"c",
",",
"RegAccess",
":",
"registry",
".",
"SET_VALUE",
"}",
"\n",
"i",
".",
"PerComponent",
"=",
"i",
".",
"deleteProductsFunc",
... | // DeepClean is only invoked from the command line, for now.
// Eventually we may need to do full uninstalls but that is kind of risky | [
"DeepClean",
"is",
"only",
"invoked",
"from",
"the",
"command",
"line",
"for",
"now",
".",
"Eventually",
"we",
"may",
"need",
"to",
"do",
"full",
"uninstalls",
"but",
"that",
"is",
"kind",
"of",
"risky"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_windows.go#L353-L360 |
145,656 | keybase/go-updater | keybase/platform_windows.go | GetAppStatePath | func (c context) GetAppStatePath() string {
roamingDir, _ := roamingDataDir()
return filepath.Join(roamingDir, "Keybase", "app-state.json")
} | go | func (c context) GetAppStatePath() string {
roamingDir, _ := roamingDataDir()
return filepath.Join(roamingDir, "Keybase", "app-state.json")
} | [
"func",
"(",
"c",
"context",
")",
"GetAppStatePath",
"(",
")",
"string",
"{",
"roamingDir",
",",
"_",
":=",
"roamingDataDir",
"(",
")",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"roamingDir",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // app-state.json is written in the roaming settings directory, which
// seems to be where Electron chooses | [
"app",
"-",
"state",
".",
"json",
"is",
"written",
"in",
"the",
"roaming",
"settings",
"directory",
"which",
"seems",
"to",
"be",
"where",
"Electron",
"chooses"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_windows.go#L412-L415 |
145,657 | keybase/go-updater | keybase/platform_windows.go | stopKeybaseProcesses | func (c context) stopKeybaseProcesses() error {
path, err := Dir("Keybase")
if err != nil {
c.log.Infof("Error getting Keybase directory: %s", err.Error())
return err
}
c.runKeybase(KeybaseCommandStop)
time.Sleep(time.Second)
// Terminate any executing processes
ospid := os.Getpid()
exes, err := filepath... | go | func (c context) stopKeybaseProcesses() error {
path, err := Dir("Keybase")
if err != nil {
c.log.Infof("Error getting Keybase directory: %s", err.Error())
return err
}
c.runKeybase(KeybaseCommandStop)
time.Sleep(time.Second)
// Terminate any executing processes
ospid := os.Getpid()
exes, err := filepath... | [
"func",
"(",
"c",
"context",
")",
"stopKeybaseProcesses",
"(",
")",
"error",
"{",
"path",
",",
"err",
":=",
"Dir",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"err",
".",
"Erro... | // copied from watchdog | [
"copied",
"from",
"watchdog"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/platform_windows.go#L422-L454 |
145,658 | keybase/go-updater | update_checker.go | NewUpdateChecker | func NewUpdateChecker(updater *Updater, ctx Context, tickDuration time.Duration, log Log) UpdateChecker {
return UpdateChecker{
updater: updater,
ctx: ctx,
log: log,
tickDuration: tickDuration,
}
} | go | func NewUpdateChecker(updater *Updater, ctx Context, tickDuration time.Duration, log Log) UpdateChecker {
return UpdateChecker{
updater: updater,
ctx: ctx,
log: log,
tickDuration: tickDuration,
}
} | [
"func",
"NewUpdateChecker",
"(",
"updater",
"*",
"Updater",
",",
"ctx",
"Context",
",",
"tickDuration",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"UpdateChecker",
"{",
"return",
"UpdateChecker",
"{",
"updater",
":",
"updater",
",",
"ctx",
":",
"ctx",
... | // NewUpdateChecker creates an update checker | [
"NewUpdateChecker",
"creates",
"an",
"update",
"checker"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/update_checker.go#L19-L26 |
145,659 | keybase/go-updater | update_checker.go | Check | func (u *UpdateChecker) Check() {
u.updater.config.SetLastUpdateCheckTime()
if err := u.check(); err != nil {
u.log.Errorf("Error in update: %s", err)
}
} | go | func (u *UpdateChecker) Check() {
u.updater.config.SetLastUpdateCheckTime()
if err := u.check(); err != nil {
u.log.Errorf("Error in update: %s", err)
}
} | [
"func",
"(",
"u",
"*",
"UpdateChecker",
")",
"Check",
"(",
")",
"{",
"u",
".",
"updater",
".",
"config",
".",
"SetLastUpdateCheckTime",
"(",
")",
"\n",
"if",
"err",
":=",
"u",
".",
"check",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"u",
".",
"log",... | // Check checks for an update. | [
"Check",
"checks",
"for",
"an",
"update",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/update_checker.go#L36-L41 |
145,660 | keybase/go-updater | update_checker.go | Start | func (u *UpdateChecker) Start() bool {
if u.ticker != nil {
return false
}
u.ticker = time.NewTicker(u.tickDuration)
go func() {
// If we haven't done an update recently, check now.
// If there is an error getting the last update time, we don't trigger a
// check and let the ticker below trigger it.
if !u... | go | func (u *UpdateChecker) Start() bool {
if u.ticker != nil {
return false
}
u.ticker = time.NewTicker(u.tickDuration)
go func() {
// If we haven't done an update recently, check now.
// If there is an error getting the last update time, we don't trigger a
// check and let the ticker below trigger it.
if !u... | [
"func",
"(",
"u",
"*",
"UpdateChecker",
")",
"Start",
"(",
")",
"bool",
"{",
"if",
"u",
".",
"ticker",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"u",
".",
"ticker",
"=",
"time",
".",
"NewTicker",
"(",
"u",
".",
"tickDuration",
")",
"\... | // Start starts the update checker. Returns false if we are already running. | [
"Start",
"starts",
"the",
"update",
"checker",
".",
"Returns",
"false",
"if",
"we",
"are",
"already",
"running",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/update_checker.go#L44-L64 |
145,661 | keybase/go-updater | update_checker.go | Stop | func (u *UpdateChecker) Stop() {
if u.ticker != nil {
u.ticker.Stop()
u.ticker = nil
}
} | go | func (u *UpdateChecker) Stop() {
if u.ticker != nil {
u.ticker.Stop()
u.ticker = nil
}
} | [
"func",
"(",
"u",
"*",
"UpdateChecker",
")",
"Stop",
"(",
")",
"{",
"if",
"u",
".",
"ticker",
"!=",
"nil",
"{",
"u",
".",
"ticker",
".",
"Stop",
"(",
")",
"\n",
"u",
".",
"ticker",
"=",
"nil",
"\n",
"}",
"\n",
"}"
] | // Stop stops the update checker | [
"Stop",
"stops",
"the",
"update",
"checker"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/update_checker.go#L67-L72 |
145,662 | keybase/go-updater | keybase/context.go | NewUpdaterContext | func NewUpdaterContext(appName string, pathToKeybase string, log Log, mode UpdaterMode) (updater.Context, *updater.Updater) {
cfg, err := newConfig(appName, pathToKeybase, log, mode.IgnoreSnooze())
if err != nil {
log.Warningf("Error loading config for context: %s", err)
}
src := NewUpdateSource(cfg, log)
// F... | go | func NewUpdaterContext(appName string, pathToKeybase string, log Log, mode UpdaterMode) (updater.Context, *updater.Updater) {
cfg, err := newConfig(appName, pathToKeybase, log, mode.IgnoreSnooze())
if err != nil {
log.Warningf("Error loading config for context: %s", err)
}
src := NewUpdateSource(cfg, log)
// F... | [
"func",
"NewUpdaterContext",
"(",
"appName",
"string",
",",
"pathToKeybase",
"string",
",",
"log",
"Log",
",",
"mode",
"UpdaterMode",
")",
"(",
"updater",
".",
"Context",
",",
"*",
"updater",
".",
"Updater",
")",
"{",
"cfg",
",",
"err",
":=",
"newConfig",
... | // NewUpdaterContext returns an updater context for Keybase | [
"NewUpdaterContext",
"returns",
"an",
"updater",
"context",
"for",
"Keybase"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/context.go#L97-L120 |
145,663 | keybase/go-updater | keybase/context.go | Verify | func (c context) Verify(update updater.Update) error {
return saltpack.VerifyDetachedFileAtPath(update.Asset.LocalPath, update.Asset.Signature, validCodeSigningKIDs, c.log)
} | go | func (c context) Verify(update updater.Update) error {
return saltpack.VerifyDetachedFileAtPath(update.Asset.LocalPath, update.Asset.Signature, validCodeSigningKIDs, c.log)
} | [
"func",
"(",
"c",
"context",
")",
"Verify",
"(",
"update",
"updater",
".",
"Update",
")",
"error",
"{",
"return",
"saltpack",
".",
"VerifyDetachedFileAtPath",
"(",
"update",
".",
"Asset",
".",
"LocalPath",
",",
"update",
".",
"Asset",
".",
"Signature",
","... | // Verify verifies the signature | [
"Verify",
"verifies",
"the",
"signature"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/context.go#L138-L140 |
145,664 | keybase/go-updater | keybase/context.go | BeforeApply | func (c context) BeforeApply(update updater.Update) error {
inUse, err := c.checkInUse()
if err != nil {
c.log.Warningf("Error trying to check in use: %s", err)
}
if inUse {
if cancel := c.PausedPrompt(); cancel {
return fmt.Errorf("Canceled by user from paused prompt")
}
}
return nil
} | go | func (c context) BeforeApply(update updater.Update) error {
inUse, err := c.checkInUse()
if err != nil {
c.log.Warningf("Error trying to check in use: %s", err)
}
if inUse {
if cancel := c.PausedPrompt(); cancel {
return fmt.Errorf("Canceled by user from paused prompt")
}
}
return nil
} | [
"func",
"(",
"c",
"context",
")",
"BeforeApply",
"(",
"update",
"updater",
".",
"Update",
")",
"error",
"{",
"inUse",
",",
"err",
":=",
"c",
".",
"checkInUse",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Warningf",
"(",
... | // BeforeApply is called before an update is applied | [
"BeforeApply",
"is",
"called",
"before",
"an",
"update",
"is",
"applied"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/context.go#L155-L166 |
145,665 | keybase/go-updater | util/file.go | safeWriteToFile | func safeWriteToFile(t SafeWriter, mode os.FileMode, log Log) error {
filename := t.GetFilename()
if filename == "" {
return fmt.Errorf("No filename")
}
log.Debugf("Writing to %s", filename)
tempFilename, tempFile, err := openTempFile(filename+"-", "", mode)
log.Debugf("Temporary file generated: %s", tempFilena... | go | func safeWriteToFile(t SafeWriter, mode os.FileMode, log Log) error {
filename := t.GetFilename()
if filename == "" {
return fmt.Errorf("No filename")
}
log.Debugf("Writing to %s", filename)
tempFilename, tempFile, err := openTempFile(filename+"-", "", mode)
log.Debugf("Temporary file generated: %s", tempFilena... | [
"func",
"safeWriteToFile",
"(",
"t",
"SafeWriter",
",",
"mode",
"os",
".",
"FileMode",
",",
"log",
"Log",
")",
"error",
"{",
"filename",
":=",
"t",
".",
"GetFilename",
"(",
")",
"\n",
"if",
"filename",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Er... | // safeWriteToFile to safely write to a file | [
"safeWriteToFile",
"to",
"safely",
"write",
"to",
"a",
"file"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L53-L85 |
145,666 | keybase/go-updater | util/file.go | MakeParentDirs | func MakeParentDirs(path string, mode os.FileMode, log Log) error {
// 2nd return value here is filename (not an error), which is not needed
dir, _ := filepath.Split(path)
if dir == "" {
return fmt.Errorf("No base directory")
}
return MakeDirs(dir, mode, log)
} | go | func MakeParentDirs(path string, mode os.FileMode, log Log) error {
// 2nd return value here is filename (not an error), which is not needed
dir, _ := filepath.Split(path)
if dir == "" {
return fmt.Errorf("No base directory")
}
return MakeDirs(dir, mode, log)
} | [
"func",
"MakeParentDirs",
"(",
"path",
"string",
",",
"mode",
"os",
".",
"FileMode",
",",
"log",
"Log",
")",
"error",
"{",
"// 2nd return value here is filename (not an error), which is not needed",
"dir",
",",
"_",
":=",
"filepath",
".",
"Split",
"(",
"path",
")"... | // MakeParentDirs ensures parent directory exist for path | [
"MakeParentDirs",
"ensures",
"parent",
"directory",
"exist",
"for",
"path"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L146-L153 |
145,667 | keybase/go-updater | util/file.go | MakeDirs | func MakeDirs(dir string, mode os.FileMode, log Log) error {
exists, err := FileExists(dir)
if err != nil {
return err
}
if !exists {
log.Debugf("Creating: %s\n", dir)
err = os.MkdirAll(dir, mode)
if err != nil {
return err
}
}
return nil
} | go | func MakeDirs(dir string, mode os.FileMode, log Log) error {
exists, err := FileExists(dir)
if err != nil {
return err
}
if !exists {
log.Debugf("Creating: %s\n", dir)
err = os.MkdirAll(dir, mode)
if err != nil {
return err
}
}
return nil
} | [
"func",
"MakeDirs",
"(",
"dir",
"string",
",",
"mode",
"os",
".",
"FileMode",
",",
"log",
"Log",
")",
"error",
"{",
"exists",
",",
"err",
":=",
"FileExists",
"(",
"dir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
... | // MakeDirs ensures directory exists for path | [
"MakeDirs",
"ensures",
"directory",
"exists",
"for",
"path"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L156-L170 |
145,668 | keybase/go-updater | util/file.go | MoveFile | func MoveFile(sourcePath string, destinationPath string, tmpDir string, log Log) error {
if _, statErr := os.Stat(destinationPath); statErr == nil {
if tmpDir == "" {
log.Infof("Removing existing destination path: %s", destinationPath)
if removeErr := os.RemoveAll(destinationPath); removeErr != nil {
retur... | go | func MoveFile(sourcePath string, destinationPath string, tmpDir string, log Log) error {
if _, statErr := os.Stat(destinationPath); statErr == nil {
if tmpDir == "" {
log.Infof("Removing existing destination path: %s", destinationPath)
if removeErr := os.RemoveAll(destinationPath); removeErr != nil {
retur... | [
"func",
"MoveFile",
"(",
"sourcePath",
"string",
",",
"destinationPath",
"string",
",",
"tmpDir",
"string",
",",
"log",
"Log",
")",
"error",
"{",
"if",
"_",
",",
"statErr",
":=",
"os",
".",
"Stat",
"(",
"destinationPath",
")",
";",
"statErr",
"==",
"nil"... | // MoveFile moves a file safely.
// It will create parent directories for destinationPath if they don't exist.
// If the destination already exists and you specify a tmpDir, it will move
// it there, otherwise it will be removed. | [
"MoveFile",
"moves",
"a",
"file",
"safely",
".",
"It",
"will",
"create",
"parent",
"directories",
"for",
"destinationPath",
"if",
"they",
"don",
"t",
"exist",
".",
"If",
"the",
"destination",
"already",
"exists",
"and",
"you",
"specify",
"a",
"tmpDir",
"it",... | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L234-L257 |
145,669 | keybase/go-updater | util/file.go | CopyFile | func CopyFile(sourcePath string, destinationPath string, log Log) error {
log.Infof("Copying %s to %s", sourcePath, destinationPath)
in, err := os.Open(sourcePath)
if err != nil {
return err
}
defer Close(in)
if _, statErr := os.Stat(destinationPath); statErr == nil {
log.Infof("Removing existing destination... | go | func CopyFile(sourcePath string, destinationPath string, log Log) error {
log.Infof("Copying %s to %s", sourcePath, destinationPath)
in, err := os.Open(sourcePath)
if err != nil {
return err
}
defer Close(in)
if _, statErr := os.Stat(destinationPath); statErr == nil {
log.Infof("Removing existing destination... | [
"func",
"CopyFile",
"(",
"sourcePath",
"string",
",",
"destinationPath",
"string",
",",
"log",
"Log",
")",
"error",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"sourcePath",
",",
"destinationPath",
")",
"\n",
"in",
",",
"err",
":=",
"os",
".",
"Ope... | // CopyFile copies a file safely.
// It will create parent directories for destinationPath if they don't exist.
// It will overwrite an existing destinationPath. | [
"CopyFile",
"copies",
"a",
"file",
"safely",
".",
"It",
"will",
"create",
"parent",
"directories",
"for",
"destinationPath",
"if",
"they",
"don",
"t",
"exist",
".",
"It",
"will",
"overwrite",
"an",
"existing",
"destinationPath",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L262-L292 |
145,670 | keybase/go-updater | util/file.go | ReadFile | func ReadFile(path string) ([]byte, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer Close(file)
data, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
return data, nil
} | go | func ReadFile(path string) ([]byte, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer Close(file)
data, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
return data, nil
} | [
"func",
"ReadFile",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"... | // ReadFile returns data for file at path | [
"ReadFile",
"returns",
"data",
"for",
"file",
"at",
"path"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L295-L306 |
145,671 | keybase/go-updater | util/file.go | Touch | func Touch(path string) error {
f, err := os.OpenFile(path, os.O_RDONLY|os.O_CREATE|os.O_TRUNC, 0600)
Close(f)
return err
} | go | func Touch(path string) error {
f, err := os.OpenFile(path, os.O_RDONLY|os.O_CREATE|os.O_TRUNC, 0600)
Close(f)
return err
} | [
"func",
"Touch",
"(",
"path",
"string",
")",
"error",
"{",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"path",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_CREATE",
"|",
"os",
".",
"O_TRUNC",
",",
"0600",
")",
"\n",
"Close",
"(",
"f",
... | // Touch a file, updating its modification time | [
"Touch",
"a",
"file",
"updating",
"its",
"modification",
"time"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L342-L346 |
145,672 | keybase/go-updater | util/file.go | FileModTime | func FileModTime(path string) (time.Time, error) {
info, err := os.Stat(path)
if err != nil {
return time.Time{}, err
}
return info.ModTime(), nil
} | go | func FileModTime(path string) (time.Time, error) {
info, err := os.Stat(path)
if err != nil {
return time.Time{}, err
}
return info.ModTime(), nil
} | [
"func",
"FileModTime",
"(",
"path",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"time",
".",
"Time",
"{",
"}",
",... | // FileModTime returns modification time for file.
// If file doesn't exist returns error. | [
"FileModTime",
"returns",
"modification",
"time",
"for",
"file",
".",
"If",
"file",
"doesn",
"t",
"exist",
"returns",
"error",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/file.go#L350-L356 |
145,673 | keybase/go-updater | util/digest.go | CheckDigest | func CheckDigest(digest string, path string, log Log) error {
if digest == "" {
return fmt.Errorf("Missing digest")
}
calcDigest, err := DigestForFileAtPath(path)
if err != nil {
return err
}
if calcDigest != digest {
return fmt.Errorf("Invalid digest: %s != %s (%s)", calcDigest, digest, path)
}
log.Infof... | go | func CheckDigest(digest string, path string, log Log) error {
if digest == "" {
return fmt.Errorf("Missing digest")
}
calcDigest, err := DigestForFileAtPath(path)
if err != nil {
return err
}
if calcDigest != digest {
return fmt.Errorf("Invalid digest: %s != %s (%s)", calcDigest, digest, path)
}
log.Infof... | [
"func",
"CheckDigest",
"(",
"digest",
"string",
",",
"path",
"string",
",",
"log",
"Log",
")",
"error",
"{",
"if",
"digest",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"calcDigest",
",",
"err",
":=... | // CheckDigest returns no error if digest matches file | [
"CheckDigest",
"returns",
"no",
"error",
"if",
"digest",
"matches",
"file"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/digest.go#L15-L28 |
145,674 | keybase/go-updater | keybase/config.go | newConfig | func newConfig(appName string, pathToKeybase string, log Log, ignoreSnooze bool) (*config, error) {
cfg := newDefaultConfig(appName, pathToKeybase, log, ignoreSnooze)
err := cfg.load()
return &cfg, err
} | go | func newConfig(appName string, pathToKeybase string, log Log, ignoreSnooze bool) (*config, error) {
cfg := newDefaultConfig(appName, pathToKeybase, log, ignoreSnooze)
err := cfg.load()
return &cfg, err
} | [
"func",
"newConfig",
"(",
"appName",
"string",
",",
"pathToKeybase",
"string",
",",
"log",
"Log",
",",
"ignoreSnooze",
"bool",
")",
"(",
"*",
"config",
",",
"error",
")",
"{",
"cfg",
":=",
"newDefaultConfig",
"(",
"appName",
",",
"pathToKeybase",
",",
"log... | // newConfig loads a config, which is valid even if it has an error | [
"newConfig",
"loads",
"a",
"config",
"which",
"is",
"valid",
"even",
"if",
"it",
"has",
"an",
"error"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/config.go#L61-L65 |
145,675 | keybase/go-updater | keybase/config.go | load | func (c *config) load() error {
path, err := c.path()
if err != nil {
return nil
}
return c.loadFromPath(path)
} | go | func (c *config) load() error {
path, err := c.path()
if err != nil {
return nil
}
return c.loadFromPath(path)
} | [
"func",
"(",
"c",
"*",
"config",
")",
"load",
"(",
")",
"error",
"{",
"path",
",",
"err",
":=",
"c",
".",
"path",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"c",
".",
"loadFromPath",
"(",
"path",
... | // load the config | [
"load",
"the",
"config"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/config.go#L77-L83 |
145,676 | keybase/go-updater | keybase/config.go | IsLastUpdateCheckTimeRecent | func (c config) IsLastUpdateCheckTimeRecent(d time.Duration) bool {
path, err := c.updateCheckTouchPath()
if err != nil {
c.log.Errorf("Error getting check path: %s", err)
return true
}
t, err := util.FileModTime(path)
if err != nil {
if os.IsNotExist(err) {
c.log.Infof("No last update time")
} else {
... | go | func (c config) IsLastUpdateCheckTimeRecent(d time.Duration) bool {
path, err := c.updateCheckTouchPath()
if err != nil {
c.log.Errorf("Error getting check path: %s", err)
return true
}
t, err := util.FileModTime(path)
if err != nil {
if os.IsNotExist(err) {
c.log.Infof("No last update time")
} else {
... | [
"func",
"(",
"c",
"config",
")",
"IsLastUpdateCheckTimeRecent",
"(",
"d",
"time",
".",
"Duration",
")",
"bool",
"{",
"path",
",",
"err",
":=",
"c",
".",
"updateCheckTouchPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Err... | // IsLastUpdateCheckTimeRecent returns true if we've updated within duration.
// If there is any kind of error, returns true. | [
"IsLastUpdateCheckTimeRecent",
"returns",
"true",
"if",
"we",
"ve",
"updated",
"within",
"duration",
".",
"If",
"there",
"is",
"any",
"kind",
"of",
"error",
"returns",
"true",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/config.go#L126-L144 |
145,677 | keybase/go-updater | keybase/config.go | SetLastUpdateCheckTime | func (c config) SetLastUpdateCheckTime() {
path, err := c.updateCheckTouchPath()
if err != nil {
c.log.Errorf("Error getting check path: %s", err)
return
}
terr := util.Touch(path)
if terr != nil {
c.log.Errorf("Error setting last update time: %s", terr)
return
}
c.log.Debugf("Set last update time")
} | go | func (c config) SetLastUpdateCheckTime() {
path, err := c.updateCheckTouchPath()
if err != nil {
c.log.Errorf("Error getting check path: %s", err)
return
}
terr := util.Touch(path)
if terr != nil {
c.log.Errorf("Error setting last update time: %s", terr)
return
}
c.log.Debugf("Set last update time")
} | [
"func",
"(",
"c",
"config",
")",
"SetLastUpdateCheckTime",
"(",
")",
"{",
"path",
",",
"err",
":=",
"c",
".",
"updateCheckTouchPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
... | // SetLastUpdateCheckTime touches file to set last update time. | [
"SetLastUpdateCheckTime",
"touches",
"file",
"to",
"set",
"last",
"update",
"time",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/config.go#L147-L159 |
145,678 | keybase/go-updater | keybase/config.go | GetUpdateAuto | func (c config) GetUpdateAuto() (bool, bool) {
return c.store.Auto, c.store.AutoSet
} | go | func (c config) GetUpdateAuto() (bool, bool) {
return c.store.Auto, c.store.AutoSet
} | [
"func",
"(",
"c",
"config",
")",
"GetUpdateAuto",
"(",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"return",
"c",
".",
"store",
".",
"Auto",
",",
"c",
".",
"store",
".",
"AutoSet",
"\n",
"}"
] | // GetUpdateAuto is the whether to update automatically and whether the user has
// set this value. Both should be true for an update to be automatically
// applied. | [
"GetUpdateAuto",
"is",
"the",
"whether",
"to",
"update",
"automatically",
"and",
"whether",
"the",
"user",
"has",
"set",
"this",
"value",
".",
"Both",
"should",
"be",
"true",
"for",
"an",
"update",
"to",
"be",
"automatically",
"applied",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/keybase/config.go#L185-L187 |
145,679 | keybase/go-updater | service/pid.go | NewLockPIDFile | func NewLockPIDFile(name string, log Log) *LockPIDFile {
return &LockPIDFile{name: name, log: log}
} | go | func NewLockPIDFile(name string, log Log) *LockPIDFile {
return &LockPIDFile{name: name, log: log}
} | [
"func",
"NewLockPIDFile",
"(",
"name",
"string",
",",
"log",
"Log",
")",
"*",
"LockPIDFile",
"{",
"return",
"&",
"LockPIDFile",
"{",
"name",
":",
"name",
",",
"log",
":",
"log",
"}",
"\n",
"}"
] | // NewLockPIDFile creates a LockPIDFile for filename name. | [
"NewLockPIDFile",
"creates",
"a",
"LockPIDFile",
"for",
"filename",
"name",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/service/pid.go#L20-L22 |
145,680 | keybase/go-updater | service/pid.go | Close | func (f *LockPIDFile) Close() (err error) {
if f.file != nil {
if e1 := f.file.Close(); e1 != nil {
f.log.Warningf("Error closing pid file: %s\n", e1)
}
f.log.Debugf("Cleaning up pidfile %s", f.name)
if err = os.Remove(f.name); err != nil {
f.log.Warningf("Error removing pidfile: %s\n", err)
}
}
retu... | go | func (f *LockPIDFile) Close() (err error) {
if f.file != nil {
if e1 := f.file.Close(); e1 != nil {
f.log.Warningf("Error closing pid file: %s\n", e1)
}
f.log.Debugf("Cleaning up pidfile %s", f.name)
if err = os.Remove(f.name); err != nil {
f.log.Warningf("Error removing pidfile: %s\n", err)
}
}
retu... | [
"func",
"(",
"f",
"*",
"LockPIDFile",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"f",
".",
"file",
"!=",
"nil",
"{",
"if",
"e1",
":=",
"f",
".",
"file",
".",
"Close",
"(",
")",
";",
"e1",
"!=",
"nil",
"{",
"f",
".",
"log",... | // Close releases the lock by closing and removing the file. | [
"Close",
"releases",
"the",
"lock",
"by",
"closing",
"and",
"removing",
"the",
"file",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/service/pid.go#L60-L71 |
145,681 | keybase/go-updater | util/unzip.go | UnzipPath | func UnzipPath(sourcePath string, log Log) (string, error) {
unzipPath := fmt.Sprintf("%s.unzipped", sourcePath)
err := unzipOver(sourcePath, unzipPath, log)
if err != nil {
return "", err
}
return unzipPath, nil
} | go | func UnzipPath(sourcePath string, log Log) (string, error) {
unzipPath := fmt.Sprintf("%s.unzipped", sourcePath)
err := unzipOver(sourcePath, unzipPath, log)
if err != nil {
return "", err
}
return unzipPath, nil
} | [
"func",
"UnzipPath",
"(",
"sourcePath",
"string",
",",
"log",
"Log",
")",
"(",
"string",
",",
"error",
")",
"{",
"unzipPath",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sourcePath",
")",
"\n",
"err",
":=",
"unzipOver",
"(",
"sourcePath",
",",
... | // UnzipPath unzips and returns path to unzipped directory | [
"UnzipPath",
"unzips",
"and",
"returns",
"path",
"to",
"unzipped",
"directory"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/util/unzip.go#L46-L53 |
145,682 | keybase/go-updater | process/matcher.go | NewMatcher | func NewMatcher(match string, matchType MatchType, log Log) Matcher {
return Matcher{match: match, matchType: matchType, log: log}
} | go | func NewMatcher(match string, matchType MatchType, log Log) Matcher {
return Matcher{match: match, matchType: matchType, log: log}
} | [
"func",
"NewMatcher",
"(",
"match",
"string",
",",
"matchType",
"MatchType",
",",
"log",
"Log",
")",
"Matcher",
"{",
"return",
"Matcher",
"{",
"match",
":",
"match",
",",
"matchType",
":",
"matchType",
",",
"log",
":",
"log",
"}",
"\n",
"}"
] | // NewMatcher returns a new matcher | [
"NewMatcher",
"returns",
"a",
"new",
"matcher"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/matcher.go#L38-L40 |
145,683 | keybase/go-updater | process/matcher.go | Fn | func (m Matcher) Fn() MatchFn {
switch m.matchType {
case PathEqual:
return m.matchPathFn(func(s, t string) bool { return s == t })
case PathContains:
return m.matchPathFn(strings.Contains)
case PathPrefix:
return m.matchPathFn(strings.HasPrefix)
case ExecutableEqual:
return m.matchExecutableFn(func(s, t s... | go | func (m Matcher) Fn() MatchFn {
switch m.matchType {
case PathEqual:
return m.matchPathFn(func(s, t string) bool { return s == t })
case PathContains:
return m.matchPathFn(strings.Contains)
case PathPrefix:
return m.matchPathFn(strings.HasPrefix)
case ExecutableEqual:
return m.matchExecutableFn(func(s, t s... | [
"func",
"(",
"m",
"Matcher",
")",
"Fn",
"(",
")",
"MatchFn",
"{",
"switch",
"m",
".",
"matchType",
"{",
"case",
"PathEqual",
":",
"return",
"m",
".",
"matchPathFn",
"(",
"func",
"(",
"s",
",",
"t",
"string",
")",
"bool",
"{",
"return",
"s",
"==",
... | // Fn is the matching function | [
"Fn",
"is",
"the",
"matching",
"function"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/process/matcher.go#L71-L84 |
145,684 | keybase/go-updater | watchdog/watchdog.go | Watch | func Watch(programs []Program, restartDelay time.Duration, log Log) error {
// Terminate any existing programs that we are supposed to monitor
terminateExisting(programs, log)
// Start monitoring all the programs
watchPrograms(programs, restartDelay, log)
return nil
} | go | func Watch(programs []Program, restartDelay time.Duration, log Log) error {
// Terminate any existing programs that we are supposed to monitor
terminateExisting(programs, log)
// Start monitoring all the programs
watchPrograms(programs, restartDelay, log)
return nil
} | [
"func",
"Watch",
"(",
"programs",
"[",
"]",
"Program",
",",
"restartDelay",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"error",
"{",
"// Terminate any existing programs that we are supposed to monitor",
"terminateExisting",
"(",
"programs",
",",
"log",
")",
"\... | // Watch monitors programs and restarts them if they aren't running | [
"Watch",
"monitors",
"programs",
"and",
"restarts",
"them",
"if",
"they",
"aren",
"t",
"running"
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/watchdog/watchdog.go#L43-L50 |
145,685 | keybase/go-updater | watchdog/watchdog.go | watchProgram | func watchProgram(program Program, restartDelay time.Duration, log Log) {
for {
start := time.Now()
log.Infof("Starting %#v", program)
cmd := exec.Command(program.Path, program.Args...)
err := cmd.Run()
if err != nil {
log.Errorf("Error running program: %q; %s", program, err)
} else {
log.Infof("Prog... | go | func watchProgram(program Program, restartDelay time.Duration, log Log) {
for {
start := time.Now()
log.Infof("Starting %#v", program)
cmd := exec.Command(program.Path, program.Args...)
err := cmd.Run()
if err != nil {
log.Errorf("Error running program: %q; %s", program, err)
} else {
log.Infof("Prog... | [
"func",
"watchProgram",
"(",
"program",
"Program",
",",
"restartDelay",
"time",
".",
"Duration",
",",
"log",
"Log",
")",
"{",
"for",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"program",
")",
... | // watchProgram will monitor a program and restart it if it exits.
// This method will run forever. | [
"watchProgram",
"will",
"monitor",
"a",
"program",
"and",
"restart",
"it",
"if",
"it",
"exits",
".",
"This",
"method",
"will",
"run",
"forever",
"."
] | 56ad0c90cf4c65f9f0ab421f09cef15e3b224512 | https://github.com/keybase/go-updater/blob/56ad0c90cf4c65f9f0ab421f09cef15e3b224512/watchdog/watchdog.go#L72-L97 |
145,686 | celrenheit/lion | lion.go | ServeNext | func (m MiddlewareFunc) ServeNext(next http.Handler) http.Handler {
return m(next)
} | go | func (m MiddlewareFunc) ServeNext(next http.Handler) http.Handler {
return m(next)
} | [
"func",
"(",
"m",
"MiddlewareFunc",
")",
"ServeNext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"m",
"(",
"next",
")",
"\n",
"}"
] | // ServeNext makes MiddlewareFunc implement Middleware | [
"ServeNext",
"makes",
"MiddlewareFunc",
"implement",
"Middleware"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/lion.go#L56-L58 |
145,687 | celrenheit/lion | lion.go | BuildHandler | func (middlewares Middlewares) BuildHandler(handler http.Handler) http.Handler {
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i].ServeNext(handler)
}
return handler
} | go | func (middlewares Middlewares) BuildHandler(handler http.Handler) http.Handler {
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i].ServeNext(handler)
}
return handler
} | [
"func",
"(",
"middlewares",
"Middlewares",
")",
"BuildHandler",
"(",
"handler",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"for",
"i",
":=",
"len",
"(",
"middlewares",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"handler",... | // BuildHandler builds a chain of middlewares from a passed Handler and returns a Handler | [
"BuildHandler",
"builds",
"a",
"chain",
"of",
"middlewares",
"from",
"a",
"passed",
"Handler",
"and",
"returns",
"a",
"Handler"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/lion.go#L64-L69 |
145,688 | celrenheit/lion | lion.go | ServeNext | func (middlewares Middlewares) ServeNext(next http.Handler) http.Handler {
return middlewares.BuildHandler(next)
} | go | func (middlewares Middlewares) ServeNext(next http.Handler) http.Handler {
return middlewares.BuildHandler(next)
} | [
"func",
"(",
"middlewares",
"Middlewares",
")",
"ServeNext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"middlewares",
".",
"BuildHandler",
"(",
"next",
")",
"\n",
"}"
] | // ServeNext allows Middlewares to implement the Middleware interface.
// This is useful to allow Grouping middlewares together and being able to use them as a single Middleware. | [
"ServeNext",
"allows",
"Middlewares",
"to",
"implement",
"the",
"Middleware",
"interface",
".",
"This",
"is",
"useful",
"to",
"allow",
"Grouping",
"middlewares",
"together",
"and",
"being",
"able",
"to",
"use",
"them",
"as",
"a",
"single",
"Middleware",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/lion.go#L73-L75 |
145,689 | celrenheit/lion | middleware/max_age.go | ServeNext | func (m *MaxAge) ServeNext(next http.Handler) http.Handler {
if m.Filter == nil {
// Filter nothing
m.Filter = func(r *http.Request) bool { return false }
}
fn := func(w http.ResponseWriter, r *http.Request) {
if m.Filter(r) {
w.Header().Add("Cache-Control", fmt.Sprintf("max-age=%d, public, must-revalidate... | go | func (m *MaxAge) ServeNext(next http.Handler) http.Handler {
if m.Filter == nil {
// Filter nothing
m.Filter = func(r *http.Request) bool { return false }
}
fn := func(w http.ResponseWriter, r *http.Request) {
if m.Filter(r) {
w.Header().Add("Cache-Control", fmt.Sprintf("max-age=%d, public, must-revalidate... | [
"func",
"(",
"m",
"*",
"MaxAge",
")",
"ServeNext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"if",
"m",
".",
"Filter",
"==",
"nil",
"{",
"// Filter nothing",
"m",
".",
"Filter",
"=",
"func",
"(",
"r",
"*",
"http",
".",
... | // MaxAge is a middleware that defines the max duration headers | [
"MaxAge",
"is",
"a",
"middleware",
"that",
"defines",
"the",
"max",
"duration",
"headers"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/middleware/max_age.go#L15-L29 |
145,690 | celrenheit/lion | middleware/recovery.go | NewRecovery | func NewRecovery() lion.Middleware {
return &Recovery{
Logger: lionLogger,
PrintStack: false,
StackAll: false,
StackSize: 1024 * 8,
}
} | go | func NewRecovery() lion.Middleware {
return &Recovery{
Logger: lionLogger,
PrintStack: false,
StackAll: false,
StackSize: 1024 * 8,
}
} | [
"func",
"NewRecovery",
"(",
")",
"lion",
".",
"Middleware",
"{",
"return",
"&",
"Recovery",
"{",
"Logger",
":",
"lionLogger",
",",
"PrintStack",
":",
"false",
",",
"StackAll",
":",
"false",
",",
"StackSize",
":",
"1024",
"*",
"8",
",",
"}",
"\n",
"}"
] | // NewRecovery creates a new Recovery instance | [
"NewRecovery",
"creates",
"a",
"new",
"Recovery",
"instance"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/middleware/recovery.go#L22-L29 |
145,691 | celrenheit/lion | middleware/recovery.go | ServeNext | func (rec *Recovery) ServeNext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
if w.Header().Get("Content-type") == "" {
w.Header().Set("Content-type", "text/plain; charset=utf-8")
}
w.WriteH... | go | func (rec *Recovery) ServeNext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
if w.Header().Get("Content-type") == "" {
w.Header().Set("Content-type", "text/plain; charset=utf-8")
}
w.WriteH... | [
"func",
"(",
"rec",
"*",
"Recovery",
")",
"ServeNext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Req... | // ServeNext is the method responsible for recovering from a panic | [
"ServeNext",
"is",
"the",
"method",
"responsible",
"for",
"recovering",
"from",
"a",
"panic"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/middleware/recovery.go#L32-L55 |
145,692 | celrenheit/lion | resource.go | Resource | func (r *Router) Resource(pattern string, resource Resource) {
sub := r.Group(pattern)
if usesRes, ok := resource.(resourceUses); ok {
if len(usesRes.Uses()) > 0 {
sub.Use(usesRes.Uses()...)
}
}
for _, m := range allowedHTTPMethods {
if hfn, ok := isHandlerFuncInResource(m, resource); ok {
s := sub.Su... | go | func (r *Router) Resource(pattern string, resource Resource) {
sub := r.Group(pattern)
if usesRes, ok := resource.(resourceUses); ok {
if len(usesRes.Uses()) > 0 {
sub.Use(usesRes.Uses()...)
}
}
for _, m := range allowedHTTPMethods {
if hfn, ok := isHandlerFuncInResource(m, resource); ok {
s := sub.Su... | [
"func",
"(",
"r",
"*",
"Router",
")",
"Resource",
"(",
"pattern",
"string",
",",
"resource",
"Resource",
")",
"{",
"sub",
":=",
"r",
".",
"Group",
"(",
"pattern",
")",
"\n\n",
"if",
"usesRes",
",",
"ok",
":=",
"resource",
".",
"(",
"resourceUses",
")... | // Resource registers a Resource with the corresponding pattern | [
"Resource",
"registers",
"a",
"Resource",
"with",
"the",
"corresponding",
"pattern"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/resource.go#L18-L36 |
145,693 | celrenheit/lion | module.go | Module | func (r *Router) Module(modules ...Module) {
for _, m := range modules {
r.registerModule(m)
}
} | go | func (r *Router) Module(modules ...Module) {
for _, m := range modules {
r.registerModule(m)
}
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Module",
"(",
"modules",
"...",
"Module",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"modules",
"{",
"r",
".",
"registerModule",
"(",
"m",
")",
"\n",
"}",
"\n",
"}"
] | // Module register modules for the current router instance. | [
"Module",
"register",
"modules",
"for",
"the",
"current",
"router",
"instance",
"."
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/module.go#L17-L21 |
145,694 | go-macaron/cache | cache.go | NewCacher | func NewCacher(name string, opt Options) (Cache, error) {
adapter, ok := adapters[name]
if !ok {
return nil, fmt.Errorf("cache: unknown adapter '%s'(forgot to import?)", name)
}
return adapter, adapter.StartAndGC(opt)
} | go | func NewCacher(name string, opt Options) (Cache, error) {
adapter, ok := adapters[name]
if !ok {
return nil, fmt.Errorf("cache: unknown adapter '%s'(forgot to import?)", name)
}
return adapter, adapter.StartAndGC(opt)
} | [
"func",
"NewCacher",
"(",
"name",
"string",
",",
"opt",
"Options",
")",
"(",
"Cache",
",",
"error",
")",
"{",
"adapter",
",",
"ok",
":=",
"adapters",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"... | // NewCacher creates and returns a new cacher by given adapter name and configuration.
// It panics when given adapter isn't registered and starts GC automatically. | [
"NewCacher",
"creates",
"and",
"returns",
"a",
"new",
"cacher",
"by",
"given",
"adapter",
"name",
"and",
"configuration",
".",
"It",
"panics",
"when",
"given",
"adapter",
"isn",
"t",
"registered",
"and",
"starts",
"GC",
"automatically",
"."
] | 56173531277692bc2925924d51fda1cd0a6b8178 | https://github.com/go-macaron/cache/blob/56173531277692bc2925924d51fda1cd0a6b8178/cache.go#L90-L96 |
145,695 | go-macaron/cache | cache.go | Cacher | func Cacher(options ...Options) macaron.Handler {
opt := prepareOptions(options)
cache, err := NewCacher(opt.Adapter, opt)
if err != nil {
panic(err)
}
return func(ctx *macaron.Context) {
ctx.Map(cache)
}
} | go | func Cacher(options ...Options) macaron.Handler {
opt := prepareOptions(options)
cache, err := NewCacher(opt.Adapter, opt)
if err != nil {
panic(err)
}
return func(ctx *macaron.Context) {
ctx.Map(cache)
}
} | [
"func",
"Cacher",
"(",
"options",
"...",
"Options",
")",
"macaron",
".",
"Handler",
"{",
"opt",
":=",
"prepareOptions",
"(",
"options",
")",
"\n",
"cache",
",",
"err",
":=",
"NewCacher",
"(",
"opt",
".",
"Adapter",
",",
"opt",
")",
"\n",
"if",
"err",
... | // Cacher is a middleware that maps a cache.Cache service into the Macaron handler chain.
// An single variadic cache.Options struct can be optionally provided to configure. | [
"Cacher",
"is",
"a",
"middleware",
"that",
"maps",
"a",
"cache",
".",
"Cache",
"service",
"into",
"the",
"Macaron",
"handler",
"chain",
".",
"An",
"single",
"variadic",
"cache",
".",
"Options",
"struct",
"can",
"be",
"optionally",
"provided",
"to",
"configur... | 56173531277692bc2925924d51fda1cd0a6b8178 | https://github.com/go-macaron/cache/blob/56173531277692bc2925924d51fda1cd0a6b8178/cache.go#L100-L109 |
145,696 | go-macaron/cache | cache.go | Register | func Register(name string, adapter Cache) {
if adapter == nil {
panic("cache: cannot register adapter with nil value")
}
if _, dup := adapters[name]; dup {
panic(fmt.Errorf("cache: cannot register adapter '%s' twice", name))
}
adapters[name] = adapter
} | go | func Register(name string, adapter Cache) {
if adapter == nil {
panic("cache: cannot register adapter with nil value")
}
if _, dup := adapters[name]; dup {
panic(fmt.Errorf("cache: cannot register adapter '%s' twice", name))
}
adapters[name] = adapter
} | [
"func",
"Register",
"(",
"name",
"string",
",",
"adapter",
"Cache",
")",
"{",
"if",
"adapter",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"dup",
":=",
"adapters",
"[",
"name",
"]",
";",
"dup",
"{",
"panic",
... | // Register registers a adapter. | [
"Register",
"registers",
"a",
"adapter",
"."
] | 56173531277692bc2925924d51fda1cd0a6b8178 | https://github.com/go-macaron/cache/blob/56173531277692bc2925924d51fda1cd0a6b8178/cache.go#L114-L122 |
145,697 | celrenheit/lion | internal/matcher/tree.go | split | func (tree *tree) split(pattern string) (out []*node) {
base := pattern
for {
if pattern == "" {
break
}
c := pattern[0]
var endinglabel byte
end := strings.IndexAny(pattern, tree.Separators())
if end < 0 {
end = len(pattern)
endinglabel = pattern[end-1]
} else {
endinglabel = pattern[end]... | go | func (tree *tree) split(pattern string) (out []*node) {
base := pattern
for {
if pattern == "" {
break
}
c := pattern[0]
var endinglabel byte
end := strings.IndexAny(pattern, tree.Separators())
if end < 0 {
end = len(pattern)
endinglabel = pattern[end-1]
} else {
endinglabel = pattern[end]... | [
"func",
"(",
"tree",
"*",
"tree",
")",
"split",
"(",
"pattern",
"string",
")",
"(",
"out",
"[",
"]",
"*",
"node",
")",
"{",
"base",
":=",
"pattern",
"\n",
"for",
"{",
"if",
"pattern",
"==",
"\"",
"\"",
"{",
"break",
"\n",
"}",
"\n",
"c",
":=",
... | // split splits a pattern into multiple nodes types | [
"split",
"splits",
"a",
"pattern",
"into",
"multiple",
"nodes",
"types"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/internal/matcher/tree.go#L379-L477 |
145,698 | celrenheit/lion | middleware/logger.go | ServeNext | func (l *Logger) ServeNext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
res := wrapResponseWriter(w)
start := time.Now()
next.ServeHTTP(res, r)
l.Printf("%s %s | %s | %dB in %v from %s", magenta(r.Method), hiBlue(r.URL.Path), statusColor(res.Statu... | go | func (l *Logger) ServeNext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
res := wrapResponseWriter(w)
start := time.Now()
next.ServeHTTP(res, r)
l.Printf("%s %s | %s | %dB in %v from %s", magenta(r.Method), hiBlue(r.URL.Path), statusColor(res.Statu... | [
"func",
"(",
"l",
"*",
"Logger",
")",
"ServeNext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request... | // ServeNext implements the Middleware interface for Logger.
// It wraps the corresponding http.ResponseWriter and saves statistics about the status code returned, the number of bytes written and the time that requests took. | [
"ServeNext",
"implements",
"the",
"Middleware",
"interface",
"for",
"Logger",
".",
"It",
"wraps",
"the",
"corresponding",
"http",
".",
"ResponseWriter",
"and",
"saves",
"statistics",
"about",
"the",
"status",
"code",
"returned",
"the",
"number",
"of",
"bytes",
"... | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/middleware/logger.go#L35-L46 |
145,699 | celrenheit/lion | router.go | New | func New(mws ...Middleware) *Router {
r := &Router{
parent: nil,
hostrm: newHostMatcher(),
middlewares: Middlewares{},
namedMiddlewares: make(map[string]Middlewares),
pool: newCtxPool(),
}
r.Use(mws...)
r.Configure(
WithLogger(lionLogger),
WithServer(&http.Server{
... | go | func New(mws ...Middleware) *Router {
r := &Router{
parent: nil,
hostrm: newHostMatcher(),
middlewares: Middlewares{},
namedMiddlewares: make(map[string]Middlewares),
pool: newCtxPool(),
}
r.Use(mws...)
r.Configure(
WithLogger(lionLogger),
WithServer(&http.Server{
... | [
"func",
"New",
"(",
"mws",
"...",
"Middleware",
")",
"*",
"Router",
"{",
"r",
":=",
"&",
"Router",
"{",
"parent",
":",
"nil",
",",
"hostrm",
":",
"newHostMatcher",
"(",
")",
",",
"middlewares",
":",
"Middlewares",
"{",
"}",
",",
"namedMiddlewares",
":"... | // New creates a new router instance | [
"New",
"creates",
"a",
"new",
"router",
"instance"
] | 4f024ad392e35a4a4a6d3ea63cfe261c9a2344da | https://github.com/celrenheit/lion/blob/4f024ad392e35a4a4a6d3ea63cfe261c9a2344da/router.go#L50-L67 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.