id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,000 | containerd/continuity | digests.go | digestsMatch | func digestsMatch(as, bs []digest.Digest) bool {
all := append(as, bs...)
uniqified, err := uniqifyDigests(all...)
if err != nil {
// the only error uniqifyDigests returns is when the digests disagree.
return false
}
disjoint := len(as) + len(bs)
if len(uniqified) == disjoint {
// if these two sets have t... | go | func digestsMatch(as, bs []digest.Digest) bool {
all := append(as, bs...)
uniqified, err := uniqifyDigests(all...)
if err != nil {
// the only error uniqifyDigests returns is when the digests disagree.
return false
}
disjoint := len(as) + len(bs)
if len(uniqified) == disjoint {
// if these two sets have t... | [
"func",
"digestsMatch",
"(",
"as",
",",
"bs",
"[",
"]",
"digest",
".",
"Digest",
")",
"bool",
"{",
"all",
":=",
"append",
"(",
"as",
",",
"bs",
"...",
")",
"\n\n",
"uniqified",
",",
"err",
":=",
"uniqifyDigests",
"(",
"all",
"...",
")",
"\n",
"if",... | // digestsMatch compares the two sets of digests to see if they match. | [
"digestsMatch",
"compares",
"the",
"two",
"sets",
"of",
"digests",
"to",
"see",
"if",
"they",
"match",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/digests.go#L81-L98 |
141,001 | containerd/continuity | resource.go | newRegularFile | func newRegularFile(base resource, paths []string, size int64, dgsts ...digest.Digest) (RegularFile, error) {
if !base.Mode().IsRegular() {
return nil, fmt.Errorf("not a regular file")
}
base.paths = make([]string, len(paths))
copy(base.paths, paths)
// make our own copy of digests
ds := make([]digest.Digest,... | go | func newRegularFile(base resource, paths []string, size int64, dgsts ...digest.Digest) (RegularFile, error) {
if !base.Mode().IsRegular() {
return nil, fmt.Errorf("not a regular file")
}
base.paths = make([]string, len(paths))
copy(base.paths, paths)
// make our own copy of digests
ds := make([]digest.Digest,... | [
"func",
"newRegularFile",
"(",
"base",
"resource",
",",
"paths",
"[",
"]",
"string",
",",
"size",
"int64",
",",
"dgsts",
"...",
"digest",
".",
"Digest",
")",
"(",
"RegularFile",
",",
"error",
")",
"{",
"if",
"!",
"base",
".",
"Mode",
"(",
")",
".",
... | // newRegularFile returns the RegularFile, using the populated base resource
// and one or more digests of the content. | [
"newRegularFile",
"returns",
"the",
"RegularFile",
"using",
"the",
"populated",
"base",
"resource",
"and",
"one",
"or",
"more",
"digests",
"of",
"the",
"content",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/resource.go#L295-L312 |
141,002 | containerd/continuity | resource.go | toProto | func toProto(resource Resource) *pb.Resource {
b := &pb.Resource{
Path: []string{resource.Path()},
Mode: uint32(resource.Mode()),
Uid: resource.UID(),
Gid: resource.GID(),
}
if xattrer, ok := resource.(XAttrer); ok {
// Sorts the XAttrs by name for consistent ordering.
keys := []string{}
xattrs := x... | go | func toProto(resource Resource) *pb.Resource {
b := &pb.Resource{
Path: []string{resource.Path()},
Mode: uint32(resource.Mode()),
Uid: resource.UID(),
Gid: resource.GID(),
}
if xattrer, ok := resource.(XAttrer); ok {
// Sorts the XAttrs by name for consistent ordering.
keys := []string{}
xattrs := x... | [
"func",
"toProto",
"(",
"resource",
"Resource",
")",
"*",
"pb",
".",
"Resource",
"{",
"b",
":=",
"&",
"pb",
".",
"Resource",
"{",
"Path",
":",
"[",
"]",
"string",
"{",
"resource",
".",
"Path",
"(",
")",
"}",
",",
"Mode",
":",
"uint32",
"(",
"reso... | // toProto converts a resource to a protobuf record. We'd like to push this
// the individual types but we want to keep this all together during
// prototyping. | [
"toProto",
"converts",
"a",
"resource",
"to",
"a",
"protobuf",
"record",
".",
"We",
"d",
"like",
"to",
"push",
"this",
"the",
"individual",
"types",
"but",
"we",
"want",
"to",
"keep",
"this",
"all",
"together",
"during",
"prototyping",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/resource.go#L476-L520 |
141,003 | containerd/continuity | resource.go | fromProto | func fromProto(b *pb.Resource) (Resource, error) {
base := &resource{
paths: b.Path,
mode: os.FileMode(b.Mode),
uid: b.Uid,
gid: b.Gid,
}
base.xattrs = make(map[string][]byte, len(b.Xattr))
for _, attr := range b.Xattr {
base.xattrs[attr.Name] = attr.Data
}
switch {
case base.Mode().IsRegular()... | go | func fromProto(b *pb.Resource) (Resource, error) {
base := &resource{
paths: b.Path,
mode: os.FileMode(b.Mode),
uid: b.Uid,
gid: b.Gid,
}
base.xattrs = make(map[string][]byte, len(b.Xattr))
for _, attr := range b.Xattr {
base.xattrs[attr.Name] = attr.Data
}
switch {
case base.Mode().IsRegular()... | [
"func",
"fromProto",
"(",
"b",
"*",
"pb",
".",
"Resource",
")",
"(",
"Resource",
",",
"error",
")",
"{",
"base",
":=",
"&",
"resource",
"{",
"paths",
":",
"b",
".",
"Path",
",",
"mode",
":",
"os",
".",
"FileMode",
"(",
"b",
".",
"Mode",
")",
",... | // fromProto converts from a protobuf Resource to a Resource interface. | [
"fromProto",
"converts",
"from",
"a",
"protobuf",
"Resource",
"to",
"a",
"Resource",
"interface",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/resource.go#L523-L557 |
141,004 | containerd/continuity | context.go | NewContextWithOptions | func NewContextWithOptions(root string, options ContextOptions) (Context, error) {
// normalize to absolute path
pathDriver := options.PathDriver
if pathDriver == nil {
pathDriver = pathdriver.LocalPathDriver
}
root = pathDriver.FromSlash(root)
root, err := pathDriver.Abs(pathDriver.Clean(root))
if err != nil... | go | func NewContextWithOptions(root string, options ContextOptions) (Context, error) {
// normalize to absolute path
pathDriver := options.PathDriver
if pathDriver == nil {
pathDriver = pathdriver.LocalPathDriver
}
root = pathDriver.FromSlash(root)
root, err := pathDriver.Abs(pathDriver.Clean(root))
if err != nil... | [
"func",
"NewContextWithOptions",
"(",
"root",
"string",
",",
"options",
"ContextOptions",
")",
"(",
"Context",
",",
"error",
")",
"{",
"// normalize to absolute path",
"pathDriver",
":=",
"options",
".",
"PathDriver",
"\n",
"if",
"pathDriver",
"==",
"nil",
"{",
... | // NewContextWithOptions returns a Context associate with the root. | [
"NewContextWithOptions",
"returns",
"a",
"Context",
"associate",
"with",
"the",
"root",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L84-L130 |
141,005 | containerd/continuity | context.go | Verify | func (c *context) Verify(resource Resource) error {
fp, err := c.fullpath(resource.Path())
if err != nil {
return err
}
fi, err := c.driver.Lstat(fp)
if err != nil {
return err
}
target, err := c.Resource(resource.Path(), fi)
if err != nil {
return err
}
if target.Path() != resource.Path() {
return... | go | func (c *context) Verify(resource Resource) error {
fp, err := c.fullpath(resource.Path())
if err != nil {
return err
}
fi, err := c.driver.Lstat(fp)
if err != nil {
return err
}
target, err := c.Resource(resource.Path(), fi)
if err != nil {
return err
}
if target.Path() != resource.Path() {
return... | [
"func",
"(",
"c",
"*",
"context",
")",
"Verify",
"(",
"resource",
"Resource",
")",
"error",
"{",
"fp",
",",
"err",
":=",
"c",
".",
"fullpath",
"(",
"resource",
".",
"Path",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n"... | // Verify the resource in the context. An error will be returned a discrepancy
// is found. | [
"Verify",
"the",
"resource",
"in",
"the",
"context",
".",
"An",
"error",
"will",
"be",
"returned",
"a",
"discrepancy",
"is",
"found",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L299-L381 |
141,006 | containerd/continuity | context.go | Walk | func (c *context) Walk(fn filepath.WalkFunc) error {
root := c.root
fi, err := c.driver.Lstat(c.root)
if err == nil && fi.Mode()&os.ModeSymlink != 0 {
root, err = c.driver.Readlink(c.root)
if err != nil {
return err
}
}
return c.pathDriver.Walk(root, func(p string, fi os.FileInfo, err error) error {
con... | go | func (c *context) Walk(fn filepath.WalkFunc) error {
root := c.root
fi, err := c.driver.Lstat(c.root)
if err == nil && fi.Mode()&os.ModeSymlink != 0 {
root, err = c.driver.Readlink(c.root)
if err != nil {
return err
}
}
return c.pathDriver.Walk(root, func(p string, fi os.FileInfo, err error) error {
con... | [
"func",
"(",
"c",
"*",
"context",
")",
"Walk",
"(",
"fn",
"filepath",
".",
"WalkFunc",
")",
"error",
"{",
"root",
":=",
"c",
".",
"root",
"\n",
"fi",
",",
"err",
":=",
"c",
".",
"driver",
".",
"Lstat",
"(",
"c",
".",
"root",
")",
"\n",
"if",
... | // Walk provides a convenience function to call filepath.Walk correctly for
// the context. Otherwise identical to filepath.Walk, the path argument is
// corrected to be contained within the context. | [
"Walk",
"provides",
"a",
"convenience",
"function",
"to",
"call",
"filepath",
".",
"Walk",
"correctly",
"for",
"the",
"context",
".",
"Otherwise",
"identical",
"to",
"filepath",
".",
"Walk",
"the",
"path",
"argument",
"is",
"corrected",
"to",
"be",
"contained"... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L590-L603 |
141,007 | containerd/continuity | context.go | fullpath | func (c *context) fullpath(p string) (string, error) {
p = c.pathDriver.Join(c.root, p)
if !strings.HasPrefix(p, c.root) {
return "", fmt.Errorf("invalid context path")
}
return p, nil
} | go | func (c *context) fullpath(p string) (string, error) {
p = c.pathDriver.Join(c.root, p)
if !strings.HasPrefix(p, c.root) {
return "", fmt.Errorf("invalid context path")
}
return p, nil
} | [
"func",
"(",
"c",
"*",
"context",
")",
"fullpath",
"(",
"p",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"p",
"=",
"c",
".",
"pathDriver",
".",
"Join",
"(",
"c",
".",
"root",
",",
"p",
")",
"\n",
"if",
"!",
"strings",
".",
"HasPrefix"... | // fullpath returns the system path for the resource, joined with the context
// root. The path p must be a part of the context. | [
"fullpath",
"returns",
"the",
"system",
"path",
"for",
"the",
"resource",
"joined",
"with",
"the",
"context",
"root",
".",
"The",
"path",
"p",
"must",
"be",
"a",
"part",
"of",
"the",
"context",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L607-L614 |
141,008 | containerd/continuity | context.go | contain | func (c *context) contain(p string) (string, error) {
return c.containWithRoot(p, c.root)
} | go | func (c *context) contain(p string) (string, error) {
return c.containWithRoot(p, c.root)
} | [
"func",
"(",
"c",
"*",
"context",
")",
"contain",
"(",
"p",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"containWithRoot",
"(",
"p",
",",
"c",
".",
"root",
")",
"\n",
"}"
] | // contain cleans and santizes the filesystem path p to be an absolute path,
// effectively relative to the context root. | [
"contain",
"cleans",
"and",
"santizes",
"the",
"filesystem",
"path",
"p",
"to",
"be",
"an",
"absolute",
"path",
"effectively",
"relative",
"to",
"the",
"context",
"root",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L618-L620 |
141,009 | containerd/continuity | context.go | containWithRoot | func (c *context) containWithRoot(p string, root string) (string, error) {
sanitized, err := c.pathDriver.Rel(root, p)
if err != nil {
return "", err
}
// ZOMBIES(stevvooe): In certain cases, we may want to remap these to a
// "containment error", so the caller can decide what to do.
return c.pathDriver.Join("... | go | func (c *context) containWithRoot(p string, root string) (string, error) {
sanitized, err := c.pathDriver.Rel(root, p)
if err != nil {
return "", err
}
// ZOMBIES(stevvooe): In certain cases, we may want to remap these to a
// "containment error", so the caller can decide what to do.
return c.pathDriver.Join("... | [
"func",
"(",
"c",
"*",
"context",
")",
"containWithRoot",
"(",
"p",
"string",
",",
"root",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"sanitized",
",",
"err",
":=",
"c",
".",
"pathDriver",
".",
"Rel",
"(",
"root",
",",
"p",
")",
"\n",
... | // containWithRoot cleans and santizes the filesystem path p to be an absolute path,
// effectively relative to the passed root. Extra care should be used when calling this
// instead of contain. This is needed for Walk, as if context root is a symlink,
// it must be evaluated prior to the Walk | [
"containWithRoot",
"cleans",
"and",
"santizes",
"the",
"filesystem",
"path",
"p",
"to",
"be",
"an",
"absolute",
"path",
"effectively",
"relative",
"to",
"the",
"passed",
"root",
".",
"Extra",
"care",
"should",
"be",
"used",
"when",
"calling",
"this",
"instead"... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L626-L635 |
141,010 | containerd/continuity | context.go | digest | func (c *context) digest(p string) (digest.Digest, error) {
f, err := c.driver.Open(c.pathDriver.Join(c.root, p))
if err != nil {
return "", err
}
defer f.Close()
return c.digester.Digest(f)
} | go | func (c *context) digest(p string) (digest.Digest, error) {
f, err := c.driver.Open(c.pathDriver.Join(c.root, p))
if err != nil {
return "", err
}
defer f.Close()
return c.digester.Digest(f)
} | [
"func",
"(",
"c",
"*",
"context",
")",
"digest",
"(",
"p",
"string",
")",
"(",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"c",
".",
"driver",
".",
"Open",
"(",
"c",
".",
"pathDriver",
".",
"Join",
"(",
"c",
".",
"... | // digest returns the digest of the file at path p, relative to the root. | [
"digest",
"returns",
"the",
"digest",
"of",
"the",
"file",
"at",
"path",
"p",
"relative",
"to",
"the",
"root",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L638-L646 |
141,011 | containerd/continuity | context.go | resolveXAttrs | func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[string][]byte, error) {
if fi.Mode().IsRegular() || fi.Mode().IsDir() {
xattrDriver, ok := c.driver.(driverpkg.XAttrDriver)
if !ok {
log.Println("xattr extraction not supported")
return nil, ErrNotSupported
}
return xattrDri... | go | func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[string][]byte, error) {
if fi.Mode().IsRegular() || fi.Mode().IsDir() {
xattrDriver, ok := c.driver.(driverpkg.XAttrDriver)
if !ok {
log.Println("xattr extraction not supported")
return nil, ErrNotSupported
}
return xattrDri... | [
"func",
"(",
"c",
"*",
"context",
")",
"resolveXAttrs",
"(",
"fp",
"string",
",",
"fi",
"os",
".",
"FileInfo",
",",
"base",
"*",
"resource",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"fi",
".",
"Mode",
... | // resolveXAttrs attempts to resolve the extended attributes for the resource
// at the path fp, which is the full path to the resource. If the resource
// cannot have xattrs, nil will be returned. | [
"resolveXAttrs",
"attempts",
"to",
"resolve",
"the",
"extended",
"attributes",
"for",
"the",
"resource",
"at",
"the",
"path",
"fp",
"which",
"is",
"the",
"full",
"path",
"to",
"the",
"resource",
".",
"If",
"the",
"resource",
"cannot",
"have",
"xattrs",
"nil"... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/context.go#L651-L673 |
141,012 | containerd/continuity | hardlinks_unix.go | newHardlinkKey | func newHardlinkKey(fi os.FileInfo) (hardlinkKey, error) {
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return hardlinkKey{}, fmt.Errorf("cannot resolve (*syscall.Stat_t) from os.FileInfo")
}
if sys.Nlink < 2 {
// NOTE(stevvooe): This is not always true for all filesystems. We
// should somehow detect this... | go | func newHardlinkKey(fi os.FileInfo) (hardlinkKey, error) {
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return hardlinkKey{}, fmt.Errorf("cannot resolve (*syscall.Stat_t) from os.FileInfo")
}
if sys.Nlink < 2 {
// NOTE(stevvooe): This is not always true for all filesystems. We
// should somehow detect this... | [
"func",
"newHardlinkKey",
"(",
"fi",
"os",
".",
"FileInfo",
")",
"(",
"hardlinkKey",
",",
"error",
")",
"{",
"sys",
",",
"ok",
":=",
"fi",
".",
"Sys",
"(",
")",
".",
"(",
"*",
"syscall",
".",
"Stat_t",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
... | // newHardlinkKey returns a hardlink key for the provided file info. If the
// resource does not represent a possible hardlink, errNotAHardLink will be
// returned. | [
"newHardlinkKey",
"returns",
"a",
"hardlink",
"key",
"for",
"the",
"provided",
"file",
"info",
".",
"If",
"the",
"resource",
"does",
"not",
"represent",
"a",
"possible",
"hardlink",
"errNotAHardLink",
"will",
"be",
"returned",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/hardlinks_unix.go#L37-L52 |
141,013 | containerd/continuity | fs/diff_unix.go | compareSysStat | func compareSysStat(s1, s2 interface{}) (bool, error) {
ls1, ok := s1.(*syscall.Stat_t)
if !ok {
return false, nil
}
ls2, ok := s2.(*syscall.Stat_t)
if !ok {
return false, nil
}
return ls1.Mode == ls2.Mode && ls1.Uid == ls2.Uid && ls1.Gid == ls2.Gid && ls1.Rdev == ls2.Rdev, nil
} | go | func compareSysStat(s1, s2 interface{}) (bool, error) {
ls1, ok := s1.(*syscall.Stat_t)
if !ok {
return false, nil
}
ls2, ok := s2.(*syscall.Stat_t)
if !ok {
return false, nil
}
return ls1.Mode == ls2.Mode && ls1.Uid == ls2.Uid && ls1.Gid == ls2.Gid && ls1.Rdev == ls2.Rdev, nil
} | [
"func",
"compareSysStat",
"(",
"s1",
",",
"s2",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"ls1",
",",
"ok",
":=",
"s1",
".",
"(",
"*",
"syscall",
".",
"Stat_t",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
",",
"ni... | // compareSysStat returns whether the stats are equivalent,
// whether the files are considered the same file, and
// an error | [
"compareSysStat",
"returns",
"whether",
"the",
"stats",
"are",
"equivalent",
"whether",
"the",
"files",
"are",
"considered",
"the",
"same",
"file",
"and",
"an",
"error"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/diff_unix.go#L43-L54 |
141,014 | containerd/continuity | manifest.go | BuildManifest | func BuildManifest(ctx Context) (*Manifest, error) {
resourcesByPath := map[string]Resource{}
hardlinks := newHardlinkManager()
if err := ctx.Walk(func(p string, fi os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error walking %s: %v", p, err)
}
if p == string(os.PathSeparator) {
// ... | go | func BuildManifest(ctx Context) (*Manifest, error) {
resourcesByPath := map[string]Resource{}
hardlinks := newHardlinkManager()
if err := ctx.Walk(func(p string, fi os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error walking %s: %v", p, err)
}
if p == string(os.PathSeparator) {
// ... | [
"func",
"BuildManifest",
"(",
"ctx",
"Context",
")",
"(",
"*",
"Manifest",
",",
"error",
")",
"{",
"resourcesByPath",
":=",
"map",
"[",
"string",
"]",
"Resource",
"{",
"}",
"\n",
"hardlinks",
":=",
"newHardlinkManager",
"(",
")",
"\n\n",
"if",
"err",
":=... | // BuildManifest creates the manifest for the given context | [
"BuildManifest",
"creates",
"the",
"manifest",
"for",
"the",
"given",
"context"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/manifest.go#L76-L136 |
141,015 | containerd/continuity | manifest.go | VerifyManifest | func VerifyManifest(ctx Context, manifest *Manifest) error {
for _, resource := range manifest.Resources {
if err := ctx.Verify(resource); err != nil {
return err
}
}
return nil
} | go | func VerifyManifest(ctx Context, manifest *Manifest) error {
for _, resource := range manifest.Resources {
if err := ctx.Verify(resource); err != nil {
return err
}
}
return nil
} | [
"func",
"VerifyManifest",
"(",
"ctx",
"Context",
",",
"manifest",
"*",
"Manifest",
")",
"error",
"{",
"for",
"_",
",",
"resource",
":=",
"range",
"manifest",
".",
"Resources",
"{",
"if",
"err",
":=",
"ctx",
".",
"Verify",
"(",
"resource",
")",
";",
"er... | // VerifyManifest verifies all the resources in a manifest
// against files from the given context. | [
"VerifyManifest",
"verifies",
"all",
"the",
"resources",
"in",
"a",
"manifest",
"against",
"files",
"from",
"the",
"given",
"context",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/manifest.go#L140-L148 |
141,016 | containerd/continuity | manifest.go | ApplyManifest | func ApplyManifest(ctx Context, manifest *Manifest) error {
for _, resource := range manifest.Resources {
if err := ctx.Apply(resource); err != nil {
return err
}
}
return nil
} | go | func ApplyManifest(ctx Context, manifest *Manifest) error {
for _, resource := range manifest.Resources {
if err := ctx.Apply(resource); err != nil {
return err
}
}
return nil
} | [
"func",
"ApplyManifest",
"(",
"ctx",
"Context",
",",
"manifest",
"*",
"Manifest",
")",
"error",
"{",
"for",
"_",
",",
"resource",
":=",
"range",
"manifest",
".",
"Resources",
"{",
"if",
"err",
":=",
"ctx",
".",
"Apply",
"(",
"resource",
")",
";",
"err"... | // ApplyManifest applies on the resources in a manifest to
// the given context. | [
"ApplyManifest",
"applies",
"on",
"the",
"resources",
"in",
"a",
"manifest",
"to",
"the",
"given",
"context",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/manifest.go#L152-L160 |
141,017 | containerd/continuity | sysx/xattr.go | Removexattr | func Removexattr(path string, attr string) (err error) {
return unix.Removexattr(path, attr)
} | go | func Removexattr(path string, attr string) (err error) {
return unix.Removexattr(path, attr)
} | [
"func",
"Removexattr",
"(",
"path",
"string",
",",
"attr",
"string",
")",
"(",
"err",
"error",
")",
"{",
"return",
"unix",
".",
"Removexattr",
"(",
"path",
",",
"attr",
")",
"\n",
"}"
] | // Removexattr calls syscall removexattr | [
"Removexattr",
"calls",
"syscall",
"removexattr"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/sysx/xattr.go#L35-L37 |
141,018 | containerd/continuity | sysx/xattr.go | Getxattr | func Getxattr(path, attr string) ([]byte, error) {
return getxattrAll(path, attr, unix.Getxattr)
} | go | func Getxattr(path, attr string) ([]byte, error) {
return getxattrAll(path, attr, unix.Getxattr)
} | [
"func",
"Getxattr",
"(",
"path",
",",
"attr",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"getxattrAll",
"(",
"path",
",",
"attr",
",",
"unix",
".",
"Getxattr",
")",
"\n",
"}"
] | // Getxattr calls syscall getxattr | [
"Getxattr",
"calls",
"syscall",
"getxattr"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/sysx/xattr.go#L45-L47 |
141,019 | containerd/continuity | sysx/xattr.go | LRemovexattr | func LRemovexattr(path string, attr string) (err error) {
return unix.Lremovexattr(path, attr)
} | go | func LRemovexattr(path string, attr string) (err error) {
return unix.Lremovexattr(path, attr)
} | [
"func",
"LRemovexattr",
"(",
"path",
"string",
",",
"attr",
"string",
")",
"(",
"err",
"error",
")",
"{",
"return",
"unix",
".",
"Lremovexattr",
"(",
"path",
",",
"attr",
")",
"\n",
"}"
] | // LRemovexattr removes an xattr, not following symlinks | [
"LRemovexattr",
"removes",
"an",
"xattr",
"not",
"following",
"symlinks"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/sysx/xattr.go#L55-L57 |
141,020 | containerd/continuity | sysx/xattr.go | LGetxattr | func LGetxattr(path, attr string) ([]byte, error) {
return getxattrAll(path, attr, unix.Lgetxattr)
} | go | func LGetxattr(path, attr string) ([]byte, error) {
return getxattrAll(path, attr, unix.Lgetxattr)
} | [
"func",
"LGetxattr",
"(",
"path",
",",
"attr",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"getxattrAll",
"(",
"path",
",",
"attr",
",",
"unix",
".",
"Lgetxattr",
")",
"\n",
"}"
] | // LGetxattr gets an xattr, not following symlinks | [
"LGetxattr",
"gets",
"an",
"xattr",
"not",
"following",
"symlinks"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/sysx/xattr.go#L65-L67 |
141,021 | containerd/continuity | devices/devices_unix.go | Mknod | func Mknod(p string, mode os.FileMode, maj, min int) error {
var (
m = syscallMode(mode.Perm())
dev uint64
)
if mode&os.ModeDevice != 0 {
dev = unix.Mkdev(uint32(maj), uint32(min))
if mode&os.ModeCharDevice != 0 {
m |= unix.S_IFCHR
} else {
m |= unix.S_IFBLK
}
} else if mode&os.ModeNamedPipe !... | go | func Mknod(p string, mode os.FileMode, maj, min int) error {
var (
m = syscallMode(mode.Perm())
dev uint64
)
if mode&os.ModeDevice != 0 {
dev = unix.Mkdev(uint32(maj), uint32(min))
if mode&os.ModeCharDevice != 0 {
m |= unix.S_IFCHR
} else {
m |= unix.S_IFBLK
}
} else if mode&os.ModeNamedPipe !... | [
"func",
"Mknod",
"(",
"p",
"string",
",",
"mode",
"os",
".",
"FileMode",
",",
"maj",
",",
"min",
"int",
")",
"error",
"{",
"var",
"(",
"m",
"=",
"syscallMode",
"(",
"mode",
".",
"Perm",
"(",
")",
")",
"\n",
"dev",
"uint64",
"\n",
")",
"\n\n",
"... | // mknod provides a shortcut for syscall.Mknod | [
"mknod",
"provides",
"a",
"shortcut",
"for",
"syscall",
".",
"Mknod"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/devices/devices_unix.go#L40-L59 |
141,022 | containerd/continuity | devices/devices_unix.go | syscallMode | func syscallMode(i os.FileMode) (o uint32) {
o |= uint32(i.Perm())
if i&os.ModeSetuid != 0 {
o |= unix.S_ISUID
}
if i&os.ModeSetgid != 0 {
o |= unix.S_ISGID
}
if i&os.ModeSticky != 0 {
o |= unix.S_ISVTX
}
return
} | go | func syscallMode(i os.FileMode) (o uint32) {
o |= uint32(i.Perm())
if i&os.ModeSetuid != 0 {
o |= unix.S_ISUID
}
if i&os.ModeSetgid != 0 {
o |= unix.S_ISGID
}
if i&os.ModeSticky != 0 {
o |= unix.S_ISVTX
}
return
} | [
"func",
"syscallMode",
"(",
"i",
"os",
".",
"FileMode",
")",
"(",
"o",
"uint32",
")",
"{",
"o",
"|=",
"uint32",
"(",
"i",
".",
"Perm",
"(",
")",
")",
"\n",
"if",
"i",
"&",
"os",
".",
"ModeSetuid",
"!=",
"0",
"{",
"o",
"|=",
"unix",
".",
"S_IS... | // syscallMode returns the syscall-specific mode bits from Go's portable mode bits. | [
"syscallMode",
"returns",
"the",
"syscall",
"-",
"specific",
"mode",
"bits",
"from",
"Go",
"s",
"portable",
"mode",
"bits",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/devices/devices_unix.go#L62-L74 |
141,023 | containerd/continuity | commands/main.go | readManifestFile | func readManifestFile(path string) (*pb.Manifest, error) {
p, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var bm pb.Manifest
if err := proto.Unmarshal(p, &bm); err != nil {
return nil, err
}
return &bm, nil
} | go | func readManifestFile(path string) (*pb.Manifest, error) {
p, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var bm pb.Manifest
if err := proto.Unmarshal(p, &bm); err != nil {
return nil, err
}
return &bm, nil
} | [
"func",
"readManifestFile",
"(",
"path",
"string",
")",
"(",
"*",
"pb",
".",
"Manifest",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // readManifestFile reads the manifest from the given path. This should
// probably be provided by the continuity library. | [
"readManifestFile",
"reads",
"the",
"manifest",
"from",
"the",
"given",
"path",
".",
"This",
"should",
"probably",
"be",
"provided",
"by",
"the",
"continuity",
"library",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/commands/main.go#L80-L93 |
141,024 | containerd/continuity | commands/main.go | newTabwriter | func newTabwriter(w io.Writer) *tabwriter.Writer {
return tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
} | go | func newTabwriter(w io.Writer) *tabwriter.Writer {
return tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
} | [
"func",
"newTabwriter",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"tabwriter",
".",
"Writer",
"{",
"return",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"2",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"}"
] | // newTabwriter provides a common tabwriter with defaults. | [
"newTabwriter",
"provides",
"a",
"common",
"tabwriter",
"with",
"defaults",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/commands/main.go#L96-L98 |
141,025 | containerd/continuity | fs/copy.go | WithAllowXAttrErrors | func WithAllowXAttrErrors() CopyDirOpt {
xeh := func(dst, src, xattrKey string, err error) error {
return nil
}
return WithXAttrErrorHandler(xeh)
} | go | func WithAllowXAttrErrors() CopyDirOpt {
xeh := func(dst, src, xattrKey string, err error) error {
return nil
}
return WithXAttrErrorHandler(xeh)
} | [
"func",
"WithAllowXAttrErrors",
"(",
")",
"CopyDirOpt",
"{",
"xeh",
":=",
"func",
"(",
"dst",
",",
"src",
",",
"xattrKey",
"string",
",",
"err",
"error",
")",
"error",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"WithXAttrErrorHandler",
"(",
"xeh",
... | // WithAllowXAttrErrors allows ignoring xattr errors. | [
"WithAllowXAttrErrors",
"allows",
"ignoring",
"xattr",
"errors",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/copy.go#L57-L62 |
141,026 | containerd/continuity | fs/copy.go | CopyDir | func CopyDir(dst, src string, opts ...CopyDirOpt) error {
var o copyDirOpts
for _, opt := range opts {
if err := opt(&o); err != nil {
return err
}
}
inodes := map[uint64]string{}
return copyDirectory(dst, src, inodes, &o)
} | go | func CopyDir(dst, src string, opts ...CopyDirOpt) error {
var o copyDirOpts
for _, opt := range opts {
if err := opt(&o); err != nil {
return err
}
}
inodes := map[uint64]string{}
return copyDirectory(dst, src, inodes, &o)
} | [
"func",
"CopyDir",
"(",
"dst",
",",
"src",
"string",
",",
"opts",
"...",
"CopyDirOpt",
")",
"error",
"{",
"var",
"o",
"copyDirOpts",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"if",
"err",
":=",
"opt",
"(",
"&",
"o",
")",
";",
"err... | // CopyDir copies the directory from src to dst.
// Most efficient copy of files is attempted. | [
"CopyDir",
"copies",
"the",
"directory",
"from",
"src",
"to",
"dst",
".",
"Most",
"efficient",
"copy",
"of",
"files",
"is",
"attempted",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/copy.go#L66-L75 |
141,027 | containerd/continuity | fs/copy.go | CopyFile | func CopyFile(target, source string) error {
src, err := os.Open(source)
if err != nil {
return errors.Wrapf(err, "failed to open source %s", source)
}
defer src.Close()
tgt, err := os.Create(target)
if err != nil {
return errors.Wrapf(err, "failed to open target %s", target)
}
defer tgt.Close()
return co... | go | func CopyFile(target, source string) error {
src, err := os.Open(source)
if err != nil {
return errors.Wrapf(err, "failed to open source %s", source)
}
defer src.Close()
tgt, err := os.Create(target)
if err != nil {
return errors.Wrapf(err, "failed to open target %s", target)
}
defer tgt.Close()
return co... | [
"func",
"CopyFile",
"(",
"target",
",",
"source",
"string",
")",
"error",
"{",
"src",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
","... | // CopyFile copies the source file to the target.
// The most efficient means of copying is used for the platform. | [
"CopyFile",
"copies",
"the",
"source",
"file",
"to",
"the",
"target",
".",
"The",
"most",
"efficient",
"means",
"of",
"copying",
"is",
"used",
"for",
"the",
"platform",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/copy.go#L159-L172 |
141,028 | containerd/continuity | ioutils.go | AtomicWriteFile | func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
buf := bytes.NewBuffer(data)
return atomicWriteFile(filename, buf, int64(len(data)), perm)
} | go | func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
buf := bytes.NewBuffer(data)
return atomicWriteFile(filename, buf, int64(len(data)), perm)
} | [
"func",
"AtomicWriteFile",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"data",
")",
"\n",
"return",
"atomicWriteFile",
"(",
"filename",
",",... | // AtomicWriteFile atomically writes data to a file by first writing to a
// temp file and calling rename. | [
"AtomicWriteFile",
"atomically",
"writes",
"data",
"to",
"a",
"file",
"by",
"first",
"writing",
"to",
"a",
"temp",
"file",
"and",
"calling",
"rename",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/ioutils.go#L29-L32 |
141,029 | containerd/continuity | ioutils.go | atomicWriteFile | func atomicWriteFile(filename string, r io.Reader, dataSize int64, perm os.FileMode) error {
f, err := ioutil.TempFile(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
if err != nil {
return err
}
err = os.Chmod(f.Name(), perm)
if err != nil {
f.Close()
return err
}
n, err := io.Copy(f, r)
if err ... | go | func atomicWriteFile(filename string, r io.Reader, dataSize int64, perm os.FileMode) error {
f, err := ioutil.TempFile(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
if err != nil {
return err
}
err = os.Chmod(f.Name(), perm)
if err != nil {
f.Close()
return err
}
n, err := io.Copy(f, r)
if err ... | [
"func",
"atomicWriteFile",
"(",
"filename",
"string",
",",
"r",
"io",
".",
"Reader",
",",
"dataSize",
"int64",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"f",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"filepath",
".",
"Dir",
"(",
... | // atomicWriteFile writes data to a file by first writing to a temp
// file and calling rename. | [
"atomicWriteFile",
"writes",
"data",
"to",
"a",
"file",
"by",
"first",
"writing",
"to",
"a",
"temp",
"file",
"and",
"calling",
"rename",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/ioutils.go#L36-L63 |
141,030 | containerd/continuity | continuityfs/provider.go | NewFSFileContentProvider | func NewFSFileContentProvider(root string, driver driver.Driver) FileContentProvider {
return &fsContentProvider{
root: root,
driver: driver,
}
} | go | func NewFSFileContentProvider(root string, driver driver.Driver) FileContentProvider {
return &fsContentProvider{
root: root,
driver: driver,
}
} | [
"func",
"NewFSFileContentProvider",
"(",
"root",
"string",
",",
"driver",
"driver",
".",
"Driver",
")",
"FileContentProvider",
"{",
"return",
"&",
"fsContentProvider",
"{",
"root",
":",
"root",
",",
"driver",
":",
"driver",
",",
"}",
"\n",
"}"
] | // NewFSFileContentProvider creates a new content provider which
// gets content from a directory on an existing filesystem based
// on the resource path. | [
"NewFSFileContentProvider",
"creates",
"a",
"new",
"content",
"provider",
"which",
"gets",
"content",
"from",
"a",
"directory",
"on",
"an",
"existing",
"filesystem",
"based",
"on",
"the",
"resource",
"path",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/continuityfs/provider.go#L46-L51 |
141,031 | containerd/continuity | driver/utils.go | ReadFile | func ReadFile(r Driver, filename string) ([]byte, error) {
f, err := r.Open(filename)
if err != nil {
return nil, err
}
defer f.Close()
data, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
return data, nil
} | go | func ReadFile(r Driver, filename string) ([]byte, error) {
f, err := r.Open(filename)
if err != nil {
return nil, err
}
defer f.Close()
data, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
return data, nil
} | [
"func",
"ReadFile",
"(",
"r",
"Driver",
",",
"filename",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"r",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // ReadFile works the same as ioutil.ReadFile with the Driver abstraction | [
"ReadFile",
"works",
"the",
"same",
"as",
"ioutil",
".",
"ReadFile",
"with",
"the",
"Driver",
"abstraction"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/utils.go#L27-L40 |
141,032 | containerd/continuity | driver/utils.go | ReadDir | func ReadDir(r Driver, dirname string) ([]os.FileInfo, error) {
f, err := r.Open(dirname)
if err != nil {
return nil, err
}
defer f.Close()
dirs, err := f.Readdir(-1)
if err != nil {
return nil, err
}
sort.Sort(fileInfos(dirs))
return dirs, nil
} | go | func ReadDir(r Driver, dirname string) ([]os.FileInfo, error) {
f, err := r.Open(dirname)
if err != nil {
return nil, err
}
defer f.Close()
dirs, err := f.Readdir(-1)
if err != nil {
return nil, err
}
sort.Sort(fileInfos(dirs))
return dirs, nil
} | [
"func",
"ReadDir",
"(",
"r",
"Driver",
",",
"dirname",
"string",
")",
"(",
"[",
"]",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"r",
".",
"Open",
"(",
"dirname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ni... | // ReadDir works the same as ioutil.ReadDir with the Driver abstraction | [
"ReadDir",
"works",
"the",
"same",
"as",
"ioutil",
".",
"ReadDir",
"with",
"the",
"Driver",
"abstraction"
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/driver/utils.go#L61-L75 |
141,033 | containerd/continuity | fs/hardlink.go | getLinkSource | func getLinkSource(name string, fi os.FileInfo, inodes map[uint64]string) (string, error) {
inode, isHardlink := getLinkInfo(fi)
if !isHardlink {
return "", nil
}
path, ok := inodes[inode]
if !ok {
inodes[inode] = name
}
return path, nil
} | go | func getLinkSource(name string, fi os.FileInfo, inodes map[uint64]string) (string, error) {
inode, isHardlink := getLinkInfo(fi)
if !isHardlink {
return "", nil
}
path, ok := inodes[inode]
if !ok {
inodes[inode] = name
}
return path, nil
} | [
"func",
"getLinkSource",
"(",
"name",
"string",
",",
"fi",
"os",
".",
"FileInfo",
",",
"inodes",
"map",
"[",
"uint64",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"inode",
",",
"isHardlink",
":=",
"getLinkInfo",
"(",
"fi",
")",
"\n",
"... | // getLinkSource returns a path for the given name and
// file info to its link source in the provided inode
// map. If the given file name is not in the map and
// has other links, it is added to the inode map
// to be a source for other link locations. | [
"getLinkSource",
"returns",
"a",
"path",
"for",
"the",
"given",
"name",
"and",
"file",
"info",
"to",
"its",
"link",
"source",
"in",
"the",
"provided",
"inode",
"map",
".",
"If",
"the",
"given",
"file",
"name",
"is",
"not",
"in",
"the",
"map",
"and",
"h... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/hardlink.go#L32-L43 |
141,034 | containerd/continuity | fs/diff.go | Changes | func Changes(ctx context.Context, a, b string, changeFn ChangeFunc) error {
if a == "" {
logrus.Debugf("Using single walk diff for %s", b)
return addDirChanges(ctx, changeFn, b)
} else if diffOptions := detectDirDiff(b, a); diffOptions != nil {
logrus.Debugf("Using single walk diff for %s from %s", diffOptions.... | go | func Changes(ctx context.Context, a, b string, changeFn ChangeFunc) error {
if a == "" {
logrus.Debugf("Using single walk diff for %s", b)
return addDirChanges(ctx, changeFn, b)
} else if diffOptions := detectDirDiff(b, a); diffOptions != nil {
logrus.Debugf("Using single walk diff for %s from %s", diffOptions.... | [
"func",
"Changes",
"(",
"ctx",
"context",
".",
"Context",
",",
"a",
",",
"b",
"string",
",",
"changeFn",
"ChangeFunc",
")",
"error",
"{",
"if",
"a",
"==",
"\"",
"\"",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"b",
")",
"\n",
"return",
"... | // Changes computes changes between two directories calling the
// given change function for each computed change. The first
// directory is intended to the base directory and second
// directory the changed directory.
//
// The change callback is called by the order of path names and
// should be appliable in that ord... | [
"Changes",
"computes",
"changes",
"between",
"two",
"directories",
"calling",
"the",
"given",
"change",
"function",
"for",
"each",
"computed",
"change",
".",
"The",
"first",
"directory",
"is",
"intended",
"to",
"the",
"base",
"directory",
"and",
"second",
"direc... | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/diff.go#L101-L112 |
141,035 | containerd/continuity | fs/diff.go | diffDirChanges | func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *diffDirOptions) error {
changedDirs := make(map[string]struct{})
return filepath.Walk(o.diffDir, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
// Rebase path
path, err = filepath.Rel(o.diffDir,... | go | func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *diffDirOptions) error {
changedDirs := make(map[string]struct{})
return filepath.Walk(o.diffDir, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
// Rebase path
path, err = filepath.Rel(o.diffDir,... | [
"func",
"diffDirChanges",
"(",
"ctx",
"context",
".",
"Context",
",",
"changeFn",
"ChangeFunc",
",",
"base",
"string",
",",
"o",
"*",
"diffDirOptions",
")",
"error",
"{",
"changedDirs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")... | // diffDirChanges walks the diff directory and compares changes against the base. | [
"diffDirChanges",
"walks",
"the",
"diff",
"directory",
"and",
"compares",
"changes",
"against",
"the",
"base",
"."
] | aaeac12a7ffcd198ae25440a9dff125c2e2703a7 | https://github.com/containerd/continuity/blob/aaeac12a7ffcd198ae25440a9dff125c2e2703a7/fs/diff.go#L146-L231 |
141,036 | emicklei/go-restful-swagger12 | swagger_webservice.go | composeDeclaration | func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix string) ApiDeclaration {
decl := ApiDeclaration{
SwaggerVersion: swaggerVersion,
BasePath: sws.config.WebServicesUrl,
ResourcePath: pathPrefix,
Models: ModelList{},
ApiVersion: ws.Version()}
// collect any p... | go | func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix string) ApiDeclaration {
decl := ApiDeclaration{
SwaggerVersion: swaggerVersion,
BasePath: sws.config.WebServicesUrl,
ResourcePath: pathPrefix,
Models: ModelList{},
ApiVersion: ws.Version()}
// collect any p... | [
"func",
"(",
"sws",
"SwaggerService",
")",
"composeDeclaration",
"(",
"ws",
"*",
"restful",
".",
"WebService",
",",
"pathPrefix",
"string",
")",
"ApiDeclaration",
"{",
"decl",
":=",
"ApiDeclaration",
"{",
"SwaggerVersion",
":",
"swaggerVersion",
",",
"BasePath",
... | // composeDeclaration uses all routes and parameters to create a ApiDeclaration | [
"composeDeclaration",
"uses",
"all",
"routes",
"and",
"parameters",
"to",
"create",
"a",
"ApiDeclaration"
] | 7524189396c68dc4b04d53852f9edc00f816b123 | https://github.com/emicklei/go-restful-swagger12/blob/7524189396c68dc4b04d53852f9edc00f816b123/swagger_webservice.go#L212-L267 |
141,037 | emicklei/go-restful-swagger12 | swagger_webservice.go | addModelsFromRouteTo | func (sws SwaggerService) addModelsFromRouteTo(operation *Operation, route restful.Route, decl *ApiDeclaration) {
if route.ReadSample != nil {
sws.addModelFromSampleTo(operation, false, route.ReadSample, &decl.Models)
}
if route.WriteSample != nil {
sws.addModelFromSampleTo(operation, true, route.WriteSample, &d... | go | func (sws SwaggerService) addModelsFromRouteTo(operation *Operation, route restful.Route, decl *ApiDeclaration) {
if route.ReadSample != nil {
sws.addModelFromSampleTo(operation, false, route.ReadSample, &decl.Models)
}
if route.WriteSample != nil {
sws.addModelFromSampleTo(operation, true, route.WriteSample, &d... | [
"func",
"(",
"sws",
"SwaggerService",
")",
"addModelsFromRouteTo",
"(",
"operation",
"*",
"Operation",
",",
"route",
"restful",
".",
"Route",
",",
"decl",
"*",
"ApiDeclaration",
")",
"{",
"if",
"route",
".",
"ReadSample",
"!=",
"nil",
"{",
"sws",
".",
"add... | // addModelsFromRoute takes any read or write sample from the Route and creates a Swagger model from it. | [
"addModelsFromRoute",
"takes",
"any",
"read",
"or",
"write",
"sample",
"from",
"the",
"Route",
"and",
"creates",
"a",
"Swagger",
"model",
"from",
"it",
"."
] | 7524189396c68dc4b04d53852f9edc00f816b123 | https://github.com/emicklei/go-restful-swagger12/blob/7524189396c68dc4b04d53852f9edc00f816b123/swagger_webservice.go#L309-L316 |
141,038 | emicklei/go-restful-swagger12 | swagger_webservice.go | composeRootPath | func composeRootPath(req *restful.Request) string {
path := "/" + req.PathParameter("a")
b := req.PathParameter("b")
if b == "" {
return path
}
path = path + "/" + b
c := req.PathParameter("c")
if c == "" {
return path
}
path = path + "/" + c
d := req.PathParameter("d")
if d == "" {
return path
}
pat... | go | func composeRootPath(req *restful.Request) string {
path := "/" + req.PathParameter("a")
b := req.PathParameter("b")
if b == "" {
return path
}
path = path + "/" + b
c := req.PathParameter("c")
if c == "" {
return path
}
path = path + "/" + c
d := req.PathParameter("d")
if d == "" {
return path
}
pat... | [
"func",
"composeRootPath",
"(",
"req",
"*",
"restful",
".",
"Request",
")",
"string",
"{",
"path",
":=",
"\"",
"\"",
"+",
"req",
".",
"PathParameter",
"(",
"\"",
"\"",
")",
"\n",
"b",
":=",
"req",
".",
"PathParameter",
"(",
"\"",
"\"",
")",
"\n",
"... | // Between 1..7 path parameters is supported | [
"Between",
"1",
"..",
"7",
"path",
"parameters",
"is",
"supported"
] | 7524189396c68dc4b04d53852f9edc00f816b123 | https://github.com/emicklei/go-restful-swagger12/blob/7524189396c68dc4b04d53852f9edc00f816b123/swagger_webservice.go#L360-L392 |
141,039 | emicklei/go-restful-swagger12 | model_builder.go | addModelFrom | func (b modelBuilder) addModelFrom(sample interface{}) {
if modelOrNil := b.addModel(reflect.TypeOf(sample), ""); modelOrNil != nil {
// allow customizations
if buildable, ok := sample.(ModelBuildable); ok {
modelOrNil = buildable.PostBuildModel(modelOrNil)
b.Models.Put(modelOrNil.Id, *modelOrNil)
}
}
} | go | func (b modelBuilder) addModelFrom(sample interface{}) {
if modelOrNil := b.addModel(reflect.TypeOf(sample), ""); modelOrNil != nil {
// allow customizations
if buildable, ok := sample.(ModelBuildable); ok {
modelOrNil = buildable.PostBuildModel(modelOrNil)
b.Models.Put(modelOrNil.Id, *modelOrNil)
}
}
} | [
"func",
"(",
"b",
"modelBuilder",
")",
"addModelFrom",
"(",
"sample",
"interface",
"{",
"}",
")",
"{",
"if",
"modelOrNil",
":=",
"b",
".",
"addModel",
"(",
"reflect",
".",
"TypeOf",
"(",
"sample",
")",
",",
"\"",
"\"",
")",
";",
"modelOrNil",
"!=",
"... | // addModelFrom creates and adds a Model to the builder and detects and calls
// the post build hook for customizations | [
"addModelFrom",
"creates",
"and",
"adds",
"a",
"Model",
"to",
"the",
"builder",
"and",
"detects",
"and",
"calls",
"the",
"post",
"build",
"hook",
"for",
"customizations"
] | 7524189396c68dc4b04d53852f9edc00f816b123 | https://github.com/emicklei/go-restful-swagger12/blob/7524189396c68dc4b04d53852f9edc00f816b123/model_builder.go#L35-L43 |
141,040 | emicklei/go-restful-swagger12 | model_builder.go | jsonNameOfField | func (b modelBuilder) jsonNameOfField(field reflect.StructField) string {
if jsonTag := field.Tag.Get("json"); jsonTag != "" {
s := strings.Split(jsonTag, ",")
if s[0] == "-" {
// empty name signals skip property
return ""
} else if s[0] != "" {
return s[0]
}
}
return field.Name
} | go | func (b modelBuilder) jsonNameOfField(field reflect.StructField) string {
if jsonTag := field.Tag.Get("json"); jsonTag != "" {
s := strings.Split(jsonTag, ",")
if s[0] == "-" {
// empty name signals skip property
return ""
} else if s[0] != "" {
return s[0]
}
}
return field.Name
} | [
"func",
"(",
"b",
"modelBuilder",
")",
"jsonNameOfField",
"(",
"field",
"reflect",
".",
"StructField",
")",
"string",
"{",
"if",
"jsonTag",
":=",
"field",
".",
"Tag",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"jsonTag",
"!=",
"\"",
"\"",
"{",
"s",
":=",... | // jsonNameOfField returns the name of the field as it should appear in JSON format
// An empty string indicates that this field is not part of the JSON representation | [
"jsonNameOfField",
"returns",
"the",
"name",
"of",
"the",
"field",
"as",
"it",
"should",
"appear",
"in",
"JSON",
"format",
"An",
"empty",
"string",
"indicates",
"that",
"this",
"field",
"is",
"not",
"part",
"of",
"the",
"JSON",
"representation"
] | 7524189396c68dc4b04d53852f9edc00f816b123 | https://github.com/emicklei/go-restful-swagger12/blob/7524189396c68dc4b04d53852f9edc00f816b123/model_builder.go#L403-L414 |
141,041 | ian-kent/envconf | envconf.go | FromEnvP | func FromEnvP(env string, value interface{}) interface{} {
ev, err := FromEnv(env, value)
if err != nil {
panic(err)
}
return ev
} | go | func FromEnvP(env string, value interface{}) interface{} {
ev, err := FromEnv(env, value)
if err != nil {
panic(err)
}
return ev
} | [
"func",
"FromEnvP",
"(",
"env",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"ev",
",",
"err",
":=",
"FromEnv",
"(",
"env",
",",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",... | // FromEnvP is the same as FromEnv, but panics on error | [
"FromEnvP",
"is",
"the",
"same",
"as",
"FromEnv",
"but",
"panics",
"on",
"error"
] | c19809918c02ab33dc8635d68c77649313185275 | https://github.com/ian-kent/envconf/blob/c19809918c02ab33dc8635d68c77649313185275/envconf.go#L16-L22 |
141,042 | ian-kent/envconf | envconf.go | FromEnv | func FromEnv(env string, value interface{}) (interface{}, error) {
envs := os.Environ()
found := false
for _, e := range envs {
if strings.HasPrefix(e, env+"=") {
found = true
break
}
}
if !found {
return value, nil
}
ev := os.Getenv(env)
switch value.(type) {
case string:
vt := interface{}(ev... | go | func FromEnv(env string, value interface{}) (interface{}, error) {
envs := os.Environ()
found := false
for _, e := range envs {
if strings.HasPrefix(e, env+"=") {
found = true
break
}
}
if !found {
return value, nil
}
ev := os.Getenv(env)
switch value.(type) {
case string:
vt := interface{}(ev... | [
"func",
"FromEnv",
"(",
"env",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"envs",
":=",
"os",
".",
"Environ",
"(",
")",
"\n",
"found",
":=",
"false",
"\n",
"for",
"_",
",",
"e",
":=",
... | // FromEnv returns the environment variable specified by env
// using the type of value | [
"FromEnv",
"returns",
"the",
"environment",
"variable",
"specified",
"by",
"env",
"using",
"the",
"type",
"of",
"value"
] | c19809918c02ab33dc8635d68c77649313185275 | https://github.com/ian-kent/envconf/blob/c19809918c02ab33dc8635d68c77649313185275/envconf.go#L26-L88 |
141,043 | weaveworks/promrus | promrus.go | NewPrometheusHook | func NewPrometheusHook() (*PrometheusHook, error) {
counterVec := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "log_messages_total",
Help: "Total number of log messages.",
}, []string{"level"})
// Initialise counters for all supported levels:
for _, level := range supportedLevels {
counterVec.WithLa... | go | func NewPrometheusHook() (*PrometheusHook, error) {
counterVec := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "log_messages_total",
Help: "Total number of log messages.",
}, []string{"level"})
// Initialise counters for all supported levels:
for _, level := range supportedLevels {
counterVec.WithLa... | [
"func",
"NewPrometheusHook",
"(",
")",
"(",
"*",
"PrometheusHook",
",",
"error",
")",
"{",
"counterVec",
":=",
"prometheus",
".",
"NewCounterVec",
"(",
"prometheus",
".",
"CounterOpts",
"{",
"Name",
":",
"\"",
"\"",
",",
"Help",
":",
"\"",
"\"",
",",
"}"... | // NewPrometheusHook creates a new instance of PrometheusHook which exposes Prometheus counters for various log levels.
// Contrarily to MustNewPrometheusHook, it returns an error to the caller in case of issue.
// Use NewPrometheusHook if you want more control. Use MustNewPrometheusHook if you want a less verbose hook... | [
"NewPrometheusHook",
"creates",
"a",
"new",
"instance",
"of",
"PrometheusHook",
"which",
"exposes",
"Prometheus",
"counters",
"for",
"various",
"log",
"levels",
".",
"Contrarily",
"to",
"MustNewPrometheusHook",
"it",
"returns",
"an",
"error",
"to",
"the",
"caller",
... | 5c7f70ad4f3233037d079b8b053fc6ceaa20697b | https://github.com/weaveworks/promrus/blob/5c7f70ad4f3233037d079b8b053fc6ceaa20697b/promrus.go#L18-L38 |
141,044 | weaveworks/promrus | promrus.go | MustNewPrometheusHook | func MustNewPrometheusHook() *PrometheusHook {
hook, err := NewPrometheusHook()
if err != nil {
panic(err)
}
return hook
} | go | func MustNewPrometheusHook() *PrometheusHook {
hook, err := NewPrometheusHook()
if err != nil {
panic(err)
}
return hook
} | [
"func",
"MustNewPrometheusHook",
"(",
")",
"*",
"PrometheusHook",
"{",
"hook",
",",
"err",
":=",
"NewPrometheusHook",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"hook",
"\n",
"}"
] | // MustNewPrometheusHook creates a new instance of PrometheusHook which exposes Prometheus counters for various log levels.
// Contrarily to NewPrometheusHook, it does not return any error to the caller, but panics instead.
// Use MustNewPrometheusHook if you want a less verbose hook creation. Use NewPrometheusHook if ... | [
"MustNewPrometheusHook",
"creates",
"a",
"new",
"instance",
"of",
"PrometheusHook",
"which",
"exposes",
"Prometheus",
"counters",
"for",
"various",
"log",
"levels",
".",
"Contrarily",
"to",
"NewPrometheusHook",
"it",
"does",
"not",
"return",
"any",
"error",
"to",
... | 5c7f70ad4f3233037d079b8b053fc6ceaa20697b | https://github.com/weaveworks/promrus/blob/5c7f70ad4f3233037d079b8b053fc6ceaa20697b/promrus.go#L43-L49 |
141,045 | weaveworks/promrus | promrus.go | Fire | func (hook *PrometheusHook) Fire(entry *logrus.Entry) error {
hook.counterVec.WithLabelValues(entry.Level.String()).Inc()
return nil
} | go | func (hook *PrometheusHook) Fire(entry *logrus.Entry) error {
hook.counterVec.WithLabelValues(entry.Level.String()).Inc()
return nil
} | [
"func",
"(",
"hook",
"*",
"PrometheusHook",
")",
"Fire",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"error",
"{",
"hook",
".",
"counterVec",
".",
"WithLabelValues",
"(",
"entry",
".",
"Level",
".",
"String",
"(",
")",
")",
".",
"Inc",
"(",
")",
... | // Fire increments the appropriate Prometheus counter depending on the entry's log level. | [
"Fire",
"increments",
"the",
"appropriate",
"Prometheus",
"counter",
"depending",
"on",
"the",
"entry",
"s",
"log",
"level",
"."
] | 5c7f70ad4f3233037d079b8b053fc6ceaa20697b | https://github.com/weaveworks/promrus/blob/5c7f70ad4f3233037d079b8b053fc6ceaa20697b/promrus.go#L52-L55 |
141,046 | alecthomas/units | bytes.go | ParseBase2Bytes | func ParseBase2Bytes(s string) (Base2Bytes, error) {
n, err := ParseUnit(s, bytesUnitMap)
if err != nil {
n, err = ParseUnit(s, oldBytesUnitMap)
}
return Base2Bytes(n), err
} | go | func ParseBase2Bytes(s string) (Base2Bytes, error) {
n, err := ParseUnit(s, bytesUnitMap)
if err != nil {
n, err = ParseUnit(s, oldBytesUnitMap)
}
return Base2Bytes(n), err
} | [
"func",
"ParseBase2Bytes",
"(",
"s",
"string",
")",
"(",
"Base2Bytes",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"ParseUnit",
"(",
"s",
",",
"bytesUnitMap",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"n",
",",
"err",
"=",
"ParseUnit",
"(",
"s",... | // ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB
// and KiB are both 1024. | [
"ParseBase2Bytes",
"supports",
"both",
"iB",
"and",
"B",
"in",
"base",
"-",
"2",
"multipliers",
".",
"That",
"is",
"KB",
"and",
"KiB",
"are",
"both",
"1024",
"."
] | 2efee857e7cfd4f3d0138cc3cbb1b4966962b93a | https://github.com/alecthomas/units/blob/2efee857e7cfd4f3d0138cc3cbb1b4966962b93a/bytes.go#L30-L36 |
141,047 | alecthomas/units | bytes.go | ParseMetricBytes | func ParseMetricBytes(s string) (MetricBytes, error) {
n, err := ParseUnit(s, metricBytesUnitMap)
return MetricBytes(n), err
} | go | func ParseMetricBytes(s string) (MetricBytes, error) {
n, err := ParseUnit(s, metricBytesUnitMap)
return MetricBytes(n), err
} | [
"func",
"ParseMetricBytes",
"(",
"s",
"string",
")",
"(",
"MetricBytes",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"ParseUnit",
"(",
"s",
",",
"metricBytesUnitMap",
")",
"\n",
"return",
"MetricBytes",
"(",
"n",
")",
",",
"err",
"\n",
"}"
] | // ParseMetricBytes parses base-10 metric byte units. That is, KB is 1000 bytes. | [
"ParseMetricBytes",
"parses",
"base",
"-",
"10",
"metric",
"byte",
"units",
".",
"That",
"is",
"KB",
"is",
"1000",
"bytes",
"."
] | 2efee857e7cfd4f3d0138cc3cbb1b4966962b93a | https://github.com/alecthomas/units/blob/2efee857e7cfd4f3d0138cc3cbb1b4966962b93a/bytes.go#L66-L69 |
141,048 | alecthomas/units | bytes.go | ParseStrictBytes | func ParseStrictBytes(s string) (int64, error) {
n, err := ParseUnit(s, bytesUnitMap)
if err != nil {
n, err = ParseUnit(s, metricBytesUnitMap)
}
return int64(n), err
} | go | func ParseStrictBytes(s string) (int64, error) {
n, err := ParseUnit(s, bytesUnitMap)
if err != nil {
n, err = ParseUnit(s, metricBytesUnitMap)
}
return int64(n), err
} | [
"func",
"ParseStrictBytes",
"(",
"s",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"ParseUnit",
"(",
"s",
",",
"bytesUnitMap",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"n",
",",
"err",
"=",
"ParseUnit",
"(",
"s",
"... | // ParseStrictBytes supports both iB and B suffixes for base 2 and metric,
// respectively. That is, KiB represents 1024 and KB represents 1000. | [
"ParseStrictBytes",
"supports",
"both",
"iB",
"and",
"B",
"suffixes",
"for",
"base",
"2",
"and",
"metric",
"respectively",
".",
"That",
"is",
"KiB",
"represents",
"1024",
"and",
"KB",
"represents",
"1000",
"."
] | 2efee857e7cfd4f3d0138cc3cbb1b4966962b93a | https://github.com/alecthomas/units/blob/2efee857e7cfd4f3d0138cc3cbb1b4966962b93a/bytes.go#L77-L83 |
141,049 | go-playground/pure | _examples/middleware/logging-recovery/logging_recovery.go | Hijack | func (lw *logWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return lw.ResponseWriter.(http.Hijacker).Hijack()
} | go | func (lw *logWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return lw.ResponseWriter.(http.Hijacker).Hijack()
} | [
"func",
"(",
"lw",
"*",
"logWriter",
")",
"Hijack",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"*",
"bufio",
".",
"ReadWriter",
",",
"error",
")",
"{",
"return",
"lw",
".",
"ResponseWriter",
".",
"(",
"http",
".",
"Hijacker",
")",
".",
"Hijack",
"(",
... | // Hijack hijacks the current http connection | [
"Hijack",
"hijacks",
"the",
"current",
"http",
"connection"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/_examples/middleware/logging-recovery/logging_recovery.go#L70-L72 |
141,050 | go-playground/pure | helpers.go | RequestVars | func RequestVars(r *http.Request) ReqVars {
rv := r.Context().Value(defaultContextIdentifier)
if rv == nil {
return new(requestVars)
}
return rv.(*requestVars)
} | go | func RequestVars(r *http.Request) ReqVars {
rv := r.Context().Value(defaultContextIdentifier)
if rv == nil {
return new(requestVars)
}
return rv.(*requestVars)
} | [
"func",
"RequestVars",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"ReqVars",
"{",
"rv",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"defaultContextIdentifier",
")",
"\n",
"if",
"rv",
"==",
"nil",
"{",
"return",
"new",
"(",
"requestVars",
... | // RequestVars returns the request scoped variables tracked by pure | [
"RequestVars",
"returns",
"the",
"request",
"scoped",
"variables",
"tracked",
"by",
"pure"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/helpers.go#L14-L22 |
141,051 | go-playground/pure | helpers.go | Attachment | func Attachment(w http.ResponseWriter, r io.Reader, filename string) (err error) {
w.Header().Set(ContentDisposition, "attachment;filename="+filename)
w.Header().Set(ContentType, detectContentType(filename))
w.WriteHeader(http.StatusOK)
_, err = io.Copy(w, r)
return
} | go | func Attachment(w http.ResponseWriter, r io.Reader, filename string) (err error) {
w.Header().Set(ContentDisposition, "attachment;filename="+filename)
w.Header().Set(ContentType, detectContentType(filename))
w.WriteHeader(http.StatusOK)
_, err = io.Copy(w, r)
return
} | [
"func",
"Attachment",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"io",
".",
"Reader",
",",
"filename",
"string",
")",
"(",
"err",
"error",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"ContentDisposition",
",",
"\"",
"\"",
"+",
... | // Attachment is a helper method for returning an attachement file
// to be downloaded, if you with to open inline see function Inline | [
"Attachment",
"is",
"a",
"helper",
"method",
"for",
"returning",
"an",
"attachement",
"file",
"to",
"be",
"downloaded",
"if",
"you",
"with",
"to",
"open",
"inline",
"see",
"function",
"Inline"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/helpers.go#L50-L59 |
141,052 | go-playground/pure | helpers.go | JSON | func JSON(w http.ResponseWriter, status int, i interface{}) error {
b, err := json.Marshal(i)
if err != nil {
return err
}
w.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
w.WriteHeader(status)
_, err = w.Write(b)
return err
} | go | func JSON(w http.ResponseWriter, status int, i interface{}) error {
b, err := json.Marshal(i)
if err != nil {
return err
}
w.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
w.WriteHeader(status)
_, err = w.Write(b)
return err
} | [
"func",
"JSON",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"status",
"int",
",",
"i",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"i",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",... | // JSON marshals provided interface + returns JSON + status code | [
"JSON",
"marshals",
"provided",
"interface",
"+",
"returns",
"JSON",
"+",
"status",
"code"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/helpers.go#L107-L119 |
141,053 | go-playground/pure | helpers.go | DecodeSEOQueryParams | func DecodeSEOQueryParams(r *http.Request, v interface{}) (err error) {
if rvi := r.Context().Value(defaultContextIdentifier); rvi != nil {
rv := rvi.(*requestVars)
values := make(url.Values, len(rv.params))
for _, p := range rv.params {
values.Add(p.key, p.value)
}
err = DefaultDecoder.Decode(v, val... | go | func DecodeSEOQueryParams(r *http.Request, v interface{}) (err error) {
if rvi := r.Context().Value(defaultContextIdentifier); rvi != nil {
rv := rvi.(*requestVars)
values := make(url.Values, len(rv.params))
for _, p := range rv.params {
values.Add(p.key, p.value)
}
err = DefaultDecoder.Decode(v, val... | [
"func",
"DecodeSEOQueryParams",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"if",
"rvi",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"defaultContextIdentifier",
")",
";",
"rv... | // DecodeSEOQueryParams decodes the SEO Query params only and ignores the normal URL Query params. | [
"DecodeSEOQueryParams",
"decodes",
"the",
"SEO",
"Query",
"params",
"only",
"and",
"ignores",
"the",
"normal",
"URL",
"Query",
"params",
"."
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/helpers.go#L376-L392 |
141,054 | go-playground/pure | request_vars.go | URLParam | func (r *requestVars) URLParam(pname string) string {
return r.params.Get(pname)
} | go | func (r *requestVars) URLParam(pname string) string {
return r.params.Get(pname)
} | [
"func",
"(",
"r",
"*",
"requestVars",
")",
"URLParam",
"(",
"pname",
"string",
")",
"string",
"{",
"return",
"r",
".",
"params",
".",
"Get",
"(",
"pname",
")",
"\n",
"}"
] | // Params returns the current routes Params | [
"Params",
"returns",
"the",
"current",
"routes",
"Params"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/request_vars.go#L18-L20 |
141,055 | go-playground/pure | pure.go | Get | func (p urlParams) Get(key string) (param string) {
for i := 0; i < len(p); i++ {
if p[i].key == key {
param = p[i].value
return
}
}
return
} | go | func (p urlParams) Get(key string) (param string) {
for i := 0; i < len(p); i++ {
if p[i].key == key {
param = p[i].value
return
}
}
return
} | [
"func",
"(",
"p",
"urlParams",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"param",
"string",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"p",
")",
";",
"i",
"++",
"{",
"if",
"p",
"[",
"i",
"]",
".",
"key",
"==",
"key",
"{... | // Get returns the URL parameter for the given key, or blank if not found | [
"Get",
"returns",
"the",
"URL",
"parameter",
"for",
"the",
"given",
"key",
"or",
"blank",
"if",
"not",
"found"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/pure.go#L66-L76 |
141,056 | go-playground/pure | pure.go | New | func New() *Mux {
p := &Mux{
routeGroup: routeGroup{
middleware: make([]Middleware, 0),
},
trees: make(map[string]*node),
mostParams: 0,
http404: default404Handler,
http405: methodNotAllowedHandler,
httpOPTIONS: ... | go | func New() *Mux {
p := &Mux{
routeGroup: routeGroup{
middleware: make([]Middleware, 0),
},
trees: make(map[string]*node),
mostParams: 0,
http404: default404Handler,
http405: methodNotAllowedHandler,
httpOPTIONS: ... | [
"func",
"New",
"(",
")",
"*",
"Mux",
"{",
"p",
":=",
"&",
"Mux",
"{",
"routeGroup",
":",
"routeGroup",
"{",
"middleware",
":",
"make",
"(",
"[",
"]",
"Middleware",
",",
"0",
")",
",",
"}",
",",
"trees",
":",
"make",
"(",
"map",
"[",
"string",
"... | // New Creates and returns a new Pure instance | [
"New",
"Creates",
"and",
"returns",
"a",
"new",
"Pure",
"instance"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/pure.go#L96-L125 |
141,057 | go-playground/pure | pure.go | RegisterAutomaticOPTIONS | func (p *Mux) RegisterAutomaticOPTIONS(middleware ...Middleware) {
p.automaticallyHandleOPTIONS = true
h := automaticOPTIONSHandler
for i := len(middleware) - 1; i >= 0; i-- {
h = middleware[i](h)
}
p.httpOPTIONS = h
} | go | func (p *Mux) RegisterAutomaticOPTIONS(middleware ...Middleware) {
p.automaticallyHandleOPTIONS = true
h := automaticOPTIONSHandler
for i := len(middleware) - 1; i >= 0; i-- {
h = middleware[i](h)
}
p.httpOPTIONS = h
} | [
"func",
"(",
"p",
"*",
"Mux",
")",
"RegisterAutomaticOPTIONS",
"(",
"middleware",
"...",
"Middleware",
")",
"{",
"p",
".",
"automaticallyHandleOPTIONS",
"=",
"true",
"\n\n",
"h",
":=",
"automaticOPTIONSHandler",
"\n\n",
"for",
"i",
":=",
"len",
"(",
"middlewar... | // RegisterAutomaticOPTIONS tells pure whether to
// automatically handle OPTION requests; manually configured
// OPTION handlers take precedence. default true | [
"RegisterAutomaticOPTIONS",
"tells",
"pure",
"whether",
"to",
"automatically",
"handle",
"OPTION",
"requests",
";",
"manually",
"configured",
"OPTION",
"handlers",
"take",
"precedence",
".",
"default",
"true"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/pure.go#L143-L154 |
141,058 | go-playground/pure | pure.go | RegisterMethodNotAllowed | func (p *Mux) RegisterMethodNotAllowed(middleware ...Middleware) {
p.handleMethodNotAllowed = true
h := methodNotAllowedHandler
for i := len(middleware) - 1; i >= 0; i-- {
h = middleware[i](h)
}
p.http405 = h
} | go | func (p *Mux) RegisterMethodNotAllowed(middleware ...Middleware) {
p.handleMethodNotAllowed = true
h := methodNotAllowedHandler
for i := len(middleware) - 1; i >= 0; i-- {
h = middleware[i](h)
}
p.http405 = h
} | [
"func",
"(",
"p",
"*",
"Mux",
")",
"RegisterMethodNotAllowed",
"(",
"middleware",
"...",
"Middleware",
")",
"{",
"p",
".",
"handleMethodNotAllowed",
"=",
"true",
"\n\n",
"h",
":=",
"methodNotAllowedHandler",
"\n\n",
"for",
"i",
":=",
"len",
"(",
"middleware",
... | // RegisterMethodNotAllowed tells pure whether to
// handle the http 405 Method Not Allowed status code | [
"RegisterMethodNotAllowed",
"tells",
"pure",
"whether",
"to",
"handle",
"the",
"http",
"405",
"Method",
"Not",
"Allowed",
"status",
"code"
] | dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37 | https://github.com/go-playground/pure/blob/dd99f50b7780fa6a1bc49b2994ecdab7b72b1c37/pure.go#L165-L176 |
141,059 | cloudfoundry-incubator/notifications | application/application.go | Crash | func (a Application) Crash() {
err := recover()
switch err.(type) {
case error:
time.Sleep(5 * time.Second)
a.logger.Fatal("crash", err.(error))
case nil:
return
default:
time.Sleep(5 * time.Second)
a.logger.Fatal("crash", nil)
}
} | go | func (a Application) Crash() {
err := recover()
switch err.(type) {
case error:
time.Sleep(5 * time.Second)
a.logger.Fatal("crash", err.(error))
case nil:
return
default:
time.Sleep(5 * time.Second)
a.logger.Fatal("crash", nil)
}
} | [
"func",
"(",
"a",
"Application",
")",
"Crash",
"(",
")",
"{",
"err",
":=",
"recover",
"(",
")",
"\n",
"switch",
"err",
".",
"(",
"type",
")",
"{",
"case",
"error",
":",
"time",
".",
"Sleep",
"(",
"5",
"*",
"time",
".",
"Second",
")",
"\n",
"a",... | // This is a hack to get the logs output to the loggregator before the process exits | [
"This",
"is",
"a",
"hack",
"to",
"get",
"the",
"logs",
"output",
"to",
"the",
"loggregator",
"before",
"the",
"process",
"exits"
] | ac5b072ac5a1283b50945c8057b954e66ab5d870 | https://github.com/cloudfoundry-incubator/notifications/blob/ac5b072ac5a1283b50945c8057b954e66ab5d870/application/application.go#L188-L200 |
141,060 | antonlindstrom/pgstore | examples/sessions.go | ExampleHandler | func ExampleHandler(w http.ResponseWriter, r *http.Request) {
// Fetch new store.
store, err := pgstore.NewPGStore("postgres://user:password@127.0.0.1:5432/database?sslmode=verify-full", []byte("secret-key"))
if err != nil {
log.Fatalf(err.Error())
}
defer store.Close()
// Run a background goroutine to clean u... | go | func ExampleHandler(w http.ResponseWriter, r *http.Request) {
// Fetch new store.
store, err := pgstore.NewPGStore("postgres://user:password@127.0.0.1:5432/database?sslmode=verify-full", []byte("secret-key"))
if err != nil {
log.Fatalf(err.Error())
}
defer store.Close()
// Run a background goroutine to clean u... | [
"func",
"ExampleHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Fetch new store.",
"store",
",",
"err",
":=",
"pgstore",
".",
"NewPGStore",
"(",
"\"",
"\"",
",",
"[",
"]",
"byte",
"(",
"\"",
"\"",... | // ExampleHandler is an example that displays the usage of PGStore. | [
"ExampleHandler",
"is",
"an",
"example",
"that",
"displays",
"the",
"usage",
"of",
"PGStore",
"."
] | a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7 | https://github.com/antonlindstrom/pgstore/blob/a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7/examples/sessions.go#L12-L42 |
141,061 | antonlindstrom/pgstore | pgstore.go | Get | func (db *PGStore) Get(r *http.Request, name string) (*sessions.Session, error) {
return sessions.GetRegistry(r).Get(db, name)
} | go | func (db *PGStore) Get(r *http.Request, name string) (*sessions.Session, error) {
return sessions.GetRegistry(r).Get(db, name)
} | [
"func",
"(",
"db",
"*",
"PGStore",
")",
"Get",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"name",
"string",
")",
"(",
"*",
"sessions",
".",
"Session",
",",
"error",
")",
"{",
"return",
"sessions",
".",
"GetRegistry",
"(",
"r",
")",
".",
"Get",
"... | // Get Fetches a session for a given name after it has been added to the
// registry. | [
"Get",
"Fetches",
"a",
"session",
"for",
"a",
"given",
"name",
"after",
"it",
"has",
"been",
"added",
"to",
"the",
"registry",
"."
] | a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7 | https://github.com/antonlindstrom/pgstore/blob/a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7/pgstore.go#L77-L79 |
141,062 | antonlindstrom/pgstore | pgstore.go | New | func (db *PGStore) New(r *http.Request, name string) (*sessions.Session, error) {
session := sessions.NewSession(db, name)
if session == nil {
return nil, nil
}
opts := *db.Options
session.Options = &(opts)
session.IsNew = true
var err error
if c, errCookie := r.Cookie(name); errCookie == nil {
err = secu... | go | func (db *PGStore) New(r *http.Request, name string) (*sessions.Session, error) {
session := sessions.NewSession(db, name)
if session == nil {
return nil, nil
}
opts := *db.Options
session.Options = &(opts)
session.IsNew = true
var err error
if c, errCookie := r.Cookie(name); errCookie == nil {
err = secu... | [
"func",
"(",
"db",
"*",
"PGStore",
")",
"New",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"name",
"string",
")",
"(",
"*",
"sessions",
".",
"Session",
",",
"error",
")",
"{",
"session",
":=",
"sessions",
".",
"NewSession",
"(",
"db",
",",
"name",
... | // New returns a new session for the given name without adding it to the registry. | [
"New",
"returns",
"a",
"new",
"session",
"for",
"the",
"given",
"name",
"without",
"adding",
"it",
"to",
"the",
"registry",
"."
] | a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7 | https://github.com/antonlindstrom/pgstore/blob/a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7/pgstore.go#L82-L108 |
141,063 | antonlindstrom/pgstore | pgstore.go | load | func (db *PGStore) load(session *sessions.Session) error {
var s PGSession
err := db.selectOne(&s, session.ID)
if err != nil {
return err
}
return securecookie.DecodeMulti(session.Name(), string(s.Data), &session.Values, db.Codecs...)
} | go | func (db *PGStore) load(session *sessions.Session) error {
var s PGSession
err := db.selectOne(&s, session.ID)
if err != nil {
return err
}
return securecookie.DecodeMulti(session.Name(), string(s.Data), &session.Values, db.Codecs...)
} | [
"func",
"(",
"db",
"*",
"PGStore",
")",
"load",
"(",
"session",
"*",
"sessions",
".",
"Session",
")",
"error",
"{",
"var",
"s",
"PGSession",
"\n\n",
"err",
":=",
"db",
".",
"selectOne",
"(",
"&",
"s",
",",
"session",
".",
"ID",
")",
"\n",
"if",
"... | // load fetches a session by ID from the database and decodes its content
// into session.Values. | [
"load",
"fetches",
"a",
"session",
"by",
"ID",
"from",
"the",
"database",
"and",
"decodes",
"its",
"content",
"into",
"session",
".",
"Values",
"."
] | a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7 | https://github.com/antonlindstrom/pgstore/blob/a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7/pgstore.go#L171-L180 |
141,064 | antonlindstrom/pgstore | pgstore.go | save | func (db *PGStore) save(session *sessions.Session) error {
encoded, err := securecookie.EncodeMulti(session.Name(), session.Values, db.Codecs...)
if err != nil {
return err
}
crOn := session.Values["created_on"]
exOn := session.Values["expires_on"]
var expiresOn time.Time
createdOn, ok := crOn.(time.Time)
... | go | func (db *PGStore) save(session *sessions.Session) error {
encoded, err := securecookie.EncodeMulti(session.Name(), session.Values, db.Codecs...)
if err != nil {
return err
}
crOn := session.Values["created_on"]
exOn := session.Values["expires_on"]
var expiresOn time.Time
createdOn, ok := crOn.(time.Time)
... | [
"func",
"(",
"db",
"*",
"PGStore",
")",
"save",
"(",
"session",
"*",
"sessions",
".",
"Session",
")",
"error",
"{",
"encoded",
",",
"err",
":=",
"securecookie",
".",
"EncodeMulti",
"(",
"session",
".",
"Name",
"(",
")",
",",
"session",
".",
"Values",
... | // save writes encoded session.Values to a database record.
// writes to http_sessions table by default. | [
"save",
"writes",
"encoded",
"session",
".",
"Values",
"to",
"a",
"database",
"record",
".",
"writes",
"to",
"http_sessions",
"table",
"by",
"default",
"."
] | a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7 | https://github.com/antonlindstrom/pgstore/blob/a407030ba6d0efd9a1aad3d0cfc18a9b13d2f2e7/pgstore.go#L184-L222 |
141,065 | yhat/wsutil | wsutil.go | ServeHTTP | func (p *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
logFunc := log.Printf
if p.ErrorLog != nil {
logFunc = p.ErrorLog.Printf
}
if !IsWebSocketRequest(r) {
http.Error(w, "Cannot handle non-WebSocket requests", 500)
logFunc("Received a request that was not a WebSocket request")
return
... | go | func (p *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
logFunc := log.Printf
if p.ErrorLog != nil {
logFunc = p.ErrorLog.Printf
}
if !IsWebSocketRequest(r) {
http.Error(w, "Cannot handle non-WebSocket requests", 500)
logFunc("Received a request that was not a WebSocket request")
return
... | [
"func",
"(",
"p",
"*",
"ReverseProxy",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"logFunc",
":=",
"log",
".",
"Printf",
"\n",
"if",
"p",
".",
"ErrorLog",
"!=",
"nil",
"{",
"logFunc",
... | // Function to implement the http.Handler interface. | [
"Function",
"to",
"implement",
"the",
"http",
".",
"Handler",
"interface",
"."
] | 1d66fa95c997864ba4d8479f56609620fe542928 | https://github.com/yhat/wsutil/blob/1d66fa95c997864ba4d8479f56609620fe542928/wsutil.go#L74-L164 |
141,066 | yourbasic/fenwick | list.go | New | func New(n ...int64) *List {
len := len(n)
t := make([]int64, len)
copy(t, n)
for i := range t {
if j := i | (i + 1); j < len {
t[j] += t[i]
}
}
return &List{
tree: t,
}
} | go | func New(n ...int64) *List {
len := len(n)
t := make([]int64, len)
copy(t, n)
for i := range t {
if j := i | (i + 1); j < len {
t[j] += t[i]
}
}
return &List{
tree: t,
}
} | [
"func",
"New",
"(",
"n",
"...",
"int64",
")",
"*",
"List",
"{",
"len",
":=",
"len",
"(",
"n",
")",
"\n",
"t",
":=",
"make",
"(",
"[",
"]",
"int64",
",",
"len",
")",
"\n",
"copy",
"(",
"t",
",",
"n",
")",
"\n",
"for",
"i",
":=",
"range",
"... | // New creates a new list with the given elements. | [
"New",
"creates",
"a",
"new",
"list",
"with",
"the",
"given",
"elements",
"."
] | 5f8823d88d1535c8a70acfaeeb7caab77427dbbd | https://github.com/yourbasic/fenwick/blob/5f8823d88d1535c8a70acfaeeb7caab77427dbbd/list.go#L33-L45 |
141,067 | yourbasic/fenwick | list.go | Get | func (l *List) Get(i int) int64 {
sum := l.tree[i]
j := i + 1
j -= j & -j
for i > j {
sum -= l.tree[i-1]
i -= i & -i
}
return sum
} | go | func (l *List) Get(i int) int64 {
sum := l.tree[i]
j := i + 1
j -= j & -j
for i > j {
sum -= l.tree[i-1]
i -= i & -i
}
return sum
} | [
"func",
"(",
"l",
"*",
"List",
")",
"Get",
"(",
"i",
"int",
")",
"int64",
"{",
"sum",
":=",
"l",
".",
"tree",
"[",
"i",
"]",
"\n",
"j",
":=",
"i",
"+",
"1",
"\n",
"j",
"-=",
"j",
"&",
"-",
"j",
"\n",
"for",
"i",
">",
"j",
"{",
"sum",
... | // Get returns the element at index i. | [
"Get",
"returns",
"the",
"element",
"at",
"index",
"i",
"."
] | 5f8823d88d1535c8a70acfaeeb7caab77427dbbd | https://github.com/yourbasic/fenwick/blob/5f8823d88d1535c8a70acfaeeb7caab77427dbbd/list.go#L53-L62 |
141,068 | yourbasic/fenwick | list.go | Set | func (l *List) Set(i int, n int64) {
n -= l.Get(i)
for len := len(l.tree); i < len; i |= i + 1 {
l.tree[i] += n
}
} | go | func (l *List) Set(i int, n int64) {
n -= l.Get(i)
for len := len(l.tree); i < len; i |= i + 1 {
l.tree[i] += n
}
} | [
"func",
"(",
"l",
"*",
"List",
")",
"Set",
"(",
"i",
"int",
",",
"n",
"int64",
")",
"{",
"n",
"-=",
"l",
".",
"Get",
"(",
"i",
")",
"\n",
"for",
"len",
":=",
"len",
"(",
"l",
".",
"tree",
")",
";",
"i",
"<",
"len",
";",
"i",
"|=",
"i",
... | // Set sets the element at index i to n. | [
"Set",
"sets",
"the",
"element",
"at",
"index",
"i",
"to",
"n",
"."
] | 5f8823d88d1535c8a70acfaeeb7caab77427dbbd | https://github.com/yourbasic/fenwick/blob/5f8823d88d1535c8a70acfaeeb7caab77427dbbd/list.go#L65-L70 |
141,069 | yourbasic/fenwick | list.go | Add | func (l *List) Add(i int, n int64) {
for len := len(l.tree); i < len; i |= i + 1 {
l.tree[i] += n
}
} | go | func (l *List) Add(i int, n int64) {
for len := len(l.tree); i < len; i |= i + 1 {
l.tree[i] += n
}
} | [
"func",
"(",
"l",
"*",
"List",
")",
"Add",
"(",
"i",
"int",
",",
"n",
"int64",
")",
"{",
"for",
"len",
":=",
"len",
"(",
"l",
".",
"tree",
")",
";",
"i",
"<",
"len",
";",
"i",
"|=",
"i",
"+",
"1",
"{",
"l",
".",
"tree",
"[",
"i",
"]",
... | // Add adds n to the element at index i. | [
"Add",
"adds",
"n",
"to",
"the",
"element",
"at",
"index",
"i",
"."
] | 5f8823d88d1535c8a70acfaeeb7caab77427dbbd | https://github.com/yourbasic/fenwick/blob/5f8823d88d1535c8a70acfaeeb7caab77427dbbd/list.go#L73-L77 |
141,070 | yourbasic/fenwick | list.go | Sum | func (l *List) Sum(i int) int64 {
var sum int64
for i > 0 {
sum += l.tree[i-1]
i -= i & -i
}
return sum
} | go | func (l *List) Sum(i int) int64 {
var sum int64
for i > 0 {
sum += l.tree[i-1]
i -= i & -i
}
return sum
} | [
"func",
"(",
"l",
"*",
"List",
")",
"Sum",
"(",
"i",
"int",
")",
"int64",
"{",
"var",
"sum",
"int64",
"\n",
"for",
"i",
">",
"0",
"{",
"sum",
"+=",
"l",
".",
"tree",
"[",
"i",
"-",
"1",
"]",
"\n",
"i",
"-=",
"i",
"&",
"-",
"i",
"\n",
"}... | // Sum returns the sum of the elements from index 0 to index i-1. | [
"Sum",
"returns",
"the",
"sum",
"of",
"the",
"elements",
"from",
"index",
"0",
"to",
"index",
"i",
"-",
"1",
"."
] | 5f8823d88d1535c8a70acfaeeb7caab77427dbbd | https://github.com/yourbasic/fenwick/blob/5f8823d88d1535c8a70acfaeeb7caab77427dbbd/list.go#L80-L87 |
141,071 | yourbasic/fenwick | list.go | Append | func (l *List) Append(n int64) {
i := len(l.tree)
l.tree = append(l.tree, 0)
l.tree[i] = n - l.Get(i)
} | go | func (l *List) Append(n int64) {
i := len(l.tree)
l.tree = append(l.tree, 0)
l.tree[i] = n - l.Get(i)
} | [
"func",
"(",
"l",
"*",
"List",
")",
"Append",
"(",
"n",
"int64",
")",
"{",
"i",
":=",
"len",
"(",
"l",
".",
"tree",
")",
"\n",
"l",
".",
"tree",
"=",
"append",
"(",
"l",
".",
"tree",
",",
"0",
")",
"\n",
"l",
".",
"tree",
"[",
"i",
"]",
... | // Append appends a new element to the end of the list. | [
"Append",
"appends",
"a",
"new",
"element",
"to",
"the",
"end",
"of",
"the",
"list",
"."
] | 5f8823d88d1535c8a70acfaeeb7caab77427dbbd | https://github.com/yourbasic/fenwick/blob/5f8823d88d1535c8a70acfaeeb7caab77427dbbd/list.go#L104-L108 |
141,072 | go-openapi/analysis | analyzer.go | New | func New(doc *spec.Swagger) *Spec {
a := &Spec{
spec: doc,
consumes: make(map[string]struct{}, 150),
produces: make(map[string]struct{}, 150),
authSchemes: make(map[string]struct{}, 150),
operations: make(map[string]map[string]*spec.Operation, 150),
allSchemas: make(map[string]SchemaRef, 150... | go | func New(doc *spec.Swagger) *Spec {
a := &Spec{
spec: doc,
consumes: make(map[string]struct{}, 150),
produces: make(map[string]struct{}, 150),
authSchemes: make(map[string]struct{}, 150),
operations: make(map[string]map[string]*spec.Operation, 150),
allSchemas: make(map[string]SchemaRef, 150... | [
"func",
"New",
"(",
"doc",
"*",
"spec",
".",
"Swagger",
")",
"*",
"Spec",
"{",
"a",
":=",
"&",
"Spec",
"{",
"spec",
":",
"doc",
",",
"consumes",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"150",
")",
",",
"produces",
... | // New takes a swagger spec object and returns an analyzed spec document.
// The analyzed document contains a number of indices that make it easier to
// reason about semantics of a swagger specification for use in code generation
// or validation etc. | [
"New",
"takes",
"a",
"swagger",
"spec",
"object",
"and",
"returns",
"an",
"analyzed",
"spec",
"document",
".",
"The",
"analyzed",
"document",
"contains",
"a",
"number",
"of",
"indices",
"that",
"make",
"it",
"easier",
"to",
"reason",
"about",
"semantics",
"o... | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L143-L179 |
141,073 | go-openapi/analysis | analyzer.go | SecurityRequirementsFor | func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) [][]SecurityRequirement {
if s.spec.Security == nil && operation.Security == nil {
return nil
}
schemes := s.spec.Security
if operation.Security != nil {
schemes = operation.Security
}
result := [][]SecurityRequirement{}
for _, scheme := ran... | go | func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) [][]SecurityRequirement {
if s.spec.Security == nil && operation.Security == nil {
return nil
}
schemes := s.spec.Security
if operation.Security != nil {
schemes = operation.Security
}
result := [][]SecurityRequirement{}
for _, scheme := ran... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"SecurityRequirementsFor",
"(",
"operation",
"*",
"spec",
".",
"Operation",
")",
"[",
"]",
"[",
"]",
"SecurityRequirement",
"{",
"if",
"s",
".",
"spec",
".",
"Security",
"==",
"nil",
"&&",
"operation",
".",
"Security",... | // SecurityRequirementsFor gets the security requirements for the operation | [
"SecurityRequirementsFor",
"gets",
"the",
"security",
"requirements",
"for",
"the",
"operation"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L493-L520 |
141,074 | go-openapi/analysis | analyzer.go | SecurityDefinitionsForRequirements | func (s *Spec) SecurityDefinitionsForRequirements(requirements []SecurityRequirement) map[string]spec.SecurityScheme {
result := make(map[string]spec.SecurityScheme)
for _, v := range requirements {
if definition, ok := s.spec.SecurityDefinitions[v.Name]; ok {
if definition != nil {
result[v.Name] = *defini... | go | func (s *Spec) SecurityDefinitionsForRequirements(requirements []SecurityRequirement) map[string]spec.SecurityScheme {
result := make(map[string]spec.SecurityScheme)
for _, v := range requirements {
if definition, ok := s.spec.SecurityDefinitions[v.Name]; ok {
if definition != nil {
result[v.Name] = *defini... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"SecurityDefinitionsForRequirements",
"(",
"requirements",
"[",
"]",
"SecurityRequirement",
")",
"map",
"[",
"string",
"]",
"spec",
".",
"SecurityScheme",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"spec"... | // SecurityDefinitionsForRequirements gets the matching security definitions for a set of requirements | [
"SecurityDefinitionsForRequirements",
"gets",
"the",
"matching",
"security",
"definitions",
"for",
"a",
"set",
"of",
"requirements"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L523-L534 |
141,075 | go-openapi/analysis | analyzer.go | SecurityDefinitionsFor | func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec.SecurityScheme {
requirements := s.SecurityRequirementsFor(operation)
if len(requirements) == 0 {
return nil
}
result := make(map[string]spec.SecurityScheme)
for _, reqs := range requirements {
for _, v := range reqs {
if v.Na... | go | func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec.SecurityScheme {
requirements := s.SecurityRequirementsFor(operation)
if len(requirements) == 0 {
return nil
}
result := make(map[string]spec.SecurityScheme)
for _, reqs := range requirements {
for _, v := range reqs {
if v.Na... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"SecurityDefinitionsFor",
"(",
"operation",
"*",
"spec",
".",
"Operation",
")",
"map",
"[",
"string",
"]",
"spec",
".",
"SecurityScheme",
"{",
"requirements",
":=",
"s",
".",
"SecurityRequirementsFor",
"(",
"operation",
")... | // SecurityDefinitionsFor gets the matching security definitions for a set of requirements | [
"SecurityDefinitionsFor",
"gets",
"the",
"matching",
"security",
"definitions",
"for",
"a",
"set",
"of",
"requirements"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L537-L562 |
141,076 | go-openapi/analysis | analyzer.go | ConsumesFor | func (s *Spec) ConsumesFor(operation *spec.Operation) []string {
if len(operation.Consumes) == 0 {
cons := make(map[string]struct{}, len(s.spec.Consumes))
for _, k := range s.spec.Consumes {
cons[k] = struct{}{}
}
return s.structMapKeys(cons)
}
cons := make(map[string]struct{}, len(operation.Consumes))
... | go | func (s *Spec) ConsumesFor(operation *spec.Operation) []string {
if len(operation.Consumes) == 0 {
cons := make(map[string]struct{}, len(s.spec.Consumes))
for _, k := range s.spec.Consumes {
cons[k] = struct{}{}
}
return s.structMapKeys(cons)
}
cons := make(map[string]struct{}, len(operation.Consumes))
... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"ConsumesFor",
"(",
"operation",
"*",
"spec",
".",
"Operation",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"operation",
".",
"Consumes",
")",
"==",
"0",
"{",
"cons",
":=",
"make",
"(",
"map",
"[",
"string",
... | // ConsumesFor gets the mediatypes for the operation | [
"ConsumesFor",
"gets",
"the",
"mediatypes",
"for",
"the",
"operation"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L565-L580 |
141,077 | go-openapi/analysis | analyzer.go | ProducesFor | func (s *Spec) ProducesFor(operation *spec.Operation) []string {
if len(operation.Produces) == 0 {
prod := make(map[string]struct{}, len(s.spec.Produces))
for _, k := range s.spec.Produces {
prod[k] = struct{}{}
}
return s.structMapKeys(prod)
}
prod := make(map[string]struct{}, len(operation.Produces))
... | go | func (s *Spec) ProducesFor(operation *spec.Operation) []string {
if len(operation.Produces) == 0 {
prod := make(map[string]struct{}, len(s.spec.Produces))
for _, k := range s.spec.Produces {
prod[k] = struct{}{}
}
return s.structMapKeys(prod)
}
prod := make(map[string]struct{}, len(operation.Produces))
... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"ProducesFor",
"(",
"operation",
"*",
"spec",
".",
"Operation",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"operation",
".",
"Produces",
")",
"==",
"0",
"{",
"prod",
":=",
"make",
"(",
"map",
"[",
"string",
... | // ProducesFor gets the mediatypes for the operation | [
"ProducesFor",
"gets",
"the",
"mediatypes",
"for",
"the",
"operation"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L583-L597 |
141,078 | go-openapi/analysis | analyzer.go | ParametersFor | func (s *Spec) ParametersFor(operationID string) []spec.Parameter {
return s.SafeParametersFor(operationID, nil)
} | go | func (s *Spec) ParametersFor(operationID string) []spec.Parameter {
return s.SafeParametersFor(operationID, nil)
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"ParametersFor",
"(",
"operationID",
"string",
")",
"[",
"]",
"spec",
".",
"Parameter",
"{",
"return",
"s",
".",
"SafeParametersFor",
"(",
"operationID",
",",
"nil",
")",
"\n",
"}"
] | // ParametersFor the specified operation id.
//
// Assumes parameters properly resolve references if any and that
// such references actually resolve to a parameter object.
// Otherwise, panics. | [
"ParametersFor",
"the",
"specified",
"operation",
"id",
".",
"Assumes",
"parameters",
"properly",
"resolve",
"references",
"if",
"any",
"and",
"that",
"such",
"references",
"actually",
"resolve",
"to",
"a",
"parameter",
"object",
".",
"Otherwise",
"panics",
"."
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L661-L663 |
141,079 | go-openapi/analysis | analyzer.go | SafeParametersFor | func (s *Spec) SafeParametersFor(operationID string, callmeOnError ErrorOnParamFunc) []spec.Parameter {
gatherParams := func(pi *spec.PathItem, op *spec.Operation) []spec.Parameter {
bag := make(map[string]spec.Parameter)
s.paramsAsMap(pi.Parameters, bag, callmeOnError)
s.paramsAsMap(op.Parameters, bag, callmeOn... | go | func (s *Spec) SafeParametersFor(operationID string, callmeOnError ErrorOnParamFunc) []spec.Parameter {
gatherParams := func(pi *spec.PathItem, op *spec.Operation) []spec.Parameter {
bag := make(map[string]spec.Parameter)
s.paramsAsMap(pi.Parameters, bag, callmeOnError)
s.paramsAsMap(op.Parameters, bag, callmeOn... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"SafeParametersFor",
"(",
"operationID",
"string",
",",
"callmeOnError",
"ErrorOnParamFunc",
")",
"[",
"]",
"spec",
".",
"Parameter",
"{",
"gatherParams",
":=",
"func",
"(",
"pi",
"*",
"spec",
".",
"PathItem",
",",
"op",... | // SafeParametersFor the specified operation id.
//
// Does not assume parameters properly resolve references or that
// such references actually resolve to a parameter object.
//
// Upon error, invoke a ErrorOnParamFunc callback with the erroneous
// parameters. If the callback is set to nil, panics upon errors. | [
"SafeParametersFor",
"the",
"specified",
"operation",
"id",
".",
"Does",
"not",
"assume",
"parameters",
"properly",
"resolve",
"references",
"or",
"that",
"such",
"references",
"actually",
"resolve",
"to",
"a",
"parameter",
"object",
".",
"Upon",
"error",
"invoke"... | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L672-L708 |
141,080 | go-openapi/analysis | analyzer.go | ParamsFor | func (s *Spec) ParamsFor(method, path string) map[string]spec.Parameter {
return s.SafeParamsFor(method, path, nil)
} | go | func (s *Spec) ParamsFor(method, path string) map[string]spec.Parameter {
return s.SafeParamsFor(method, path, nil)
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"ParamsFor",
"(",
"method",
",",
"path",
"string",
")",
"map",
"[",
"string",
"]",
"spec",
".",
"Parameter",
"{",
"return",
"s",
".",
"SafeParamsFor",
"(",
"method",
",",
"path",
",",
"nil",
")",
"\n",
"}"
] | // ParamsFor the specified method and path. Aggregates them with the defaults etc, so it's all the params that
// apply for the method and path.
//
// Assumes parameters properly resolve references if any and that
// such references actually resolve to a parameter object.
// Otherwise, panics. | [
"ParamsFor",
"the",
"specified",
"method",
"and",
"path",
".",
"Aggregates",
"them",
"with",
"the",
"defaults",
"etc",
"so",
"it",
"s",
"all",
"the",
"params",
"that",
"apply",
"for",
"the",
"method",
"and",
"path",
".",
"Assumes",
"parameters",
"properly",
... | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L716-L718 |
141,081 | go-openapi/analysis | analyzer.go | SafeParamsFor | func (s *Spec) SafeParamsFor(method, path string, callmeOnError ErrorOnParamFunc) map[string]spec.Parameter {
res := make(map[string]spec.Parameter)
if pi, ok := s.spec.Paths.Paths[path]; ok {
s.paramsAsMap(pi.Parameters, res, callmeOnError)
s.paramsAsMap(s.operations[strings.ToUpper(method)][path].Parameters, re... | go | func (s *Spec) SafeParamsFor(method, path string, callmeOnError ErrorOnParamFunc) map[string]spec.Parameter {
res := make(map[string]spec.Parameter)
if pi, ok := s.spec.Paths.Paths[path]; ok {
s.paramsAsMap(pi.Parameters, res, callmeOnError)
s.paramsAsMap(s.operations[strings.ToUpper(method)][path].Parameters, re... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"SafeParamsFor",
"(",
"method",
",",
"path",
"string",
",",
"callmeOnError",
"ErrorOnParamFunc",
")",
"map",
"[",
"string",
"]",
"spec",
".",
"Parameter",
"{",
"res",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"sp... | // SafeParamsFor the specified method and path. Aggregates them with the defaults etc, so it's all the params that
// apply for the method and path.
//
// Does not assume parameters properly resolve references or that
// such references actually resolve to a parameter object.
//
// Upon error, invoke a ErrorOnParamFunc... | [
"SafeParamsFor",
"the",
"specified",
"method",
"and",
"path",
".",
"Aggregates",
"them",
"with",
"the",
"defaults",
"etc",
"so",
"it",
"s",
"all",
"the",
"params",
"that",
"apply",
"for",
"the",
"method",
"and",
"path",
".",
"Does",
"not",
"assume",
"param... | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L728-L735 |
141,082 | go-openapi/analysis | analyzer.go | OperationForName | func (s *Spec) OperationForName(operationID string) (string, string, *spec.Operation, bool) {
for method, pathItem := range s.operations {
for path, op := range pathItem {
if operationID == op.ID {
return method, path, op, true
}
}
}
return "", "", nil, false
} | go | func (s *Spec) OperationForName(operationID string) (string, string, *spec.Operation, bool) {
for method, pathItem := range s.operations {
for path, op := range pathItem {
if operationID == op.ID {
return method, path, op, true
}
}
}
return "", "", nil, false
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"OperationForName",
"(",
"operationID",
"string",
")",
"(",
"string",
",",
"string",
",",
"*",
"spec",
".",
"Operation",
",",
"bool",
")",
"{",
"for",
"method",
",",
"pathItem",
":=",
"range",
"s",
".",
"operations",... | // OperationForName gets the operation for the given id | [
"OperationForName",
"gets",
"the",
"operation",
"for",
"the",
"given",
"id"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L738-L747 |
141,083 | go-openapi/analysis | analyzer.go | OperationFor | func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) {
if mp, ok := s.operations[strings.ToUpper(method)]; ok {
op, fn := mp[path]
return op, fn
}
return nil, false
} | go | func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) {
if mp, ok := s.operations[strings.ToUpper(method)]; ok {
op, fn := mp[path]
return op, fn
}
return nil, false
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"OperationFor",
"(",
"method",
",",
"path",
"string",
")",
"(",
"*",
"spec",
".",
"Operation",
",",
"bool",
")",
"{",
"if",
"mp",
",",
"ok",
":=",
"s",
".",
"operations",
"[",
"strings",
".",
"ToUpper",
"(",
"m... | // OperationFor the given method and path | [
"OperationFor",
"the",
"given",
"method",
"and",
"path"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L750-L756 |
141,084 | go-openapi/analysis | analyzer.go | AllPaths | func (s *Spec) AllPaths() map[string]spec.PathItem {
if s.spec == nil || s.spec.Paths == nil {
return nil
}
return s.spec.Paths.Paths
} | go | func (s *Spec) AllPaths() map[string]spec.PathItem {
if s.spec == nil || s.spec.Paths == nil {
return nil
}
return s.spec.Paths.Paths
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllPaths",
"(",
")",
"map",
"[",
"string",
"]",
"spec",
".",
"PathItem",
"{",
"if",
"s",
".",
"spec",
"==",
"nil",
"||",
"s",
".",
"spec",
".",
"Paths",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
... | // AllPaths returns all the paths in the swagger spec | [
"AllPaths",
"returns",
"all",
"the",
"paths",
"in",
"the",
"swagger",
"spec"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L776-L781 |
141,085 | go-openapi/analysis | analyzer.go | OperationIDs | func (s *Spec) OperationIDs() []string {
if len(s.operations) == 0 {
return nil
}
result := make([]string, 0, len(s.operations))
for method, v := range s.operations {
for p, o := range v {
if o.ID != "" {
result = append(result, o.ID)
} else {
result = append(result, fmt.Sprintf("%s %s", strings.T... | go | func (s *Spec) OperationIDs() []string {
if len(s.operations) == 0 {
return nil
}
result := make([]string, 0, len(s.operations))
for method, v := range s.operations {
for p, o := range v {
if o.ID != "" {
result = append(result, o.ID)
} else {
result = append(result, fmt.Sprintf("%s %s", strings.T... | [
"func",
"(",
"s",
"*",
"Spec",
")",
"OperationIDs",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"s",
".",
"operations",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
... | // OperationIDs gets all the operation ids based on method an dpath | [
"OperationIDs",
"gets",
"all",
"the",
"operation",
"ids",
"based",
"on",
"method",
"an",
"dpath"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L784-L799 |
141,086 | go-openapi/analysis | analyzer.go | SchemasWithAllOf | func (s *Spec) SchemasWithAllOf() (result []SchemaRef) {
for _, v := range s.allOfs {
result = append(result, v)
}
return
} | go | func (s *Spec) SchemasWithAllOf() (result []SchemaRef) {
for _, v := range s.allOfs {
result = append(result, v)
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"SchemasWithAllOf",
"(",
")",
"(",
"result",
"[",
"]",
"SchemaRef",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"allOfs",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"v",
")",
"\n",
"}",
"\... | // SchemasWithAllOf returns schema references to all schemas that are defined
// with an allOf key | [
"SchemasWithAllOf",
"returns",
"schema",
"references",
"to",
"all",
"schemas",
"that",
"are",
"defined",
"with",
"an",
"allOf",
"key"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L840-L845 |
141,087 | go-openapi/analysis | analyzer.go | AllDefinitions | func (s *Spec) AllDefinitions() (result []SchemaRef) {
for _, v := range s.allSchemas {
result = append(result, v)
}
return
} | go | func (s *Spec) AllDefinitions() (result []SchemaRef) {
for _, v := range s.allSchemas {
result = append(result, v)
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllDefinitions",
"(",
")",
"(",
"result",
"[",
"]",
"SchemaRef",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"allSchemas",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"v",
")",
"\n",
"}",
... | // AllDefinitions returns schema references for all the definitions that were discovered | [
"AllDefinitions",
"returns",
"schema",
"references",
"for",
"all",
"the",
"definitions",
"that",
"were",
"discovered"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L848-L853 |
141,088 | go-openapi/analysis | analyzer.go | AllDefinitionReferences | func (s *Spec) AllDefinitionReferences() (result []string) {
for _, v := range s.references.schemas {
result = append(result, v.String())
}
return
} | go | func (s *Spec) AllDefinitionReferences() (result []string) {
for _, v := range s.references.schemas {
result = append(result, v.String())
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllDefinitionReferences",
"(",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"references",
".",
"schemas",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"v"... | // AllDefinitionReferences returns json refs for all the discovered schemas | [
"AllDefinitionReferences",
"returns",
"json",
"refs",
"for",
"all",
"the",
"discovered",
"schemas"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L856-L861 |
141,089 | go-openapi/analysis | analyzer.go | AllParameterReferences | func (s *Spec) AllParameterReferences() (result []string) {
for _, v := range s.references.parameters {
result = append(result, v.String())
}
return
} | go | func (s *Spec) AllParameterReferences() (result []string) {
for _, v := range s.references.parameters {
result = append(result, v.String())
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllParameterReferences",
"(",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"references",
".",
"parameters",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"... | // AllParameterReferences returns json refs for all the discovered parameters | [
"AllParameterReferences",
"returns",
"json",
"refs",
"for",
"all",
"the",
"discovered",
"parameters"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L864-L869 |
141,090 | go-openapi/analysis | analyzer.go | AllResponseReferences | func (s *Spec) AllResponseReferences() (result []string) {
for _, v := range s.references.responses {
result = append(result, v.String())
}
return
} | go | func (s *Spec) AllResponseReferences() (result []string) {
for _, v := range s.references.responses {
result = append(result, v.String())
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllResponseReferences",
"(",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"references",
".",
"responses",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"v"... | // AllResponseReferences returns json refs for all the discovered responses | [
"AllResponseReferences",
"returns",
"json",
"refs",
"for",
"all",
"the",
"discovered",
"responses"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L872-L877 |
141,091 | go-openapi/analysis | analyzer.go | AllPathItemReferences | func (s *Spec) AllPathItemReferences() (result []string) {
for _, v := range s.references.pathItems {
result = append(result, v.String())
}
return
} | go | func (s *Spec) AllPathItemReferences() (result []string) {
for _, v := range s.references.pathItems {
result = append(result, v.String())
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllPathItemReferences",
"(",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"references",
".",
"pathItems",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"v"... | // AllPathItemReferences returns the references for all the items | [
"AllPathItemReferences",
"returns",
"the",
"references",
"for",
"all",
"the",
"items"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L880-L885 |
141,092 | go-openapi/analysis | analyzer.go | AllReferences | func (s *Spec) AllReferences() (result []string) {
for _, v := range s.references.allRefs {
result = append(result, v.String())
}
return
} | go | func (s *Spec) AllReferences() (result []string) {
for _, v := range s.references.allRefs {
result = append(result, v.String())
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllReferences",
"(",
")",
"(",
"result",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"references",
".",
"allRefs",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"v",
".",
... | // AllReferences returns all the references found in the document, with possible duplicates | [
"AllReferences",
"returns",
"all",
"the",
"references",
"found",
"in",
"the",
"document",
"with",
"possible",
"duplicates"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L899-L904 |
141,093 | go-openapi/analysis | analyzer.go | AllRefs | func (s *Spec) AllRefs() (result []spec.Ref) {
set := make(map[string]struct{})
for _, v := range s.references.allRefs {
a := v.String()
if a == "" {
continue
}
if _, ok := set[a]; !ok {
set[a] = struct{}{}
result = append(result, v)
}
}
return
} | go | func (s *Spec) AllRefs() (result []spec.Ref) {
set := make(map[string]struct{})
for _, v := range s.references.allRefs {
a := v.String()
if a == "" {
continue
}
if _, ok := set[a]; !ok {
set[a] = struct{}{}
result = append(result, v)
}
}
return
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"AllRefs",
"(",
")",
"(",
"result",
"[",
"]",
"spec",
".",
"Ref",
")",
"{",
"set",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".... | // AllRefs returns all the unique references found in the document | [
"AllRefs",
"returns",
"all",
"the",
"unique",
"references",
"found",
"in",
"the",
"document"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/analyzer.go#L907-L920 |
141,094 | go-openapi/analysis | schema.go | Schema | func Schema(opts SchemaOpts) (*AnalyzedSchema, error) {
if opts.Schema == nil {
return nil, fmt.Errorf("no schema to analyze")
}
a := &AnalyzedSchema{
schema: opts.Schema,
root: opts.Root,
basePath: opts.BasePath,
}
a.initializeFlags()
a.inferKnownType()
a.inferEnum()
a.inferBaseType()
if err ... | go | func Schema(opts SchemaOpts) (*AnalyzedSchema, error) {
if opts.Schema == nil {
return nil, fmt.Errorf("no schema to analyze")
}
a := &AnalyzedSchema{
schema: opts.Schema,
root: opts.Root,
basePath: opts.BasePath,
}
a.initializeFlags()
a.inferKnownType()
a.inferEnum()
a.inferBaseType()
if err ... | [
"func",
"Schema",
"(",
"opts",
"SchemaOpts",
")",
"(",
"*",
"AnalyzedSchema",
",",
"error",
")",
"{",
"if",
"opts",
".",
"Schema",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"a",
":=",
"... | // Schema analysis, will classify the schema according to known
// patterns. | [
"Schema",
"analysis",
"will",
"classify",
"the",
"schema",
"according",
"to",
"known",
"patterns",
"."
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/schema.go#L20-L54 |
141,095 | go-openapi/analysis | schema.go | inherits | func (a *AnalyzedSchema) inherits(other *AnalyzedSchema) {
if other == nil {
return
}
a.hasProps = other.hasProps
a.hasAllOf = other.hasAllOf
a.hasItems = other.hasItems
a.hasAdditionalItems = other.hasAdditionalItems
a.hasAdditionalProps = other.hasAdditionalProps
a.hasRef = other.hasRef
a.IsKnownType = ot... | go | func (a *AnalyzedSchema) inherits(other *AnalyzedSchema) {
if other == nil {
return
}
a.hasProps = other.hasProps
a.hasAllOf = other.hasAllOf
a.hasItems = other.hasItems
a.hasAdditionalItems = other.hasAdditionalItems
a.hasAdditionalProps = other.hasAdditionalProps
a.hasRef = other.hasRef
a.IsKnownType = ot... | [
"func",
"(",
"a",
"*",
"AnalyzedSchema",
")",
"inherits",
"(",
"other",
"*",
"AnalyzedSchema",
")",
"{",
"if",
"other",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"a",
".",
"hasProps",
"=",
"other",
".",
"hasProps",
"\n",
"a",
".",
"hasAllOf",
"=",... | // Inherits copies value fields from other onto this schema | [
"Inherits",
"copies",
"value",
"fields",
"from",
"other",
"onto",
"this",
"schema"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/schema.go#L83-L105 |
141,096 | go-openapi/analysis | flatten.go | ExpandOpts | func (f *FlattenOpts) ExpandOpts(skipSchemas bool) *swspec.ExpandOptions {
return &swspec.ExpandOptions{RelativeBase: f.BasePath, SkipSchemas: skipSchemas}
} | go | func (f *FlattenOpts) ExpandOpts(skipSchemas bool) *swspec.ExpandOptions {
return &swspec.ExpandOptions{RelativeBase: f.BasePath, SkipSchemas: skipSchemas}
} | [
"func",
"(",
"f",
"*",
"FlattenOpts",
")",
"ExpandOpts",
"(",
"skipSchemas",
"bool",
")",
"*",
"swspec",
".",
"ExpandOptions",
"{",
"return",
"&",
"swspec",
".",
"ExpandOptions",
"{",
"RelativeBase",
":",
"f",
".",
"BasePath",
",",
"SkipSchemas",
":",
"ski... | // ExpandOpts creates a spec.ExpandOptions to configure expanding a specification document. | [
"ExpandOpts",
"creates",
"a",
"spec",
".",
"ExpandOptions",
"to",
"configure",
"expanding",
"a",
"specification",
"document",
"."
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/flatten.go#L54-L56 |
141,097 | go-openapi/analysis | flatten.go | nameInlinedSchemas | func nameInlinedSchemas(opts *FlattenOpts) error {
debugLog("nameInlinedSchemas")
namer := &inlineSchemaNamer{
Spec: opts.Swagger(),
Operations: opRefsByRef(gatherOperations(opts.Spec, nil)),
flattenContext: opts.flattenContext,
opts: opts,
}
depthFirst := sortDepthFirst(opts.Spec.al... | go | func nameInlinedSchemas(opts *FlattenOpts) error {
debugLog("nameInlinedSchemas")
namer := &inlineSchemaNamer{
Spec: opts.Swagger(),
Operations: opRefsByRef(gatherOperations(opts.Spec, nil)),
flattenContext: opts.flattenContext,
opts: opts,
}
depthFirst := sortDepthFirst(opts.Spec.al... | [
"func",
"nameInlinedSchemas",
"(",
"opts",
"*",
"FlattenOpts",
")",
"error",
"{",
"debugLog",
"(",
"\"",
"\"",
")",
"\n",
"namer",
":=",
"&",
"inlineSchemaNamer",
"{",
"Spec",
":",
"opts",
".",
"Swagger",
"(",
")",
",",
"Operations",
":",
"opRefsByRef",
... | // nameInlinedSchemas replaces every complex inline construct by a named definition. | [
"nameInlinedSchemas",
"replaces",
"every",
"complex",
"inline",
"construct",
"by",
"a",
"named",
"definition",
"."
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/flatten.go#L241-L266 |
141,098 | go-openapi/analysis | flatten.go | normalizePath | func normalizePath(ref swspec.Ref, opts *FlattenOpts) (normalizedPath string) {
if ref.HasFragmentOnly || filepath.IsAbs(ref.String()) {
normalizedPath = ref.String()
return
}
refURL, _ := url.Parse(ref.String())
if refURL.Host != "" {
normalizedPath = ref.String()
return
}
parts := strings.Split(ref.St... | go | func normalizePath(ref swspec.Ref, opts *FlattenOpts) (normalizedPath string) {
if ref.HasFragmentOnly || filepath.IsAbs(ref.String()) {
normalizedPath = ref.String()
return
}
refURL, _ := url.Parse(ref.String())
if refURL.Host != "" {
normalizedPath = ref.String()
return
}
parts := strings.Split(ref.St... | [
"func",
"normalizePath",
"(",
"ref",
"swspec",
".",
"Ref",
",",
"opts",
"*",
"FlattenOpts",
")",
"(",
"normalizedPath",
"string",
")",
"{",
"if",
"ref",
".",
"HasFragmentOnly",
"||",
"filepath",
".",
"IsAbs",
"(",
"ref",
".",
"String",
"(",
")",
")",
"... | // normalizePath renders absolute path on remote file refs | [
"normalizePath",
"renders",
"absolute",
"path",
"on",
"remote",
"file",
"refs"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/flatten.go#L872-L888 |
141,099 | go-openapi/analysis | flatten.go | getPointerFromKey | func getPointerFromKey(spec *swspec.Swagger, key string) (string, interface{}, error) {
// unescape chars in key, e.g. "{}" from path params
pth, _ := internal.PathUnescape(key[1:])
ptr, err := jsonpointer.New(pth)
if err != nil {
return "", nil, err
}
value, _, err := ptr.Get(spec)
if err != nil {
debugLog... | go | func getPointerFromKey(spec *swspec.Swagger, key string) (string, interface{}, error) {
// unescape chars in key, e.g. "{}" from path params
pth, _ := internal.PathUnescape(key[1:])
ptr, err := jsonpointer.New(pth)
if err != nil {
return "", nil, err
}
value, _, err := ptr.Get(spec)
if err != nil {
debugLog... | [
"func",
"getPointerFromKey",
"(",
"spec",
"*",
"swspec",
".",
"Swagger",
",",
"key",
"string",
")",
"(",
"string",
",",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// unescape chars in key, e.g. \"{}\" from path params",
"pth",
",",
"_",
":=",
"internal",
... | // getPointerFromKey retrieves the content of the JSON pointer "key" | [
"getPointerFromKey",
"retrieves",
"the",
"content",
"of",
"the",
"JSON",
"pointer",
"key"
] | e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014 | https://github.com/go-openapi/analysis/blob/e2f3fdbb7ed0e56e070ccbfb6fc75b288a33c014/flatten.go#L938-L952 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.