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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
148,900 | magefile/mage | mage/main.go | Magefiles | func Magefiles(magePath, goos, goarch, goCmd string, stderr io.Writer, isDebug bool) ([]string, error) {
start := time.Now()
defer func() {
debug.Println("time to scan for Magefiles:", time.Since(start))
}()
fail := func(err error) ([]string, error) {
return nil, err
}
env, err := internal.EnvWithGOOS(goos, ... | go | func Magefiles(magePath, goos, goarch, goCmd string, stderr io.Writer, isDebug bool) ([]string, error) {
start := time.Now()
defer func() {
debug.Println("time to scan for Magefiles:", time.Since(start))
}()
fail := func(err error) ([]string, error) {
return nil, err
}
env, err := internal.EnvWithGOOS(goos, ... | [
"func",
"Magefiles",
"(",
"magePath",
",",
"goos",
",",
"goarch",
",",
"goCmd",
"string",
",",
"stderr",
"io",
".",
"Writer",
",",
"isDebug",
"bool",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",... | // Magefiles returns the list of magefiles in dir. | [
"Magefiles",
"returns",
"the",
"list",
"of",
"magefiles",
"in",
"dir",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L411-L471 |
148,901 | magefile/mage | mage/main.go | Compile | func Compile(goos, goarch, magePath, goCmd, compileTo string, gofiles []string, isDebug bool, stderr, stdout io.Writer) error {
debug.Println("compiling to", compileTo)
debug.Println("compiling using gocmd:", goCmd)
if isDebug {
internal.RunDebug(goCmd, "version")
internal.RunDebug(goCmd, "env")
}
environ, err... | go | func Compile(goos, goarch, magePath, goCmd, compileTo string, gofiles []string, isDebug bool, stderr, stdout io.Writer) error {
debug.Println("compiling to", compileTo)
debug.Println("compiling using gocmd:", goCmd)
if isDebug {
internal.RunDebug(goCmd, "version")
internal.RunDebug(goCmd, "env")
}
environ, err... | [
"func",
"Compile",
"(",
"goos",
",",
"goarch",
",",
"magePath",
",",
"goCmd",
",",
"compileTo",
"string",
",",
"gofiles",
"[",
"]",
"string",
",",
"isDebug",
"bool",
",",
"stderr",
",",
"stdout",
"io",
".",
"Writer",
")",
"error",
"{",
"debug",
".",
... | // Compile uses the go tool to compile the files into an executable at path. | [
"Compile",
"uses",
"the",
"go",
"tool",
"to",
"compile",
"the",
"files",
"into",
"an",
"executable",
"at",
"path",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L474-L502 |
148,902 | magefile/mage | mage/main.go | GenerateMainfile | func GenerateMainfile(binaryName, path string, info *parse.PkgInfo) error {
debug.Println("Creating mainfile at", path)
f, err := os.Create(path)
if err != nil {
return fmt.Errorf("error creating generated mainfile: %v", err)
}
defer f.Close()
data := mainfileTemplateData{
Description: info.Description,
Fu... | go | func GenerateMainfile(binaryName, path string, info *parse.PkgInfo) error {
debug.Println("Creating mainfile at", path)
f, err := os.Create(path)
if err != nil {
return fmt.Errorf("error creating generated mainfile: %v", err)
}
defer f.Close()
data := mainfileTemplateData{
Description: info.Description,
Fu... | [
"func",
"GenerateMainfile",
"(",
"binaryName",
",",
"path",
"string",
",",
"info",
"*",
"parse",
".",
"PkgInfo",
")",
"error",
"{",
"debug",
".",
"Println",
"(",
"\"",
"\"",
",",
"path",
")",
"\n\n",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
... | // GenerateMainfile generates the mage mainfile at path. | [
"GenerateMainfile",
"generates",
"the",
"mage",
"mainfile",
"at",
"path",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L505-L539 |
148,903 | magefile/mage | mage/main.go | ExeName | func ExeName(goCmd, cacheDir string, files []string) (string, error) {
var hashes []string
for _, s := range files {
h, err := hashFile(s)
if err != nil {
return "", err
}
hashes = append(hashes, h)
}
// hash the mainfile template to ensure if it gets updated, we make a new
// binary.
hashes = append(h... | go | func ExeName(goCmd, cacheDir string, files []string) (string, error) {
var hashes []string
for _, s := range files {
h, err := hashFile(s)
if err != nil {
return "", err
}
hashes = append(hashes, h)
}
// hash the mainfile template to ensure if it gets updated, we make a new
// binary.
hashes = append(h... | [
"func",
"ExeName",
"(",
"goCmd",
",",
"cacheDir",
"string",
",",
"files",
"[",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"hashes",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"files",
"{",
"h",
",",
"err... | // ExeName reports the executable filename that this version of Mage would
// create for the given magefiles. | [
"ExeName",
"reports",
"the",
"executable",
"filename",
"that",
"this",
"version",
"of",
"Mage",
"would",
"create",
"for",
"the",
"given",
"magefiles",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L543-L568 |
148,904 | magefile/mage | mage/main.go | RunCompiled | func RunCompiled(inv Invocation, exePath string, errlog *log.Logger) int {
debug.Println("running binary", exePath)
c := exec.Command(exePath, inv.Args...)
c.Stderr = inv.Stderr
c.Stdout = inv.Stdout
c.Stdin = inv.Stdin
c.Dir = inv.Dir
// intentionally pass through unaltered os.Environ here.. your magefile has
... | go | func RunCompiled(inv Invocation, exePath string, errlog *log.Logger) int {
debug.Println("running binary", exePath)
c := exec.Command(exePath, inv.Args...)
c.Stderr = inv.Stderr
c.Stdout = inv.Stdout
c.Stdin = inv.Stdin
c.Dir = inv.Dir
// intentionally pass through unaltered os.Environ here.. your magefile has
... | [
"func",
"RunCompiled",
"(",
"inv",
"Invocation",
",",
"exePath",
"string",
",",
"errlog",
"*",
"log",
".",
"Logger",
")",
"int",
"{",
"debug",
".",
"Println",
"(",
"\"",
"\"",
",",
"exePath",
")",
"\n",
"c",
":=",
"exec",
".",
"Command",
"(",
"exePat... | // RunCompiled runs an already-compiled mage command with the given args, | [
"RunCompiled",
"runs",
"an",
"already",
"-",
"compiled",
"mage",
"command",
"with",
"the",
"given",
"args"
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L600-L634 |
148,905 | magefile/mage | mage/main.go | removeContents | func removeContents(dir string) error {
debug.Println("removing all files in", dir)
files, err := ioutil.ReadDir(dir)
if err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
for _, f := range files {
if f.IsDir() {
continue
}
err = os.Remove(filepath.Join(dir, f.Name()))
if err != nil... | go | func removeContents(dir string) error {
debug.Println("removing all files in", dir)
files, err := ioutil.ReadDir(dir)
if err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
for _, f := range files {
if f.IsDir() {
continue
}
err = os.Remove(filepath.Join(dir, f.Name()))
if err != nil... | [
"func",
"removeContents",
"(",
"dir",
"string",
")",
"error",
"{",
"debug",
".",
"Println",
"(",
"\"",
"\"",
",",
"dir",
")",
"\n",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"dir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"... | // removeContents removes all files but not any subdirectories in the given
// directory. | [
"removeContents",
"removes",
"all",
"files",
"but",
"not",
"any",
"subdirectories",
"in",
"the",
"given",
"directory",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L648-L668 |
148,906 | magefile/mage | magefile.go | Install | func Install() error {
name := "mage"
if runtime.GOOS == "windows" {
name += ".exe"
}
gocmd := mg.GoCmd()
// use GOBIN if set in the environment, otherwise fall back to first path
// in GOPATH environment string
bin, err := sh.Output(gocmd, "env", "GOBIN")
if err != nil {
return fmt.Errorf("can't determine... | go | func Install() error {
name := "mage"
if runtime.GOOS == "windows" {
name += ".exe"
}
gocmd := mg.GoCmd()
// use GOBIN if set in the environment, otherwise fall back to first path
// in GOPATH environment string
bin, err := sh.Output(gocmd, "env", "GOBIN")
if err != nil {
return fmt.Errorf("can't determine... | [
"func",
"Install",
"(",
")",
"error",
"{",
"name",
":=",
"\"",
"\"",
"\n",
"if",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{",
"name",
"+=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"gocmd",
":=",
"mg",
".",
"GoCmd",
"(",
")",
"\n",
"// use GOBIN if set in ... | // Runs "go install" for mage. This generates the version info the binary. | [
"Runs",
"go",
"install",
"for",
"mage",
".",
"This",
"generates",
"the",
"version",
"info",
"the",
"binary",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/magefile.go#L23-L56 |
148,907 | magefile/mage | magefile.go | Release | func Release() (err error) {
tag := os.Getenv("TAG")
if !releaseTag.MatchString(tag) {
return errors.New("TAG environment variable must be in semver v1.x.x format, but was " + tag)
}
if err := sh.RunV("git", "tag", "-a", tag, "-m", tag); err != nil {
return err
}
if err := sh.RunV("git", "push", "origin", ta... | go | func Release() (err error) {
tag := os.Getenv("TAG")
if !releaseTag.MatchString(tag) {
return errors.New("TAG environment variable must be in semver v1.x.x format, but was " + tag)
}
if err := sh.RunV("git", "tag", "-a", tag, "-m", tag); err != nil {
return err
}
if err := sh.RunV("git", "push", "origin", ta... | [
"func",
"Release",
"(",
")",
"(",
"err",
"error",
")",
"{",
"tag",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"!",
"releaseTag",
".",
"MatchString",
"(",
"tag",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
"+",
"... | // Generates a new release. Expects the TAG environment variable to be set,
// which will create a new tag with that name. | [
"Generates",
"a",
"new",
"release",
".",
"Expects",
"the",
"TAG",
"environment",
"variable",
"to",
"be",
"set",
"which",
"will",
"create",
"a",
"new",
"tag",
"with",
"that",
"name",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/magefile.go#L62-L81 |
148,908 | magefile/mage | parse/parse.go | ID | func (f Function) ID() string {
path := "<current>"
if f.ImportPath != "" {
path = f.ImportPath
}
receiver := ""
if f.Receiver != "" {
receiver = f.Receiver + "."
}
return fmt.Sprintf("%s.%s%s", path, receiver, f.Name)
} | go | func (f Function) ID() string {
path := "<current>"
if f.ImportPath != "" {
path = f.ImportPath
}
receiver := ""
if f.Receiver != "" {
receiver = f.Receiver + "."
}
return fmt.Sprintf("%s.%s%s", path, receiver, f.Name)
} | [
"func",
"(",
"f",
"Function",
")",
"ID",
"(",
")",
"string",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"if",
"f",
".",
"ImportPath",
"!=",
"\"",
"\"",
"{",
"path",
"=",
"f",
".",
"ImportPath",
"\n",
"}",
"\n",
"receiver",
":=",
"\"",
"\"",
"\n",
"if... | // ID returns user-readable information about where this function is defined. | [
"ID",
"returns",
"user",
"-",
"readable",
"information",
"about",
"where",
"this",
"function",
"is",
"defined",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L54-L64 |
148,909 | magefile/mage | parse/parse.go | TargetName | func (f Function) TargetName() string {
var names []string
for _, s := range []string{f.PkgAlias, f.Receiver, f.Name} {
if s != "" {
names = append(names, s)
}
}
return strings.Join(names, ":")
} | go | func (f Function) TargetName() string {
var names []string
for _, s := range []string{f.PkgAlias, f.Receiver, f.Name} {
if s != "" {
names = append(names, s)
}
}
return strings.Join(names, ":")
} | [
"func",
"(",
"f",
"Function",
")",
"TargetName",
"(",
")",
"string",
"{",
"var",
"names",
"[",
"]",
"string",
"\n\n",
"for",
"_",
",",
"s",
":=",
"range",
"[",
"]",
"string",
"{",
"f",
".",
"PkgAlias",
",",
"f",
".",
"Receiver",
",",
"f",
".",
... | // TargetName returns the name of the target as it should appear when used from
// the mage cli. It is always lowercase. | [
"TargetName",
"returns",
"the",
"name",
"of",
"the",
"target",
"as",
"it",
"should",
"appear",
"when",
"used",
"from",
"the",
"mage",
"cli",
".",
"It",
"is",
"always",
"lowercase",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L68-L77 |
148,910 | magefile/mage | parse/parse.go | PrimaryPackage | func PrimaryPackage(gocmd, path string, files []string) (*PkgInfo, error) {
info, err := Package(path, files)
if err != nil {
return nil, err
}
if err := setImports(gocmd, info); err != nil {
return nil, err
}
setDefault(info)
setAliases(info)
return info, nil
} | go | func PrimaryPackage(gocmd, path string, files []string) (*PkgInfo, error) {
info, err := Package(path, files)
if err != nil {
return nil, err
}
if err := setImports(gocmd, info); err != nil {
return nil, err
}
setDefault(info)
setAliases(info)
return info, nil
} | [
"func",
"PrimaryPackage",
"(",
"gocmd",
",",
"path",
"string",
",",
"files",
"[",
"]",
"string",
")",
"(",
"*",
"PkgInfo",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"Package",
"(",
"path",
",",
"files",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // PrimaryPackage parses a package. If files is non-empty, it will only parse the files given. | [
"PrimaryPackage",
"parses",
"a",
"package",
".",
"If",
"files",
"is",
"non",
"-",
"empty",
"it",
"will",
"only",
"parse",
"the",
"files",
"given",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L129-L142 |
148,911 | magefile/mage | parse/parse.go | Package | func Package(path string, files []string) (*PkgInfo, error) {
start := time.Now()
defer func() {
debug.Println("time parse Magefiles:", time.Since(start))
}()
fset := token.NewFileSet()
pkg, err := getPackage(path, files, fset)
if err != nil {
return nil, err
}
p := doc.New(pkg, "./", 0)
pi := &PkgInfo{
... | go | func Package(path string, files []string) (*PkgInfo, error) {
start := time.Now()
defer func() {
debug.Println("time parse Magefiles:", time.Since(start))
}()
fset := token.NewFileSet()
pkg, err := getPackage(path, files, fset)
if err != nil {
return nil, err
}
p := doc.New(pkg, "./", 0)
pi := &PkgInfo{
... | [
"func",
"Package",
"(",
"path",
"string",
",",
"files",
"[",
"]",
"string",
")",
"(",
"*",
"PkgInfo",
",",
"error",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"debug",
".",
"Println",
"(",
"\"",
... | // Package compiles information about a mage package. | [
"Package",
"compiles",
"information",
"about",
"a",
"mage",
"package",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L186-L218 |
148,912 | magefile/mage | parse/parse.go | checkDupeTargets | func checkDupeTargets(info *PkgInfo) (hasDupes bool, names map[string][]string) {
names = map[string][]string{}
lowers := map[string]bool{}
for _, f := range info.Funcs {
low := strings.ToLower(f.Name)
if f.Receiver != "" {
low = strings.ToLower(f.Receiver) + ":" + low
}
if lowers[low] {
hasDupes = tru... | go | func checkDupeTargets(info *PkgInfo) (hasDupes bool, names map[string][]string) {
names = map[string][]string{}
lowers := map[string]bool{}
for _, f := range info.Funcs {
low := strings.ToLower(f.Name)
if f.Receiver != "" {
low = strings.ToLower(f.Receiver) + ":" + low
}
if lowers[low] {
hasDupes = tru... | [
"func",
"checkDupeTargets",
"(",
"info",
"*",
"PkgInfo",
")",
"(",
"hasDupes",
"bool",
",",
"names",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"{",
"names",
"=",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"{",
"}",
"\n",
"lowers",
":=... | // checkDupeTargets checks a package for duplicate target names. | [
"checkDupeTargets",
"checks",
"a",
"package",
"for",
"duplicate",
"target",
"names",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L463-L478 |
148,913 | magefile/mage | parse/parse.go | sanitizeSynopsis | func sanitizeSynopsis(f *doc.Func) string {
synopsis := doc.Synopsis(f.Doc)
// If the synopsis begins with the function name, remove it. This is done to
// not repeat the text.
// From:
// clean Clean removes the temporarily generated files
// To:
// clean removes the temporarily generated files
if syns := st... | go | func sanitizeSynopsis(f *doc.Func) string {
synopsis := doc.Synopsis(f.Doc)
// If the synopsis begins with the function name, remove it. This is done to
// not repeat the text.
// From:
// clean Clean removes the temporarily generated files
// To:
// clean removes the temporarily generated files
if syns := st... | [
"func",
"sanitizeSynopsis",
"(",
"f",
"*",
"doc",
".",
"Func",
")",
"string",
"{",
"synopsis",
":=",
"doc",
".",
"Synopsis",
"(",
"f",
".",
"Doc",
")",
"\n\n",
"// If the synopsis begins with the function name, remove it. This is done to",
"// not repeat the text.",
"... | // sanitizeSynopsis sanitizes function Doc to create a summary. | [
"sanitizeSynopsis",
"sanitizes",
"function",
"Doc",
"to",
"create",
"a",
"summary",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L481-L495 |
148,914 | magefile/mage | parse/parse.go | getPackage | func getPackage(path string, files []string, fset *token.FileSet) (*ast.Package, error) {
var filter func(f os.FileInfo) bool
if len(files) > 0 {
fm := make(map[string]bool, len(files))
for _, f := range files {
fm[f] = true
}
filter = func(f os.FileInfo) bool {
return fm[f.Name()]
}
}
pkgs, err :... | go | func getPackage(path string, files []string, fset *token.FileSet) (*ast.Package, error) {
var filter func(f os.FileInfo) bool
if len(files) > 0 {
fm := make(map[string]bool, len(files))
for _, f := range files {
fm[f] = true
}
filter = func(f os.FileInfo) bool {
return fm[f.Name()]
}
}
pkgs, err :... | [
"func",
"getPackage",
"(",
"path",
"string",
",",
"files",
"[",
"]",
"string",
",",
"fset",
"*",
"token",
".",
"FileSet",
")",
"(",
"*",
"ast",
".",
"Package",
",",
"error",
")",
"{",
"var",
"filter",
"func",
"(",
"f",
"os",
".",
"FileInfo",
")",
... | // getPackage returns the non-test package at the given path. | [
"getPackage",
"returns",
"the",
"non",
"-",
"test",
"package",
"at",
"the",
"given",
"path",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L657-L681 |
148,915 | magefile/mage | mg/errors.go | Fatal | func Fatal(code int, args ...interface{}) error {
return fatalErr{
code: code,
error: errors.New(fmt.Sprint(args...)),
}
} | go | func Fatal(code int, args ...interface{}) error {
return fatalErr{
code: code,
error: errors.New(fmt.Sprint(args...)),
}
} | [
"func",
"Fatal",
"(",
"code",
"int",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"fatalErr",
"{",
"code",
":",
"code",
",",
"error",
":",
"errors",
".",
"New",
"(",
"fmt",
".",
"Sprint",
"(",
"args",
"...",
")",
")",
"... | // Fatal returns an error that will cause mage to print out the
// given args and exit with the given exit code. | [
"Fatal",
"returns",
"an",
"error",
"that",
"will",
"cause",
"mage",
"to",
"print",
"out",
"the",
"given",
"args",
"and",
"exit",
"with",
"the",
"given",
"exit",
"code",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/errors.go#L23-L28 |
148,916 | magefile/mage | mg/errors.go | Fatalf | func Fatalf(code int, format string, args ...interface{}) error {
return fatalErr{
code: code,
error: fmt.Errorf(format, args...),
}
} | go | func Fatalf(code int, format string, args ...interface{}) error {
return fatalErr{
code: code,
error: fmt.Errorf(format, args...),
}
} | [
"func",
"Fatalf",
"(",
"code",
"int",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"fatalErr",
"{",
"code",
":",
"code",
",",
"error",
":",
"fmt",
".",
"Errorf",
"(",
"format",
",",
"args",
"...",
... | // Fatalf returns an error that will cause mage to print out the
// given message and exit with the given exit code. | [
"Fatalf",
"returns",
"an",
"error",
"that",
"will",
"cause",
"mage",
"to",
"print",
"out",
"the",
"given",
"message",
"and",
"exit",
"with",
"the",
"given",
"exit",
"code",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/errors.go#L32-L37 |
148,917 | magefile/mage | target/target.go | Dir | func Dir(dst string, sources ...string) (bool, error) {
stat, err := os.Stat(os.ExpandEnv(dst))
if os.IsNotExist(err) {
return true, nil
}
if err != nil {
return false, err
}
srcTime := stat.ModTime()
if stat.IsDir() {
srcTime, err = calDirModTimeRecursive(dst, stat)
if err != nil {
return false, err
... | go | func Dir(dst string, sources ...string) (bool, error) {
stat, err := os.Stat(os.ExpandEnv(dst))
if os.IsNotExist(err) {
return true, nil
}
if err != nil {
return false, err
}
srcTime := stat.ModTime()
if stat.IsDir() {
srcTime, err = calDirModTimeRecursive(dst, stat)
if err != nil {
return false, err
... | [
"func",
"Dir",
"(",
"dst",
"string",
",",
"sources",
"...",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"stat",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"os",
".",
"ExpandEnv",
"(",
"dst",
")",
")",
"\n",
"if",
"os",
".",
"IsNotExist",
... | // Dir reports whether any of the sources have been modified more recently than
// the destination. If a source or destination is a directory, modtimes of
// files under those directories are compared instead. If the destination file
// doesn't exist, it always returns true and nil. It's an error if any of the
// so... | [
"Dir",
"reports",
"whether",
"any",
"of",
"the",
"sources",
"have",
"been",
"modified",
"more",
"recently",
"than",
"the",
"destination",
".",
"If",
"a",
"source",
"or",
"destination",
"is",
"a",
"directory",
"modtimes",
"of",
"files",
"under",
"those",
"dir... | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/target/target.go#L79-L106 |
148,918 | magefile/mage | sh/cmd.go | OutCmd | func OutCmd(cmd string, args ...string) func(args ...string) (string, error) {
return func(args2 ...string) (string, error) {
return Output(cmd, append(args, args2...)...)
}
} | go | func OutCmd(cmd string, args ...string) func(args ...string) (string, error) {
return func(args2 ...string) (string, error) {
return Output(cmd, append(args, args2...)...)
}
} | [
"func",
"OutCmd",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"func",
"(",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"func",
"(",
"args2",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{"... | // OutCmd is like RunCmd except the command returns the output of the
// command. | [
"OutCmd",
"is",
"like",
"RunCmd",
"except",
"the",
"command",
"returns",
"the",
"output",
"of",
"the",
"command",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/cmd.go#L42-L46 |
148,919 | magefile/mage | sh/cmd.go | Run | func Run(cmd string, args ...string) error {
return RunWith(nil, cmd, args...)
} | go | func Run(cmd string, args ...string) error {
return RunWith(nil, cmd, args...)
} | [
"func",
"Run",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"return",
"RunWith",
"(",
"nil",
",",
"cmd",
",",
"args",
"...",
")",
"\n",
"}"
] | // Run is like RunWith, but doesn't specify any environment variables. | [
"Run",
"is",
"like",
"RunWith",
"but",
"doesn",
"t",
"specify",
"any",
"environment",
"variables",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/cmd.go#L49-L51 |
148,920 | magefile/mage | sh/cmd.go | RunV | func RunV(cmd string, args ...string) error {
_, err := Exec(nil, os.Stdout, os.Stderr, cmd, args...)
return err
} | go | func RunV(cmd string, args ...string) error {
_, err := Exec(nil, os.Stdout, os.Stderr, cmd, args...)
return err
} | [
"func",
"RunV",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"Exec",
"(",
"nil",
",",
"os",
".",
"Stdout",
",",
"os",
".",
"Stderr",
",",
"cmd",
",",
"args",
"...",
")",
"\n",
"return",
"err",
"\... | // RunV is like Run, but always sends the command's stdout to os.Stdout. | [
"RunV",
"is",
"like",
"Run",
"but",
"always",
"sends",
"the",
"command",
"s",
"stdout",
"to",
"os",
".",
"Stdout",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/cmd.go#L54-L57 |
148,921 | magefile/mage | sh/cmd.go | RunWith | func RunWith(env map[string]string, cmd string, args ...string) error {
var output io.Writer
if mg.Verbose() {
output = os.Stdout
}
_, err := Exec(env, output, os.Stderr, cmd, args...)
return err
} | go | func RunWith(env map[string]string, cmd string, args ...string) error {
var output io.Writer
if mg.Verbose() {
output = os.Stdout
}
_, err := Exec(env, output, os.Stderr, cmd, args...)
return err
} | [
"func",
"RunWith",
"(",
"env",
"map",
"[",
"string",
"]",
"string",
",",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"var",
"output",
"io",
".",
"Writer",
"\n",
"if",
"mg",
".",
"Verbose",
"(",
")",
"{",
"output",
"=",
"os",
... | // RunWith runs the given command, directing stderr to this program's stderr and
// printing stdout to stdout if mage was run with -v. It adds adds env to the
// environment variables for the command being run. Environment variables should
// be in the format name=value. | [
"RunWith",
"runs",
"the",
"given",
"command",
"directing",
"stderr",
"to",
"this",
"program",
"s",
"stderr",
"and",
"printing",
"stdout",
"to",
"stdout",
"if",
"mage",
"was",
"run",
"with",
"-",
"v",
".",
"It",
"adds",
"adds",
"env",
"to",
"the",
"enviro... | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/cmd.go#L63-L70 |
148,922 | magefile/mage | sh/cmd.go | Output | func Output(cmd string, args ...string) (string, error) {
buf := &bytes.Buffer{}
_, err := Exec(nil, buf, os.Stderr, cmd, args...)
return strings.TrimSuffix(buf.String(), "\n"), err
} | go | func Output(cmd string, args ...string) (string, error) {
buf := &bytes.Buffer{}
_, err := Exec(nil, buf, os.Stderr, cmd, args...)
return strings.TrimSuffix(buf.String(), "\n"), err
} | [
"func",
"Output",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"Exec",
"(",
"nil",
",",
"buf",
",",
"os",
".",
... | // Output runs the command and returns the text from stdout. | [
"Output",
"runs",
"the",
"command",
"and",
"returns",
"the",
"text",
"from",
"stdout",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/cmd.go#L73-L77 |
148,923 | magefile/mage | sh/cmd.go | OutputWith | func OutputWith(env map[string]string, cmd string, args ...string) (string, error) {
buf := &bytes.Buffer{}
_, err := Exec(env, buf, os.Stderr, cmd, args...)
return strings.TrimSuffix(buf.String(), "\n"), err
} | go | func OutputWith(env map[string]string, cmd string, args ...string) (string, error) {
buf := &bytes.Buffer{}
_, err := Exec(env, buf, os.Stderr, cmd, args...)
return strings.TrimSuffix(buf.String(), "\n"), err
} | [
"func",
"OutputWith",
"(",
"env",
"map",
"[",
"string",
"]",
"string",
",",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"_",
",",
"err",
":="... | // OutputWith is like RunWith, but returns what is written to stdout. | [
"OutputWith",
"is",
"like",
"RunWith",
"but",
"returns",
"what",
"is",
"written",
"to",
"stdout",
"."
] | 5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed | https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/cmd.go#L80-L84 |
148,924 | appleboy/gin-jwt | auth_jwt.go | New | func New(m *GinJWTMiddleware) (*GinJWTMiddleware, error) {
if err := m.MiddlewareInit(); err != nil {
return nil, err
}
return m, nil
} | go | func New(m *GinJWTMiddleware) (*GinJWTMiddleware, error) {
if err := m.MiddlewareInit(); err != nil {
return nil, err
}
return m, nil
} | [
"func",
"New",
"(",
"m",
"*",
"GinJWTMiddleware",
")",
"(",
"*",
"GinJWTMiddleware",
",",
"error",
")",
"{",
"if",
"err",
":=",
"m",
".",
"MiddlewareInit",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"ret... | // New for check error with GinJWTMiddleware | [
"New",
"for",
"check",
"error",
"with",
"GinJWTMiddleware"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L193-L199 |
148,925 | appleboy/gin-jwt | auth_jwt.go | MiddlewareInit | func (mw *GinJWTMiddleware) MiddlewareInit() error {
if mw.TokenLookup == "" {
mw.TokenLookup = "header:Authorization"
}
if mw.SigningAlgorithm == "" {
mw.SigningAlgorithm = "HS256"
}
if mw.Timeout == 0 {
mw.Timeout = time.Hour
}
if mw.TimeFunc == nil {
mw.TimeFunc = time.Now
}
mw.TokenHeadName = ... | go | func (mw *GinJWTMiddleware) MiddlewareInit() error {
if mw.TokenLookup == "" {
mw.TokenLookup = "header:Authorization"
}
if mw.SigningAlgorithm == "" {
mw.SigningAlgorithm = "HS256"
}
if mw.Timeout == 0 {
mw.Timeout = time.Hour
}
if mw.TimeFunc == nil {
mw.TimeFunc = time.Now
}
mw.TokenHeadName = ... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"MiddlewareInit",
"(",
")",
"error",
"{",
"if",
"mw",
".",
"TokenLookup",
"==",
"\"",
"\"",
"{",
"mw",
".",
"TokenLookup",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"mw",
".",
"SigningAlgorithm",
"==",
... | // MiddlewareInit initialize jwt configs. | [
"MiddlewareInit",
"initialize",
"jwt",
"configs",
"."
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L248-L339 |
148,926 | appleboy/gin-jwt | auth_jwt.go | MiddlewareFunc | func (mw *GinJWTMiddleware) MiddlewareFunc() gin.HandlerFunc {
return func(c *gin.Context) {
mw.middlewareImpl(c)
}
} | go | func (mw *GinJWTMiddleware) MiddlewareFunc() gin.HandlerFunc {
return func(c *gin.Context) {
mw.middlewareImpl(c)
}
} | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"MiddlewareFunc",
"(",
")",
"gin",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"mw",
".",
"middlewareImpl",
"(",
"c",
")",
"\n",
"}",
"\n",
"}"
] | // MiddlewareFunc makes GinJWTMiddleware implement the Middleware interface. | [
"MiddlewareFunc",
"makes",
"GinJWTMiddleware",
"implement",
"the",
"Middleware",
"interface",
"."
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L342-L346 |
148,927 | appleboy/gin-jwt | auth_jwt.go | GetClaimsFromJWT | func (mw *GinJWTMiddleware) GetClaimsFromJWT(c *gin.Context) (MapClaims, error) {
token, err := mw.ParseToken(c)
if err != nil {
return nil, err
}
if mw.SendAuthorization {
if v, ok := c.Get("JWT_TOKEN"); ok {
c.Header("Authorization", mw.TokenHeadName+" "+v.(string))
}
}
claims := MapClaims{}
for ke... | go | func (mw *GinJWTMiddleware) GetClaimsFromJWT(c *gin.Context) (MapClaims, error) {
token, err := mw.ParseToken(c)
if err != nil {
return nil, err
}
if mw.SendAuthorization {
if v, ok := c.Get("JWT_TOKEN"); ok {
c.Header("Authorization", mw.TokenHeadName+" "+v.(string))
}
}
claims := MapClaims{}
for ke... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"GetClaimsFromJWT",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"(",
"MapClaims",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"mw",
".",
"ParseToken",
"(",
"c",
")",
"\n\n",
"if",
"err",
"!=",
... | // GetClaimsFromJWT get claims from JWT token | [
"GetClaimsFromJWT",
"get",
"claims",
"from",
"JWT",
"token"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L386-L405 |
148,928 | appleboy/gin-jwt | auth_jwt.go | RefreshToken | func (mw *GinJWTMiddleware) RefreshToken(c *gin.Context) (string, time.Time, error) {
claims, err := mw.CheckIfTokenExpire(c)
if err != nil {
return "", time.Now(), err
}
// Create the token
newToken := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm))
newClaims := newToken.Claims.(jwt.MapClaims)
for key :=... | go | func (mw *GinJWTMiddleware) RefreshToken(c *gin.Context) (string, time.Time, error) {
claims, err := mw.CheckIfTokenExpire(c)
if err != nil {
return "", time.Now(), err
}
// Create the token
newToken := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm))
newClaims := newToken.Claims.(jwt.MapClaims)
for key :=... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"RefreshToken",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"(",
"string",
",",
"time",
".",
"Time",
",",
"error",
")",
"{",
"claims",
",",
"err",
":=",
"mw",
".",
"CheckIfTokenExpire",
"(",
"c",
")",
... | // RefreshToken refresh token and check if token is expired | [
"RefreshToken",
"refresh",
"token",
"and",
"check",
"if",
"token",
"is",
"expired"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L485-L523 |
148,929 | appleboy/gin-jwt | auth_jwt.go | CheckIfTokenExpire | func (mw *GinJWTMiddleware) CheckIfTokenExpire(c *gin.Context) (jwt.MapClaims, error) {
token, err := mw.ParseToken(c)
if err != nil {
// If we receive an error, and the error is anything other than a single
// ValidationErrorExpired, we want to return the error.
// If the error is just ValidationErrorExpired,... | go | func (mw *GinJWTMiddleware) CheckIfTokenExpire(c *gin.Context) (jwt.MapClaims, error) {
token, err := mw.ParseToken(c)
if err != nil {
// If we receive an error, and the error is anything other than a single
// ValidationErrorExpired, we want to return the error.
// If the error is just ValidationErrorExpired,... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"CheckIfTokenExpire",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"(",
"jwt",
".",
"MapClaims",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"mw",
".",
"ParseToken",
"(",
"c",
")",
"\n\n",
"if",
... | // CheckIfTokenExpire check if token expire | [
"CheckIfTokenExpire",
"check",
"if",
"token",
"expire"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L526-L550 |
148,930 | appleboy/gin-jwt | auth_jwt.go | TokenGenerator | func (mw *GinJWTMiddleware) TokenGenerator(data interface{}) (string, time.Time, error) {
token := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm))
claims := token.Claims.(jwt.MapClaims)
if mw.PayloadFunc != nil {
for key, value := range mw.PayloadFunc(data) {
claims[key] = value
}
}
expire := mw.TimeFu... | go | func (mw *GinJWTMiddleware) TokenGenerator(data interface{}) (string, time.Time, error) {
token := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm))
claims := token.Claims.(jwt.MapClaims)
if mw.PayloadFunc != nil {
for key, value := range mw.PayloadFunc(data) {
claims[key] = value
}
}
expire := mw.TimeFu... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"TokenGenerator",
"(",
"data",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"time",
".",
"Time",
",",
"error",
")",
"{",
"token",
":=",
"jwt",
".",
"New",
"(",
"jwt",
".",
"GetSigningMethod",
"(",
"... | // TokenGenerator method that clients can use to get a jwt token. | [
"TokenGenerator",
"method",
"that",
"clients",
"can",
"use",
"to",
"get",
"a",
"jwt",
"token",
"."
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L553-L572 |
148,931 | appleboy/gin-jwt | auth_jwt.go | ParseToken | func (mw *GinJWTMiddleware) ParseToken(c *gin.Context) (*jwt.Token, error) {
var token string
var err error
methods := strings.Split(mw.TokenLookup, ",")
for _, method := range methods {
if len(token) > 0 {
break
}
parts := strings.Split(strings.TrimSpace(method), ":")
k := strings.TrimSpace(parts[0])
... | go | func (mw *GinJWTMiddleware) ParseToken(c *gin.Context) (*jwt.Token, error) {
var token string
var err error
methods := strings.Split(mw.TokenLookup, ",")
for _, method := range methods {
if len(token) > 0 {
break
}
parts := strings.Split(strings.TrimSpace(method), ":")
k := strings.TrimSpace(parts[0])
... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"ParseToken",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"(",
"*",
"jwt",
".",
"Token",
",",
"error",
")",
"{",
"var",
"token",
"string",
"\n",
"var",
"err",
"error",
"\n\n",
"methods",
":=",
"strings"... | // ParseToken parse jwt token from gin context | [
"ParseToken",
"parse",
"jwt",
"token",
"from",
"gin",
"context"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L620-L661 |
148,932 | appleboy/gin-jwt | auth_jwt.go | ParseTokenString | func (mw *GinJWTMiddleware) ParseTokenString(token string) (*jwt.Token, error) {
return jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
if jwt.GetSigningMethod(mw.SigningAlgorithm) != t.Method {
return nil, ErrInvalidSigningAlgorithm
}
if mw.usingPublicKeyAlgo() {
return mw.pubKey, nil
}
re... | go | func (mw *GinJWTMiddleware) ParseTokenString(token string) (*jwt.Token, error) {
return jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
if jwt.GetSigningMethod(mw.SigningAlgorithm) != t.Method {
return nil, ErrInvalidSigningAlgorithm
}
if mw.usingPublicKeyAlgo() {
return mw.pubKey, nil
}
re... | [
"func",
"(",
"mw",
"*",
"GinJWTMiddleware",
")",
"ParseTokenString",
"(",
"token",
"string",
")",
"(",
"*",
"jwt",
".",
"Token",
",",
"error",
")",
"{",
"return",
"jwt",
".",
"Parse",
"(",
"token",
",",
"func",
"(",
"t",
"*",
"jwt",
".",
"Token",
"... | // ParseTokenString parse jwt token string | [
"ParseTokenString",
"parse",
"jwt",
"token",
"string"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L664-L675 |
148,933 | appleboy/gin-jwt | auth_jwt.go | ExtractClaims | func ExtractClaims(c *gin.Context) MapClaims {
claims, exists := c.Get("JWT_PAYLOAD")
if !exists {
return make(MapClaims)
}
return claims.(MapClaims)
} | go | func ExtractClaims(c *gin.Context) MapClaims {
claims, exists := c.Get("JWT_PAYLOAD")
if !exists {
return make(MapClaims)
}
return claims.(MapClaims)
} | [
"func",
"ExtractClaims",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"MapClaims",
"{",
"claims",
",",
"exists",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"!",
"exists",
"{",
"return",
"make",
"(",
"MapClaims",
")",
"\n",
"}",
"\n\n",
... | // ExtractClaims help to extract the JWT claims | [
"ExtractClaims",
"help",
"to",
"extract",
"the",
"JWT",
"claims"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L687-L694 |
148,934 | appleboy/gin-jwt | auth_jwt.go | ExtractClaimsFromToken | func ExtractClaimsFromToken(token *jwt.Token) MapClaims {
if token == nil {
return make(MapClaims)
}
claims := MapClaims{}
for key, value := range token.Claims.(jwt.MapClaims) {
claims[key] = value
}
return claims
} | go | func ExtractClaimsFromToken(token *jwt.Token) MapClaims {
if token == nil {
return make(MapClaims)
}
claims := MapClaims{}
for key, value := range token.Claims.(jwt.MapClaims) {
claims[key] = value
}
return claims
} | [
"func",
"ExtractClaimsFromToken",
"(",
"token",
"*",
"jwt",
".",
"Token",
")",
"MapClaims",
"{",
"if",
"token",
"==",
"nil",
"{",
"return",
"make",
"(",
"MapClaims",
")",
"\n",
"}",
"\n\n",
"claims",
":=",
"MapClaims",
"{",
"}",
"\n",
"for",
"key",
","... | // ExtractClaimsFromToken help to extract the JWT claims from token | [
"ExtractClaimsFromToken",
"help",
"to",
"extract",
"the",
"JWT",
"claims",
"from",
"token"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L697-L708 |
148,935 | appleboy/gin-jwt | auth_jwt.go | GetToken | func GetToken(c *gin.Context) string {
token, exists := c.Get("JWT_TOKEN")
if !exists {
return ""
}
return token.(string)
} | go | func GetToken(c *gin.Context) string {
token, exists := c.Get("JWT_TOKEN")
if !exists {
return ""
}
return token.(string)
} | [
"func",
"GetToken",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"string",
"{",
"token",
",",
"exists",
":=",
"c",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"!",
"exists",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"token",
".",
... | // GetToken help to get the JWT token string | [
"GetToken",
"help",
"to",
"get",
"the",
"JWT",
"token",
"string"
] | 633d983b91f09beefb1128c4558d4642a379c602 | https://github.com/appleboy/gin-jwt/blob/633d983b91f09beefb1128c4558d4642a379c602/auth_jwt.go#L711-L718 |
148,936 | brianvoe/gofakeit | user_agent.go | UserAgent | func UserAgent() string {
randNum := randIntRange(0, 4)
switch randNum {
case 0:
return ChromeUserAgent()
case 1:
return FirefoxUserAgent()
case 2:
return SafariUserAgent()
case 3:
return OperaUserAgent()
default:
return ChromeUserAgent()
}
} | go | func UserAgent() string {
randNum := randIntRange(0, 4)
switch randNum {
case 0:
return ChromeUserAgent()
case 1:
return FirefoxUserAgent()
case 2:
return SafariUserAgent()
case 3:
return OperaUserAgent()
default:
return ChromeUserAgent()
}
} | [
"func",
"UserAgent",
"(",
")",
"string",
"{",
"randNum",
":=",
"randIntRange",
"(",
"0",
",",
"4",
")",
"\n",
"switch",
"randNum",
"{",
"case",
"0",
":",
"return",
"ChromeUserAgent",
"(",
")",
"\n",
"case",
"1",
":",
"return",
"FirefoxUserAgent",
"(",
... | // UserAgent will generate a random broswer user agent | [
"UserAgent",
"will",
"generate",
"a",
"random",
"broswer",
"user",
"agent"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/user_agent.go#L6-L20 |
148,937 | brianvoe/gofakeit | user_agent.go | ChromeUserAgent | func ChromeUserAgent() string {
randNum1 := strconv.Itoa(randIntRange(531, 536)) + strconv.Itoa(randIntRange(0, 2))
randNum2 := strconv.Itoa(randIntRange(36, 40))
randNum3 := strconv.Itoa(randIntRange(800, 899))
return "Mozilla/5.0 " + "(" + randomPlatform() + ") AppleWebKit/" + randNum1 + " (KHTML, like Gecko) Chr... | go | func ChromeUserAgent() string {
randNum1 := strconv.Itoa(randIntRange(531, 536)) + strconv.Itoa(randIntRange(0, 2))
randNum2 := strconv.Itoa(randIntRange(36, 40))
randNum3 := strconv.Itoa(randIntRange(800, 899))
return "Mozilla/5.0 " + "(" + randomPlatform() + ") AppleWebKit/" + randNum1 + " (KHTML, like Gecko) Chr... | [
"func",
"ChromeUserAgent",
"(",
")",
"string",
"{",
"randNum1",
":=",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"531",
",",
"536",
")",
")",
"+",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"0",
",",
"2",
")",
")",
"\n",
"randNum2",
":=... | // ChromeUserAgent will generate a random chrome browser user agent string | [
"ChromeUserAgent",
"will",
"generate",
"a",
"random",
"chrome",
"browser",
"user",
"agent",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/user_agent.go#L23-L28 |
148,938 | brianvoe/gofakeit | user_agent.go | FirefoxUserAgent | func FirefoxUserAgent() string {
ver := "Gecko/" + Date().Format("2006-02-01") + " Firefox/" + strconv.Itoa(randIntRange(35, 37)) + ".0"
platforms := []string{
"(" + windowsPlatformToken() + "; " + "en-US" + "; rv:1.9." + strconv.Itoa(randIntRange(0, 3)) + ".20) " + ver,
"(" + linuxPlatformToken() + "; rv:" + str... | go | func FirefoxUserAgent() string {
ver := "Gecko/" + Date().Format("2006-02-01") + " Firefox/" + strconv.Itoa(randIntRange(35, 37)) + ".0"
platforms := []string{
"(" + windowsPlatformToken() + "; " + "en-US" + "; rv:1.9." + strconv.Itoa(randIntRange(0, 3)) + ".20) " + ver,
"(" + linuxPlatformToken() + "; rv:" + str... | [
"func",
"FirefoxUserAgent",
"(",
")",
"string",
"{",
"ver",
":=",
"\"",
"\"",
"+",
"Date",
"(",
")",
".",
"Format",
"(",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"35",
",",
"37",
")",
")",
"+",
"\... | // FirefoxUserAgent will generate a random firefox broswer user agent string | [
"FirefoxUserAgent",
"will",
"generate",
"a",
"random",
"firefox",
"broswer",
"user",
"agent",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/user_agent.go#L31-L40 |
148,939 | brianvoe/gofakeit | user_agent.go | SafariUserAgent | func SafariUserAgent() string {
randNum := strconv.Itoa(randIntRange(531, 536)) + "." + strconv.Itoa(randIntRange(1, 51)) + "." + strconv.Itoa(randIntRange(1, 8))
ver := strconv.Itoa(randIntRange(4, 6)) + "." + strconv.Itoa(randIntRange(0, 2))
mobileDevices := []string{
"iPhone; CPU iPhone OS",
"iPad; CPU OS",
... | go | func SafariUserAgent() string {
randNum := strconv.Itoa(randIntRange(531, 536)) + "." + strconv.Itoa(randIntRange(1, 51)) + "." + strconv.Itoa(randIntRange(1, 8))
ver := strconv.Itoa(randIntRange(4, 6)) + "." + strconv.Itoa(randIntRange(0, 2))
mobileDevices := []string{
"iPhone; CPU iPhone OS",
"iPad; CPU OS",
... | [
"func",
"SafariUserAgent",
"(",
")",
"string",
"{",
"randNum",
":=",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"531",
",",
"536",
")",
")",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"1",
",",
"51",
")",
")",
"+... | // SafariUserAgent will generate a random safari browser user agent string | [
"SafariUserAgent",
"will",
"generate",
"a",
"random",
"safari",
"browser",
"user",
"agent",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/user_agent.go#L43-L59 |
148,940 | brianvoe/gofakeit | user_agent.go | OperaUserAgent | func OperaUserAgent() string {
platform := "(" + randomPlatform() + "; en-US) Presto/2." + strconv.Itoa(randIntRange(8, 13)) + "." + strconv.Itoa(randIntRange(160, 355)) + " Version/" + strconv.Itoa(randIntRange(10, 13)) + ".00"
return "Opera/" + strconv.Itoa(randIntRange(8, 10)) + "." + strconv.Itoa(randIntRange(10... | go | func OperaUserAgent() string {
platform := "(" + randomPlatform() + "; en-US) Presto/2." + strconv.Itoa(randIntRange(8, 13)) + "." + strconv.Itoa(randIntRange(160, 355)) + " Version/" + strconv.Itoa(randIntRange(10, 13)) + ".00"
return "Opera/" + strconv.Itoa(randIntRange(8, 10)) + "." + strconv.Itoa(randIntRange(10... | [
"func",
"OperaUserAgent",
"(",
")",
"string",
"{",
"platform",
":=",
"\"",
"\"",
"+",
"randomPlatform",
"(",
")",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"8",
",",
"13",
")",
")",
"+",
"\"",
"\"",
"+",
"strconv",
"."... | // OperaUserAgent will generate a random opera browser user agent string | [
"OperaUserAgent",
"will",
"generate",
"a",
"random",
"opera",
"browser",
"user",
"agent",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/user_agent.go#L62-L66 |
148,941 | brianvoe/gofakeit | user_agent.go | macPlatformToken | func macPlatformToken() string {
return "Macintosh; " + getRandValue([]string{"computer", "mac_processor"}) + " Mac OS X 10_" + strconv.Itoa(randIntRange(5, 9)) + "_" + strconv.Itoa(randIntRange(0, 10))
} | go | func macPlatformToken() string {
return "Macintosh; " + getRandValue([]string{"computer", "mac_processor"}) + " Mac OS X 10_" + strconv.Itoa(randIntRange(5, 9)) + "_" + strconv.Itoa(randIntRange(0, 10))
} | [
"func",
"macPlatformToken",
"(",
")",
"string",
"{",
"return",
"\"",
"\"",
"+",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"5",
",",
... | // macPlatformToken will generate a random mac platform | [
"macPlatformToken",
"will",
"generate",
"a",
"random",
"mac",
"platform"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/user_agent.go#L74-L76 |
148,942 | brianvoe/gofakeit | address.go | Address | func Address() *AddressInfo {
street := Street()
city := City()
state := State()
zip := Zip()
return &AddressInfo{
Address: street + ", " + city + ", " + state + " " + zip,
Street: street,
City: city,
State: state,
Zip: zip,
Country: Country(),
Latitude: Latitude(),
Longitud... | go | func Address() *AddressInfo {
street := Street()
city := City()
state := State()
zip := Zip()
return &AddressInfo{
Address: street + ", " + city + ", " + state + " " + zip,
Street: street,
City: city,
State: state,
Zip: zip,
Country: Country(),
Latitude: Latitude(),
Longitud... | [
"func",
"Address",
"(",
")",
"*",
"AddressInfo",
"{",
"street",
":=",
"Street",
"(",
")",
"\n",
"city",
":=",
"City",
"(",
")",
"\n",
"state",
":=",
"State",
"(",
")",
"\n",
"zip",
":=",
"Zip",
"(",
")",
"\n\n",
"return",
"&",
"AddressInfo",
"{",
... | // Address will generate a struct of address information | [
"Address",
"will",
"generate",
"a",
"struct",
"of",
"address",
"information"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/address.go#L22-L38 |
148,943 | brianvoe/gofakeit | address.go | Street | func Street() (street string) {
switch randInt := randIntRange(1, 2); randInt {
case 1:
street = StreetNumber() + " " + StreetPrefix() + " " + StreetName() + StreetSuffix()
case 2:
street = StreetNumber() + " " + StreetName() + StreetSuffix()
}
return
} | go | func Street() (street string) {
switch randInt := randIntRange(1, 2); randInt {
case 1:
street = StreetNumber() + " " + StreetPrefix() + " " + StreetName() + StreetSuffix()
case 2:
street = StreetNumber() + " " + StreetName() + StreetSuffix()
}
return
} | [
"func",
"Street",
"(",
")",
"(",
"street",
"string",
")",
"{",
"switch",
"randInt",
":=",
"randIntRange",
"(",
"1",
",",
"2",
")",
";",
"randInt",
"{",
"case",
"1",
":",
"street",
"=",
"StreetNumber",
"(",
")",
"+",
"\"",
"\"",
"+",
"StreetPrefix",
... | // Street will generate a random address street string | [
"Street",
"will",
"generate",
"a",
"random",
"address",
"street",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/address.go#L41-L50 |
148,944 | brianvoe/gofakeit | address.go | City | func City() (city string) {
switch randInt := randIntRange(1, 3); randInt {
case 1:
city = FirstName() + StreetSuffix()
case 2:
city = LastName() + StreetSuffix()
case 3:
city = StreetPrefix() + " " + LastName()
}
return
} | go | func City() (city string) {
switch randInt := randIntRange(1, 3); randInt {
case 1:
city = FirstName() + StreetSuffix()
case 2:
city = LastName() + StreetSuffix()
case 3:
city = StreetPrefix() + " " + LastName()
}
return
} | [
"func",
"City",
"(",
")",
"(",
"city",
"string",
")",
"{",
"switch",
"randInt",
":=",
"randIntRange",
"(",
"1",
",",
"3",
")",
";",
"randInt",
"{",
"case",
"1",
":",
"city",
"=",
"FirstName",
"(",
")",
"+",
"StreetSuffix",
"(",
")",
"\n",
"case",
... | // City will generate a random city string | [
"City",
"will",
"generate",
"a",
"random",
"city",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/address.go#L73-L84 |
148,945 | brianvoe/gofakeit | address.go | LongitudeInRange | func LongitudeInRange(min, max float64) (float64, error) {
if min > max || min < -180 || min > 180 || max < -180 || max > 180 {
return 0, errors.New("input range is invalid")
}
return randFloat64Range(min, max), nil
} | go | func LongitudeInRange(min, max float64) (float64, error) {
if min > max || min < -180 || min > 180 || max < -180 || max > 180 {
return 0, errors.New("input range is invalid")
}
return randFloat64Range(min, max), nil
} | [
"func",
"LongitudeInRange",
"(",
"min",
",",
"max",
"float64",
")",
"(",
"float64",
",",
"error",
")",
"{",
"if",
"min",
">",
"max",
"||",
"min",
"<",
"-",
"180",
"||",
"min",
">",
"180",
"||",
"max",
"<",
"-",
"180",
"||",
"max",
">",
"180",
"... | // LongitudeInRange will generate a random longitude within the input range | [
"LongitudeInRange",
"will",
"generate",
"a",
"random",
"longitude",
"within",
"the",
"input",
"range"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/address.go#L126-L131 |
148,946 | brianvoe/gofakeit | misc.go | getRandValue | func getRandValue(dataVal []string) string {
if !dataCheck(dataVal) {
return ""
}
return data.Data[dataVal[0]][dataVal[1]][rand.Intn(len(data.Data[dataVal[0]][dataVal[1]]))]
} | go | func getRandValue(dataVal []string) string {
if !dataCheck(dataVal) {
return ""
}
return data.Data[dataVal[0]][dataVal[1]][rand.Intn(len(data.Data[dataVal[0]][dataVal[1]]))]
} | [
"func",
"getRandValue",
"(",
"dataVal",
"[",
"]",
"string",
")",
"string",
"{",
"if",
"!",
"dataCheck",
"(",
"dataVal",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"data",
".",
"Data",
"[",
"dataVal",
"[",
"0",
"]",
"]",
"[",
"dataVa... | // Get Random Value | [
"Get",
"Random",
"Value"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/misc.go#L41-L46 |
148,947 | brianvoe/gofakeit | misc.go | getRandIntValue | func getRandIntValue(dataVal []string) int {
if !intDataCheck(dataVal) {
return 0
}
return data.IntData[dataVal[0]][dataVal[1]][rand.Intn(len(data.IntData[dataVal[0]][dataVal[1]]))]
} | go | func getRandIntValue(dataVal []string) int {
if !intDataCheck(dataVal) {
return 0
}
return data.IntData[dataVal[0]][dataVal[1]][rand.Intn(len(data.IntData[dataVal[0]][dataVal[1]]))]
} | [
"func",
"getRandIntValue",
"(",
"dataVal",
"[",
"]",
"string",
")",
"int",
"{",
"if",
"!",
"intDataCheck",
"(",
"dataVal",
")",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"data",
".",
"IntData",
"[",
"dataVal",
"[",
"0",
"]",
"]",
"[",
"dataVal",... | // Get Random Integer Value | [
"Get",
"Random",
"Integer",
"Value"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/misc.go#L49-L54 |
148,948 | brianvoe/gofakeit | misc.go | replaceWithLetters | func replaceWithLetters(str string) string {
if str == "" {
return str
}
bytestr := []byte(str)
for i := 0; i < len(bytestr); i++ {
if bytestr[i] == questionmark {
bytestr[i] = byte(randLetter())
}
}
return string(bytestr)
} | go | func replaceWithLetters(str string) string {
if str == "" {
return str
}
bytestr := []byte(str)
for i := 0; i < len(bytestr); i++ {
if bytestr[i] == questionmark {
bytestr[i] = byte(randLetter())
}
}
return string(bytestr)
} | [
"func",
"replaceWithLetters",
"(",
"str",
"string",
")",
"string",
"{",
"if",
"str",
"==",
"\"",
"\"",
"{",
"return",
"str",
"\n",
"}",
"\n",
"bytestr",
":=",
"[",
"]",
"byte",
"(",
"str",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
... | // Replace ? with ASCII lowercase letters | [
"Replace",
"?",
"with",
"ASCII",
"lowercase",
"letters"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/misc.go#L75-L87 |
148,949 | brianvoe/gofakeit | misc.go | randIntRange | func randIntRange(min, max int) int {
if min == max {
return min
}
return rand.Intn((max+1)-min) + min
} | go | func randIntRange(min, max int) int {
if min == max {
return min
}
return rand.Intn((max+1)-min) + min
} | [
"func",
"randIntRange",
"(",
"min",
",",
"max",
"int",
")",
"int",
"{",
"if",
"min",
"==",
"max",
"{",
"return",
"min",
"\n",
"}",
"\n",
"return",
"rand",
".",
"Intn",
"(",
"(",
"max",
"+",
"1",
")",
"-",
"min",
")",
"+",
"min",
"\n",
"}"
] | // Generate random integer between min and max | [
"Generate",
"random",
"integer",
"between",
"min",
"and",
"max"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/misc.go#L100-L105 |
148,950 | brianvoe/gofakeit | misc.go | Categories | func Categories() map[string][]string {
types := make(map[string][]string)
for category, subCategoriesMap := range data.Data {
subCategories := make([]string, 0)
for subType := range subCategoriesMap {
subCategories = append(subCategories, subType)
}
types[category] = subCategories
}
return types
} | go | func Categories() map[string][]string {
types := make(map[string][]string)
for category, subCategoriesMap := range data.Data {
subCategories := make([]string, 0)
for subType := range subCategoriesMap {
subCategories = append(subCategories, subType)
}
types[category] = subCategories
}
return types
} | [
"func",
"Categories",
"(",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"{",
"types",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"\n",
"for",
"category",
",",
"subCategoriesMap",
":=",
"range",
"data",
".",
"Data",
... | // Categories will return a map string array of available data categories and sub categories | [
"Categories",
"will",
"return",
"a",
"map",
"string",
"array",
"of",
"available",
"data",
"categories",
"and",
"sub",
"categories"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/misc.go#L122-L132 |
148,951 | brianvoe/gofakeit | password.go | Password | func Password(lower bool, upper bool, numeric bool, special bool, space bool, num int) string {
// Make sure the num minimun is at least 5
if num < 5 {
num = 5
}
i := 0
b := make([]byte, num)
var passString string
if lower {
passString += lowerStr
b[i] = lowerStr[rand.Int63()%int64(len(lowerStr))]
i++
... | go | func Password(lower bool, upper bool, numeric bool, special bool, space bool, num int) string {
// Make sure the num minimun is at least 5
if num < 5 {
num = 5
}
i := 0
b := make([]byte, num)
var passString string
if lower {
passString += lowerStr
b[i] = lowerStr[rand.Int63()%int64(len(lowerStr))]
i++
... | [
"func",
"Password",
"(",
"lower",
"bool",
",",
"upper",
"bool",
",",
"numeric",
"bool",
",",
"special",
"bool",
",",
"space",
"bool",
",",
"num",
"int",
")",
"string",
"{",
"// Make sure the num minimun is at least 5",
"if",
"num",
"<",
"5",
"{",
"num",
"=... | // Password will generate a random password
// Minimum number length of 5 if less than | [
"Password",
"will",
"generate",
"a",
"random",
"password",
"Minimum",
"number",
"length",
"of",
"5",
"if",
"less",
"than"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/password.go#L15-L68 |
148,952 | brianvoe/gofakeit | currency.go | Currency | func Currency() *CurrencyInfo {
index := rand.Intn(len(data.Data["currency"]["short"]))
return &CurrencyInfo{
Short: data.Data["currency"]["short"][index],
Long: data.Data["currency"]["long"][index],
}
} | go | func Currency() *CurrencyInfo {
index := rand.Intn(len(data.Data["currency"]["short"]))
return &CurrencyInfo{
Short: data.Data["currency"]["short"][index],
Long: data.Data["currency"]["long"][index],
}
} | [
"func",
"Currency",
"(",
")",
"*",
"CurrencyInfo",
"{",
"index",
":=",
"rand",
".",
"Intn",
"(",
"len",
"(",
"data",
".",
"Data",
"[",
"\"",
"\"",
"]",
"[",
"\"",
"\"",
"]",
")",
")",
"\n",
"return",
"&",
"CurrencyInfo",
"{",
"Short",
":",
"data"... | // Currency will generate a struct with random currency information | [
"Currency",
"will",
"generate",
"a",
"struct",
"with",
"random",
"currency",
"information"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/currency.go#L17-L23 |
148,953 | brianvoe/gofakeit | currency.go | Price | func Price(min, max float64) float64 {
return math.Floor(randFloat64Range(min, max)*100) / 100
} | go | func Price(min, max float64) float64 {
return math.Floor(randFloat64Range(min, max)*100) / 100
} | [
"func",
"Price",
"(",
"min",
",",
"max",
"float64",
")",
"float64",
"{",
"return",
"math",
".",
"Floor",
"(",
"randFloat64Range",
"(",
"min",
",",
"max",
")",
"*",
"100",
")",
"/",
"100",
"\n",
"}"
] | // Price will take in a min and max value and return a formatted price | [
"Price",
"will",
"take",
"in",
"a",
"min",
"and",
"max",
"value",
"and",
"return",
"a",
"formatted",
"price"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/currency.go#L36-L38 |
148,954 | brianvoe/gofakeit | words.go | Paragraph | func Paragraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
return paragraphGenerator(paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, Sentence)
} | go | func Paragraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
return paragraphGenerator(paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, Sentence)
} | [
"func",
"Paragraph",
"(",
"paragraphCount",
"int",
",",
"sentenceCount",
"int",
",",
"wordCount",
"int",
",",
"separator",
"string",
")",
"string",
"{",
"return",
"paragraphGenerator",
"(",
"paragrapOptions",
"{",
"paragraphCount",
",",
"sentenceCount",
",",
"word... | // Paragraph will generate a random paragraphGenerator
// Set Paragraph Count
// Set Sentence Count
// Set Word Count
// Set Paragraph Separator | [
"Paragraph",
"will",
"generate",
"a",
"random",
"paragraphGenerator",
"Set",
"Paragraph",
"Count",
"Set",
"Sentence",
"Count",
"Set",
"Word",
"Count",
"Set",
"Paragraph",
"Separator"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/words.go#L36-L38 |
148,955 | brianvoe/gofakeit | payment.go | CreditCard | func CreditCard() *CreditCardInfo {
return &CreditCardInfo{
Type: CreditCardType(),
Number: CreditCardNumber(),
Exp: CreditCardExp(),
Cvv: CreditCardCvv(),
}
} | go | func CreditCard() *CreditCardInfo {
return &CreditCardInfo{
Type: CreditCardType(),
Number: CreditCardNumber(),
Exp: CreditCardExp(),
Cvv: CreditCardCvv(),
}
} | [
"func",
"CreditCard",
"(",
")",
"*",
"CreditCardInfo",
"{",
"return",
"&",
"CreditCardInfo",
"{",
"Type",
":",
"CreditCardType",
"(",
")",
",",
"Number",
":",
"CreditCardNumber",
"(",
")",
",",
"Exp",
":",
"CreditCardExp",
"(",
")",
",",
"Cvv",
":",
"Cre... | // CreditCard will generate a struct full of credit card information | [
"CreditCard",
"will",
"generate",
"a",
"struct",
"full",
"of",
"credit",
"card",
"information"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/payment.go#L17-L24 |
148,956 | brianvoe/gofakeit | payment.go | CreditCardNumber | func CreditCardNumber() int {
integer, _ := strconv.Atoi(replaceWithNumbers(getRandValue([]string{"payment", "number"})))
return integer
} | go | func CreditCardNumber() int {
integer, _ := strconv.Atoi(replaceWithNumbers(getRandValue([]string{"payment", "number"})))
return integer
} | [
"func",
"CreditCardNumber",
"(",
")",
"int",
"{",
"integer",
",",
"_",
":=",
"strconv",
".",
"Atoi",
"(",
"replaceWithNumbers",
"(",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
")",
")",
"\n",
"return",
"integ... | // CreditCardNumber will generate a random credit card number int | [
"CreditCardNumber",
"will",
"generate",
"a",
"random",
"credit",
"card",
"number",
"int"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/payment.go#L32-L35 |
148,957 | brianvoe/gofakeit | payment.go | CreditCardNumberLuhn | func CreditCardNumberLuhn() int {
cc := ""
for i := 0; i < 100000; i++ {
cc = replaceWithNumbers(getRandValue([]string{"payment", "number"}))
if luhn(cc) {
break
}
}
integer, _ := strconv.Atoi(cc)
return integer
} | go | func CreditCardNumberLuhn() int {
cc := ""
for i := 0; i < 100000; i++ {
cc = replaceWithNumbers(getRandValue([]string{"payment", "number"}))
if luhn(cc) {
break
}
}
integer, _ := strconv.Atoi(cc)
return integer
} | [
"func",
"CreditCardNumberLuhn",
"(",
")",
"int",
"{",
"cc",
":=",
"\"",
"\"",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"100000",
";",
"i",
"++",
"{",
"cc",
"=",
"replaceWithNumbers",
"(",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",... | // CreditCardNumberLuhn will generate a random credit card number int that passes luhn test | [
"CreditCardNumberLuhn",
"will",
"generate",
"a",
"random",
"credit",
"card",
"number",
"int",
"that",
"passes",
"luhn",
"test"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/payment.go#L38-L48 |
148,958 | brianvoe/gofakeit | payment.go | CreditCardExp | func CreditCardExp() string {
month := strconv.Itoa(randIntRange(1, 12))
if len(month) == 1 {
month = "0" + month
}
return month + "/" + strconv.Itoa(randIntRange(currentYear+1, currentYear+10))
} | go | func CreditCardExp() string {
month := strconv.Itoa(randIntRange(1, 12))
if len(month) == 1 {
month = "0" + month
}
return month + "/" + strconv.Itoa(randIntRange(currentYear+1, currentYear+10))
} | [
"func",
"CreditCardExp",
"(",
")",
"string",
"{",
"month",
":=",
"strconv",
".",
"Itoa",
"(",
"randIntRange",
"(",
"1",
",",
"12",
")",
")",
"\n",
"if",
"len",
"(",
"month",
")",
"==",
"1",
"{",
"month",
"=",
"\"",
"\"",
"+",
"month",
"\n",
"}",
... | // CreditCardExp will generate a random credit card expiration date string
// Exp date will always be a future date | [
"CreditCardExp",
"will",
"generate",
"a",
"random",
"credit",
"card",
"expiration",
"date",
"string",
"Exp",
"date",
"will",
"always",
"be",
"a",
"future",
"date"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/payment.go#L52-L58 |
148,959 | brianvoe/gofakeit | payment.go | luhn | func luhn(s string) bool {
var t = [...]int{0, 2, 4, 6, 8, 1, 3, 5, 7, 9}
odd := len(s) & 1
var sum int
for i, c := range s {
if c < '0' || c > '9' {
return false
}
if i&1 == odd {
sum += t[c-'0']
} else {
sum += int(c - '0')
}
}
return sum%10 == 0
} | go | func luhn(s string) bool {
var t = [...]int{0, 2, 4, 6, 8, 1, 3, 5, 7, 9}
odd := len(s) & 1
var sum int
for i, c := range s {
if c < '0' || c > '9' {
return false
}
if i&1 == odd {
sum += t[c-'0']
} else {
sum += int(c - '0')
}
}
return sum%10 == 0
} | [
"func",
"luhn",
"(",
"s",
"string",
")",
"bool",
"{",
"var",
"t",
"=",
"[",
"...",
"]",
"int",
"{",
"0",
",",
"2",
",",
"4",
",",
"6",
",",
"8",
",",
"1",
",",
"3",
",",
"5",
",",
"7",
",",
"9",
"}",
"\n",
"odd",
":=",
"len",
"(",
"s"... | // luhn check is used for checking if credit card is valid | [
"luhn",
"check",
"is",
"used",
"for",
"checking",
"if",
"credit",
"card",
"is",
"valid"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/payment.go#L66-L81 |
148,960 | brianvoe/gofakeit | color.go | HexColor | func HexColor() string {
color := make([]byte, 6)
hashQuestion := []byte("?#")
for i := 0; i < 6; i++ {
color[i] = hashQuestion[rand.Intn(2)]
}
return "#" + replaceWithLetters(replaceWithNumbers(string(color)))
// color := ""
// for i := 1; i <= 6; i++ {
// color += RandString([]string{"?", "#"})
// }
/... | go | func HexColor() string {
color := make([]byte, 6)
hashQuestion := []byte("?#")
for i := 0; i < 6; i++ {
color[i] = hashQuestion[rand.Intn(2)]
}
return "#" + replaceWithLetters(replaceWithNumbers(string(color)))
// color := ""
// for i := 1; i <= 6; i++ {
// color += RandString([]string{"?", "#"})
// }
/... | [
"func",
"HexColor",
"(",
")",
"string",
"{",
"color",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"6",
")",
"\n",
"hashQuestion",
":=",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"6",
";",
"i",
"++",
"... | // HexColor will generate a random hexadecimal color string | [
"HexColor",
"will",
"generate",
"a",
"random",
"hexadecimal",
"color",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/color.go#L16-L39 |
148,961 | brianvoe/gofakeit | string.go | ShuffleStrings | func ShuffleStrings(a []string) {
swap := func(i, j int) {
a[i], a[j] = a[j], a[i]
}
//to avoid upgrading to 1.10 I copied the algorithm
n := len(a)
if n <= 1 {
return
}
//if size is > int32 probably it will never finish, or ran out of entropy
i := n - 1
for ; i > 0; i-- {
j := int(rand.Int31n(int32(i +... | go | func ShuffleStrings(a []string) {
swap := func(i, j int) {
a[i], a[j] = a[j], a[i]
}
//to avoid upgrading to 1.10 I copied the algorithm
n := len(a)
if n <= 1 {
return
}
//if size is > int32 probably it will never finish, or ran out of entropy
i := n - 1
for ; i > 0; i-- {
j := int(rand.Int31n(int32(i +... | [
"func",
"ShuffleStrings",
"(",
"a",
"[",
"]",
"string",
")",
"{",
"swap",
":=",
"func",
"(",
"i",
",",
"j",
"int",
")",
"{",
"a",
"[",
"i",
"]",
",",
"a",
"[",
"j",
"]",
"=",
"a",
"[",
"j",
"]",
",",
"a",
"[",
"i",
"]",
"\n",
"}",
"\n",... | // ShuffleStrings will randomize a slice of strings | [
"ShuffleStrings",
"will",
"randomize",
"a",
"slice",
"of",
"strings"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/string.go#L23-L39 |
148,962 | brianvoe/gofakeit | string.go | RandString | func RandString(a []string) string {
size := len(a)
if size == 0 {
return ""
}
return a[rand.Intn(size)]
} | go | func RandString(a []string) string {
size := len(a)
if size == 0 {
return ""
}
return a[rand.Intn(size)]
} | [
"func",
"RandString",
"(",
"a",
"[",
"]",
"string",
")",
"string",
"{",
"size",
":=",
"len",
"(",
"a",
")",
"\n",
"if",
"size",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"a",
"[",
"rand",
".",
"Intn",
"(",
"size",
")",
... | // RandString will take in a slice of string and return a randomly selected value | [
"RandString",
"will",
"take",
"in",
"a",
"slice",
"of",
"string",
"and",
"return",
"a",
"randomly",
"selected",
"value"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/string.go#L42-L48 |
148,963 | brianvoe/gofakeit | vehicle.go | Vehicle | func Vehicle() *VehicleInfo {
return &VehicleInfo{
VehicleType: VehicleType(),
Fuel: FuelType(),
TransmissionGear: TransmissionGearType(),
Brand: CarMaker(),
Model: CarModel(),
Year: Year(),
}
} | go | func Vehicle() *VehicleInfo {
return &VehicleInfo{
VehicleType: VehicleType(),
Fuel: FuelType(),
TransmissionGear: TransmissionGearType(),
Brand: CarMaker(),
Model: CarModel(),
Year: Year(),
}
} | [
"func",
"Vehicle",
"(",
")",
"*",
"VehicleInfo",
"{",
"return",
"&",
"VehicleInfo",
"{",
"VehicleType",
":",
"VehicleType",
"(",
")",
",",
"Fuel",
":",
"FuelType",
"(",
")",
",",
"TransmissionGear",
":",
"TransmissionGearType",
"(",
")",
",",
"Brand",
":",... | // Vehicle will generate a struct with vehicle information | [
"Vehicle",
"will",
"generate",
"a",
"struct",
"with",
"vehicle",
"information"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/vehicle.go#L20-L30 |
148,964 | brianvoe/gofakeit | hipster.go | HipsterParagraph | func HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
return paragraphGenerator(paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, HipsterSentence)
} | go | func HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
return paragraphGenerator(paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, HipsterSentence)
} | [
"func",
"HipsterParagraph",
"(",
"paragraphCount",
"int",
",",
"sentenceCount",
"int",
",",
"wordCount",
"int",
",",
"separator",
"string",
")",
"string",
"{",
"return",
"paragraphGenerator",
"(",
"paragrapOptions",
"{",
"paragraphCount",
",",
"sentenceCount",
",",
... | // HipsterParagraph will generate a random paragraphGenerator
// Set Paragraph Count
// Set Sentence Count
// Set Word Count
// Set Paragraph Separator | [
"HipsterParagraph",
"will",
"generate",
"a",
"random",
"paragraphGenerator",
"Set",
"Paragraph",
"Count",
"Set",
"Sentence",
"Count",
"Set",
"Word",
"Count",
"Set",
"Paragraph",
"Separator"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/hipster.go#L18-L20 |
148,965 | brianvoe/gofakeit | hacker.go | HackerPhrase | func HackerPhrase() string {
words := strings.Split(Generate(getRandValue([]string{"hacker", "phrase"})), " ")
words[0] = strings.Title(words[0])
return strings.Join(words, " ")
} | go | func HackerPhrase() string {
words := strings.Split(Generate(getRandValue([]string{"hacker", "phrase"})), " ")
words[0] = strings.Title(words[0])
return strings.Join(words, " ")
} | [
"func",
"HackerPhrase",
"(",
")",
"string",
"{",
"words",
":=",
"strings",
".",
"Split",
"(",
"Generate",
"(",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"words",
"[",
"0"... | // HackerPhrase will return a random hacker sentence | [
"HackerPhrase",
"will",
"return",
"a",
"random",
"hacker",
"sentence"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/hacker.go#L6-L10 |
148,966 | brianvoe/gofakeit | number.go | ShuffleInts | func ShuffleInts(a []int) {
for i := range a {
j := rand.Intn(i + 1)
a[i], a[j] = a[j], a[i]
}
} | go | func ShuffleInts(a []int) {
for i := range a {
j := rand.Intn(i + 1)
a[i], a[j] = a[j], a[i]
}
} | [
"func",
"ShuffleInts",
"(",
"a",
"[",
"]",
"int",
")",
"{",
"for",
"i",
":=",
"range",
"a",
"{",
"j",
":=",
"rand",
".",
"Intn",
"(",
"i",
"+",
"1",
")",
"\n",
"a",
"[",
"i",
"]",
",",
"a",
"[",
"j",
"]",
"=",
"a",
"[",
"j",
"]",
",",
... | // ShuffleInts will randomize a slice of ints | [
"ShuffleInts",
"will",
"randomize",
"a",
"slice",
"of",
"ints"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/number.go#L79-L84 |
148,967 | brianvoe/gofakeit | job.go | Job | func Job() *JobInfo {
return &JobInfo{
Company: Company(),
Title: JobTitle(),
Descriptor: JobDescriptor(),
Level: JobLevel(),
}
} | go | func Job() *JobInfo {
return &JobInfo{
Company: Company(),
Title: JobTitle(),
Descriptor: JobDescriptor(),
Level: JobLevel(),
}
} | [
"func",
"Job",
"(",
")",
"*",
"JobInfo",
"{",
"return",
"&",
"JobInfo",
"{",
"Company",
":",
"Company",
"(",
")",
",",
"Title",
":",
"JobTitle",
"(",
")",
",",
"Descriptor",
":",
"JobDescriptor",
"(",
")",
",",
"Level",
":",
"JobLevel",
"(",
")",
"... | // Job will generate a struct with random job information | [
"Job",
"will",
"generate",
"a",
"struct",
"with",
"random",
"job",
"information"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/job.go#L12-L19 |
148,968 | brianvoe/gofakeit | contact.go | Email | func Email() string {
var email string
email = getRandValue([]string{"person", "first"}) + getRandValue([]string{"person", "last"})
email += "@"
email += getRandValue([]string{"person", "last"}) + "." + getRandValue([]string{"internet", "domain_suffix"})
return strings.ToLower(email)
} | go | func Email() string {
var email string
email = getRandValue([]string{"person", "first"}) + getRandValue([]string{"person", "last"})
email += "@"
email += getRandValue([]string{"person", "last"}) + "." + getRandValue([]string{"internet", "domain_suffix"})
return strings.ToLower(email)
} | [
"func",
"Email",
"(",
")",
"string",
"{",
"var",
"email",
"string",
"\n\n",
"email",
"=",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
"+",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"... | // Email will generate a random email string | [
"Email",
"will",
"generate",
"a",
"random",
"email",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/contact.go#L32-L40 |
148,969 | brianvoe/gofakeit | person.go | Person | func Person() *PersonInfo {
return &PersonInfo{
FirstName: FirstName(),
LastName: LastName(),
Gender: Gender(),
SSN: SSN(),
Image: ImageURL(300, 300) + "/people",
Job: Job(),
Address: Address(),
Contact: Contact(),
CreditCard: CreditCard(),
}
} | go | func Person() *PersonInfo {
return &PersonInfo{
FirstName: FirstName(),
LastName: LastName(),
Gender: Gender(),
SSN: SSN(),
Image: ImageURL(300, 300) + "/people",
Job: Job(),
Address: Address(),
Contact: Contact(),
CreditCard: CreditCard(),
}
} | [
"func",
"Person",
"(",
")",
"*",
"PersonInfo",
"{",
"return",
"&",
"PersonInfo",
"{",
"FirstName",
":",
"FirstName",
"(",
")",
",",
"LastName",
":",
"LastName",
"(",
")",
",",
"Gender",
":",
"Gender",
"(",
")",
",",
"SSN",
":",
"SSN",
"(",
")",
","... | // Person will generate a struct with person information | [
"Person",
"will",
"generate",
"a",
"struct",
"with",
"person",
"information"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/person.go#L33-L45 |
148,970 | brianvoe/gofakeit | company.go | Company | func Company() (company string) {
switch randInt := randIntRange(1, 3); randInt {
case 1:
company = LastName() + ", " + LastName() + " and " + LastName()
case 2:
company = LastName() + "-" + LastName()
case 3:
company = LastName() + " " + CompanySuffix()
}
return
} | go | func Company() (company string) {
switch randInt := randIntRange(1, 3); randInt {
case 1:
company = LastName() + ", " + LastName() + " and " + LastName()
case 2:
company = LastName() + "-" + LastName()
case 3:
company = LastName() + " " + CompanySuffix()
}
return
} | [
"func",
"Company",
"(",
")",
"(",
"company",
"string",
")",
"{",
"switch",
"randInt",
":=",
"randIntRange",
"(",
"1",
",",
"3",
")",
";",
"randInt",
"{",
"case",
"1",
":",
"company",
"=",
"LastName",
"(",
")",
"+",
"\"",
"\"",
"+",
"LastName",
"(",... | // Company will generate a random company name string | [
"Company",
"will",
"generate",
"a",
"random",
"company",
"name",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/company.go#L4-L15 |
148,971 | brianvoe/gofakeit | datetime.go | Date | func Date() time.Time {
return time.Date(Year(), time.Month(Number(0, 12)), Day(), Hour(), Minute(), Second(), NanoSecond(), time.UTC)
} | go | func Date() time.Time {
return time.Date(Year(), time.Month(Number(0, 12)), Day(), Hour(), Minute(), Second(), NanoSecond(), time.UTC)
} | [
"func",
"Date",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Date",
"(",
"Year",
"(",
")",
",",
"time",
".",
"Month",
"(",
"Number",
"(",
"0",
",",
"12",
")",
")",
",",
"Day",
"(",
")",
",",
"Hour",
"(",
")",
",",
"Minute",
"... | // Date will generate a random time.Time struct | [
"Date",
"will",
"generate",
"a",
"random",
"time",
".",
"Time",
"struct"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/datetime.go#L9-L11 |
148,972 | brianvoe/gofakeit | datetime.go | DateRange | func DateRange(start, end time.Time) time.Time {
return time.Unix(0, int64(Number(int(start.UnixNano()), int(end.UnixNano())))).UTC()
} | go | func DateRange(start, end time.Time) time.Time {
return time.Unix(0, int64(Number(int(start.UnixNano()), int(end.UnixNano())))).UTC()
} | [
"func",
"DateRange",
"(",
"start",
",",
"end",
"time",
".",
"Time",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"int64",
"(",
"Number",
"(",
"int",
"(",
"start",
".",
"UnixNano",
"(",
")",
")",
",",
"int",
"(",
... | // DateRange will generate a random time.Time struct between a start and end date | [
"DateRange",
"will",
"generate",
"a",
"random",
"time",
".",
"Time",
"struct",
"between",
"a",
"start",
"and",
"end",
"date"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/datetime.go#L14-L16 |
148,973 | brianvoe/gofakeit | datetime.go | TimeZoneOffset | func TimeZoneOffset() float32 {
value, _ := strconv.ParseFloat(getRandValue([]string{"timezone", "offset"}), 32)
return float32(value)
} | go | func TimeZoneOffset() float32 {
value, _ := strconv.ParseFloat(getRandValue([]string{"timezone", "offset"}), 32)
return float32(value)
} | [
"func",
"TimeZoneOffset",
"(",
")",
"float32",
"{",
"value",
",",
"_",
":=",
"strconv",
".",
"ParseFloat",
"(",
"getRandValue",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
",",
"32",
")",
"\n",
"return",
"float32",
"(",
"va... | // TimeZoneOffset will select a random timezone offset | [
"TimeZoneOffset",
"will",
"select",
"a",
"random",
"timezone",
"offset"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/datetime.go#L74-L77 |
148,974 | brianvoe/gofakeit | internet.go | URL | func URL() string {
url := "http" + RandString([]string{"s", ""}) + "://www."
url += DomainName()
// Slugs
num := Number(1, 4)
slug := make([]string, num)
for i := 0; i < num; i++ {
slug[i] = BS()
}
url += "/" + strings.ToLower(strings.Join(slug, "/"))
return url
} | go | func URL() string {
url := "http" + RandString([]string{"s", ""}) + "://www."
url += DomainName()
// Slugs
num := Number(1, 4)
slug := make([]string, num)
for i := 0; i < num; i++ {
slug[i] = BS()
}
url += "/" + strings.ToLower(strings.Join(slug, "/"))
return url
} | [
"func",
"URL",
"(",
")",
"string",
"{",
"url",
":=",
"\"",
"\"",
"+",
"RandString",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
"+",
"\"",
"\"",
"\n",
"url",
"+=",
"DomainName",
"(",
")",
"\n\n",
"// Slugs",
"num",
":="... | // URL will generate a random url string | [
"URL",
"will",
"generate",
"a",
"random",
"url",
"string"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/internet.go#L20-L33 |
148,975 | brianvoe/gofakeit | internet.go | IPv4Address | func IPv4Address() string {
num := func() int { return 2 + rand.Intn(254) }
return fmt.Sprintf("%d.%d.%d.%d", num(), num(), num(), num())
} | go | func IPv4Address() string {
num := func() int { return 2 + rand.Intn(254) }
return fmt.Sprintf("%d.%d.%d.%d", num(), num(), num(), num())
} | [
"func",
"IPv4Address",
"(",
")",
"string",
"{",
"num",
":=",
"func",
"(",
")",
"int",
"{",
"return",
"2",
"+",
"rand",
".",
"Intn",
"(",
"254",
")",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"num",
"(",
")",
",",
"num",
... | // IPv4Address will generate a random version 4 ip address | [
"IPv4Address",
"will",
"generate",
"a",
"random",
"version",
"4",
"ip",
"address"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/internet.go#L41-L44 |
148,976 | brianvoe/gofakeit | internet.go | IPv6Address | func IPv6Address() string {
num := 65536
return fmt.Sprintf("2001:cafe:%x:%x:%x:%x:%x:%x", rand.Intn(num), rand.Intn(num), rand.Intn(num), rand.Intn(num), rand.Intn(num), rand.Intn(num))
} | go | func IPv6Address() string {
num := 65536
return fmt.Sprintf("2001:cafe:%x:%x:%x:%x:%x:%x", rand.Intn(num), rand.Intn(num), rand.Intn(num), rand.Intn(num), rand.Intn(num), rand.Intn(num))
} | [
"func",
"IPv6Address",
"(",
")",
"string",
"{",
"num",
":=",
"65536",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"rand",
".",
"Intn",
"(",
"num",
")",
",",
"rand",
".",
"Intn",
"(",
"num",
")",
",",
"rand",
".",
"Intn",
"(",
"... | // IPv6Address will generate a random version 6 ip address | [
"IPv6Address",
"will",
"generate",
"a",
"random",
"version",
"6",
"ip",
"address"
] | a5ac7cef41d64b726c51e8826e02dad0c34f55b4 | https://github.com/brianvoe/gofakeit/blob/a5ac7cef41d64b726c51e8826e02dad0c34f55b4/internet.go#L47-L50 |
148,977 | gorilla/handlers | cors.go | AllowedMethods | func AllowedMethods(methods []string) CORSOption {
return func(ch *cors) error {
ch.allowedMethods = []string{}
for _, v := range methods {
normalizedMethod := strings.ToUpper(strings.TrimSpace(v))
if normalizedMethod == "" {
continue
}
if !ch.isMatch(normalizedMethod, ch.allowedMethods) {
ch.... | go | func AllowedMethods(methods []string) CORSOption {
return func(ch *cors) error {
ch.allowedMethods = []string{}
for _, v := range methods {
normalizedMethod := strings.ToUpper(strings.TrimSpace(v))
if normalizedMethod == "" {
continue
}
if !ch.isMatch(normalizedMethod, ch.allowedMethods) {
ch.... | [
"func",
"AllowedMethods",
"(",
"methods",
"[",
"]",
"string",
")",
"CORSOption",
"{",
"return",
"func",
"(",
"ch",
"*",
"cors",
")",
"error",
"{",
"ch",
".",
"allowedMethods",
"=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"ra... | // AllowedMethods can be used to explicitly allow methods in the
// Access-Control-Allow-Methods header.
// This is a replacement operation so you must also
// pass GET, HEAD, and POST if you wish to support those methods. | [
"AllowedMethods",
"can",
"be",
"used",
"to",
"explicitly",
"allow",
"methods",
"in",
"the",
"Access",
"-",
"Control",
"-",
"Allow",
"-",
"Methods",
"header",
".",
"This",
"is",
"a",
"replacement",
"operation",
"so",
"you",
"must",
"also",
"pass",
"GET",
"H... | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/cors.go#L214-L230 |
148,978 | gorilla/handlers | cors.go | AllowedOriginValidator | func AllowedOriginValidator(fn OriginValidator) CORSOption {
return func(ch *cors) error {
ch.allowedOriginValidator = fn
return nil
}
} | go | func AllowedOriginValidator(fn OriginValidator) CORSOption {
return func(ch *cors) error {
ch.allowedOriginValidator = fn
return nil
}
} | [
"func",
"AllowedOriginValidator",
"(",
"fn",
"OriginValidator",
")",
"CORSOption",
"{",
"return",
"func",
"(",
"ch",
"*",
"cors",
")",
"error",
"{",
"ch",
".",
"allowedOriginValidator",
"=",
"fn",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // AllowedOriginValidator sets a function for evaluating allowed origins in CORS requests, represented by the
// 'Allow-Access-Control-Origin' HTTP header. | [
"AllowedOriginValidator",
"sets",
"a",
"function",
"for",
"evaluating",
"allowed",
"origins",
"in",
"CORS",
"requests",
"represented",
"by",
"the",
"Allow",
"-",
"Access",
"-",
"Control",
"-",
"Origin",
"HTTP",
"header",
"."
] | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/cors.go#L251-L256 |
148,979 | gorilla/handlers | cors.go | ExposedHeaders | func ExposedHeaders(headers []string) CORSOption {
return func(ch *cors) error {
ch.exposedHeaders = []string{}
for _, v := range headers {
normalizedHeader := http.CanonicalHeaderKey(strings.TrimSpace(v))
if normalizedHeader == "" {
continue
}
if !ch.isMatch(normalizedHeader, ch.exposedHeaders) {... | go | func ExposedHeaders(headers []string) CORSOption {
return func(ch *cors) error {
ch.exposedHeaders = []string{}
for _, v := range headers {
normalizedHeader := http.CanonicalHeaderKey(strings.TrimSpace(v))
if normalizedHeader == "" {
continue
}
if !ch.isMatch(normalizedHeader, ch.exposedHeaders) {... | [
"func",
"ExposedHeaders",
"(",
"headers",
"[",
"]",
"string",
")",
"CORSOption",
"{",
"return",
"func",
"(",
"ch",
"*",
"cors",
")",
"error",
"{",
"ch",
".",
"exposedHeaders",
"=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"ra... | // ExposedHeaders can be used to specify headers that are available
// and will not be stripped out by the user-agent. | [
"ExposedHeaders",
"can",
"be",
"used",
"to",
"specify",
"headers",
"that",
"are",
"available",
"and",
"will",
"not",
"be",
"stripped",
"out",
"by",
"the",
"user",
"-",
"agent",
"."
] | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/cors.go#L273-L289 |
148,980 | gorilla/handlers | logging.go | buildCommonLogLine | func buildCommonLogLine(req *http.Request, url url.URL, ts time.Time, status int, size int) []byte {
username := "-"
if url.User != nil {
if name := url.User.Username(); name != "" {
username = name
}
}
host, _, err := net.SplitHostPort(req.RemoteAddr)
if err != nil {
host = req.RemoteAddr
}
uri := r... | go | func buildCommonLogLine(req *http.Request, url url.URL, ts time.Time, status int, size int) []byte {
username := "-"
if url.User != nil {
if name := url.User.Username(); name != "" {
username = name
}
}
host, _, err := net.SplitHostPort(req.RemoteAddr)
if err != nil {
host = req.RemoteAddr
}
uri := r... | [
"func",
"buildCommonLogLine",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"url",
"url",
".",
"URL",
",",
"ts",
"time",
".",
"Time",
",",
"status",
"int",
",",
"size",
"int",
")",
"[",
"]",
"byte",
"{",
"username",
":=",
"\"",
"\"",
"\n",
"if",
... | // buildCommonLogLine builds a log entry for req in Apache Common Log Format.
// ts is the timestamp with which the entry should be logged.
// status and size are used to provide the response HTTP status and size. | [
"buildCommonLogLine",
"builds",
"a",
"log",
"entry",
"for",
"req",
"in",
"Apache",
"Common",
"Log",
"Format",
".",
"ts",
"is",
"the",
"timestamp",
"with",
"which",
"the",
"entry",
"should",
"be",
"logged",
".",
"status",
"and",
"size",
"are",
"used",
"to",... | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/logging.go#L151-L194 |
148,981 | gorilla/handlers | logging.go | writeLog | func writeLog(writer io.Writer, params LogFormatterParams) {
buf := buildCommonLogLine(params.Request, params.URL, params.TimeStamp, params.StatusCode, params.Size)
buf = append(buf, '\n')
writer.Write(buf)
} | go | func writeLog(writer io.Writer, params LogFormatterParams) {
buf := buildCommonLogLine(params.Request, params.URL, params.TimeStamp, params.StatusCode, params.Size)
buf = append(buf, '\n')
writer.Write(buf)
} | [
"func",
"writeLog",
"(",
"writer",
"io",
".",
"Writer",
",",
"params",
"LogFormatterParams",
")",
"{",
"buf",
":=",
"buildCommonLogLine",
"(",
"params",
".",
"Request",
",",
"params",
".",
"URL",
",",
"params",
".",
"TimeStamp",
",",
"params",
".",
"Status... | // writeLog writes a log entry for req to w in Apache Common Log Format.
// ts is the timestamp with which the entry should be logged.
// status and size are used to provide the response HTTP status and size. | [
"writeLog",
"writes",
"a",
"log",
"entry",
"for",
"req",
"to",
"w",
"in",
"Apache",
"Common",
"Log",
"Format",
".",
"ts",
"is",
"the",
"timestamp",
"with",
"which",
"the",
"entry",
"should",
"be",
"logged",
".",
"status",
"and",
"size",
"are",
"used",
... | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/logging.go#L199-L203 |
148,982 | gorilla/handlers | logging.go | writeCombinedLog | func writeCombinedLog(writer io.Writer, params LogFormatterParams) {
buf := buildCommonLogLine(params.Request, params.URL, params.TimeStamp, params.StatusCode, params.Size)
buf = append(buf, ` "`...)
buf = appendQuoted(buf, params.Request.Referer())
buf = append(buf, `" "`...)
buf = appendQuoted(buf, params.Reques... | go | func writeCombinedLog(writer io.Writer, params LogFormatterParams) {
buf := buildCommonLogLine(params.Request, params.URL, params.TimeStamp, params.StatusCode, params.Size)
buf = append(buf, ` "`...)
buf = appendQuoted(buf, params.Request.Referer())
buf = append(buf, `" "`...)
buf = appendQuoted(buf, params.Reques... | [
"func",
"writeCombinedLog",
"(",
"writer",
"io",
".",
"Writer",
",",
"params",
"LogFormatterParams",
")",
"{",
"buf",
":=",
"buildCommonLogLine",
"(",
"params",
".",
"Request",
",",
"params",
".",
"URL",
",",
"params",
".",
"TimeStamp",
",",
"params",
".",
... | // writeCombinedLog writes a log entry for req to w in Apache Combined Log Format.
// ts is the timestamp with which the entry should be logged.
// status and size are used to provide the response HTTP status and size. | [
"writeCombinedLog",
"writes",
"a",
"log",
"entry",
"for",
"req",
"to",
"w",
"in",
"Apache",
"Combined",
"Log",
"Format",
".",
"ts",
"is",
"the",
"timestamp",
"with",
"which",
"the",
"entry",
"should",
"be",
"logged",
".",
"status",
"and",
"size",
"are",
... | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/logging.go#L208-L216 |
148,983 | gorilla/handlers | logging.go | CustomLoggingHandler | func CustomLoggingHandler(out io.Writer, h http.Handler, f LogFormatter) http.Handler {
return loggingHandler{out, h, f}
} | go | func CustomLoggingHandler(out io.Writer, h http.Handler, f LogFormatter) http.Handler {
return loggingHandler{out, h, f}
} | [
"func",
"CustomLoggingHandler",
"(",
"out",
"io",
".",
"Writer",
",",
"h",
"http",
".",
"Handler",
",",
"f",
"LogFormatter",
")",
"http",
".",
"Handler",
"{",
"return",
"loggingHandler",
"{",
"out",
",",
"h",
",",
"f",
"}",
"\n",
"}"
] | // CustomLoggingHandler provides a way to supply a custom log formatter
// while taking advantage of the mechanisms in this package | [
"CustomLoggingHandler",
"provides",
"a",
"way",
"to",
"supply",
"a",
"custom",
"log",
"formatter",
"while",
"taking",
"advantage",
"of",
"the",
"mechanisms",
"in",
"this",
"package"
] | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/logging.go#L250-L252 |
148,984 | gorilla/handlers | handlers.go | isContentType | func isContentType(h http.Header, contentType string) bool {
ct := h.Get("Content-Type")
if i := strings.IndexRune(ct, ';'); i != -1 {
ct = ct[0:i]
}
return ct == contentType
} | go | func isContentType(h http.Header, contentType string) bool {
ct := h.Get("Content-Type")
if i := strings.IndexRune(ct, ';'); i != -1 {
ct = ct[0:i]
}
return ct == contentType
} | [
"func",
"isContentType",
"(",
"h",
"http",
".",
"Header",
",",
"contentType",
"string",
")",
"bool",
"{",
"ct",
":=",
"h",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"i",
":=",
"strings",
".",
"IndexRune",
"(",
"ct",
",",
"';'",
")",
";",
"i",... | // isContentType validates the Content-Type header matches the supplied
// contentType. That is, its type and subtype match. | [
"isContentType",
"validates",
"the",
"Content",
"-",
"Type",
"header",
"matches",
"the",
"supplied",
"contentType",
".",
"That",
"is",
"its",
"type",
"and",
"subtype",
"match",
"."
] | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/handlers.go#L112-L118 |
148,985 | gorilla/handlers | handlers.go | ContentTypeHandler | func ContentTypeHandler(h http.Handler, contentTypes ...string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !(r.Method == "PUT" || r.Method == "POST" || r.Method == "PATCH") {
h.ServeHTTP(w, r)
return
}
for _, ct := range contentTypes {
if isContentType(r.He... | go | func ContentTypeHandler(h http.Handler, contentTypes ...string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !(r.Method == "PUT" || r.Method == "POST" || r.Method == "PATCH") {
h.ServeHTTP(w, r)
return
}
for _, ct := range contentTypes {
if isContentType(r.He... | [
"func",
"ContentTypeHandler",
"(",
"h",
"http",
".",
"Handler",
",",
"contentTypes",
"...",
"string",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
"."... | // ContentTypeHandler wraps and returns a http.Handler, validating the request
// content type is compatible with the contentTypes list. It writes a HTTP 415
// error if that fails.
//
// Only PUT, POST, and PATCH requests are considered. | [
"ContentTypeHandler",
"wraps",
"and",
"returns",
"a",
"http",
".",
"Handler",
"validating",
"the",
"request",
"content",
"type",
"is",
"compatible",
"with",
"the",
"contentTypes",
"list",
".",
"It",
"writes",
"a",
"HTTP",
"415",
"error",
"if",
"that",
"fails",... | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/handlers.go#L125-L140 |
148,986 | gorilla/handlers | recovery.go | RecoveryLogger | func RecoveryLogger(logger RecoveryHandlerLogger) RecoveryOption {
return func(h http.Handler) {
r := h.(*recoveryHandler)
r.logger = logger
}
} | go | func RecoveryLogger(logger RecoveryHandlerLogger) RecoveryOption {
return func(h http.Handler) {
r := h.(*recoveryHandler)
r.logger = logger
}
} | [
"func",
"RecoveryLogger",
"(",
"logger",
"RecoveryHandlerLogger",
")",
"RecoveryOption",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"{",
"r",
":=",
"h",
".",
"(",
"*",
"recoveryHandler",
")",
"\n",
"r",
".",
"logger",
"=",
"logger",
"\... | // RecoveryLogger is a functional option to override
// the default logger | [
"RecoveryLogger",
"is",
"a",
"functional",
"option",
"to",
"override",
"the",
"default",
"logger"
] | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/recovery.go#L54-L59 |
148,987 | gorilla/handlers | recovery.go | PrintRecoveryStack | func PrintRecoveryStack(print bool) RecoveryOption {
return func(h http.Handler) {
r := h.(*recoveryHandler)
r.printStack = print
}
} | go | func PrintRecoveryStack(print bool) RecoveryOption {
return func(h http.Handler) {
r := h.(*recoveryHandler)
r.printStack = print
}
} | [
"func",
"PrintRecoveryStack",
"(",
"print",
"bool",
")",
"RecoveryOption",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"{",
"r",
":=",
"h",
".",
"(",
"*",
"recoveryHandler",
")",
"\n",
"r",
".",
"printStack",
"=",
"print",
"\n",
"}",
... | // PrintRecoveryStack is a functional option to enable
// or disable printing stack traces on panic. | [
"PrintRecoveryStack",
"is",
"a",
"functional",
"option",
"to",
"enable",
"or",
"disable",
"printing",
"stack",
"traces",
"on",
"panic",
"."
] | ac6d24f88de4584385a0cb3a88f953d08a2f7a05 | https://github.com/gorilla/handlers/blob/ac6d24f88de4584385a0cb3a88f953d08a2f7a05/recovery.go#L63-L68 |
148,988 | colinmarc/hdfs | internal/rpc/block_writer.go | SetDeadline | func (bw *BlockWriter) SetDeadline(t time.Time) error {
bw.deadline = t
if bw.conn != nil {
return bw.conn.SetDeadline(t)
}
// Return the error at connection time.
return nil
} | go | func (bw *BlockWriter) SetDeadline(t time.Time) error {
bw.deadline = t
if bw.conn != nil {
return bw.conn.SetDeadline(t)
}
// Return the error at connection time.
return nil
} | [
"func",
"(",
"bw",
"*",
"BlockWriter",
")",
"SetDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"bw",
".",
"deadline",
"=",
"t",
"\n",
"if",
"bw",
".",
"conn",
"!=",
"nil",
"{",
"return",
"bw",
".",
"conn",
".",
"SetDeadline",
"(",
"... | // SetDeadline sets the deadline for future Write, Flush, and Close calls. A
// zero value for t means those calls will not time out. | [
"SetDeadline",
"sets",
"the",
"deadline",
"for",
"future",
"Write",
"Flush",
"and",
"Close",
"calls",
".",
"A",
"zero",
"value",
"for",
"t",
"means",
"those",
"calls",
"will",
"not",
"time",
"out",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/internal/rpc/block_writer.go#L49-L57 |
148,989 | colinmarc/hdfs | internal/rpc/block_writer.go | Flush | func (bw *BlockWriter) Flush() error {
if bw.stream != nil {
return bw.stream.flush(true)
}
return nil
} | go | func (bw *BlockWriter) Flush() error {
if bw.stream != nil {
return bw.stream.flush(true)
}
return nil
} | [
"func",
"(",
"bw",
"*",
"BlockWriter",
")",
"Flush",
"(",
")",
"error",
"{",
"if",
"bw",
".",
"stream",
"!=",
"nil",
"{",
"return",
"bw",
".",
"stream",
".",
"flush",
"(",
"true",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Flush flushes any unwritten packets out to the datanode. | [
"Flush",
"flushes",
"any",
"unwritten",
"packets",
"out",
"to",
"the",
"datanode",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/internal/rpc/block_writer.go#L94-L100 |
148,990 | colinmarc/hdfs | internal/rpc/block_writer.go | Close | func (bw *BlockWriter) Close() error {
bw.closed = true
if bw.conn != nil {
defer bw.conn.Close()
}
if bw.stream != nil {
// TODO: handle failures, set up recovery pipeline
err := bw.stream.finish()
if err != nil {
return err
}
}
return nil
} | go | func (bw *BlockWriter) Close() error {
bw.closed = true
if bw.conn != nil {
defer bw.conn.Close()
}
if bw.stream != nil {
// TODO: handle failures, set up recovery pipeline
err := bw.stream.finish()
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"bw",
"*",
"BlockWriter",
")",
"Close",
"(",
")",
"error",
"{",
"bw",
".",
"closed",
"=",
"true",
"\n",
"if",
"bw",
".",
"conn",
"!=",
"nil",
"{",
"defer",
"bw",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"bw",
... | // Close implements io.Closer. It flushes any unwritten packets out to the
// datanode, and sends a final packet indicating the end of the block. The
// block must still be finalized with the namenode. | [
"Close",
"implements",
"io",
".",
"Closer",
".",
"It",
"flushes",
"any",
"unwritten",
"packets",
"out",
"to",
"the",
"datanode",
"and",
"sends",
"a",
"final",
"packet",
"indicating",
"the",
"end",
"of",
"the",
"block",
".",
"The",
"block",
"must",
"still",... | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/internal/rpc/block_writer.go#L105-L120 |
148,991 | colinmarc/hdfs | internal/rpc/namenode.go | NewNamenodeConnection | func NewNamenodeConnection(options NamenodeConnectionOptions) (*NamenodeConnection, error) {
// Build the list of hosts to be used for failover.
hostList := make([]*namenodeHost, len(options.Addresses))
for i, addr := range options.Addresses {
hostList[i] = &namenodeHost{address: addr}
}
var user, realm string
... | go | func NewNamenodeConnection(options NamenodeConnectionOptions) (*NamenodeConnection, error) {
// Build the list of hosts to be used for failover.
hostList := make([]*namenodeHost, len(options.Addresses))
for i, addr := range options.Addresses {
hostList[i] = &namenodeHost{address: addr}
}
var user, realm string
... | [
"func",
"NewNamenodeConnection",
"(",
"options",
"NamenodeConnectionOptions",
")",
"(",
"*",
"NamenodeConnection",
",",
"error",
")",
"{",
"// Build the list of hosts to be used for failover.",
"hostList",
":=",
"make",
"(",
"[",
"]",
"*",
"namenodeHost",
",",
"len",
... | // NewNamenodeConnectionWithOptions creates a new connection to a namenode with
// the given options and performs an initial handshake. | [
"NewNamenodeConnectionWithOptions",
"creates",
"a",
"new",
"connection",
"to",
"a",
"namenode",
"with",
"the",
"given",
"options",
"and",
"performs",
"an",
"initial",
"handshake",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/internal/rpc/namenode.go#L82-L123 |
148,992 | colinmarc/hdfs | internal/rpc/namenode.go | Execute | func (c *NamenodeConnection) Execute(method string, req proto.Message, resp proto.Message) error {
c.reqLock.Lock()
defer c.reqLock.Unlock()
c.currentRequestID++
for {
err := c.resolveConnection()
if err != nil {
return err
}
err = c.writeRequest(method, req)
if err != nil {
c.markFailure(err)
... | go | func (c *NamenodeConnection) Execute(method string, req proto.Message, resp proto.Message) error {
c.reqLock.Lock()
defer c.reqLock.Unlock()
c.currentRequestID++
for {
err := c.resolveConnection()
if err != nil {
return err
}
err = c.writeRequest(method, req)
if err != nil {
c.markFailure(err)
... | [
"func",
"(",
"c",
"*",
"NamenodeConnection",
")",
"Execute",
"(",
"method",
"string",
",",
"req",
"proto",
".",
"Message",
",",
"resp",
"proto",
".",
"Message",
")",
"error",
"{",
"c",
".",
"reqLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
... | // Execute performs an rpc call. It does this by sending req over the wire and
// unmarshaling the result into resp. | [
"Execute",
"performs",
"an",
"rpc",
"call",
".",
"It",
"does",
"this",
"by",
"sending",
"req",
"over",
"the",
"wire",
"and",
"unmarshaling",
"the",
"result",
"into",
"resp",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/internal/rpc/namenode.go#L178-L211 |
148,993 | colinmarc/hdfs | internal/rpc/namenode.go | Close | func (c *NamenodeConnection) Close() error {
if c.conn != nil {
return c.conn.Close()
}
return nil
} | go | func (c *NamenodeConnection) Close() error {
if c.conn != nil {
return c.conn.Close()
}
return nil
} | [
"func",
"(",
"c",
"*",
"NamenodeConnection",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
".",
"conn",
"!=",
"nil",
"{",
"return",
"c",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close terminates all underlying socket connections to remote server. | [
"Close",
"terminates",
"all",
"underlying",
"socket",
"connections",
"to",
"remote",
"server",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/internal/rpc/namenode.go#L326-L331 |
148,994 | colinmarc/hdfs | file_reader.go | Open | func (c *Client) Open(name string) (*FileReader, error) {
info, err := c.getFileInfo(name)
if err != nil {
return nil, &os.PathError{"open", name, interpretException(err)}
}
return &FileReader{
client: c,
name: name,
info: info,
closed: false,
}, nil
} | go | func (c *Client) Open(name string) (*FileReader, error) {
info, err := c.getFileInfo(name)
if err != nil {
return nil, &os.PathError{"open", name, interpretException(err)}
}
return &FileReader{
client: c,
name: name,
info: info,
closed: false,
}, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Open",
"(",
"name",
"string",
")",
"(",
"*",
"FileReader",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"c",
".",
"getFileInfo",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // Open returns an FileReader which can be used for reading. | [
"Open",
"returns",
"an",
"FileReader",
"which",
"can",
"be",
"used",
"for",
"reading",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/file_reader.go#L35-L47 |
148,995 | colinmarc/hdfs | file_reader.go | SetDeadline | func (f *FileReader) SetDeadline(t time.Time) error {
f.deadline = t
if f.blockReader != nil {
return f.blockReader.SetDeadline(t)
}
// Return the error at connection time.
return nil
} | go | func (f *FileReader) SetDeadline(t time.Time) error {
f.deadline = t
if f.blockReader != nil {
return f.blockReader.SetDeadline(t)
}
// Return the error at connection time.
return nil
} | [
"func",
"(",
"f",
"*",
"FileReader",
")",
"SetDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"f",
".",
"deadline",
"=",
"t",
"\n",
"if",
"f",
".",
"blockReader",
"!=",
"nil",
"{",
"return",
"f",
".",
"blockReader",
".",
"SetDeadline",
... | // SetDeadline sets the deadline for future Read, ReadAt, and Checksum calls. A
// zero value for t means those calls will not time out. | [
"SetDeadline",
"sets",
"the",
"deadline",
"for",
"future",
"Read",
"ReadAt",
"and",
"Checksum",
"calls",
".",
"A",
"zero",
"value",
"for",
"t",
"means",
"those",
"calls",
"will",
"not",
"time",
"out",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/file_reader.go#L61-L69 |
148,996 | colinmarc/hdfs | file_reader.go | Seek | func (f *FileReader) Seek(offset int64, whence int) (int64, error) {
if f.closed {
return 0, io.ErrClosedPipe
}
var off int64
if whence == 0 {
off = offset
} else if whence == 1 {
off = f.offset + offset
} else if whence == 2 {
off = f.info.Size() + offset
} else {
return f.offset, fmt.Errorf("invalid... | go | func (f *FileReader) Seek(offset int64, whence int) (int64, error) {
if f.closed {
return 0, io.ErrClosedPipe
}
var off int64
if whence == 0 {
off = offset
} else if whence == 1 {
off = f.offset + offset
} else if whence == 2 {
off = f.info.Size() + offset
} else {
return f.offset, fmt.Errorf("invalid... | [
"func",
"(",
"f",
"*",
"FileReader",
")",
"Seek",
"(",
"offset",
"int64",
",",
"whence",
"int",
")",
"(",
"int64",
",",
"error",
")",
"{",
"if",
"f",
".",
"closed",
"{",
"return",
"0",
",",
"io",
".",
"ErrClosedPipe",
"\n",
"}",
"\n\n",
"var",
"o... | // Seek implements io.Seeker.
//
// The seek is virtual - it starts a new block read at the new position. | [
"Seek",
"implements",
"io",
".",
"Seeker",
".",
"The",
"seek",
"is",
"virtual",
"-",
"it",
"starts",
"a",
"new",
"block",
"read",
"at",
"the",
"new",
"position",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/file_reader.go#L131-L159 |
148,997 | colinmarc/hdfs | file_writer.go | CreateFile | func (c *Client) CreateFile(name string, replication int, blockSize int64, perm os.FileMode) (*FileWriter, error) {
createReq := &hdfs.CreateRequestProto{
Src: proto.String(name),
Masked: &hdfs.FsPermissionProto{Perm: proto.Uint32(uint32(perm))},
ClientName: proto.String(c.namenode.ClientName),
... | go | func (c *Client) CreateFile(name string, replication int, blockSize int64, perm os.FileMode) (*FileWriter, error) {
createReq := &hdfs.CreateRequestProto{
Src: proto.String(name),
Masked: &hdfs.FsPermissionProto{Perm: proto.Uint32(uint32(perm))},
ClientName: proto.String(c.namenode.ClientName),
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateFile",
"(",
"name",
"string",
",",
"replication",
"int",
",",
"blockSize",
"int64",
",",
"perm",
"os",
".",
"FileMode",
")",
"(",
"*",
"FileWriter",
",",
"error",
")",
"{",
"createReq",
":=",
"&",
"hdfs",
... | // CreateFile opens a new file in HDFS with the given replication, block size,
// and permissions, and returns an io.WriteCloser for writing to it. Because of
// the way that HDFS writes are buffered and acknowledged asynchronously, it is
// very important that Close is called after all data has been written. | [
"CreateFile",
"opens",
"a",
"new",
"file",
"in",
"HDFS",
"with",
"the",
"given",
"replication",
"block",
"size",
"and",
"permissions",
"and",
"returns",
"an",
"io",
".",
"WriteCloser",
"for",
"writing",
"to",
"it",
".",
"Because",
"of",
"the",
"way",
"that... | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/file_writer.go#L55-L78 |
148,998 | colinmarc/hdfs | file_writer.go | Append | func (c *Client) Append(name string) (*FileWriter, error) {
_, err := c.getFileInfo(name)
if err != nil {
return nil, &os.PathError{"append", name, interpretException(err)}
}
appendReq := &hdfs.AppendRequestProto{
Src: proto.String(name),
ClientName: proto.String(c.namenode.ClientName),
}
appendResp... | go | func (c *Client) Append(name string) (*FileWriter, error) {
_, err := c.getFileInfo(name)
if err != nil {
return nil, &os.PathError{"append", name, interpretException(err)}
}
appendReq := &hdfs.AppendRequestProto{
Src: proto.String(name),
ClientName: proto.String(c.namenode.ClientName),
}
appendResp... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Append",
"(",
"name",
"string",
")",
"(",
"*",
"FileWriter",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"c",
".",
"getFileInfo",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // Append opens an existing file in HDFS and returns an io.WriteCloser for
// writing to it. Because of the way that HDFS writes are buffered and
// acknowledged asynchronously, it is very important that Close is called after
// all data has been written. | [
"Append",
"opens",
"an",
"existing",
"file",
"in",
"HDFS",
"and",
"returns",
"an",
"io",
".",
"WriteCloser",
"for",
"writing",
"to",
"it",
".",
"Because",
"of",
"the",
"way",
"that",
"HDFS",
"writes",
"are",
"buffered",
"and",
"acknowledged",
"asynchronously... | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/file_writer.go#L84-L131 |
148,999 | colinmarc/hdfs | file_writer.go | CreateEmptyFile | func (c *Client) CreateEmptyFile(name string) error {
f, err := c.Create(name)
if err != nil {
return err
}
return f.Close()
} | go | func (c *Client) CreateEmptyFile(name string) error {
f, err := c.Create(name)
if err != nil {
return err
}
return f.Close()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateEmptyFile",
"(",
"name",
"string",
")",
"error",
"{",
"f",
",",
"err",
":=",
"c",
".",
"Create",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"f"... | // CreateEmptyFile creates a empty file at the given name, with the
// permissions 0644. | [
"CreateEmptyFile",
"creates",
"a",
"empty",
"file",
"at",
"the",
"given",
"name",
"with",
"the",
"permissions",
"0644",
"."
] | 6f7e441ec688730014b4ca08657db358d7a45b87 | https://github.com/colinmarc/hdfs/blob/6f7e441ec688730014b4ca08657db358d7a45b87/file_writer.go#L135-L142 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.