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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithNoColor | func WithNoColor(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyNoColor, bv)
} | go | func WithNoColor(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyNoColor, bv)
} | [
"func",
"WithNoColor",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyNoColor",
",",
"bv",
")",
"\n",
"}"
] | // WithNoColor returns a context with the value for ask for more set | [
"WithNoColor",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"ask",
"for",
"more",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L281-L283 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasNoColor | func HasNoColor(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNoColor).(bool)
return ok
} | go | func HasNoColor(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNoColor).(bool)
return ok
} | [
"func",
"HasNoColor",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyNoColor",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasNoColor returns true if a value for NoColor has been set in this context | [
"HasNoColor",
"returns",
"true",
"if",
"a",
"value",
"for",
"NoColor",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L286-L289 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithAlwaysYes | func WithAlwaysYes(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAlwaysYes, bv)
} | go | func WithAlwaysYes(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAlwaysYes, bv)
} | [
"func",
"WithAlwaysYes",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAlwaysYes",
",",
"bv",
")",
"\n",
"}"
] | // WithAlwaysYes returns a context with the value of always yes set | [
"WithAlwaysYes",
"returns",
"a",
"context",
"with",
"the",
"value",
"of",
"always",
"yes",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L301-L303 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasAlwaysYes | func HasAlwaysYes(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAlwaysYes).(bool)
return ok
} | go | func HasAlwaysYes(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAlwaysYes).(bool)
return ok
} | [
"func",
"HasAlwaysYes",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAlwaysYes",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasAlwaysYes returns true if a value for AlwaysYes has been set in this context | [
"HasAlwaysYes",
"returns",
"true",
"if",
"a",
"value",
"for",
"AlwaysYes",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L306-L309 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithFuzzySearch | func WithFuzzySearch(ctx context.Context, fuzzy bool) context.Context {
return context.WithValue(ctx, ctxKeyFuzzySearch, fuzzy)
} | go | func WithFuzzySearch(ctx context.Context, fuzzy bool) context.Context {
return context.WithValue(ctx, ctxKeyFuzzySearch, fuzzy)
} | [
"func",
"WithFuzzySearch",
"(",
"ctx",
"context",
".",
"Context",
",",
"fuzzy",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyFuzzySearch",
",",
"fuzzy",
")",
"\n",
"}"
] | // WithFuzzySearch returns a context with the value for fuzzy search set | [
"WithFuzzySearch",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"fuzzy",
"search",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L321-L323 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasFuzzySearch | func HasFuzzySearch(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyFuzzySearch).(bool)
return ok
} | go | func HasFuzzySearch(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyFuzzySearch).(bool)
return ok
} | [
"func",
"HasFuzzySearch",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyFuzzySearch",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasFuzzySearch returns true if a value for FuzzySearch has been set in this context | [
"HasFuzzySearch",
"returns",
"true",
"if",
"a",
"value",
"for",
"FuzzySearch",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L326-L329 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithVerbose | func WithVerbose(ctx context.Context, verbose bool) context.Context {
return context.WithValue(ctx, ctxKeyVerbose, verbose)
} | go | func WithVerbose(ctx context.Context, verbose bool) context.Context {
return context.WithValue(ctx, ctxKeyVerbose, verbose)
} | [
"func",
"WithVerbose",
"(",
"ctx",
"context",
".",
"Context",
",",
"verbose",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyVerbose",
",",
"verbose",
")",
"\n",
"}"
] | // WithVerbose returns a context with the value for verbose set | [
"WithVerbose",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"verbose",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L341-L343 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasVerbose | func HasVerbose(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyVerbose).(bool)
return ok
} | go | func HasVerbose(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyVerbose).(bool)
return ok
} | [
"func",
"HasVerbose",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyVerbose",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasVerbose returns true if a value for Verbose has been set in this context | [
"HasVerbose",
"returns",
"true",
"if",
"a",
"value",
"for",
"Verbose",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L346-L349 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithNotifications | func WithNotifications(ctx context.Context, verbose bool) context.Context {
return context.WithValue(ctx, ctxKeyNotifications, verbose)
} | go | func WithNotifications(ctx context.Context, verbose bool) context.Context {
return context.WithValue(ctx, ctxKeyNotifications, verbose)
} | [
"func",
"WithNotifications",
"(",
"ctx",
"context",
".",
"Context",
",",
"verbose",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyNotifications",
",",
"verbose",
")",
"\n",
"}"
] | // WithNotifications returns a context with the value for Notifications set | [
"WithNotifications",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"Notifications",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L361-L363 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasNotifications | func HasNotifications(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNotifications).(bool)
return ok
} | go | func HasNotifications(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNotifications).(bool)
return ok
} | [
"func",
"HasNotifications",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyNotifications",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasNotifications returns true if a value for Notifications has been set in this context | [
"HasNotifications",
"returns",
"true",
"if",
"a",
"value",
"for",
"Notifications",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L366-L369 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithAutoClip | func WithAutoClip(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAutoClip, bv)
} | go | func WithAutoClip(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAutoClip, bv)
} | [
"func",
"WithAutoClip",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAutoClip",
",",
"bv",
")",
"\n",
"}"
] | // WithAutoClip returns a context with the value for AutoClip set | [
"WithAutoClip",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"AutoClip",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L381-L383 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasAutoClip | func HasAutoClip(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAutoClip).(bool)
return ok
} | go | func HasAutoClip(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAutoClip).(bool)
return ok
} | [
"func",
"HasAutoClip",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAutoClip",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasAutoClip returns true if a value for AutoClip has been set in this context | [
"HasAutoClip",
"returns",
"true",
"if",
"a",
"value",
"for",
"AutoClip",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L386-L389 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithEditRecipients | func WithEditRecipients(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyEditRecipients, bv)
} | go | func WithEditRecipients(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyEditRecipients, bv)
} | [
"func",
"WithEditRecipients",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyEditRecipients",
",",
"bv",
")",
"\n",
"}"
] | // WithEditRecipients returns a context with the value for EditRecipients set | [
"WithEditRecipients",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"EditRecipients",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L401-L403 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasEditRecipients | func HasEditRecipients(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyEditRecipients).(bool)
return ok
} | go | func HasEditRecipients(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyEditRecipients).(bool)
return ok
} | [
"func",
"HasEditRecipients",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyEditRecipients",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasEditRecipients returns true if a value for EditRecipients has been set in this context | [
"HasEditRecipients",
"returns",
"true",
"if",
"a",
"value",
"for",
"EditRecipients",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L406-L409 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithConcurrency | func WithConcurrency(ctx context.Context, to int) context.Context {
return context.WithValue(ctx, ctxKeyConcurrency, to)
} | go | func WithConcurrency(ctx context.Context, to int) context.Context {
return context.WithValue(ctx, ctxKeyConcurrency, to)
} | [
"func",
"WithConcurrency",
"(",
"ctx",
"context",
".",
"Context",
",",
"to",
"int",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyConcurrency",
",",
"to",
")",
"\n",
"}"
] | // WithConcurrency returns a context with the value for clip timeout set | [
"WithConcurrency",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"clip",
"timeout",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L421-L423 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasConcurrency | func HasConcurrency(ctx context.Context) bool {
iv, ok := ctx.Value(ctxKeyConcurrency).(int)
if iv <= 1 {
return false
}
return ok
} | go | func HasConcurrency(ctx context.Context) bool {
iv, ok := ctx.Value(ctxKeyConcurrency).(int)
if iv <= 1 {
return false
}
return ok
} | [
"func",
"HasConcurrency",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"iv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyConcurrency",
")",
".",
"(",
"int",
")",
"\n",
"if",
"iv",
"<=",
"1",
"{",
"return",
"false",
"\n",
"}",
"\n"... | // HasConcurrency returns true if a value for Concurrency has been set in this context and is bigger than 1
// since if it is equal to 1, we are not working concurrently. | [
"HasConcurrency",
"returns",
"true",
"if",
"a",
"value",
"for",
"Concurrency",
"has",
"been",
"set",
"in",
"this",
"context",
"and",
"is",
"bigger",
"than",
"1",
"since",
"if",
"it",
"is",
"equal",
"to",
"1",
"we",
"are",
"not",
"working",
"concurrently",
... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L427-L433 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithProgressCallback | func WithProgressCallback(ctx context.Context, cb ProgressCallback) context.Context {
return context.WithValue(ctx, ctxKeyProgressCallback, cb)
} | go | func WithProgressCallback(ctx context.Context, cb ProgressCallback) context.Context {
return context.WithValue(ctx, ctxKeyProgressCallback, cb)
} | [
"func",
"WithProgressCallback",
"(",
"ctx",
"context",
".",
"Context",
",",
"cb",
"ProgressCallback",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyProgressCallback",
",",
"cb",
")",
"\n",
"}"
] | // WithProgressCallback returns a context with the value of ProgressCallback set | [
"WithProgressCallback",
"returns",
"a",
"context",
"with",
"the",
"value",
"of",
"ProgressCallback",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L445-L447 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasProgressCallback | func HasProgressCallback(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyProgressCallback).(ProgressCallback)
return ok
} | go | func HasProgressCallback(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyProgressCallback).(ProgressCallback)
return ok
} | [
"func",
"HasProgressCallback",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyProgressCallback",
")",
".",
"(",
"ProgressCallback",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasProgressCallback returns true if a ProgressCallback has been set | [
"HasProgressCallback",
"returns",
"true",
"if",
"a",
"ProgressCallback",
"has",
"been",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L450-L453 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | GetProgressCallback | func GetProgressCallback(ctx context.Context) ProgressCallback {
cb, ok := ctx.Value(ctxKeyProgressCallback).(ProgressCallback)
if !ok || cb == nil {
return func() {}
}
return cb
} | go | func GetProgressCallback(ctx context.Context) ProgressCallback {
cb, ok := ctx.Value(ctxKeyProgressCallback).(ProgressCallback)
if !ok || cb == nil {
return func() {}
}
return cb
} | [
"func",
"GetProgressCallback",
"(",
"ctx",
"context",
".",
"Context",
")",
"ProgressCallback",
"{",
"cb",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyProgressCallback",
")",
".",
"(",
"ProgressCallback",
")",
"\n",
"if",
"!",
"ok",
"||",
"cb",
"==",
... | // GetProgressCallback return the set progress callback or a default one.
// It never returns nil | [
"GetProgressCallback",
"return",
"the",
"set",
"progress",
"callback",
"or",
"a",
"default",
"one",
".",
"It",
"never",
"returns",
"nil"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L457-L463 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithConfigDir | func WithConfigDir(ctx context.Context, cfgdir string) context.Context {
return context.WithValue(ctx, ctxKeyConfigDir, cfgdir)
} | go | func WithConfigDir(ctx context.Context, cfgdir string) context.Context {
return context.WithValue(ctx, ctxKeyConfigDir, cfgdir)
} | [
"func",
"WithConfigDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfgdir",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyConfigDir",
",",
"cfgdir",
")",
"\n",
"}"
] | // WithConfigDir returns a context with the config dir set. | [
"WithConfigDir",
"returns",
"a",
"context",
"with",
"the",
"config",
"dir",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L466-L468 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasConfigDir | func HasConfigDir(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyConfigDir).(string)
return ok
} | go | func HasConfigDir(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyConfigDir).(string)
return ok
} | [
"func",
"HasConfigDir",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyConfigDir",
")",
".",
"(",
"string",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasConfigDir returns true if a config dir has been set. | [
"HasConfigDir",
"returns",
"true",
"if",
"a",
"config",
"dir",
"has",
"been",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L471-L474 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | GetConfigDir | func GetConfigDir(ctx context.Context) string {
cd, ok := ctx.Value(ctxKeyConfigDir).(string)
if !ok {
return ""
}
return cd
} | go | func GetConfigDir(ctx context.Context) string {
cd, ok := ctx.Value(ctxKeyConfigDir).(string)
if !ok {
return ""
}
return cd
} | [
"func",
"GetConfigDir",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"cd",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyConfigDir",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
... | // GetConfigDir returns the config dir if set or an empty string. | [
"GetConfigDir",
"returns",
"the",
"config",
"dir",
"if",
"set",
"or",
"an",
"empty",
"string",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L477-L483 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithAlias | func WithAlias(ctx context.Context, alias string) context.Context {
return context.WithValue(ctx, ctxKeyAlias, alias)
} | go | func WithAlias(ctx context.Context, alias string) context.Context {
return context.WithValue(ctx, ctxKeyAlias, alias)
} | [
"func",
"WithAlias",
"(",
"ctx",
"context",
".",
"Context",
",",
"alias",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAlias",
",",
"alias",
")",
"\n",
"}"
] | // WithAlias returns an context with the alias set. | [
"WithAlias",
"returns",
"an",
"context",
"with",
"the",
"alias",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L486-L488 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasAlias | func HasAlias(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAlias).(string)
return ok
} | go | func HasAlias(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAlias).(string)
return ok
} | [
"func",
"HasAlias",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAlias",
")",
".",
"(",
"string",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasAlias returns true if a value for alias has been set. | [
"HasAlias",
"returns",
"true",
"if",
"a",
"value",
"for",
"alias",
"has",
"been",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L491-L494 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | GetAlias | func GetAlias(ctx context.Context) string {
a, ok := ctx.Value(ctxKeyAlias).(string)
if !ok {
return ""
}
return a
} | go | func GetAlias(ctx context.Context) string {
a, ok := ctx.Value(ctxKeyAlias).(string)
if !ok {
return ""
}
return a
} | [
"func",
"GetAlias",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"a",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAlias",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return... | // GetAlias returns an alias if it has been set or an empty string otherwise. | [
"GetAlias",
"returns",
"an",
"alias",
"if",
"it",
"has",
"been",
"set",
"or",
"an",
"empty",
"string",
"otherwise",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L497-L503 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithAutoPrint | func WithAutoPrint(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAutoPrint, bv)
} | go | func WithAutoPrint(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAutoPrint, bv)
} | [
"func",
"WithAutoPrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAutoPrint",
",",
"bv",
")",
"\n",
"}"
] | // WithAutoPrint returns a context with the value for auto print set. | [
"WithAutoPrint",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"auto",
"print",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L506-L508 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasAutoPrint | func HasAutoPrint(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAutoPrint).(bool)
return ok
} | go | func HasAutoPrint(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAutoPrint).(bool)
return ok
} | [
"func",
"HasAutoPrint",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAutoPrint",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasAutoPrint returns true if a specific value for auto print was set. | [
"HasAutoPrint",
"returns",
"true",
"if",
"a",
"specific",
"value",
"for",
"auto",
"print",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L511-L514 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | IsAutoPrint | func IsAutoPrint(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyAutoPrint).(bool)
if !ok {
return false
}
return bv
} | go | func IsAutoPrint(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyAutoPrint).(bool)
if !ok {
return false
}
return bv
} | [
"func",
"IsAutoPrint",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"bv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAutoPrint",
")",
".",
"(",
"bool",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return"... | // IsAutoPrint returns the value of auto print or false if none was set. | [
"IsAutoPrint",
"returns",
"the",
"value",
"of",
"auto",
"print",
"or",
"false",
"if",
"none",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L517-L523 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithGitInit | func WithGitInit(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyGitInit, bv)
} | go | func WithGitInit(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyGitInit, bv)
} | [
"func",
"WithGitInit",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyGitInit",
",",
"bv",
")",
"\n",
"}"
] | // WithGitInit returns a context with the value for the git init flag set. | [
"WithGitInit",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"the",
"git",
"init",
"flag",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L526-L528 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasGitInit | func HasGitInit(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyGitInit).(bool)
return ok
} | go | func HasGitInit(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyGitInit).(bool)
return ok
} | [
"func",
"HasGitInit",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyGitInit",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasGitInit returns true if the git init flag was set. | [
"HasGitInit",
"returns",
"true",
"if",
"the",
"git",
"init",
"flag",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L531-L534 | train |
gopasspw/gopass | pkg/ctxutil/ctxutil.go | IsGitInit | func IsGitInit(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyGitInit).(bool)
if !ok {
return true
}
return bv
} | go | func IsGitInit(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyGitInit).(bool)
if !ok {
return true
}
return bv
} | [
"func",
"IsGitInit",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"bv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyGitInit",
")",
".",
"(",
"bool",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"... | // IsGitInit returns the value of the git init flag or ture if none was set. | [
"IsGitInit",
"returns",
"the",
"value",
"of",
"the",
"git",
"init",
"flag",
"or",
"ture",
"if",
"none",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L537-L543 | train |
gopasspw/gopass | pkg/completion/zsh/completion.go | GetCompletion | func GetCompletion(a *cli.App) (string, error) {
tplFuncs := template.FuncMap{
"formatFlag": formatFlagFunc(),
}
tpl, err := template.New("zsh").Funcs(tplFuncs).Parse(zshTemplate)
if err != nil {
return "", err
}
buf := &bytes.Buffer{}
if err := tpl.Execute(buf, a); err != nil {
return "", err
}
return b... | go | func GetCompletion(a *cli.App) (string, error) {
tplFuncs := template.FuncMap{
"formatFlag": formatFlagFunc(),
}
tpl, err := template.New("zsh").Funcs(tplFuncs).Parse(zshTemplate)
if err != nil {
return "", err
}
buf := &bytes.Buffer{}
if err := tpl.Execute(buf, a); err != nil {
return "", err
}
return b... | [
"func",
"GetCompletion",
"(",
"a",
"*",
"cli",
".",
"App",
")",
"(",
"string",
",",
"error",
")",
"{",
"tplFuncs",
":=",
"template",
".",
"FuncMap",
"{",
"\"",
"\"",
":",
"formatFlagFunc",
"(",
")",
",",
"}",
"\n",
"tpl",
",",
"err",
":=",
"templat... | // GetCompletion returns a zsh completion script | [
"GetCompletion",
"returns",
"a",
"zsh",
"completion",
"script"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/completion/zsh/completion.go#L56-L69 | train |
gopasspw/gopass | pkg/action/binary/sum.go | Sum | func Sum(ctx context.Context, c *cli.Context, store storer) error {
name := c.Args().First()
if name == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "Usage: %s sha256 name", c.App.Name)
}
if !strings.HasSuffix(name, Suffix) {
name += Suffix
}
buf, err := binaryGet(ctx, name, store)
if err != ni... | go | func Sum(ctx context.Context, c *cli.Context, store storer) error {
name := c.Args().First()
if name == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "Usage: %s sha256 name", c.App.Name)
}
if !strings.HasSuffix(name, Suffix) {
name += Suffix
}
buf, err := binaryGet(ctx, name, store)
if err != ni... | [
"func",
"Sum",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"store",
"storer",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n",
"if",
"name",
"==",
"\"",
"\"",
"{",
... | // Sum decodes binary content and computes the SHA256 checksum | [
"Sum",
"decodes",
"binary",
"content",
"and",
"computes",
"the",
"SHA256",
"checksum"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/binary/sum.go#L15-L35 | train |
gopasspw/gopass | pkg/store/sub/read.go | Get | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.storage.Get(ctx, p)
if err != nil {
out.Debug(ctx, "File %s not found: %s", p, err)
return nil, store.ErrNotFound
}
content, err := s.crypto.Decrypt(ctx, ciphertext)
if err != nil {
out... | go | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.storage.Get(ctx, p)
if err != nil {
out.Debug(ctx, "File %s not found: %s", p, err)
return nil, store.ErrNotFound
}
content, err := s.crypto.Decrypt(ctx, ciphertext)
if err != nil {
out... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"store",
".",
"Secret",
",",
"error",
")",
"{",
"p",
":=",
"s",
".",
"passfile",
"(",
"name",
")",
"\n\n",
"ciphertext",
",",
"err... | // Get returns the plaintext of a single key | [
"Get",
"returns",
"the",
"plaintext",
"of",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/read.go#L12-L32 | train |
gopasspw/gopass | pkg/action/jsonapi.go | JSONAPI | func (s *Action) JSONAPI(ctx context.Context, c *cli.Context) error {
api := jsonapi.API{Store: s.Store, Reader: stdin, Writer: stdout, Version: s.version}
if err := api.ReadAndRespond(ctx); err != nil {
return api.RespondError(err)
}
return nil
} | go | func (s *Action) JSONAPI(ctx context.Context, c *cli.Context) error {
api := jsonapi.API{Store: s.Store, Reader: stdin, Writer: stdout, Version: s.version}
if err := api.ReadAndRespond(ctx); err != nil {
return api.RespondError(err)
}
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"JSONAPI",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"api",
":=",
"jsonapi",
".",
"API",
"{",
"Store",
":",
"s",
".",
"Store",
",",
"Reader",
":",
"stdin"... | // JSONAPI reads a json message on stdin and responds on stdout | [
"JSONAPI",
"reads",
"a",
"json",
"message",
"on",
"stdin",
"and",
"responds",
"on",
"stdout"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/jsonapi.go#L19-L25 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Get | func (m *InMem) Get(ctx context.Context, name string) ([]byte, error) {
m.Lock()
defer m.Unlock()
sec, found := m.data[name]
if !found {
return nil, fmt.Errorf("entry not found")
}
return sec, nil
} | go | func (m *InMem) Get(ctx context.Context, name string) ([]byte, error) {
m.Lock()
defer m.Unlock()
sec, found := m.data[name]
if !found {
return nil, fmt.Errorf("entry not found")
}
return sec, nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"se... | // Get retrieves a value | [
"Get",
"retrieves",
"a",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L27-L36 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Set | func (m *InMem) Set(ctx context.Context, name string, value []byte) error {
m.Lock()
defer m.Unlock()
m.data[name] = value
return nil
} | go | func (m *InMem) Set(ctx context.Context, name string, value []byte) error {
m.Lock()
defer m.Unlock()
m.data[name] = value
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"m",
... | // Set writes a value | [
"Set",
"writes",
"a",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L39-L45 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Delete | func (m *InMem) Delete(ctx context.Context, name string) error {
m.Lock()
defer m.Unlock()
delete(m.data, name)
return nil
} | go | func (m *InMem) Delete(ctx context.Context, name string) error {
m.Lock()
defer m.Unlock()
delete(m.data, name)
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"m",
".",
"data",
",... | // Delete removes a value | [
"Delete",
"removes",
"a",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L48-L54 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Exists | func (m *InMem) Exists(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
_, found := m.data[name]
return found
} | go | func (m *InMem) Exists(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
_, found := m.data[name]
return found
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"_",
",",
"found",
":=",
"m",
".",
... | // Exists checks is a value exists | [
"Exists",
"checks",
"is",
"a",
"value",
"exists"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L57-L63 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | List | func (m *InMem) List(ctx context.Context, prefix string) ([]string, error) {
m.Lock()
defer m.Unlock()
keys := make([]string, 0, len(m.data))
for k := range m.data {
keys = append(keys, k)
}
sort.Strings(keys)
return keys, nil
} | go | func (m *InMem) List(ctx context.Context, prefix string) ([]string, error) {
m.Lock()
defer m.Unlock()
keys := make([]string, 0, len(m.data))
for k := range m.data {
keys = append(keys, k)
}
sort.Strings(keys)
return keys, nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
... | // List shows all values | [
"List",
"shows",
"all",
"values"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L66-L76 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | IsDir | func (m *InMem) IsDir(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
for k := range m.data {
if strings.HasPrefix(k, name+"/") {
return true
}
}
return false
} | go | func (m *InMem) IsDir(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
for k := range m.data {
if strings.HasPrefix(k, name+"/") {
return true
}
}
return false
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"k",
":=",
"range",
"m",
".",
... | // IsDir returns true if the entry is a directory | [
"IsDir",
"returns",
"true",
"if",
"the",
"entry",
"is",
"a",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L79-L89 | train |
gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Prune | func (m *InMem) Prune(ctx context.Context, prefix string) error {
m.Lock()
defer m.Unlock()
deleted := 0
for k := range m.data {
if strings.HasPrefix(k, prefix+"/") {
delete(m.data, k)
deleted++
}
}
if deleted < 1 {
return fmt.Errorf("not found")
}
return nil
} | go | func (m *InMem) Prune(ctx context.Context, prefix string) error {
m.Lock()
defer m.Unlock()
deleted := 0
for k := range m.data {
if strings.HasPrefix(k, prefix+"/") {
delete(m.data, k)
deleted++
}
}
if deleted < 1 {
return fmt.Errorf("not found")
}
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Prune",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"deleted",
":=",
"0",
"\n",
"for",
... | // Prune removes a directory | [
"Prune",
"removes",
"a",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L92-L107 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/private_key.go | GenerateKeypair | func GenerateKeypair(passphrase string) (*PrivateKey, error) {
pub, priv, err := box.GenerateKey(crypto_rand.Reader)
if err != nil {
return nil, err
}
k := &PrivateKey{
PublicKey: PublicKey{
CreationTime: time.Now(),
PubKeyAlgo: PubKeyNaCl,
PublicKey: *pub,
Identity: &xcpb.Identity{},
},
... | go | func GenerateKeypair(passphrase string) (*PrivateKey, error) {
pub, priv, err := box.GenerateKey(crypto_rand.Reader)
if err != nil {
return nil, err
}
k := &PrivateKey{
PublicKey: PublicKey{
CreationTime: time.Now(),
PubKeyAlgo: PubKeyNaCl,
PublicKey: *pub,
Identity: &xcpb.Identity{},
},
... | [
"func",
"GenerateKeypair",
"(",
"passphrase",
"string",
")",
"(",
"*",
"PrivateKey",
",",
"error",
")",
"{",
"pub",
",",
"priv",
",",
"err",
":=",
"box",
".",
"GenerateKey",
"(",
"crypto_rand",
".",
"Reader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // GenerateKeypair generates a new keypair | [
"GenerateKeypair",
"generates",
"a",
"new",
"keypair"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/private_key.go#L41-L58 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/private_key.go | Encrypt | func (p *PrivateKey) Encrypt(passphrase string) error {
p.Salt = make([]byte, saltLength)
if n, err := crypto_rand.Read(p.Salt); err != nil || n < len(p.Salt) {
return err
}
secretKey := p.deriveKey(passphrase)
var nonce [nonceLength]byte
if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil {
r... | go | func (p *PrivateKey) Encrypt(passphrase string) error {
p.Salt = make([]byte, saltLength)
if n, err := crypto_rand.Read(p.Salt); err != nil || n < len(p.Salt) {
return err
}
secretKey := p.deriveKey(passphrase)
var nonce [nonceLength]byte
if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil {
r... | [
"func",
"(",
"p",
"*",
"PrivateKey",
")",
"Encrypt",
"(",
"passphrase",
"string",
")",
"error",
"{",
"p",
".",
"Salt",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"saltLength",
")",
"\n",
"if",
"n",
",",
"err",
":=",
"crypto_rand",
".",
"Read",
"(",
... | // Encrypt encrypts the private key material with the given passphrase | [
"Encrypt",
"encrypts",
"the",
"private",
"key",
"material",
"with",
"the",
"given",
"passphrase"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/private_key.go#L61-L76 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/private_key.go | Decrypt | func (p *PrivateKey) Decrypt(passphrase string) error {
if !p.Encrypted {
return nil
}
secretKey := p.deriveKey(passphrase)
decrypted, ok := secretbox.Open(nil, p.EncryptedData, &p.Nonce, &secretKey)
if !ok {
return fmt.Errorf("decryption error")
}
copy(p.privateKey[:], decrypted)
p.Encrypted = false
ret... | go | func (p *PrivateKey) Decrypt(passphrase string) error {
if !p.Encrypted {
return nil
}
secretKey := p.deriveKey(passphrase)
decrypted, ok := secretbox.Open(nil, p.EncryptedData, &p.Nonce, &secretKey)
if !ok {
return fmt.Errorf("decryption error")
}
copy(p.privateKey[:], decrypted)
p.Encrypted = false
ret... | [
"func",
"(",
"p",
"*",
"PrivateKey",
")",
"Decrypt",
"(",
"passphrase",
"string",
")",
"error",
"{",
"if",
"!",
"p",
".",
"Encrypted",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"secretKey",
":=",
"p",
".",
"deriveKey",
"(",
"passphrase",
")",
"\n\n",
"d... | // Decrypt decrypts the private key | [
"Decrypt",
"decrypts",
"the",
"private",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/private_key.go#L79-L93 | train |
gopasspw/gopass | pkg/action/create/create.go | Create | func Create(ctx context.Context, c *cli.Context, store storer) error {
s := creator{store: store}
acts := make(cui.Actions, 0, 5)
acts = append(acts, cui.Action{Name: "Website Login", Fn: s.createWebsite})
acts = append(acts, cui.Action{Name: "PIN Code (numerical)", Fn: s.createPIN})
acts = append(acts, cui.Action... | go | func Create(ctx context.Context, c *cli.Context, store storer) error {
s := creator{store: store}
acts := make(cui.Actions, 0, 5)
acts = append(acts, cui.Action{Name: "Website Login", Fn: s.createWebsite})
acts = append(acts, cui.Action{Name: "PIN Code (numerical)", Fn: s.createPIN})
acts = append(acts, cui.Action... | [
"func",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"store",
"storer",
")",
"error",
"{",
"s",
":=",
"creator",
"{",
"store",
":",
"store",
"}",
"\n",
"acts",
":=",
"make",
"(",
"cui",
".",
"Actions",... | // Create displays the password creation wizard | [
"Create",
"displays",
"the",
"password",
"creation",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L49-L66 | train |
gopasspw/gopass | pkg/action/create/create.go | extractHostname | func extractHostname(in string) string {
if in == "" {
return ""
}
// help url.Parse by adding a scheme if one is missing. This should still
// allow for any scheme, but by default we assume http (only for parsing)
urlStr := in
if !strings.Contains(urlStr, "://") {
urlStr = "http://" + urlStr
}
u, err := ur... | go | func extractHostname(in string) string {
if in == "" {
return ""
}
// help url.Parse by adding a scheme if one is missing. This should still
// allow for any scheme, but by default we assume http (only for parsing)
urlStr := in
if !strings.Contains(urlStr, "://") {
urlStr = "http://" + urlStr
}
u, err := ur... | [
"func",
"extractHostname",
"(",
"in",
"string",
")",
"string",
"{",
"if",
"in",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"// help url.Parse by adding a scheme if one is missing. This should still",
"// allow for any scheme, but by default we assume http... | // extractHostname tries to extract the hostname from a URL in a filepath-safe
// way for use in the name of a secret | [
"extractHostname",
"tries",
"to",
"extract",
"the",
"hostname",
"from",
"a",
"URL",
"in",
"a",
"filepath",
"-",
"safe",
"way",
"for",
"use",
"in",
"the",
"name",
"of",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L70-L87 | train |
gopasspw/gopass | pkg/action/create/create.go | createAWS | func (s *creator) createAWS(ctx context.Context, c *cli.Context) error {
var (
account = c.Args().Get(0)
username = c.Args().Get(1)
accesskey = c.Args().Get(2)
secretkey string
region string
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating AWS credentials ...")
account... | go | func (s *creator) createAWS(ctx context.Context, c *cli.Context) error {
var (
account = c.Args().Get(0)
username = c.Args().Get(1)
accesskey = c.Args().Get(2)
secretkey string
region string
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating AWS credentials ...")
account... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createAWS",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"(",
"account",
"=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"userna... | // createAWS will walk through the AWS credential creation wizard | [
"createAWS",
"will",
"walk",
"through",
"the",
"AWS",
"credential",
"creation",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L254-L314 | train |
gopasspw/gopass | pkg/action/create/create.go | createGCP | func (s *creator) createGCP(ctx context.Context, c *cli.Context) error {
var (
project string
username string
svcaccfn = c.Args().Get(0)
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating GCP credentials ...")
svcaccfn, err = termio.AskForString(ctx, fmtfn(2, "1", "Service Account ... | go | func (s *creator) createGCP(ctx context.Context, c *cli.Context) error {
var (
project string
username string
svcaccfn = c.Args().Get(0)
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating GCP credentials ...")
svcaccfn, err = termio.AskForString(ctx, fmtfn(2, "1", "Service Account ... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGCP",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"(",
"project",
"string",
"\n",
"username",
"string",
"\n",
"svcaccfn",
"=",
"c",
".",
"Args",
... | // createGCP will walk through the GCP credential creation wizard | [
"createGCP",
"will",
"walk",
"through",
"the",
"GCP",
"credential",
"creation",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L317-L378 | train |
gopasspw/gopass | pkg/action/create/create.go | extractGCPInfo | func extractGCPInfo(buf []byte) (string, string, error) {
var m map[string]string
if err := json.Unmarshal(buf, &m); err != nil {
return "", "", err
}
p := strings.Split(m["client_email"], "@")
if len(p) < 2 {
return "", "", fmt.Errorf("client_email contains no email")
}
username := p[0]
p = strings.Split(p... | go | func extractGCPInfo(buf []byte) (string, string, error) {
var m map[string]string
if err := json.Unmarshal(buf, &m); err != nil {
return "", "", err
}
p := strings.Split(m["client_email"], "@")
if len(p) < 2 {
return "", "", fmt.Errorf("client_email contains no email")
}
username := p[0]
p = strings.Split(p... | [
"func",
"extractGCPInfo",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"var",
"m",
"map",
"[",
"string",
"]",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"buf",
",",
"&",
"m",
")",... | // extractGCPInfo will extract the GCP details from the given json blob | [
"extractGCPInfo",
"will",
"extract",
"the",
"GCP",
"details",
"from",
"the",
"given",
"json",
"blob"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L381-L396 | train |
gopasspw/gopass | pkg/action/create/create.go | createGeneric | func (s *creator) createGeneric(ctx context.Context, c *cli.Context) error {
var (
shortname = c.Args().Get(0)
password string
store = c.String("store")
err error
genPw bool
)
out.Green(ctx, "=> Creating generic secret ...")
shortname, err = termio.AskForString(ctx, fmtfn(2, "1", "Name"), s... | go | func (s *creator) createGeneric(ctx context.Context, c *cli.Context) error {
var (
shortname = c.Args().Get(0)
password string
store = c.String("store")
err error
genPw bool
)
out.Green(ctx, "=> Creating generic secret ...")
shortname, err = termio.AskForString(ctx, fmtfn(2, "1", "Name"), s... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGeneric",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"(",
"shortname",
"=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"... | // createGeneric will walk through the generic secret wizard | [
"createGeneric",
"will",
"walk",
"through",
"the",
"generic",
"secret",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L399-L468 | train |
gopasspw/gopass | pkg/action/create/create.go | createGeneratePassword | func (s *creator) createGeneratePassword(ctx context.Context) (string, error) {
noXkcd, err := termio.AskForBool(ctx, fmtfn(4, "a", "Cryptic Password?"), true)
if err != nil {
return "", err
}
if !noXkcd {
length, err := termio.AskForInt(ctx, fmtfn(4, "b", "How many words?"), 4)
if err != nil {
return "", ... | go | func (s *creator) createGeneratePassword(ctx context.Context) (string, error) {
noXkcd, err := termio.AskForBool(ctx, fmtfn(4, "a", "Cryptic Password?"), true)
if err != nil {
return "", err
}
if !noXkcd {
length, err := termio.AskForInt(ctx, fmtfn(4, "b", "How many words?"), 4)
if err != nil {
return "", ... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGeneratePassword",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"noXkcd",
",",
"err",
":=",
"termio",
".",
"AskForBool",
"(",
"ctx",
",",
"fmtfn",
"(",
"4",
",",
"\""... | // createGeneratePasssword will walk through the password generation steps | [
"createGeneratePasssword",
"will",
"walk",
"through",
"the",
"password",
"generation",
"steps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L471-L504 | train |
gopasspw/gopass | pkg/action/create/create.go | createGeneratePIN | func (s *creator) createGeneratePIN(ctx context.Context) (string, error) {
length, err := termio.AskForInt(ctx, fmtfn(4, "a", "How long?"), 4)
if err != nil {
return "", err
}
return pwgen.GeneratePasswordCharset(length, "0123456789"), nil
} | go | func (s *creator) createGeneratePIN(ctx context.Context) (string, error) {
length, err := termio.AskForInt(ctx, fmtfn(4, "a", "How long?"), 4)
if err != nil {
return "", err
}
return pwgen.GeneratePasswordCharset(length, "0123456789"), nil
} | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGeneratePIN",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"length",
",",
"err",
":=",
"termio",
".",
"AskForInt",
"(",
"ctx",
",",
"fmtfn",
"(",
"4",
",",
"\"",
"\... | // createGeneratePIN will walk through the PIN generation steps | [
"createGeneratePIN",
"will",
"walk",
"through",
"the",
"PIN",
"generation",
"steps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L507-L513 | train |
gopasspw/gopass | pkg/backend/context.go | WithCryptoBackendString | func WithCryptoBackendString(ctx context.Context, be string) context.Context {
if cb := cryptoBackendFromName(be); cb >= 0 {
ctx = WithCryptoBackend(ctx, cb)
}
return ctx
} | go | func WithCryptoBackendString(ctx context.Context, be string) context.Context {
if cb := cryptoBackendFromName(be); cb >= 0 {
ctx = WithCryptoBackend(ctx, cb)
}
return ctx
} | [
"func",
"WithCryptoBackendString",
"(",
"ctx",
"context",
".",
"Context",
",",
"be",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"cb",
":=",
"cryptoBackendFromName",
"(",
"be",
")",
";",
"cb",
">=",
"0",
"{",
"ctx",
"=",
"WithCryptoBackend",
"(",
... | // WithCryptoBackendString returns a context with the given crypto backend set | [
"WithCryptoBackendString",
"returns",
"a",
"context",
"with",
"the",
"given",
"crypto",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L19-L24 | train |
gopasspw/gopass | pkg/backend/context.go | WithCryptoBackend | func WithCryptoBackend(ctx context.Context, be CryptoBackend) context.Context {
return context.WithValue(ctx, ctxKeyCryptoBackend, be)
} | go | func WithCryptoBackend(ctx context.Context, be CryptoBackend) context.Context {
return context.WithValue(ctx, ctxKeyCryptoBackend, be)
} | [
"func",
"WithCryptoBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"be",
"CryptoBackend",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyCryptoBackend",
",",
"be",
")",
"\n",
"}"
] | // WithCryptoBackend returns a context with the given crypto backend set | [
"WithCryptoBackend",
"returns",
"a",
"context",
"with",
"the",
"given",
"crypto",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L27-L29 | train |
gopasspw/gopass | pkg/backend/context.go | HasCryptoBackend | func HasCryptoBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyCryptoBackend).(CryptoBackend)
return ok
} | go | func HasCryptoBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyCryptoBackend).(CryptoBackend)
return ok
} | [
"func",
"HasCryptoBackend",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyCryptoBackend",
")",
".",
"(",
"CryptoBackend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasCryptoBackend returns true if a value for crypto backend has been set in the context | [
"HasCryptoBackend",
"returns",
"true",
"if",
"a",
"value",
"for",
"crypto",
"backend",
"has",
"been",
"set",
"in",
"the",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L32-L35 | train |
gopasspw/gopass | pkg/backend/context.go | WithRCSBackendString | func WithRCSBackendString(ctx context.Context, sb string) context.Context {
if be := rcsBackendFromName(sb); be >= 0 {
return WithRCSBackend(ctx, be)
}
return WithRCSBackend(ctx, Noop)
} | go | func WithRCSBackendString(ctx context.Context, sb string) context.Context {
if be := rcsBackendFromName(sb); be >= 0 {
return WithRCSBackend(ctx, be)
}
return WithRCSBackend(ctx, Noop)
} | [
"func",
"WithRCSBackendString",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"be",
":=",
"rcsBackendFromName",
"(",
"sb",
")",
";",
"be",
">=",
"0",
"{",
"return",
"WithRCSBackend",
"(",
"ctx",
",... | // WithRCSBackendString returns a context with the given sync backend set | [
"WithRCSBackendString",
"returns",
"a",
"context",
"with",
"the",
"given",
"sync",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L52-L57 | train |
gopasspw/gopass | pkg/backend/context.go | WithRCSBackend | func WithRCSBackend(ctx context.Context, sb RCSBackend) context.Context {
return context.WithValue(ctx, ctxKeyRCSBackend, sb)
} | go | func WithRCSBackend(ctx context.Context, sb RCSBackend) context.Context {
return context.WithValue(ctx, ctxKeyRCSBackend, sb)
} | [
"func",
"WithRCSBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"RCSBackend",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyRCSBackend",
",",
"sb",
")",
"\n",
"}"
] | // WithRCSBackend returns a context with the given sync backend set | [
"WithRCSBackend",
"returns",
"a",
"context",
"with",
"the",
"given",
"sync",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L60-L62 | train |
gopasspw/gopass | pkg/backend/context.go | HasRCSBackend | func HasRCSBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyRCSBackend).(RCSBackend)
return ok
} | go | func HasRCSBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyRCSBackend).(RCSBackend)
return ok
} | [
"func",
"HasRCSBackend",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyRCSBackend",
")",
".",
"(",
"RCSBackend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasRCSBackend returns true if a value for sync backend has been set in the context | [
"HasRCSBackend",
"returns",
"true",
"if",
"a",
"value",
"for",
"sync",
"backend",
"has",
"been",
"set",
"in",
"the",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L65-L68 | train |
gopasspw/gopass | pkg/backend/context.go | WithStorageBackendString | func WithStorageBackendString(ctx context.Context, sb string) context.Context {
return WithStorageBackend(ctx, storageBackendFromName(sb))
} | go | func WithStorageBackendString(ctx context.Context, sb string) context.Context {
return WithStorageBackend(ctx, storageBackendFromName(sb))
} | [
"func",
"WithStorageBackendString",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"WithStorageBackend",
"(",
"ctx",
",",
"storageBackendFromName",
"(",
"sb",
")",
")",
"\n",
"}"
] | // WithStorageBackendString returns a context with the given store backend set | [
"WithStorageBackendString",
"returns",
"a",
"context",
"with",
"the",
"given",
"store",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L80-L82 | train |
gopasspw/gopass | pkg/backend/context.go | WithStorageBackend | func WithStorageBackend(ctx context.Context, sb StorageBackend) context.Context {
return context.WithValue(ctx, ctxKeyStorageBackend, sb)
} | go | func WithStorageBackend(ctx context.Context, sb StorageBackend) context.Context {
return context.WithValue(ctx, ctxKeyStorageBackend, sb)
} | [
"func",
"WithStorageBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"StorageBackend",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyStorageBackend",
",",
"sb",
")",
"\n",
"}"
] | // WithStorageBackend returns a context with the given store backend set | [
"WithStorageBackend",
"returns",
"a",
"context",
"with",
"the",
"given",
"store",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L85-L87 | train |
gopasspw/gopass | pkg/backend/context.go | HasStorageBackend | func HasStorageBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyStorageBackend).(StorageBackend)
return ok
} | go | func HasStorageBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyStorageBackend).(StorageBackend)
return ok
} | [
"func",
"HasStorageBackend",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyStorageBackend",
")",
".",
"(",
"StorageBackend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasStorageBackend returns true if a value for store backend was set | [
"HasStorageBackend",
"returns",
"true",
"if",
"a",
"value",
"for",
"store",
"backend",
"was",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L99-L102 | train |
gopasspw/gopass | pkg/config/config.go | New | func New() *Config {
return &Config{
Path: configLocation(),
Root: &StoreConfig{
AskForMore: false,
AutoClip: true,
AutoImport: true,
AutoSync: true,
ClipTimeout: 45,
Concurrency: 1,
NoColor: false,
NoConfirm: false,
NoPager: false,
SafeContent: f... | go | func New() *Config {
return &Config{
Path: configLocation(),
Root: &StoreConfig{
AskForMore: false,
AutoClip: true,
AutoImport: true,
AutoSync: true,
ClipTimeout: 45,
Concurrency: 1,
NoColor: false,
NoConfirm: false,
NoPager: false,
SafeContent: f... | [
"func",
"New",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Path",
":",
"configLocation",
"(",
")",
",",
"Root",
":",
"&",
"StoreConfig",
"{",
"AskForMore",
":",
"false",
",",
"AutoClip",
":",
"true",
",",
"AutoImport",
":",
"true",
"... | // New creates a new config with sane default values | [
"New",
"creates",
"a",
"new",
"config",
"with",
"sane",
"default",
"values"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/config.go#L37-L56 | train |
gopasspw/gopass | pkg/config/config.go | GetRecipientHash | func (c *Config) GetRecipientHash(alias, name string) string {
if alias == "" {
return c.Root.RecipientHash[name]
}
if sc, found := c.Mounts[alias]; found && sc != nil {
return sc.RecipientHash[name]
}
return ""
} | go | func (c *Config) GetRecipientHash(alias, name string) string {
if alias == "" {
return c.Root.RecipientHash[name]
}
if sc, found := c.Mounts[alias]; found && sc != nil {
return sc.RecipientHash[name]
}
return ""
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetRecipientHash",
"(",
"alias",
",",
"name",
"string",
")",
"string",
"{",
"if",
"alias",
"==",
"\"",
"\"",
"{",
"return",
"c",
".",
"Root",
".",
"RecipientHash",
"[",
"name",
"]",
"\n",
"}",
"\n",
"if",
"sc"... | // GetRecipientHash returns the recipients hash for the given store and file | [
"GetRecipientHash",
"returns",
"the",
"recipients",
"hash",
"for",
"the",
"given",
"store",
"and",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/config.go#L125-L133 | train |
gopasspw/gopass | pkg/config/config.go | SetRecipientHash | func (c *Config) SetRecipientHash(alias, name, value string) error {
if alias == "" {
c.Root.setRecipientHash(name, value)
} else {
if sc, found := c.Mounts[alias]; found && sc != nil {
sc.setRecipientHash(name, value)
}
}
return c.Save()
} | go | func (c *Config) SetRecipientHash(alias, name, value string) error {
if alias == "" {
c.Root.setRecipientHash(name, value)
} else {
if sc, found := c.Mounts[alias]; found && sc != nil {
sc.setRecipientHash(name, value)
}
}
return c.Save()
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"SetRecipientHash",
"(",
"alias",
",",
"name",
",",
"value",
"string",
")",
"error",
"{",
"if",
"alias",
"==",
"\"",
"\"",
"{",
"c",
".",
"Root",
".",
"setRecipientHash",
"(",
"name",
",",
"value",
")",
"\n",
"... | // SetRecipientHash will set and save the recipient hash for the given store
// and file | [
"SetRecipientHash",
"will",
"set",
"and",
"save",
"the",
"recipient",
"hash",
"for",
"the",
"given",
"store",
"and",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/config.go#L137-L147 | train |
gopasspw/gopass | pkg/store/sub/list.go | List | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
if s.storage == nil || s.crypto == nil {
return nil, nil
}
lst, err := s.storage.List(ctx, prefix)
if err != nil {
return nil, err
}
out.Debug(ctx, "sub.List(%s): %+v\n", prefix, lst)
out := make([]string, 0, len(lst))
cExt := "."... | go | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
if s.storage == nil || s.crypto == nil {
return nil, nil
}
lst, err := s.storage.List(ctx, prefix)
if err != nil {
return nil, err
}
out.Debug(ctx, "sub.List(%s): %+v\n", prefix, lst)
out := make([]string, 0, len(lst))
cExt := "."... | [
"func",
"(",
"s",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"s",
".",
"storage",
"==",
"nil",
"||",
"s",
".",
"crypto",
"==",
"nil",
"{... | // List will list all entries in this store | [
"List",
"will",
"list",
"all",
"entries",
"in",
"this",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/list.go#L16-L39 | train |
gopasspw/gopass | pkg/action/init.go | Initialized | func (s *Action) Initialized(ctx context.Context, c *cli.Context) error {
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialize store: %s", err)
}
if inited {
out.Debug(ctx, "Store is already initialized")
return nil
}
out.Debug(ctx, "Store ne... | go | func (s *Action) Initialized(ctx context.Context, c *cli.Context) error {
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialize store: %s", err)
}
if inited {
out.Debug(ctx, "Store is already initialized")
return nil
}
out.Debug(ctx, "Store ne... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"inited",
",",
"err",
":=",
"s",
".",
"Store",
".",
"Initialized",
"(",
"ctx",
")",
"\n",
"if",
"... | // Initialized returns an error if the store is not properly
// prepared. | [
"Initialized",
"returns",
"an",
"error",
"if",
"the",
"store",
"is",
"not",
"properly",
"prepared",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L25-L46 | train |
gopasspw/gopass | pkg/action/init.go | Init | func (s *Action) Init(ctx context.Context, c *cli.Context) error {
path := c.String("path")
alias := c.String("store")
ctx = initParseContext(ctx, c)
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialized store: %s", err)
}
if inited {
out.Erro... | go | func (s *Action) Init(ctx context.Context, c *cli.Context) error {
path := c.String("path")
alias := c.String("store")
ctx = initParseContext(ctx, c)
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialized store: %s", err)
}
if inited {
out.Erro... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Init",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"path",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"alias",
":=",
"c",
".",
"String",
"(",
... | // Init a new password store with a first gpg id | [
"Init",
"a",
"new",
"password",
"store",
"with",
"a",
"first",
"gpg",
"id"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L49-L66 | train |
gopasspw/gopass | pkg/action/init.go | initLocal | func (s *Action) initLocal(ctx context.Context, c *cli.Context) error {
ctx = out.AddPrefix(ctx, "[local] ")
path := ""
if s.Store != nil {
path = s.Store.URL()
}
out.Print(ctx, "Initializing your local store ...")
if err := s.init(out.WithHidden(ctx, true), "", path); err != nil {
return errors.Wrapf(err, ... | go | func (s *Action) initLocal(ctx context.Context, c *cli.Context) error {
ctx = out.AddPrefix(ctx, "[local] ")
path := ""
if s.Store != nil {
path = s.Store.URL()
}
out.Print(ctx, "Initializing your local store ...")
if err := s.init(out.WithHidden(ctx, true), "", path); err != nil {
return errors.Wrapf(err, ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"initLocal",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"ctx",
"=",
"out",
".",
"AddPrefix",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n\n",
"path",
":=",
"\"",
... | // initLocal will initialize a local store, useful for local-only setups or as
// part of team setups to create the root store | [
"initLocal",
"will",
"initialize",
"a",
"local",
"store",
"useful",
"for",
"local",
"-",
"only",
"setups",
"or",
"as",
"part",
"of",
"team",
"setups",
"to",
"create",
"the",
"root",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L323-L364 | train |
gopasspw/gopass | pkg/action/init.go | initCreateTeam | func (s *Action) initCreateTeam(ctx context.Context, c *cli.Context, team, remote string) error {
var err error
out.Print(ctx, "Creating a new team ...")
if err := s.initLocal(ctx, c); err != nil {
return errors.Wrapf(err, "failed to create local store")
}
// name of the new team
team, err = termio.AskForStri... | go | func (s *Action) initCreateTeam(ctx context.Context, c *cli.Context, team, remote string) error {
var err error
out.Print(ctx, "Creating a new team ...")
if err := s.initLocal(ctx, c); err != nil {
return errors.Wrapf(err, "failed to create local store")
}
// name of the new team
team, err = termio.AskForStri... | [
"func",
"(",
"s",
"*",
"Action",
")",
"initCreateTeam",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"team",
",",
"remote",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"out",
".",
"Print",
"(",
"... | // initCreateTeam will create a local root store and a shared team store | [
"initCreateTeam",
"will",
"create",
"a",
"local",
"root",
"store",
"and",
"a",
"shared",
"team",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L367-L395 | train |
gopasspw/gopass | pkg/notify/notify_dbus.go | Notify | func Notify(ctx context.Context, subj, msg string) error {
if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
return nil
}
conn, err := dbus.SessionBus()
if err != nil {
return err
}
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
call := obj.Call... | go | func Notify(ctx context.Context, subj, msg string) error {
if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
return nil
}
conn, err := dbus.SessionBus()
if err != nil {
return err
}
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
call := obj.Call... | [
"func",
"Notify",
"(",
"ctx",
"context",
".",
"Context",
",",
"subj",
",",
"msg",
"string",
")",
"error",
"{",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"||",
"!",
"ctxutil",
".",
"IsNotifications",
"(",
"ctx",
")",
"{",
... | // Notify displays a desktop notification with dbus | [
"Notify",
"displays",
"a",
"desktop",
"notification",
"with",
"dbus"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/notify/notify_dbus.go#L15-L31 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/public_key.go | Fingerprint | func (p PublicKey) Fingerprint() string {
h := make([]byte, 20)
d := sha3.NewShake256()
_, _ = d.Write([]byte{0x42})
_ = binary.Write(d, binary.LittleEndian, p.PubKeyAlgo)
_, _ = d.Write(p.PublicKey[:])
_, _ = d.Read(h)
return fmt.Sprintf("%x", h)
} | go | func (p PublicKey) Fingerprint() string {
h := make([]byte, 20)
d := sha3.NewShake256()
_, _ = d.Write([]byte{0x42})
_ = binary.Write(d, binary.LittleEndian, p.PubKeyAlgo)
_, _ = d.Write(p.PublicKey[:])
_, _ = d.Read(h)
return fmt.Sprintf("%x", h)
} | [
"func",
"(",
"p",
"PublicKey",
")",
"Fingerprint",
"(",
")",
"string",
"{",
"h",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"20",
")",
"\n",
"d",
":=",
"sha3",
".",
"NewShake256",
"(",
")",
"\n",
"_",
",",
"_",
"=",
"d",
".",
"Write",
"(",
"["... | // Fingerprint calculates the unique ID of a public key | [
"Fingerprint",
"calculates",
"the",
"unique",
"ID",
"of",
"a",
"public",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/public_key.go#L30-L38 | train |
gopasspw/gopass | pkg/action/completion.go | bashEscape | func bashEscape(s string) string {
return escapeRegExp.ReplaceAllStringFunc(s, func(c string) string {
if c == `\` {
return `\\\\`
}
return `\\` + c
})
} | go | func bashEscape(s string) string {
return escapeRegExp.ReplaceAllStringFunc(s, func(c string) string {
if c == `\` {
return `\\\\`
}
return `\\` + c
})
} | [
"func",
"bashEscape",
"(",
"s",
"string",
")",
"string",
"{",
"return",
"escapeRegExp",
".",
"ReplaceAllStringFunc",
"(",
"s",
",",
"func",
"(",
"c",
"string",
")",
"string",
"{",
"if",
"c",
"==",
"`\\`",
"{",
"return",
"`\\\\\\\\`",
"\n",
"}",
"\n",
"... | // bashEscape Escape special characters with `\` | [
"bashEscape",
"Escape",
"special",
"characters",
"with",
"\\"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L20-L27 | train |
gopasspw/gopass | pkg/action/completion.go | Complete | func (s *Action) Complete(ctx context.Context, c *cli.Context) {
_, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil
if err != nil {
out.Error(ctx, "Store not initialized: %s", err)
return
}
list, err := s.Store.List(ctx, 0)
if err != nil {
return
}
for _, v := range list ... | go | func (s *Action) Complete(ctx context.Context, c *cli.Context) {
_, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil
if err != nil {
out.Error(ctx, "Store not initialized: %s", err)
return
}
list, err := s.Store.List(ctx, 0)
if err != nil {
return
}
for _, v := range list ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Complete",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"_",
",",
"err",
":=",
"s",
".",
"Store",
".",
"Initialized",
"(",
"ctx",
")",
"// important to make sure the struc... | // Complete prints a list of all password names to os.Stdout | [
"Complete",
"prints",
"a",
"list",
"of",
"all",
"password",
"names",
"to",
"os",
".",
"Stdout"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L30-L44 | train |
gopasspw/gopass | pkg/action/completion.go | CompletionOpenBSDKsh | func (s *Action) CompletionOpenBSDKsh(c *cli.Context, a *cli.App) error {
out := `
PASS_LIST=$(gopass ls -f)
set -A complete_gopass -- $PASS_LIST %s
`
if a == nil {
return fmt.Errorf("can not parse command options")
}
var opts []string
for _, opt := range a.Commands {
opts = append(opts, opt.Name)
if len(o... | go | func (s *Action) CompletionOpenBSDKsh(c *cli.Context, a *cli.App) error {
out := `
PASS_LIST=$(gopass ls -f)
set -A complete_gopass -- $PASS_LIST %s
`
if a == nil {
return fmt.Errorf("can not parse command options")
}
var opts []string
for _, opt := range a.Commands {
opts = append(opts, opt.Name)
if len(o... | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionOpenBSDKsh",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"a",
"*",
"cli",
".",
"App",
")",
"error",
"{",
"out",
":=",
"`\nPASS_LIST=$(gopass ls -f)\nset -A complete_gopass -- $PASS_LIST %s\n`",
"\n\n",
"if",
"a",
... | // CompletionOpenBSDKsh returns an OpenBSD ksh script used for auto completion | [
"CompletionOpenBSDKsh",
"returns",
"an",
"OpenBSD",
"ksh",
"script",
"used",
"for",
"auto",
"completion"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L47-L67 | train |
gopasspw/gopass | pkg/action/completion.go | CompletionBash | func (s *Action) CompletionBash(c *cli.Context) error {
out := `_gopass_bash_autocomplete() {
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
local IFS=$'\n'
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ... | go | func (s *Action) CompletionBash(c *cli.Context) error {
out := `_gopass_bash_autocomplete() {
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
local IFS=$'\n'
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionBash",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"out",
":=",
"`_gopass_bash_autocomplete() {\n local cur opts base\n COMPREPLY=()\n cur=\"${COMP_WORDS[COMP_CWORD]}\"\n opts=$( ${COMP_WORDS[@]:0:$COMP... | // CompletionBash returns a bash script used for auto completion | [
"CompletionBash",
"returns",
"a",
"bash",
"script",
"used",
"for",
"auto",
"completion"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L70-L89 | train |
gopasspw/gopass | pkg/action/completion.go | CompletionFish | func (s *Action) CompletionFish(c *cli.Context, a *cli.App) error {
comp, err := fishcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | go | func (s *Action) CompletionFish(c *cli.Context, a *cli.App) error {
comp, err := fishcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionFish",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"a",
"*",
"cli",
".",
"App",
")",
"error",
"{",
"comp",
",",
"err",
":=",
"fishcomp",
".",
"GetCompletion",
"(",
"a",
")",
"\n",
"if",
"err",
"!=",... | // CompletionFish returns an autocompletion script for fish | [
"CompletionFish",
"returns",
"an",
"autocompletion",
"script",
"for",
"fish"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L92-L100 | train |
gopasspw/gopass | pkg/action/completion.go | CompletionZSH | func (s *Action) CompletionZSH(c *cli.Context, a *cli.App) error {
comp, err := zshcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | go | func (s *Action) CompletionZSH(c *cli.Context, a *cli.App) error {
comp, err := zshcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionZSH",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"a",
"*",
"cli",
".",
"App",
")",
"error",
"{",
"comp",
",",
"err",
":=",
"zshcomp",
".",
"GetCompletion",
"(",
"a",
")",
"\n",
"if",
"err",
"!=",
... | // CompletionZSH returns a zsh completion script | [
"CompletionZSH",
"returns",
"a",
"zsh",
"completion",
"script"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L103-L111 | train |
gopasspw/gopass | pkg/agent/client/client.go | New | func New(dir string) *Client {
socket := filepath.Join(dir, ".gopass-agent.sock")
return &Client{
http: &http.Client{
Transport: &http.Transport{
DialContext: func(context.Context, string, string) (net.Conn, error) {
return net.Dial("unix", socket)
},
},
Timeout: 10 * time.Minute,
},
}
} | go | func New(dir string) *Client {
socket := filepath.Join(dir, ".gopass-agent.sock")
return &Client{
http: &http.Client{
Transport: &http.Transport{
DialContext: func(context.Context, string, string) (net.Conn, error) {
return net.Dial("unix", socket)
},
},
Timeout: 10 * time.Minute,
},
}
} | [
"func",
"New",
"(",
"dir",
"string",
")",
"*",
"Client",
"{",
"socket",
":=",
"filepath",
".",
"Join",
"(",
"dir",
",",
"\"",
"\"",
")",
"\n",
"return",
"&",
"Client",
"{",
"http",
":",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"&",
"htt... | // New creates a new client | [
"New",
"creates",
"a",
"new",
"client"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/client.go#L24-L36 | train |
gopasspw/gopass | pkg/agent/client/client.go | Ping | func (c *Client) Ping(ctx context.Context) error {
pc := &http.Client{
Transport: c.http.Transport,
Timeout: 5 * time.Second,
}
resp, err := pc.Get("http://unix/ping")
if err != nil {
return err
}
_ = resp.Body.Close()
return nil
} | go | func (c *Client) Ping(ctx context.Context) error {
pc := &http.Client{
Transport: c.http.Transport,
Timeout: 5 * time.Second,
}
resp, err := pc.Get("http://unix/ping")
if err != nil {
return err
}
_ = resp.Body.Close()
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Ping",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"pc",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"c",
".",
"http",
".",
"Transport",
",",
"Timeout",
":",
"5",
"*",
"time",
".",... | // Ping checks connectivity to the agent | [
"Ping",
"checks",
"connectivity",
"to",
"the",
"agent"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/client.go#L39-L50 | train |
gopasspw/gopass | pkg/agent/client/client.go | Remove | func (c *Client) Remove(ctx context.Context, key string) error {
if err := c.checkAgent(ctx); err != nil {
return errors.Wrapf(err, "agent not available: %s", err)
}
u, err := url.Parse("http://unix/cache/remove")
if err != nil {
return errors.Wrapf(err, "failed to build request url")
}
values := u.Query()
... | go | func (c *Client) Remove(ctx context.Context, key string) error {
if err := c.checkAgent(ctx); err != nil {
return errors.Wrapf(err, "agent not available: %s", err)
}
u, err := url.Parse("http://unix/cache/remove")
if err != nil {
return errors.Wrapf(err, "failed to build request url")
}
values := u.Query()
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"checkAgent",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wr... | // Remove un-caches a single key | [
"Remove",
"un",
"-",
"caches",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/client.go#L72-L97 | train |
gopasspw/gopass | pkg/backend/crypto/xc/import.go | ImportPublicKey | func (x *XC) ImportPublicKey(ctx context.Context, buf []byte) error {
if err := x.pubring.Import(buf); err != nil {
return err
}
return x.pubring.Save()
} | go | func (x *XC) ImportPublicKey(ctx context.Context, buf []byte) error {
if err := x.pubring.Import(buf); err != nil {
return err
}
return x.pubring.Save()
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ImportPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"x",
".",
"pubring",
".",
"Import",
"(",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
"... | // ImportPublicKey imports a given public key into the keyring | [
"ImportPublicKey",
"imports",
"a",
"given",
"public",
"key",
"into",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/import.go#L6-L11 | train |
gopasspw/gopass | pkg/backend/crypto/xc/import.go | ImportPrivateKey | func (x *XC) ImportPrivateKey(ctx context.Context, buf []byte) error {
if err := x.secring.Import(buf); err != nil {
return err
}
return x.secring.Save()
} | go | func (x *XC) ImportPrivateKey(ctx context.Context, buf []byte) error {
if err := x.secring.Import(buf); err != nil {
return err
}
return x.secring.Save()
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ImportPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"x",
".",
"secring",
".",
"Import",
"(",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
... | // ImportPrivateKey imports a given private key into the keyring | [
"ImportPrivateKey",
"imports",
"a",
"given",
"private",
"key",
"into",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/import.go#L14-L19 | train |
gopasspw/gopass | pkg/backend/crypto/xc/xc.go | New | func New(dir string, client agentClient) (*XC, error) {
skr, _ := keyring.LoadSecring(filepath.Join(dir, secringFilename))
pkr, _ := keyring.LoadPubring(filepath.Join(dir, pubringFilename), skr)
return &XC{
dir: dir,
pubring: pkr,
secring: skr,
client: client,
}, nil
} | go | func New(dir string, client agentClient) (*XC, error) {
skr, _ := keyring.LoadSecring(filepath.Join(dir, secringFilename))
pkr, _ := keyring.LoadPubring(filepath.Join(dir, pubringFilename), skr)
return &XC{
dir: dir,
pubring: pkr,
secring: skr,
client: client,
}, nil
} | [
"func",
"New",
"(",
"dir",
"string",
",",
"client",
"agentClient",
")",
"(",
"*",
"XC",
",",
"error",
")",
"{",
"skr",
",",
"_",
":=",
"keyring",
".",
"LoadSecring",
"(",
"filepath",
".",
"Join",
"(",
"dir",
",",
"secringFilename",
")",
")",
"\n",
... | // New creates a new XC backend | [
"New",
"creates",
"a",
"new",
"XC",
"backend"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L37-L46 | train |
gopasspw/gopass | pkg/backend/crypto/xc/xc.go | RemoveKey | func (x *XC) RemoveKey(id string) error {
if x.secring.Contains(id) {
if err := x.secring.Remove(id); err != nil {
return err
}
return x.secring.Save()
}
if x.pubring.Contains(id) {
if err := x.pubring.Remove(id); err != nil {
return err
}
return x.pubring.Save()
}
return fmt.Errorf("not found")
... | go | func (x *XC) RemoveKey(id string) error {
if x.secring.Contains(id) {
if err := x.secring.Remove(id); err != nil {
return err
}
return x.secring.Save()
}
if x.pubring.Contains(id) {
if err := x.pubring.Remove(id); err != nil {
return err
}
return x.pubring.Save()
}
return fmt.Errorf("not found")
... | [
"func",
"(",
"x",
"*",
"XC",
")",
"RemoveKey",
"(",
"id",
"string",
")",
"error",
"{",
"if",
"x",
".",
"secring",
".",
"Contains",
"(",
"id",
")",
"{",
"if",
"err",
":=",
"x",
".",
"secring",
".",
"Remove",
"(",
"id",
")",
";",
"err",
"!=",
"... | // RemoveKey removes a single key from the keyring | [
"RemoveKey",
"removes",
"a",
"single",
"key",
"from",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L49-L63 | train |
gopasspw/gopass | pkg/backend/crypto/xc/xc.go | Initialized | func (x *XC) Initialized(ctx context.Context) error {
if x == nil {
return fmt.Errorf("XC not initialized")
}
if x.pubring == nil {
return fmt.Errorf("pubring not initialized")
}
if x.secring == nil {
return fmt.Errorf("secring not initialized")
}
if x.client == nil {
return fmt.Errorf("client not initia... | go | func (x *XC) Initialized(ctx context.Context) error {
if x == nil {
return fmt.Errorf("XC not initialized")
}
if x.pubring == nil {
return fmt.Errorf("pubring not initialized")
}
if x.secring == nil {
return fmt.Errorf("secring not initialized")
}
if x.client == nil {
return fmt.Errorf("client not initia... | [
"func",
"(",
"x",
"*",
"XC",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"x",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"x",
".",
"pubring",
"==",
"nil... | // Initialized returns an error if this backend is not properly initialized | [
"Initialized",
"returns",
"an",
"error",
"if",
"this",
"backend",
"is",
"not",
"properly",
"initialized"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L66-L83 | train |
gopasspw/gopass | pkg/backend/crypto/xc/xc.go | Version | func (x *XC) Version(ctx context.Context) semver.Version {
return semver.Version{
Patch: 1,
}
} | go | func (x *XC) Version(ctx context.Context) semver.Version {
return semver.Version{
Patch: 1,
}
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"Version",
"(",
"ctx",
"context",
".",
"Context",
")",
"semver",
".",
"Version",
"{",
"return",
"semver",
".",
"Version",
"{",
"Patch",
":",
"1",
",",
"}",
"\n",
"}"
] | // Version returns 0.0.1 | [
"Version",
"returns",
"0",
".",
"0",
".",
"1"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L91-L95 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/binary.go | Binary | func Binary(ctx context.Context, bin string) (string, error) {
bins, err := detectBinaryCandidates(bin)
if err != nil {
return "", err
}
bv := make(byVersion, 0, len(bins))
for _, b := range bins {
//out.Debug(ctx, "gpg.detectBinary - Looking for '%s' ...", b)
if p, err := exec.LookPath(b); err == nil {
g... | go | func Binary(ctx context.Context, bin string) (string, error) {
bins, err := detectBinaryCandidates(bin)
if err != nil {
return "", err
}
bv := make(byVersion, 0, len(bins))
for _, b := range bins {
//out.Debug(ctx, "gpg.detectBinary - Looking for '%s' ...", b)
if p, err := exec.LookPath(b); err == nil {
g... | [
"func",
"Binary",
"(",
"ctx",
"context",
".",
"Context",
",",
"bin",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"bins",
",",
"err",
":=",
"detectBinaryCandidates",
"(",
"bin",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",... | // Binary reutrns the GGP binary location | [
"Binary",
"reutrns",
"the",
"GGP",
"binary",
"location"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/binary.go#L19-L43 | train |
gopasspw/gopass | pkg/out/context.go | WithPrefix | func WithPrefix(ctx context.Context, prefix string) context.Context {
return context.WithValue(ctx, ctxKeyPrefix, prefix)
} | go | func WithPrefix(ctx context.Context, prefix string) context.Context {
return context.WithValue(ctx, ctxKeyPrefix, prefix)
} | [
"func",
"WithPrefix",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyPrefix",
",",
"prefix",
")",
"\n",
"}"
] | // WithPrefix returns a context with the given prefix set | [
"WithPrefix",
"returns",
"a",
"context",
"with",
"the",
"given",
"prefix",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L14-L16 | train |
gopasspw/gopass | pkg/out/context.go | AddPrefix | func AddPrefix(ctx context.Context, prefix string) context.Context {
if prefix == "" {
return ctx
}
pfx := Prefix(ctx)
if pfx == "" {
return WithPrefix(ctx, prefix)
}
return WithPrefix(ctx, pfx+prefix)
} | go | func AddPrefix(ctx context.Context, prefix string) context.Context {
if prefix == "" {
return ctx
}
pfx := Prefix(ctx)
if pfx == "" {
return WithPrefix(ctx, prefix)
}
return WithPrefix(ctx, pfx+prefix)
} | [
"func",
"AddPrefix",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"prefix",
"==",
"\"",
"\"",
"{",
"return",
"ctx",
"\n",
"}",
"\n",
"pfx",
":=",
"Prefix",
"(",
"ctx",
")",
"\n",
"if",
"... | // AddPrefix returns a context with the given prefix added to end of the
// existing prefix | [
"AddPrefix",
"returns",
"a",
"context",
"with",
"the",
"given",
"prefix",
"added",
"to",
"end",
"of",
"the",
"existing",
"prefix"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L20-L29 | train |
gopasspw/gopass | pkg/out/context.go | Prefix | func Prefix(ctx context.Context) string {
sv, ok := ctx.Value(ctxKeyPrefix).(string)
if !ok {
return ""
}
return sv
} | go | func Prefix(ctx context.Context) string {
sv, ok := ctx.Value(ctxKeyPrefix).(string)
if !ok {
return ""
}
return sv
} | [
"func",
"Prefix",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"sv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyPrefix",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return... | // Prefix returns the prefix or an empty string | [
"Prefix",
"returns",
"the",
"prefix",
"or",
"an",
"empty",
"string"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L32-L38 | train |
gopasspw/gopass | pkg/out/context.go | WithHidden | func WithHidden(ctx context.Context, hidden bool) context.Context {
return context.WithValue(ctx, ctxKeyHidden, hidden)
} | go | func WithHidden(ctx context.Context, hidden bool) context.Context {
return context.WithValue(ctx, ctxKeyHidden, hidden)
} | [
"func",
"WithHidden",
"(",
"ctx",
"context",
".",
"Context",
",",
"hidden",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyHidden",
",",
"hidden",
")",
"\n",
"}"
] | // WithHidden returns a context with the flag value for hidden set | [
"WithHidden",
"returns",
"a",
"context",
"with",
"the",
"flag",
"value",
"for",
"hidden",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L41-L43 | train |
gopasspw/gopass | pkg/out/context.go | IsHidden | func IsHidden(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyHidden).(bool)
if !ok {
return false
}
return bv
} | go | func IsHidden(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyHidden).(bool)
if !ok {
return false
}
return bv
} | [
"func",
"IsHidden",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"bv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyHidden",
")",
".",
"(",
"bool",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"b... | // IsHidden returns true if any output should be hidden in this context | [
"IsHidden",
"returns",
"true",
"if",
"any",
"output",
"should",
"be",
"hidden",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L46-L52 | train |
gopasspw/gopass | pkg/out/context.go | WithNewline | func WithNewline(ctx context.Context, nl bool) context.Context {
return context.WithValue(ctx, ctxKeyNewline, nl)
} | go | func WithNewline(ctx context.Context, nl bool) context.Context {
return context.WithValue(ctx, ctxKeyNewline, nl)
} | [
"func",
"WithNewline",
"(",
"ctx",
"context",
".",
"Context",
",",
"nl",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyNewline",
",",
"nl",
")",
"\n",
"}"
] | // WithNewline returns a context with the flag value for newline set | [
"WithNewline",
"returns",
"a",
"context",
"with",
"the",
"flag",
"value",
"for",
"newline",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L55-L57 | train |
gopasspw/gopass | pkg/action/move.go | Move | func (s *Action) Move(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
if len(c.Args()) != 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mv old-path new-path", s.Name)
}
from := c.Args()[0]
to := c.Args()[1]
if !force {
if s.Store.Exists(ctx, to) && !termio.AskForConfirmation(ct... | go | func (s *Action) Move(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
if len(c.Args()) != 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mv old-path new-path", s.Name)
}
from := c.Args()[0]
to := c.Args()[1]
if !force {
if s.Store.Exists(ctx, to) && !termio.AskForConfirmation(ct... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Move",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"force",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"c",
".",
"Args",
"... | // Move the content from one secret to another | [
"Move",
"the",
"content",
"from",
"one",
"secret",
"to",
"another"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/move.go#L13-L34 | train |
gopasspw/gopass | pkg/config/secrets/config.go | New | func New(dir, passphrase string) (*Config, error) {
if dir == "" || dir == "." {
return nil, fmt.Errorf("dir must not be empty")
}
fn := filepath.Join(dir, filename)
c := &Config{
filename: fn,
passphrase: passphrase,
}
if !fsutil.IsFile(fn) {
err := save(c.filename, c.passphrase, map[string]string{})... | go | func New(dir, passphrase string) (*Config, error) {
if dir == "" || dir == "." {
return nil, fmt.Errorf("dir must not be empty")
}
fn := filepath.Join(dir, filename)
c := &Config{
filename: fn,
passphrase: passphrase,
}
if !fsutil.IsFile(fn) {
err := save(c.filename, c.passphrase, map[string]string{})... | [
"func",
"New",
"(",
"dir",
",",
"passphrase",
"string",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"if",
"dir",
"==",
"\"",
"\"",
"||",
"dir",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
... | // New will load the given file from disk and try to unseal it | [
"New",
"will",
"load",
"the",
"given",
"file",
"from",
"disk",
"and",
"try",
"to",
"unseal",
"it"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L33-L54 | train |
gopasspw/gopass | pkg/config/secrets/config.go | Get | func (c *Config) Get(key string) (string, error) {
data, err := load(c.filename, c.passphrase)
return data[key], err
} | go | func (c *Config) Get(key string) (string, error) {
data, err := load(c.filename, c.passphrase)
return data[key], err
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"load",
"(",
"c",
".",
"filename",
",",
"c",
".",
"passphrase",
")",
"\n",
"return",
"data",
"[",
"key",
"]... | // Get loads the requested key from disk | [
"Get",
"loads",
"the",
"requested",
"key",
"from",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L57-L60 | train |
gopasspw/gopass | pkg/config/secrets/config.go | Set | func (c *Config) Set(key, value string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
old := data[key]
if value == old {
return nil
}
data[key] = value
return save(c.filename, c.passphrase, data)
} | go | func (c *Config) Set(key, value string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
old := data[key]
if value == old {
return nil
}
data[key] = value
return save(c.filename, c.passphrase, data)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"data",
",",
"err",
":=",
"load",
"(",
"c",
".",
"filename",
",",
"c",
".",
"passphrase",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"e... | // Set writes the requested key to disk | [
"Set",
"writes",
"the",
"requested",
"key",
"to",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L63-L76 | train |
gopasspw/gopass | pkg/config/secrets/config.go | Unset | func (c *Config) Unset(key string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
_, found := data[key]
if !found {
return nil
}
delete(data, key)
return save(c.filename, c.passphrase, data)
} | go | func (c *Config) Unset(key string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
_, found := data[key]
if !found {
return nil
}
delete(data, key)
return save(c.filename, c.passphrase, data)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Unset",
"(",
"key",
"string",
")",
"error",
"{",
"data",
",",
"err",
":=",
"load",
"(",
"c",
".",
"filename",
",",
"c",
".",
"passphrase",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
... | // Unset removes the key from the storage | [
"Unset",
"removes",
"the",
"key",
"from",
"the",
"storage"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L79-L92 | train |
gopasspw/gopass | pkg/config/secrets/config.go | open | func open(buf []byte, passphrase string) (map[string]string, error) {
salt := make([]byte, saltLength)
copy(salt, buf[:saltLength])
var nonce [nonceLength]byte
copy(nonce[:], buf[saltLength:nonceLength+saltLength])
secretKey := deriveKey(passphrase, salt)
decrypted, ok := secretbox.Open(nil, buf[nonceLength+saltL... | go | func open(buf []byte, passphrase string) (map[string]string, error) {
salt := make([]byte, saltLength)
copy(salt, buf[:saltLength])
var nonce [nonceLength]byte
copy(nonce[:], buf[saltLength:nonceLength+saltLength])
secretKey := deriveKey(passphrase, salt)
decrypted, ok := secretbox.Open(nil, buf[nonceLength+saltL... | [
"func",
"open",
"(",
"buf",
"[",
"]",
"byte",
",",
"passphrase",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"salt",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"saltLength",
")",
"\n",
"copy",
"(",
"salt",
",",... | // open will try to unseal the given buffer | [
"open",
"will",
"try",
"to",
"unseal",
"the",
"given",
"buffer"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L103-L118 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.