repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
minio/mc | pkg/colorjson/decode.go | addErrorContext | func (d *decodeState) addErrorContext(err error) error {
if d.errorContext.Struct != "" || d.errorContext.Field != "" {
switch err := err.(type) {
case *UnmarshalTypeError:
err.Struct = d.errorContext.Struct
err.Field = d.errorContext.Field
return err
}
}
return err
} | go | func (d *decodeState) addErrorContext(err error) error {
if d.errorContext.Struct != "" || d.errorContext.Field != "" {
switch err := err.(type) {
case *UnmarshalTypeError:
err.Struct = d.errorContext.Struct
err.Field = d.errorContext.Field
return err
}
}
return err
} | [
"func",
"(",
"d",
"*",
"decodeState",
")",
"addErrorContext",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"d",
".",
"errorContext",
".",
"Struct",
"!=",
"\"",
"\"",
"||",
"d",
".",
"errorContext",
".",
"Field",
"!=",
"\"",
"\"",
"{",
"switch",
"err... | // addErrorContext returns a new error enhanced with information from d.errorContext | [
"addErrorContext",
"returns",
"a",
"new",
"error",
"enhanced",
"with",
"information",
"from",
"d",
".",
"errorContext"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/decode.go#L318-L328 | train |
minio/mc | pkg/colorjson/decode.go | skip | func (d *decodeState) skip() {
s, data, i := &d.scan, d.data, d.off
depth := len(s.parseState)
for {
op := s.step(s, data[i])
i++
if len(s.parseState) < depth {
d.off = i
d.opcode = op
return
}
}
} | go | func (d *decodeState) skip() {
s, data, i := &d.scan, d.data, d.off
depth := len(s.parseState)
for {
op := s.step(s, data[i])
i++
if len(s.parseState) < depth {
d.off = i
d.opcode = op
return
}
}
} | [
"func",
"(",
"d",
"*",
"decodeState",
")",
"skip",
"(",
")",
"{",
"s",
",",
"data",
",",
"i",
":=",
"&",
"d",
".",
"scan",
",",
"d",
".",
"data",
",",
"d",
".",
"off",
"\n",
"depth",
":=",
"len",
"(",
"s",
".",
"parseState",
")",
"\n",
"for... | // skip scans to the end of what was started. | [
"skip",
"scans",
"to",
"the",
"end",
"of",
"what",
"was",
"started",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/decode.go#L331-L343 | train |
minio/mc | cmd/pipe-main.go | checkPipeSyntax | func checkPipeSyntax(ctx *cli.Context) {
if len(ctx.Args()) > 1 {
cli.ShowCommandHelpAndExit(ctx, "pipe", 1) // last argument is exit code.
}
} | go | func checkPipeSyntax(ctx *cli.Context) {
if len(ctx.Args()) > 1 {
cli.ShowCommandHelpAndExit(ctx, "pipe", 1) // last argument is exit code.
}
} | [
"func",
"checkPipeSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
">",
"1",
"{",
"cli",
".",
"ShowCommandHelpAndExit",
"(",
"ctx",
",",
"\"",
"\"",
",",
"1",
")",
"// last argument is ex... | // check pipe input arguments. | [
"check",
"pipe",
"input",
"arguments",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/pipe-main.go#L95-L99 | train |
minio/mc | cmd/pipe-main.go | mainPipe | func mainPipe(ctx *cli.Context) error {
// Parse encryption keys per command.
encKeyDB, err := getEncKeys(ctx)
fatalIf(err, "Unable to parse encryption keys.")
// validate pipe input arguments.
checkPipeSyntax(ctx)
if len(ctx.Args()) == 0 {
err = pipe("", nil)
fatalIf(err.Trace("stdout"), "Unable to write t... | go | func mainPipe(ctx *cli.Context) error {
// Parse encryption keys per command.
encKeyDB, err := getEncKeys(ctx)
fatalIf(err, "Unable to parse encryption keys.")
// validate pipe input arguments.
checkPipeSyntax(ctx)
if len(ctx.Args()) == 0 {
err = pipe("", nil)
fatalIf(err.Trace("stdout"), "Unable to write t... | [
"func",
"mainPipe",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// Parse encryption keys per command.",
"encKeyDB",
",",
"err",
":=",
"getEncKeys",
"(",
"ctx",
")",
"\n",
"fatalIf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n\n",
"// validate pipe ... | // mainPipe is the main entry point for pipe command. | [
"mainPipe",
"is",
"the",
"main",
"entry",
"point",
"for",
"pipe",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/pipe-main.go#L102-L122 | train |
minio/mc | cmd/certs.go | getCertsDir | func getCertsDir() (string, *probe.Error) {
p, err := getMcConfigDir()
if err != nil {
return "", err.Trace()
}
return filepath.Join(p, globalMCCertsDir), nil
} | go | func getCertsDir() (string, *probe.Error) {
p, err := getMcConfigDir()
if err != nil {
return "", err.Trace()
}
return filepath.Join(p, globalMCCertsDir), nil
} | [
"func",
"getCertsDir",
"(",
")",
"(",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"p",
",",
"err",
":=",
"getMcConfigDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
".",
"Trace",
"(",
")",
"\n",
"... | // getCertsDir - return the full path of certs dir | [
"getCertsDir",
"-",
"return",
"the",
"full",
"path",
"of",
"certs",
"dir"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L29-L35 | train |
minio/mc | cmd/certs.go | isCertsDirExists | func isCertsDirExists() bool {
certsDir, err := getCertsDir()
fatalIf(err.Trace(), "Unable to determine certs folder.")
if _, e := os.Stat(certsDir); e != nil {
return false
}
return true
} | go | func isCertsDirExists() bool {
certsDir, err := getCertsDir()
fatalIf(err.Trace(), "Unable to determine certs folder.")
if _, e := os.Stat(certsDir); e != nil {
return false
}
return true
} | [
"func",
"isCertsDirExists",
"(",
")",
"bool",
"{",
"certsDir",
",",
"err",
":=",
"getCertsDir",
"(",
")",
"\n",
"fatalIf",
"(",
"err",
".",
"Trace",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"_",
",",
"e",
":=",
"os",
".",
"Stat",
"(",
"certsDi... | // isCertsDirExists - verify if certs directory exists. | [
"isCertsDirExists",
"-",
"verify",
"if",
"certs",
"directory",
"exists",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L38-L45 | train |
minio/mc | cmd/certs.go | createCertsDir | func createCertsDir() *probe.Error {
p, err := getCertsDir()
if err != nil {
return err.Trace()
}
if e := os.MkdirAll(p, 0700); e != nil {
return probe.NewError(e)
}
return nil
} | go | func createCertsDir() *probe.Error {
p, err := getCertsDir()
if err != nil {
return err.Trace()
}
if e := os.MkdirAll(p, 0700); e != nil {
return probe.NewError(e)
}
return nil
} | [
"func",
"createCertsDir",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"p",
",",
"err",
":=",
"getCertsDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Trace",
"(",
")",
"\n",
"}",
"\n",
"if",
"e",
":=",
"os",
".",
"Mkd... | // createCertsDir - create MinIO Client certs folder | [
"createCertsDir",
"-",
"create",
"MinIO",
"Client",
"certs",
"folder"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L48-L57 | train |
minio/mc | cmd/certs.go | getCAsDir | func getCAsDir() (string, *probe.Error) {
p, err := getCertsDir()
if err != nil {
return "", err.Trace()
}
return filepath.Join(p, globalMCCAsDir), nil
} | go | func getCAsDir() (string, *probe.Error) {
p, err := getCertsDir()
if err != nil {
return "", err.Trace()
}
return filepath.Join(p, globalMCCAsDir), nil
} | [
"func",
"getCAsDir",
"(",
")",
"(",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"p",
",",
"err",
":=",
"getCertsDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
".",
"Trace",
"(",
")",
"\n",
"}",
... | // getCAsDir - return the full path of CAs dir | [
"getCAsDir",
"-",
"return",
"the",
"full",
"path",
"of",
"CAs",
"dir"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L60-L66 | train |
minio/mc | cmd/certs.go | isCAsDirExists | func isCAsDirExists() bool {
CAsDir, err := getCAsDir()
fatalIf(err.Trace(), "Unable to determine CAs folder.")
if _, e := os.Stat(CAsDir); e != nil {
return false
}
return true
} | go | func isCAsDirExists() bool {
CAsDir, err := getCAsDir()
fatalIf(err.Trace(), "Unable to determine CAs folder.")
if _, e := os.Stat(CAsDir); e != nil {
return false
}
return true
} | [
"func",
"isCAsDirExists",
"(",
")",
"bool",
"{",
"CAsDir",
",",
"err",
":=",
"getCAsDir",
"(",
")",
"\n",
"fatalIf",
"(",
"err",
".",
"Trace",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"_",
",",
"e",
":=",
"os",
".",
"Stat",
"(",
"CAsDir",
")... | // isCAsDirExists - verify if CAs directory exists. | [
"isCAsDirExists",
"-",
"verify",
"if",
"CAs",
"directory",
"exists",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L78-L85 | train |
minio/mc | cmd/certs.go | createCAsDir | func createCAsDir() *probe.Error {
p, err := getCAsDir()
if err != nil {
return err.Trace()
}
if e := os.MkdirAll(p, 0700); e != nil {
return probe.NewError(e)
}
return nil
} | go | func createCAsDir() *probe.Error {
p, err := getCAsDir()
if err != nil {
return err.Trace()
}
if e := os.MkdirAll(p, 0700); e != nil {
return probe.NewError(e)
}
return nil
} | [
"func",
"createCAsDir",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"p",
",",
"err",
":=",
"getCAsDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Trace",
"(",
")",
"\n",
"}",
"\n",
"if",
"e",
":=",
"os",
".",
"MkdirAl... | // createCAsDir - create MinIO Client CAs folder | [
"createCAsDir",
"-",
"create",
"MinIO",
"Client",
"CAs",
"folder"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L88-L97 | train |
minio/mc | cmd/certs.go | mustGetCAFiles | func mustGetCAFiles() (caCerts []string) {
CAsDir := mustGetCAsDir()
caFiles, _ := ioutil.ReadDir(CAsDir)
for _, cert := range caFiles {
caCerts = append(caCerts, filepath.Join(CAsDir, cert.Name()))
}
return
} | go | func mustGetCAFiles() (caCerts []string) {
CAsDir := mustGetCAsDir()
caFiles, _ := ioutil.ReadDir(CAsDir)
for _, cert := range caFiles {
caCerts = append(caCerts, filepath.Join(CAsDir, cert.Name()))
}
return
} | [
"func",
"mustGetCAFiles",
"(",
")",
"(",
"caCerts",
"[",
"]",
"string",
")",
"{",
"CAsDir",
":=",
"mustGetCAsDir",
"(",
")",
"\n",
"caFiles",
",",
"_",
":=",
"ioutil",
".",
"ReadDir",
"(",
"CAsDir",
")",
"\n",
"for",
"_",
",",
"cert",
":=",
"range",
... | // mustGetCAFiles - get the list of the CA certificates stored in MinIO config dir | [
"mustGetCAFiles",
"-",
"get",
"the",
"list",
"of",
"the",
"CA",
"certificates",
"stored",
"in",
"MinIO",
"config",
"dir"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L100-L107 | train |
minio/mc | cmd/certs.go | loadRootCAs | func loadRootCAs() {
caFiles := mustGetCAFiles()
if len(caFiles) == 0 {
return
}
// Get system cert pool, and empty cert pool under Windows because it is not supported
globalRootCAs = mustGetSystemCertPool()
// Load custom root CAs for client requests
for _, caFile := range caFiles {
caCert, err := ioutil.Re... | go | func loadRootCAs() {
caFiles := mustGetCAFiles()
if len(caFiles) == 0 {
return
}
// Get system cert pool, and empty cert pool under Windows because it is not supported
globalRootCAs = mustGetSystemCertPool()
// Load custom root CAs for client requests
for _, caFile := range caFiles {
caCert, err := ioutil.Re... | [
"func",
"loadRootCAs",
"(",
")",
"{",
"caFiles",
":=",
"mustGetCAFiles",
"(",
")",
"\n",
"if",
"len",
"(",
"caFiles",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"// Get system cert pool, and empty cert pool under Windows because it is not supported",
"globalRootC... | // loadRootCAs fetches CA files provided in MinIO config and adds them to globalRootCAs
// Currently under Windows, there is no way to load system + user CAs at the same time | [
"loadRootCAs",
"fetches",
"CA",
"files",
"provided",
"in",
"MinIO",
"config",
"and",
"adds",
"them",
"to",
"globalRootCAs",
"Currently",
"under",
"Windows",
"there",
"is",
"no",
"way",
"to",
"load",
"system",
"+",
"user",
"CAs",
"at",
"the",
"same",
"time"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/certs.go#L120-L135 | train |
minio/mc | pkg/httptracer/httptracer.go | CancelRequest | func (t RoundTripTrace) CancelRequest(req *http.Request) {
transport, ok := t.Transport.(*http.Transport)
if ok {
transport.CancelRequest(req)
}
} | go | func (t RoundTripTrace) CancelRequest(req *http.Request) {
transport, ok := t.Transport.(*http.Transport)
if ok {
transport.CancelRequest(req)
}
} | [
"func",
"(",
"t",
"RoundTripTrace",
")",
"CancelRequest",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"transport",
",",
"ok",
":=",
"t",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Transport",
")",
"\n",
"if",
"ok",
"{",
"transport",
".",
... | // CancelRequest implements functinality to cancel an underlying request. | [
"CancelRequest",
"implements",
"functinality",
"to",
"cancel",
"an",
"underlying",
"request",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/httptracer/httptracer.go#L40-L45 | train |
minio/mc | pkg/httptracer/httptracer.go | RoundTrip | func (t RoundTripTrace) RoundTrip(req *http.Request) (res *http.Response, err error) {
timeStamp := time.Now()
if t.Transport == nil {
return nil, errors.New("Invalid Argument")
}
res, err = t.Transport.RoundTrip(req)
if err != nil {
return res, err
}
if t.Trace != nil {
err = t.Trace.Request(req)
if ... | go | func (t RoundTripTrace) RoundTrip(req *http.Request) (res *http.Response, err error) {
timeStamp := time.Now()
if t.Transport == nil {
return nil, errors.New("Invalid Argument")
}
res, err = t.Transport.RoundTrip(req)
if err != nil {
return res, err
}
if t.Trace != nil {
err = t.Trace.Request(req)
if ... | [
"func",
"(",
"t",
"RoundTripTrace",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"res",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"{",
"timeStamp",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"if",
"t",
".",
... | // RoundTrip executes user provided request and response hooks for each HTTP call. | [
"RoundTrip",
"executes",
"user",
"provided",
"request",
"and",
"response",
"hooks",
"for",
"each",
"HTTP",
"call",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/httptracer/httptracer.go#L48-L73 | train |
minio/mc | cmd/admin-user-add-policy.go | checkAdminUserPolicySyntax | func checkAdminUserPolicySyntax(ctx *cli.Context) {
if len(ctx.Args()) != 3 {
cli.ShowCommandHelpAndExit(ctx, "policy", 1) // last argument is exit code
}
} | go | func checkAdminUserPolicySyntax(ctx *cli.Context) {
if len(ctx.Args()) != 3 {
cli.ShowCommandHelpAndExit(ctx, "policy", 1) // last argument is exit code
}
} | [
"func",
"checkAdminUserPolicySyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"!=",
"3",
"{",
"cli",
".",
"ShowCommandHelpAndExit",
"(",
"ctx",
",",
"\"",
"\"",
",",
"1",
")",
"// last ar... | // checkAdminUserPolicySyntax - validate all the passed arguments | [
"checkAdminUserPolicySyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-user-add-policy.go#L51-L55 | train |
minio/mc | cmd/admin-user-add-policy.go | mainAdminUserPolicy | func mainAdminUserPolicy(ctx *cli.Context) error {
checkAdminUserPolicySyntax(ctx)
console.SetColor("UserMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
fatalIf(er... | go | func mainAdminUserPolicy(ctx *cli.Context) error {
checkAdminUserPolicySyntax(ctx)
console.SetColor("UserMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
fatalIf(er... | [
"func",
"mainAdminUserPolicy",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"checkAdminUserPolicySyntax",
"(",
"ctx",
")",
"\n\n",
"console",
".",
"SetColor",
"(",
"\"",
"\"",
",",
"color",
".",
"New",
"(",
"color",
".",
"FgGreen",
")",
")"... | // mainAdminUserPolicy is the handle for "mc admin user policy" command. | [
"mainAdminUserPolicy",
"is",
"the",
"handle",
"for",
"mc",
"admin",
"user",
"policy",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-user-add-policy.go#L58-L81 | train |
minio/mc | cmd/admin-service-status.go | checkAdminServiceStatusSyntax | func checkAdminServiceStatusSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
cli.ShowCommandHelpAndExit(ctx, "status", 1) // last argument is exit code
}
} | go | func checkAdminServiceStatusSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
cli.ShowCommandHelpAndExit(ctx, "status", 1) // last argument is exit code
}
} | [
"func",
"checkAdminServiceStatusSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"==",
"0",
"||",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
">",
"2",
"{",
"cli",
".",
"ShowComman... | // checkAdminServiceStatusSyntax - validate all the passed arguments | [
"checkAdminServiceStatusSyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-service-status.go#L93-L97 | train |
minio/mc | cmd/session-v8.go | String | func (s sessionV8) String() string {
message := console.Colorize("SessionID", fmt.Sprintf("%s -> ", s.SessionID))
message = message + console.Colorize("SessionTime", fmt.Sprintf("[%s]", s.Header.When.Local().Format(printDate)))
message = message + console.Colorize("Command", fmt.Sprintf(" %s %s", s.Header.CommandTyp... | go | func (s sessionV8) String() string {
message := console.Colorize("SessionID", fmt.Sprintf("%s -> ", s.SessionID))
message = message + console.Colorize("SessionTime", fmt.Sprintf("[%s]", s.Header.When.Local().Format(printDate)))
message = message + console.Colorize("Command", fmt.Sprintf(" %s %s", s.Header.CommandTyp... | [
"func",
"(",
"s",
"sessionV8",
")",
"String",
"(",
")",
"string",
"{",
"message",
":=",
"console",
".",
"Colorize",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"SessionID",
")",
")",
"\n",
"message",
"=",
"message",... | // String colorized session message. | [
"String",
"colorized",
"session",
"message",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L86-L91 | train |
minio/mc | cmd/session-v8.go | JSON | func (s sessionV8) JSON() string {
sessionMsg := sessionMessage{
SessionID: s.SessionID,
Time: s.Header.When.Local(),
CommandType: s.Header.CommandType,
CommandArgs: s.Header.CommandArgs,
}
sessionMsg.Status = "success"
sessionBytes, e := json.MarshalIndent(sessionMsg, "", " ")
fatalIf(probe.NewEr... | go | func (s sessionV8) JSON() string {
sessionMsg := sessionMessage{
SessionID: s.SessionID,
Time: s.Header.When.Local(),
CommandType: s.Header.CommandType,
CommandArgs: s.Header.CommandArgs,
}
sessionMsg.Status = "success"
sessionBytes, e := json.MarshalIndent(sessionMsg, "", " ")
fatalIf(probe.NewEr... | [
"func",
"(",
"s",
"sessionV8",
")",
"JSON",
"(",
")",
"string",
"{",
"sessionMsg",
":=",
"sessionMessage",
"{",
"SessionID",
":",
"s",
".",
"SessionID",
",",
"Time",
":",
"s",
".",
"Header",
".",
"When",
".",
"Local",
"(",
")",
",",
"CommandType",
":... | // JSON jsonified session message. | [
"JSON",
"jsonified",
"session",
"message",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L94-L106 | train |
minio/mc | cmd/session-v8.go | loadSessionV8 | func loadSessionV8(sid string) (*sessionV8, *probe.Error) {
if !isSessionDirExists() {
return nil, errInvalidArgument().Trace()
}
sessionFile, err := getSessionFile(sid)
if err != nil {
return nil, err.Trace(sid)
}
if _, e := os.Stat(sessionFile); e != nil {
return nil, probe.NewError(e)
}
// Initialize... | go | func loadSessionV8(sid string) (*sessionV8, *probe.Error) {
if !isSessionDirExists() {
return nil, errInvalidArgument().Trace()
}
sessionFile, err := getSessionFile(sid)
if err != nil {
return nil, err.Trace(sid)
}
if _, e := os.Stat(sessionFile); e != nil {
return nil, probe.NewError(e)
}
// Initialize... | [
"func",
"loadSessionV8",
"(",
"sid",
"string",
")",
"(",
"*",
"sessionV8",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"if",
"!",
"isSessionDirExists",
"(",
")",
"{",
"return",
"nil",
",",
"errInvalidArgument",
"(",
")",
".",
"Trace",
"(",
")",
"\n",
... | // loadSessionV8 - reads session file if exists and re-initiates internal variables | [
"loadSessionV8",
"-",
"reads",
"session",
"file",
"if",
"exists",
"and",
"re",
"-",
"initiates",
"internal",
"variables"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L109-L163 | train |
minio/mc | cmd/session-v8.go | newSessionV8 | func newSessionV8() *sessionV8 {
s := &sessionV8{}
s.Header = &sessionV8Header{}
s.Header.Version = globalSessionConfigVersion
// map of command and files copied.
s.Header.GlobalBoolFlags = make(map[string]bool)
s.Header.GlobalIntFlags = make(map[string]int)
s.Header.GlobalStringFlags = make(map[string]string)
... | go | func newSessionV8() *sessionV8 {
s := &sessionV8{}
s.Header = &sessionV8Header{}
s.Header.Version = globalSessionConfigVersion
// map of command and files copied.
s.Header.GlobalBoolFlags = make(map[string]bool)
s.Header.GlobalIntFlags = make(map[string]int)
s.Header.GlobalStringFlags = make(map[string]string)
... | [
"func",
"newSessionV8",
"(",
")",
"*",
"sessionV8",
"{",
"s",
":=",
"&",
"sessionV8",
"{",
"}",
"\n",
"s",
".",
"Header",
"=",
"&",
"sessionV8Header",
"{",
"}",
"\n",
"s",
".",
"Header",
".",
"Version",
"=",
"globalSessionConfigVersion",
"\n",
"// map of... | // newSessionV8 provides a new session. | [
"newSessionV8",
"provides",
"a",
"new",
"session",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L166-L195 | train |
minio/mc | cmd/session-v8.go | HasData | func (s sessionV8) HasData() bool {
return s.Header.LastCopied != "" || s.Header.LastRemoved != ""
} | go | func (s sessionV8) HasData() bool {
return s.Header.LastCopied != "" || s.Header.LastRemoved != ""
} | [
"func",
"(",
"s",
"sessionV8",
")",
"HasData",
"(",
")",
"bool",
"{",
"return",
"s",
".",
"Header",
".",
"LastCopied",
"!=",
"\"",
"\"",
"||",
"s",
".",
"Header",
".",
"LastRemoved",
"!=",
"\"",
"\"",
"\n",
"}"
] | // HasData provides true if this is a session resume, false otherwise. | [
"HasData",
"provides",
"true",
"if",
"this",
"is",
"a",
"session",
"resume",
"false",
"otherwise",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L198-L200 | train |
minio/mc | cmd/session-v8.go | NewDataReader | func (s *sessionV8) NewDataReader() io.Reader {
// DataFP is always intitialized, either via new or load functions.
s.DataFP.Seek(0, os.SEEK_SET)
return io.Reader(s.DataFP)
} | go | func (s *sessionV8) NewDataReader() io.Reader {
// DataFP is always intitialized, either via new or load functions.
s.DataFP.Seek(0, os.SEEK_SET)
return io.Reader(s.DataFP)
} | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"NewDataReader",
"(",
")",
"io",
".",
"Reader",
"{",
"// DataFP is always intitialized, either via new or load functions.",
"s",
".",
"DataFP",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"\n",
"return",
"io... | // NewDataReader provides reader interface to session data file. | [
"NewDataReader",
"provides",
"reader",
"interface",
"to",
"session",
"data",
"file",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L203-L207 | train |
minio/mc | cmd/session-v8.go | NewDataWriter | func (s *sessionV8) NewDataWriter() io.Writer {
// DataFP is always intitialized, either via new or load functions.
s.DataFP.Seek(0, os.SEEK_SET)
// when moving to file position 0 we want to truncate the file as well,
// otherwise we'll partly overwrite existing data
s.DataFP.Truncate(0)
return io.Writer(s.DataFP... | go | func (s *sessionV8) NewDataWriter() io.Writer {
// DataFP is always intitialized, either via new or load functions.
s.DataFP.Seek(0, os.SEEK_SET)
// when moving to file position 0 we want to truncate the file as well,
// otherwise we'll partly overwrite existing data
s.DataFP.Truncate(0)
return io.Writer(s.DataFP... | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"NewDataWriter",
"(",
")",
"io",
".",
"Writer",
"{",
"// DataFP is always intitialized, either via new or load functions.",
"s",
".",
"DataFP",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"\n",
"// when moving... | // NewDataReader provides writer interface to session data file. | [
"NewDataReader",
"provides",
"writer",
"interface",
"to",
"session",
"data",
"file",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L210-L217 | train |
minio/mc | cmd/session-v8.go | Save | func (s *sessionV8) Save() *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.DataFP.dirty {
if err := s.DataFP.Sync(); err != nil {
return probe.NewError(err)
}
s.DataFP.dirty = false
}
qs, e := quick.NewConfig(s.Header, nil)
if e != nil {
return probe.NewError(e).Trace(s.SessionID)
}
sess... | go | func (s *sessionV8) Save() *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.DataFP.dirty {
if err := s.DataFP.Sync(); err != nil {
return probe.NewError(err)
}
s.DataFP.dirty = false
}
qs, e := quick.NewConfig(s.Header, nil)
if e != nil {
return probe.NewError(e).Trace(s.SessionID)
}
sess... | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"Save",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"DataFP",
".",
"dirty",
"... | // Save this session. | [
"Save",
"this",
"session",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L220-L245 | train |
minio/mc | cmd/session-v8.go | setGlobals | func (s *sessionV8) setGlobals() {
s.Header.GlobalBoolFlags["quiet"] = globalQuiet
s.Header.GlobalBoolFlags["debug"] = globalDebug
s.Header.GlobalBoolFlags["json"] = globalJSON
s.Header.GlobalBoolFlags["noColor"] = globalNoColor
s.Header.GlobalBoolFlags["insecure"] = globalInsecure
} | go | func (s *sessionV8) setGlobals() {
s.Header.GlobalBoolFlags["quiet"] = globalQuiet
s.Header.GlobalBoolFlags["debug"] = globalDebug
s.Header.GlobalBoolFlags["json"] = globalJSON
s.Header.GlobalBoolFlags["noColor"] = globalNoColor
s.Header.GlobalBoolFlags["insecure"] = globalInsecure
} | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"setGlobals",
"(",
")",
"{",
"s",
".",
"Header",
".",
"GlobalBoolFlags",
"[",
"\"",
"\"",
"]",
"=",
"globalQuiet",
"\n",
"s",
".",
"Header",
".",
"GlobalBoolFlags",
"[",
"\"",
"\"",
"]",
"=",
"globalDebug",
"\... | // setGlobals captures the state of global variables into session header.
// Used by newSession. | [
"setGlobals",
"captures",
"the",
"state",
"of",
"global",
"variables",
"into",
"session",
"header",
".",
"Used",
"by",
"newSession",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L249-L255 | train |
minio/mc | cmd/session-v8.go | restoreGlobals | func (s sessionV8) restoreGlobals() {
quiet := s.Header.GlobalBoolFlags["quiet"]
debug := s.Header.GlobalBoolFlags["debug"]
json := s.Header.GlobalBoolFlags["json"]
noColor := s.Header.GlobalBoolFlags["noColor"]
insecure := s.Header.GlobalBoolFlags["insecure"]
setGlobals(quiet, debug, json, noColor, insecure)
} | go | func (s sessionV8) restoreGlobals() {
quiet := s.Header.GlobalBoolFlags["quiet"]
debug := s.Header.GlobalBoolFlags["debug"]
json := s.Header.GlobalBoolFlags["json"]
noColor := s.Header.GlobalBoolFlags["noColor"]
insecure := s.Header.GlobalBoolFlags["insecure"]
setGlobals(quiet, debug, json, noColor, insecure)
} | [
"func",
"(",
"s",
"sessionV8",
")",
"restoreGlobals",
"(",
")",
"{",
"quiet",
":=",
"s",
".",
"Header",
".",
"GlobalBoolFlags",
"[",
"\"",
"\"",
"]",
"\n",
"debug",
":=",
"s",
".",
"Header",
".",
"GlobalBoolFlags",
"[",
"\"",
"\"",
"]",
"\n",
"json",... | // RestoreGlobals restores the state of global variables.
// Used by resumeSession. | [
"RestoreGlobals",
"restores",
"the",
"state",
"of",
"global",
"variables",
".",
"Used",
"by",
"resumeSession",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L259-L266 | train |
minio/mc | cmd/session-v8.go | isModified | func (s *sessionV8) isModified(sessionFile string) (bool, *probe.Error) {
qs, e := quick.NewConfig(s.Header, nil)
if e != nil {
return false, probe.NewError(e).Trace(s.SessionID)
}
var currentHeader = &sessionV8Header{}
currentQS, e := quick.LoadConfig(sessionFile, nil, currentHeader)
if e != nil {
// If ses... | go | func (s *sessionV8) isModified(sessionFile string) (bool, *probe.Error) {
qs, e := quick.NewConfig(s.Header, nil)
if e != nil {
return false, probe.NewError(e).Trace(s.SessionID)
}
var currentHeader = &sessionV8Header{}
currentQS, e := quick.LoadConfig(sessionFile, nil, currentHeader)
if e != nil {
// If ses... | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"isModified",
"(",
"sessionFile",
"string",
")",
"(",
"bool",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"qs",
",",
"e",
":=",
"quick",
".",
"NewConfig",
"(",
"s",
".",
"Header",
",",
"nil",
")",
"\n",
"if... | // IsModified - returns if in memory session header has changed from
// its on disk value. | [
"IsModified",
"-",
"returns",
"if",
"in",
"memory",
"session",
"header",
"has",
"changed",
"from",
"its",
"on",
"disk",
"value",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L270-L295 | train |
minio/mc | cmd/session-v8.go | save | func (s *sessionV8) save() *probe.Error {
sessionFile, err := getSessionFile(s.SessionID)
if err != nil {
return err.Trace(s.SessionID)
}
// Verify if sessionFile is modified.
modified, err := s.isModified(sessionFile)
if err != nil {
return err.Trace(s.SessionID)
}
// Header is modified, we save it.
if m... | go | func (s *sessionV8) save() *probe.Error {
sessionFile, err := getSessionFile(s.SessionID)
if err != nil {
return err.Trace(s.SessionID)
}
// Verify if sessionFile is modified.
modified, err := s.isModified(sessionFile)
if err != nil {
return err.Trace(s.SessionID)
}
// Header is modified, we save it.
if m... | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"save",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"sessionFile",
",",
"err",
":=",
"getSessionFile",
"(",
"s",
".",
"SessionID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Trace",
"(",... | // save - wrapper for quick.Save and saves only if sessionHeader is
// modified. | [
"save",
"-",
"wrapper",
"for",
"quick",
".",
"Save",
"and",
"saves",
"only",
"if",
"sessionHeader",
"is",
"modified",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L299-L323 | train |
minio/mc | cmd/session-v8.go | Close | func (s *sessionV8) Close() *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
if err := s.DataFP.Close(); err != nil {
return probe.NewError(err)
}
// Attempt to save the header if modified.
return s.save()
} | go | func (s *sessionV8) Close() *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
if err := s.DataFP.Close(); err != nil {
return probe.NewError(err)
}
// Attempt to save the header if modified.
return s.save()
} | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"Close",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"s",
".",
"DataFP",
"... | // Close ends this session and removes all associated session files. | [
"Close",
"ends",
"this",
"session",
"and",
"removes",
"all",
"associated",
"session",
"files",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L326-L336 | train |
minio/mc | cmd/session-v8.go | Delete | func (s *sessionV8) Delete() *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.DataFP != nil {
name := s.DataFP.Name()
// close file pro-actively before deleting
// ignore any error, it could be possibly that
// the file is closed already
s.DataFP.Close()
// Remove the data file.
if e := os.R... | go | func (s *sessionV8) Delete() *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.DataFP != nil {
name := s.DataFP.Name()
// close file pro-actively before deleting
// ignore any error, it could be possibly that
// the file is closed already
s.DataFP.Close()
// Remove the data file.
if e := os.R... | [
"func",
"(",
"s",
"*",
"sessionV8",
")",
"Delete",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"DataFP",
"!=",
"nil",
... | // Delete removes all the session files. | [
"Delete",
"removes",
"all",
"the",
"session",
"files",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L339-L371 | train |
minio/mc | cmd/session-v8.go | isLastFactory | func isLastFactory(lastURL string) func(string) bool {
last := true // closure
return func(sourceURL string) bool {
if sourceURL == "" {
fatalIf(errInvalidArgument().Trace(), "Empty source argument passed.")
}
if lastURL == "" {
return false
}
if last {
if lastURL == sourceURL {
last = false /... | go | func isLastFactory(lastURL string) func(string) bool {
last := true // closure
return func(sourceURL string) bool {
if sourceURL == "" {
fatalIf(errInvalidArgument().Trace(), "Empty source argument passed.")
}
if lastURL == "" {
return false
}
if last {
if lastURL == sourceURL {
last = false /... | [
"func",
"isLastFactory",
"(",
"lastURL",
"string",
")",
"func",
"(",
"string",
")",
"bool",
"{",
"last",
":=",
"true",
"// closure",
"\n",
"return",
"func",
"(",
"sourceURL",
"string",
")",
"bool",
"{",
"if",
"sourceURL",
"==",
"\"",
"\"",
"{",
"fatalIf"... | // Create a factory function to simplify checking if
// object was last operated on. | [
"Create",
"a",
"factory",
"function",
"to",
"simplify",
"checking",
"if",
"object",
"was",
"last",
"operated",
"on",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/session-v8.go#L381-L399 | train |
minio/mc | cmd/client-s3.go | AddNotificationConfig | func (c *s3Client) AddNotificationConfig(arn string, events []string, prefix, suffix string) *probe.Error {
bucket, _ := c.url2BucketAndObject()
// Validate total fields in ARN.
fields := strings.Split(arn, ":")
if len(fields) != 6 {
return errInvalidArgument()
}
// Get any enabled notification.
mb, e := c.ap... | go | func (c *s3Client) AddNotificationConfig(arn string, events []string, prefix, suffix string) *probe.Error {
bucket, _ := c.url2BucketAndObject()
// Validate total fields in ARN.
fields := strings.Split(arn, ":")
if len(fields) != 6 {
return errInvalidArgument()
}
// Get any enabled notification.
mb, e := c.ap... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"AddNotificationConfig",
"(",
"arn",
"string",
",",
"events",
"[",
"]",
"string",
",",
"prefix",
",",
"suffix",
"string",
")",
"*",
"probe",
".",
"Error",
"{",
"bucket",
",",
"_",
":=",
"c",
".",
"url2BucketAndOb... | // Add bucket notification | [
"Add",
"bucket",
"notification"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L243-L302 | train |
minio/mc | cmd/client-s3.go | RemoveNotificationConfig | func (c *s3Client) RemoveNotificationConfig(arn string) *probe.Error {
bucket, _ := c.url2BucketAndObject()
// Remove all notification configs if arn is empty
if arn == "" {
if err := c.api.RemoveAllBucketNotification(bucket); err != nil {
return probe.NewError(err)
}
return nil
}
mb, e := c.api.GetBucke... | go | func (c *s3Client) RemoveNotificationConfig(arn string) *probe.Error {
bucket, _ := c.url2BucketAndObject()
// Remove all notification configs if arn is empty
if arn == "" {
if err := c.api.RemoveAllBucketNotification(bucket); err != nil {
return probe.NewError(err)
}
return nil
}
mb, e := c.api.GetBucke... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"RemoveNotificationConfig",
"(",
"arn",
"string",
")",
"*",
"probe",
".",
"Error",
"{",
"bucket",
",",
"_",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"// Remove all notification configs if arn is empty",
"if",... | // Remove bucket notification | [
"Remove",
"bucket",
"notification"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L305-L342 | train |
minio/mc | cmd/client-s3.go | ListNotificationConfigs | func (c *s3Client) ListNotificationConfigs(arn string) ([]notificationConfig, *probe.Error) {
var configs []notificationConfig
bucket, _ := c.url2BucketAndObject()
mb, e := c.api.GetBucketNotification(bucket)
if e != nil {
return nil, probe.NewError(e)
}
// Generate pretty event names from event types
prettyE... | go | func (c *s3Client) ListNotificationConfigs(arn string) ([]notificationConfig, *probe.Error) {
var configs []notificationConfig
bucket, _ := c.url2BucketAndObject()
mb, e := c.api.GetBucketNotification(bucket)
if e != nil {
return nil, probe.NewError(e)
}
// Generate pretty event names from event types
prettyE... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"ListNotificationConfigs",
"(",
"arn",
"string",
")",
"(",
"[",
"]",
"notificationConfig",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"var",
"configs",
"[",
"]",
"notificationConfig",
"\n",
"bucket",
",",
"_",
":="... | // List notification configs | [
"List",
"notification",
"configs"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L353-L423 | train |
minio/mc | cmd/client-s3.go | selectObjectOutputOpts | func selectObjectOutputOpts(selOpts SelectObjectOpts, i minio.SelectObjectInputSerialization) minio.SelectObjectOutputSerialization {
var isOK bool
var recDelim, fldDelim, quoteChar, quoteEscChar, qf string
o := minio.SelectObjectOutputSerialization{}
if _, ok := selOpts.OutputSerOpts["json"]; ok {
recDelim, isO... | go | func selectObjectOutputOpts(selOpts SelectObjectOpts, i minio.SelectObjectInputSerialization) minio.SelectObjectOutputSerialization {
var isOK bool
var recDelim, fldDelim, quoteChar, quoteEscChar, qf string
o := minio.SelectObjectOutputSerialization{}
if _, ok := selOpts.OutputSerOpts["json"]; ok {
recDelim, isO... | [
"func",
"selectObjectOutputOpts",
"(",
"selOpts",
"SelectObjectOpts",
",",
"i",
"minio",
".",
"SelectObjectInputSerialization",
")",
"minio",
".",
"SelectObjectOutputSerialization",
"{",
"var",
"isOK",
"bool",
"\n",
"var",
"recDelim",
",",
"fldDelim",
",",
"quoteChar"... | // set the SelectObjectOutputSerialization struct using options passed in by client. If unspecified,
// default S3 API specified defaults | [
"set",
"the",
"SelectObjectOutputSerialization",
"struct",
"using",
"options",
"passed",
"in",
"by",
"client",
".",
"If",
"unspecified",
"default",
"S3",
"API",
"specified",
"defaults"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L435-L476 | train |
minio/mc | cmd/client-s3.go | selectObjectInputOpts | func selectObjectInputOpts(selOpts SelectObjectOpts, object string) minio.SelectObjectInputSerialization {
var isOK bool
var recDelim, fldDelim, quoteChar, quoteEscChar, fileHeader, commentChar, typ string
i := minio.SelectObjectInputSerialization{}
if _, ok := selOpts.InputSerOpts["parquet"]; ok {
i.Parquet = &... | go | func selectObjectInputOpts(selOpts SelectObjectOpts, object string) minio.SelectObjectInputSerialization {
var isOK bool
var recDelim, fldDelim, quoteChar, quoteEscChar, fileHeader, commentChar, typ string
i := minio.SelectObjectInputSerialization{}
if _, ok := selOpts.InputSerOpts["parquet"]; ok {
i.Parquet = &... | [
"func",
"selectObjectInputOpts",
"(",
"selOpts",
"SelectObjectOpts",
",",
"object",
"string",
")",
"minio",
".",
"SelectObjectInputSerialization",
"{",
"var",
"isOK",
"bool",
"\n",
"var",
"recDelim",
",",
"fldDelim",
",",
"quoteChar",
",",
"quoteEscChar",
",",
"fi... | // set the SelectObjectInputSerialization struct using options passed in by client. If unspecified,
// default S3 API specified defaults | [
"set",
"the",
"SelectObjectInputSerialization",
"struct",
"using",
"options",
"passed",
"in",
"by",
"client",
".",
"If",
"unspecified",
"default",
"S3",
"API",
"specified",
"defaults"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L484-L541 | train |
minio/mc | cmd/client-s3.go | selectCompressionType | func selectCompressionType(selOpts SelectObjectOpts, object string) minio.SelectCompressionType {
ext := filepath.Ext(object)
contentType := mimedb.TypeByExtension(ext)
if selOpts.CompressionType != "" {
return selOpts.CompressionType
}
if strings.Contains(ext, "parquet") || strings.Contains(object, ".parquet")... | go | func selectCompressionType(selOpts SelectObjectOpts, object string) minio.SelectCompressionType {
ext := filepath.Ext(object)
contentType := mimedb.TypeByExtension(ext)
if selOpts.CompressionType != "" {
return selOpts.CompressionType
}
if strings.Contains(ext, "parquet") || strings.Contains(object, ".parquet")... | [
"func",
"selectCompressionType",
"(",
"selOpts",
"SelectObjectOpts",
",",
"object",
"string",
")",
"minio",
".",
"SelectCompressionType",
"{",
"ext",
":=",
"filepath",
".",
"Ext",
"(",
"object",
")",
"\n",
"contentType",
":=",
"mimedb",
".",
"TypeByExtension",
"... | // get client specified compression type or default compression type from file extension | [
"get",
"client",
"specified",
"compression",
"type",
"or",
"default",
"compression",
"type",
"from",
"file",
"extension"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L544-L562 | train |
minio/mc | cmd/client-s3.go | Get | func (c *s3Client) Get(sse encrypt.ServerSide) (io.ReadCloser, *probe.Error) {
bucket, object := c.url2BucketAndObject()
opts := minio.GetObjectOptions{}
opts.ServerSideEncryption = sse
reader, e := c.api.GetObject(bucket, object, opts)
if e != nil {
errResponse := minio.ToErrorResponse(e)
if errResponse.Code ... | go | func (c *s3Client) Get(sse encrypt.ServerSide) (io.ReadCloser, *probe.Error) {
bucket, object := c.url2BucketAndObject()
opts := minio.GetObjectOptions{}
opts.ServerSideEncryption = sse
reader, e := c.api.GetObject(bucket, object, opts)
if e != nil {
errResponse := minio.ToErrorResponse(e)
if errResponse.Code ... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"Get",
"(",
"sse",
"encrypt",
".",
"ServerSide",
")",
"(",
"io",
".",
"ReadCloser",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"bucket",
",",
"object",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"... | // Get - get object with metadata. | [
"Get",
"-",
"get",
"object",
"with",
"metadata",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L707-L730 | train |
minio/mc | cmd/client-s3.go | Copy | func (c *s3Client) Copy(source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string) *probe.Error {
dstBucket, dstObject := c.url2BucketAndObject()
if dstBucket == "" {
return probe.NewError(BucketNameEmpty{})
}
tokens := splitStr(source, string(c.targetURL.Separa... | go | func (c *s3Client) Copy(source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string) *probe.Error {
dstBucket, dstObject := c.url2BucketAndObject()
if dstBucket == "" {
return probe.NewError(BucketNameEmpty{})
}
tokens := splitStr(source, string(c.targetURL.Separa... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"Copy",
"(",
"source",
"string",
",",
"size",
"int64",
",",
"progress",
"io",
".",
"Reader",
",",
"srcSSE",
",",
"tgtSSE",
"encrypt",
".",
"ServerSide",
",",
"metadata",
"map",
"[",
"string",
"]",
"string",
")",
... | // Copy - copy object, uses server side copy API. Also uses an abstracted API
// such that large file sizes will be copied in multipart manner on server
// side. | [
"Copy",
"-",
"copy",
"object",
"uses",
"server",
"side",
"copy",
"API",
".",
"Also",
"uses",
"an",
"abstracted",
"API",
"such",
"that",
"large",
"file",
"sizes",
"will",
"be",
"copied",
"in",
"multipart",
"manner",
"on",
"server",
"side",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L735-L775 | train |
minio/mc | cmd/client-s3.go | Put | func (c *s3Client) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide) (int64, *probe.Error) {
bucket, object := c.url2BucketAndObject()
contentType, ok := metadata["Content-Type"]
if ok {
delete(metadata, "Content-Type")
} else {
// Set... | go | func (c *s3Client) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide) (int64, *probe.Error) {
bucket, object := c.url2BucketAndObject()
contentType, ok := metadata["Content-Type"]
if ok {
delete(metadata, "Content-Type")
} else {
// Set... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"Put",
"(",
"ctx",
"context",
".",
"Context",
",",
"reader",
"io",
".",
"Reader",
",",
"size",
"int64",
",",
"metadata",
"map",
"[",
"string",
"]",
"string",
",",
"progress",
"io",
".",
"Reader",
",",
"sse",
... | // Put - upload an object with custom metadata. | [
"Put",
"-",
"upload",
"an",
"object",
"with",
"custom",
"metadata",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L778-L867 | train |
minio/mc | cmd/client-s3.go | removeIncompleteObjects | func (c *s3Client) removeIncompleteObjects(bucket string, objectsCh <-chan string) <-chan minio.RemoveObjectError {
removeObjectErrorCh := make(chan minio.RemoveObjectError)
// Goroutine reads from objectsCh and sends error to removeObjectErrorCh if any.
go func() {
defer close(removeObjectErrorCh)
for object ... | go | func (c *s3Client) removeIncompleteObjects(bucket string, objectsCh <-chan string) <-chan minio.RemoveObjectError {
removeObjectErrorCh := make(chan minio.RemoveObjectError)
// Goroutine reads from objectsCh and sends error to removeObjectErrorCh if any.
go func() {
defer close(removeObjectErrorCh)
for object ... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"removeIncompleteObjects",
"(",
"bucket",
"string",
",",
"objectsCh",
"<-",
"chan",
"string",
")",
"<-",
"chan",
"minio",
".",
"RemoveObjectError",
"{",
"removeObjectErrorCh",
":=",
"make",
"(",
"chan",
"minio",
".",
"... | // Remove incomplete uploads. | [
"Remove",
"incomplete",
"uploads",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L870-L885 | train |
minio/mc | cmd/client-s3.go | MakeBucket | func (c *s3Client) MakeBucket(region string, ignoreExisting bool) *probe.Error {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return probe.NewError(BucketNameEmpty{})
}
if object != "" {
if strings.HasSuffix(object, "/") {
retry:
if _, e := c.api.PutObject(bucket, object, bytes.NewReader([]b... | go | func (c *s3Client) MakeBucket(region string, ignoreExisting bool) *probe.Error {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return probe.NewError(BucketNameEmpty{})
}
if object != "" {
if strings.HasSuffix(object, "/") {
retry:
if _, e := c.api.PutObject(bucket, object, bytes.NewReader([]b... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"MakeBucket",
"(",
"region",
"string",
",",
"ignoreExisting",
"bool",
")",
"*",
"probe",
".",
"Error",
"{",
"bucket",
",",
"object",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"if",
"bucket",
"==",
"\... | // MakeBucket - make a new bucket. | [
"MakeBucket",
"-",
"make",
"a",
"new",
"bucket",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L984-L1022 | train |
minio/mc | cmd/client-s3.go | GetAccessRules | func (c *s3Client) GetAccessRules() (map[string]string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return map[string]string{}, probe.NewError(BucketNameEmpty{})
}
policies := map[string]string{}
policyStr, e := c.api.GetBucketPolicy(bucket)
if e != nil {
return nil, probe.NewE... | go | func (c *s3Client) GetAccessRules() (map[string]string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return map[string]string{}, probe.NewError(BucketNameEmpty{})
}
policies := map[string]string{}
policyStr, e := c.api.GetBucketPolicy(bucket)
if e != nil {
return nil, probe.NewE... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"GetAccessRules",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"bucket",
",",
"object",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"if",
"bucket",
... | // GetAccessRules - get configured policies from the server | [
"GetAccessRules",
"-",
"get",
"configured",
"policies",
"from",
"the",
"server"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1025-L1048 | train |
minio/mc | cmd/client-s3.go | GetAccess | func (c *s3Client) GetAccess() (string, string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return "", "", probe.NewError(BucketNameEmpty{})
}
policyStr, e := c.api.GetBucketPolicy(bucket)
if e != nil {
return "", "", probe.NewError(e)
}
if policyStr == "" {
return string(po... | go | func (c *s3Client) GetAccess() (string, string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return "", "", probe.NewError(BucketNameEmpty{})
}
policyStr, e := c.api.GetBucketPolicy(bucket)
if e != nil {
return "", "", probe.NewError(e)
}
if policyStr == "" {
return string(po... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"GetAccess",
"(",
")",
"(",
"string",
",",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"bucket",
",",
"object",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"if",
"bucket",
"==",
"\"",
"\""... | // GetAccess get access policy permissions. | [
"GetAccess",
"get",
"access",
"policy",
"permissions",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1051-L1072 | train |
minio/mc | cmd/client-s3.go | SetAccess | func (c *s3Client) SetAccess(bucketPolicy string, isJSON bool) *probe.Error {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return probe.NewError(BucketNameEmpty{})
}
if isJSON {
if e := c.api.SetBucketPolicy(bucket, bucketPolicy); e != nil {
return probe.NewError(e)
}
return nil
}
policy... | go | func (c *s3Client) SetAccess(bucketPolicy string, isJSON bool) *probe.Error {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return probe.NewError(BucketNameEmpty{})
}
if isJSON {
if e := c.api.SetBucketPolicy(bucket, bucketPolicy); e != nil {
return probe.NewError(e)
}
return nil
}
policy... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"SetAccess",
"(",
"bucketPolicy",
"string",
",",
"isJSON",
"bool",
")",
"*",
"probe",
".",
"Error",
"{",
"bucket",
",",
"object",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"if",
"bucket",
"==",
"\"",... | // SetAccess set access policy permissions. | [
"SetAccess",
"set",
"access",
"policy",
"permissions",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1075-L1111 | train |
minio/mc | cmd/client-s3.go | listObjectWrapper | func (c *s3Client) listObjectWrapper(bucket, object string, isRecursive bool, doneCh chan struct{}) <-chan minio.ObjectInfo {
if isAmazon(c.targetURL.Host) || isAmazonAccelerated(c.targetURL.Host) {
return c.api.ListObjectsV2(bucket, object, isRecursive, doneCh)
}
return c.api.ListObjects(bucket, object, isRecursi... | go | func (c *s3Client) listObjectWrapper(bucket, object string, isRecursive bool, doneCh chan struct{}) <-chan minio.ObjectInfo {
if isAmazon(c.targetURL.Host) || isAmazonAccelerated(c.targetURL.Host) {
return c.api.ListObjectsV2(bucket, object, isRecursive, doneCh)
}
return c.api.ListObjects(bucket, object, isRecursi... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"listObjectWrapper",
"(",
"bucket",
",",
"object",
"string",
",",
"isRecursive",
"bool",
",",
"doneCh",
"chan",
"struct",
"{",
"}",
")",
"<-",
"chan",
"minio",
".",
"ObjectInfo",
"{",
"if",
"isAmazon",
"(",
"c",
... | // listObjectWrapper - select ObjectList version depending on the target hostname | [
"listObjectWrapper",
"-",
"select",
"ObjectList",
"version",
"depending",
"on",
"the",
"target",
"hostname"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1114-L1119 | train |
minio/mc | cmd/client-s3.go | getObjectStat | func (c *s3Client) getObjectStat(bucket, object string, opts minio.StatObjectOptions) (*clientContent, *probe.Error) {
objectMetadata := &clientContent{}
objectStat, e := c.api.StatObject(bucket, object, opts)
if e != nil {
errResponse := minio.ToErrorResponse(e)
if errResponse.Code == "AccessDenied" {
return... | go | func (c *s3Client) getObjectStat(bucket, object string, opts minio.StatObjectOptions) (*clientContent, *probe.Error) {
objectMetadata := &clientContent{}
objectStat, e := c.api.StatObject(bucket, object, opts)
if e != nil {
errResponse := minio.ToErrorResponse(e)
if errResponse.Code == "AccessDenied" {
return... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"getObjectStat",
"(",
"bucket",
",",
"object",
"string",
",",
"opts",
"minio",
".",
"StatObjectOptions",
")",
"(",
"*",
"clientContent",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"objectMetadata",
":=",
"&",
"clie... | // getObjectStat returns the metadata of an object from a HEAD call. | [
"getObjectStat",
"returns",
"the",
"metadata",
"of",
"an",
"object",
"from",
"a",
"HEAD",
"call",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1229-L1281 | train |
minio/mc | cmd/client-s3.go | url2BucketAndObject | func (c *s3Client) url2BucketAndObject() (bucketName, objectName string) {
path := c.targetURL.Path
// Convert any virtual host styled requests.
//
// For the time being this check is introduced for S3,
// If you have custom virtual styled hosts please.
// List them below.
if c.virtualStyle {
var bucket string... | go | func (c *s3Client) url2BucketAndObject() (bucketName, objectName string) {
path := c.targetURL.Path
// Convert any virtual host styled requests.
//
// For the time being this check is introduced for S3,
// If you have custom virtual styled hosts please.
// List them below.
if c.virtualStyle {
var bucket string... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"url2BucketAndObject",
"(",
")",
"(",
"bucketName",
",",
"objectName",
"string",
")",
"{",
"path",
":=",
"c",
".",
"targetURL",
".",
"Path",
"\n",
"// Convert any virtual host styled requests.",
"//",
"// For the time being ... | // url2BucketAndObject gives bucketName and objectName from URL path. | [
"url2BucketAndObject",
"gives",
"bucketName",
"and",
"objectName",
"from",
"URL",
"path",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1317-L1340 | train |
minio/mc | cmd/client-s3.go | splitPath | func (c *s3Client) splitPath(path string) (bucketName, objectName string) {
path = strings.TrimPrefix(path, string(c.targetURL.Separator))
// Handle path if its virtual style.
if c.virtualStyle {
hostIndex := strings.Index(c.targetURL.Host, "s3")
if hostIndex == -1 {
hostIndex = strings.Index(c.targetURL.Hos... | go | func (c *s3Client) splitPath(path string) (bucketName, objectName string) {
path = strings.TrimPrefix(path, string(c.targetURL.Separator))
// Handle path if its virtual style.
if c.virtualStyle {
hostIndex := strings.Index(c.targetURL.Host, "s3")
if hostIndex == -1 {
hostIndex = strings.Index(c.targetURL.Hos... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"splitPath",
"(",
"path",
"string",
")",
"(",
"bucketName",
",",
"objectName",
"string",
")",
"{",
"path",
"=",
"strings",
".",
"TrimPrefix",
"(",
"path",
",",
"string",
"(",
"c",
".",
"targetURL",
".",
"Separato... | // splitPath split path into bucket and object. | [
"splitPath",
"split",
"path",
"into",
"bucket",
"and",
"object",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1343-L1364 | train |
minio/mc | cmd/client-s3.go | objectMultipartInfo2ClientContent | func (c *s3Client) objectMultipartInfo2ClientContent(bucket string, entry minio.ObjectMultipartInfo) clientContent {
content := clientContent{}
url := *c.targetURL
// Join bucket and incoming object key.
url.Path = c.joinPath(bucket, entry.Key)
content.URL = url
content.Size = entry.Size
content.Time = entry.In... | go | func (c *s3Client) objectMultipartInfo2ClientContent(bucket string, entry minio.ObjectMultipartInfo) clientContent {
content := clientContent{}
url := *c.targetURL
// Join bucket and incoming object key.
url.Path = c.joinPath(bucket, entry.Key)
content.URL = url
content.Size = entry.Size
content.Time = entry.In... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"objectMultipartInfo2ClientContent",
"(",
"bucket",
"string",
",",
"entry",
"minio",
".",
"ObjectMultipartInfo",
")",
"clientContent",
"{",
"content",
":=",
"clientContent",
"{",
"}",
"\n",
"url",
":=",
"*",
"c",
".",
... | // Convert objectMultipartInfo to clientContent | [
"Convert",
"objectMultipartInfo",
"to",
"clientContent"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1525-L1542 | train |
minio/mc | cmd/client-s3.go | joinPath | func (c *s3Client) joinPath(bucket string, objects ...string) string {
p := string(c.targetURL.Separator) + bucket
for _, o := range objects {
p += string(c.targetURL.Separator) + o
}
return p
} | go | func (c *s3Client) joinPath(bucket string, objects ...string) string {
p := string(c.targetURL.Separator) + bucket
for _, o := range objects {
p += string(c.targetURL.Separator) + o
}
return p
} | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"joinPath",
"(",
"bucket",
"string",
",",
"objects",
"...",
"string",
")",
"string",
"{",
"p",
":=",
"string",
"(",
"c",
".",
"targetURL",
".",
"Separator",
")",
"+",
"bucket",
"\n",
"for",
"_",
",",
"o",
":=... | // Returns new path by joining path segments with URL path separator. | [
"Returns",
"new",
"path",
"by",
"joining",
"path",
"segments",
"with",
"URL",
"path",
"separator",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1643-L1649 | train |
minio/mc | cmd/client-s3.go | objectInfo2ClientContent | func (c *s3Client) objectInfo2ClientContent(bucket string, entry minio.ObjectInfo) clientContent {
content := clientContent{}
url := *c.targetURL
// Join bucket and incoming object key.
url.Path = c.joinPath(bucket, entry.Key)
content.URL = url
content.Size = entry.Size
content.ETag = entry.ETag
content.Time =... | go | func (c *s3Client) objectInfo2ClientContent(bucket string, entry minio.ObjectInfo) clientContent {
content := clientContent{}
url := *c.targetURL
// Join bucket and incoming object key.
url.Path = c.joinPath(bucket, entry.Key)
content.URL = url
content.Size = entry.Size
content.ETag = entry.ETag
content.Time =... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"objectInfo2ClientContent",
"(",
"bucket",
"string",
",",
"entry",
"minio",
".",
"ObjectInfo",
")",
"clientContent",
"{",
"content",
":=",
"clientContent",
"{",
"}",
"\n",
"url",
":=",
"*",
"c",
".",
"targetURL",
"\n... | // Convert objectInfo to clientContent | [
"Convert",
"objectInfo",
"to",
"clientContent"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1652-L1670 | train |
minio/mc | cmd/client-s3.go | bucketStat | func (c *s3Client) bucketStat(bucket string) (*clientContent, *probe.Error) {
exists, e := c.api.BucketExists(bucket)
if e != nil {
return nil, probe.NewError(e)
}
if !exists {
return nil, probe.NewError(BucketDoesNotExist{Bucket: bucket})
}
return &clientContent{URL: *c.targetURL, Time: time.Unix(0, 0), Type... | go | func (c *s3Client) bucketStat(bucket string) (*clientContent, *probe.Error) {
exists, e := c.api.BucketExists(bucket)
if e != nil {
return nil, probe.NewError(e)
}
if !exists {
return nil, probe.NewError(BucketDoesNotExist{Bucket: bucket})
}
return &clientContent{URL: *c.targetURL, Time: time.Unix(0, 0), Type... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"bucketStat",
"(",
"bucket",
"string",
")",
"(",
"*",
"clientContent",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"exists",
",",
"e",
":=",
"c",
".",
"api",
".",
"BucketExists",
"(",
"bucket",
")",
"\n",
"if"... | // Returns bucket stat info of current bucket. | [
"Returns",
"bucket",
"stat",
"info",
"of",
"current",
"bucket",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1673-L1682 | train |
minio/mc | cmd/client-s3.go | ShareDownload | func (c *s3Client) ShareDownload(expires time.Duration) (string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
// No additional request parameters are set for the time being.
reqParams := make(url.Values)
presignedURL, e := c.api.PresignedGetObject(bucket, object, expires, reqParams)
if e != nil {
re... | go | func (c *s3Client) ShareDownload(expires time.Duration) (string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
// No additional request parameters are set for the time being.
reqParams := make(url.Values)
presignedURL, e := c.api.PresignedGetObject(bucket, object, expires, reqParams)
if e != nil {
re... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"ShareDownload",
"(",
"expires",
"time",
".",
"Duration",
")",
"(",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"bucket",
",",
"object",
":=",
"c",
".",
"url2BucketAndObject",
"(",
")",
"\n",
"// No addi... | // ShareDownload - get a usable presigned object url to share. | [
"ShareDownload",
"-",
"get",
"a",
"usable",
"presigned",
"object",
"url",
"to",
"share",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1926-L1935 | train |
minio/mc | cmd/client-s3.go | ShareUpload | func (c *s3Client) ShareUpload(isRecursive bool, expires time.Duration, contentType string) (string, map[string]string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
p := minio.NewPostPolicy()
if e := p.SetExpires(UTCNow().Add(expires)); e != nil {
return "", nil, probe.NewError(e)
}
if strings.TrimS... | go | func (c *s3Client) ShareUpload(isRecursive bool, expires time.Duration, contentType string) (string, map[string]string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
p := minio.NewPostPolicy()
if e := p.SetExpires(UTCNow().Add(expires)); e != nil {
return "", nil, probe.NewError(e)
}
if strings.TrimS... | [
"func",
"(",
"c",
"*",
"s3Client",
")",
"ShareUpload",
"(",
"isRecursive",
"bool",
",",
"expires",
"time",
".",
"Duration",
",",
"contentType",
"string",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"string",
",",
"*",
"probe",
".",
"Error",
")"... | // ShareUpload - get data for presigned post http form upload. | [
"ShareUpload",
"-",
"get",
"data",
"for",
"presigned",
"post",
"http",
"form",
"upload",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/client-s3.go#L1938-L1965 | train |
minio/mc | cmd/admin-top-locks.go | String | func (u lockMessage) String() string {
timeFieldMaxLen := 20
resourceFieldMaxLen := -1
typeFieldMaxLen := 6
ownerFieldMaxLen := 20
lockState, timeDiff := getTimeDiff(u.Lock.Timestamp)
return console.Colorize(lockState, newPrettyTable(" ",
Field{"Time", timeFieldMaxLen},
Field{"Type", typeFieldMaxLen},
Fie... | go | func (u lockMessage) String() string {
timeFieldMaxLen := 20
resourceFieldMaxLen := -1
typeFieldMaxLen := 6
ownerFieldMaxLen := 20
lockState, timeDiff := getTimeDiff(u.Lock.Timestamp)
return console.Colorize(lockState, newPrettyTable(" ",
Field{"Time", timeFieldMaxLen},
Field{"Type", typeFieldMaxLen},
Fie... | [
"func",
"(",
"u",
"lockMessage",
")",
"String",
"(",
")",
"string",
"{",
"timeFieldMaxLen",
":=",
"20",
"\n",
"resourceFieldMaxLen",
":=",
"-",
"1",
"\n",
"typeFieldMaxLen",
":=",
"6",
"\n",
"ownerFieldMaxLen",
":=",
"20",
"\n\n",
"lockState",
",",
"timeDiff... | // String colorized oldest locks message. | [
"String",
"colorized",
"oldest",
"locks",
"message",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-top-locks.go#L75-L88 | train |
minio/mc | cmd/admin-top-locks.go | checkAdminTopLocksSyntax | func checkAdminTopLocksSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
cli.ShowCommandHelpAndExit(ctx, "locks", 1) // last argument is exit code
}
} | go | func checkAdminTopLocksSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
cli.ShowCommandHelpAndExit(ctx, "locks", 1) // last argument is exit code
}
} | [
"func",
"checkAdminTopLocksSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"==",
"0",
"||",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
">",
"1",
"{",
"cli",
".",
"ShowCommandHelp... | // checkAdminTopLocksSyntax - validate all the passed arguments | [
"checkAdminTopLocksSyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-top-locks.go#L99-L103 | train |
minio/mc | cmd/admin-top-locks.go | printLocks | func printLocks(locks madmin.LockEntries) {
if !globalJSON {
printHeaders()
}
for _, entry := range locks {
printMsg(lockMessage{Lock: entry})
}
} | go | func printLocks(locks madmin.LockEntries) {
if !globalJSON {
printHeaders()
}
for _, entry := range locks {
printMsg(lockMessage{Lock: entry})
}
} | [
"func",
"printLocks",
"(",
"locks",
"madmin",
".",
"LockEntries",
")",
"{",
"if",
"!",
"globalJSON",
"{",
"printHeaders",
"(",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"entry",
":=",
"range",
"locks",
"{",
"printMsg",
"(",
"lockMessage",
"{",
"Lock",
":"... | // Prints oldest locks. | [
"Prints",
"oldest",
"locks",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-top-locks.go#L144-L151 | train |
minio/mc | cmd/watch.go | NewWatcher | func NewWatcher(sessionStartTime time.Time) *Watcher {
return &Watcher{
sessionStartTime: sessionStartTime,
errorChan: make(chan *probe.Error),
eventInfoChan: make(chan EventInfo),
o: []*watchObject{},
}
} | go | func NewWatcher(sessionStartTime time.Time) *Watcher {
return &Watcher{
sessionStartTime: sessionStartTime,
errorChan: make(chan *probe.Error),
eventInfoChan: make(chan EventInfo),
o: []*watchObject{},
}
} | [
"func",
"NewWatcher",
"(",
"sessionStartTime",
"time",
".",
"Time",
")",
"*",
"Watcher",
"{",
"return",
"&",
"Watcher",
"{",
"sessionStartTime",
":",
"sessionStartTime",
",",
"errorChan",
":",
"make",
"(",
"chan",
"*",
"probe",
".",
"Error",
")",
",",
"eve... | // NewWatcher creates a new watcher | [
"NewWatcher",
"creates",
"a",
"new",
"watcher"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/watch.go#L102-L109 | train |
minio/mc | cmd/watch.go | Join | func (w *Watcher) Join(client Client, recursive bool) *probe.Error {
wo, err := client.Watch(watchParams{
recursive: recursive,
events: []string{"put", "delete"},
})
if err != nil {
return err
}
w.o = append(w.o, wo)
// join monitoring waitgroup
w.wg.Add(1)
// wait for events and errors of individua... | go | func (w *Watcher) Join(client Client, recursive bool) *probe.Error {
wo, err := client.Watch(watchParams{
recursive: recursive,
events: []string{"put", "delete"},
})
if err != nil {
return err
}
w.o = append(w.o, wo)
// join monitoring waitgroup
w.wg.Add(1)
// wait for events and errors of individua... | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"Join",
"(",
"client",
"Client",
",",
"recursive",
"bool",
")",
"*",
"probe",
".",
"Error",
"{",
"wo",
",",
"err",
":=",
"client",
".",
"Watch",
"(",
"watchParams",
"{",
"recursive",
":",
"recursive",
",",
"even... | // Join the watcher with client | [
"Join",
"the",
"watcher",
"with",
"client"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/watch.go#L145-L183 | train |
boombuler/barcode | code39/encoder.go | Encode | func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.BarcodeIntCS, error) {
if fullASCIIMode {
var err error
content, err = prepare(content)
if err != nil {
return nil, err
}
} else if strings.ContainsRune(content, '*') {
return nil, errors.New("invalid data! try full ascii mode... | go | func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.BarcodeIntCS, error) {
if fullASCIIMode {
var err error
content, err = prepare(content)
if err != nil {
return nil, err
}
} else if strings.ContainsRune(content, '*') {
return nil, errors.New("invalid data! try full ascii mode... | [
"func",
"Encode",
"(",
"content",
"string",
",",
"includeChecksum",
"bool",
",",
"fullASCIIMode",
"bool",
")",
"(",
"barcode",
".",
"BarcodeIntCS",
",",
"error",
")",
"{",
"if",
"fullASCIIMode",
"{",
"var",
"err",
"error",
"\n",
"content",
",",
"err",
"=",... | // Encode returns a code39 barcode for the given content
// if includeChecksum is set to true, a checksum character is calculated and added to the content | [
"Encode",
"returns",
"a",
"code39",
"barcode",
"for",
"the",
"given",
"content",
"if",
"includeChecksum",
"is",
"set",
"to",
"true",
"a",
"checksum",
"character",
"is",
"calculated",
"and",
"added",
"to",
"the",
"content"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/code39/encoder.go#L116-L152 | train |
boombuler/barcode | utils/galoisfield.go | NewGaloisField | func NewGaloisField(pp, fieldSize, b int) *GaloisField {
result := new(GaloisField)
result.Size = fieldSize
result.Base = b
result.ALogTbl = make([]int, fieldSize)
result.LogTbl = make([]int, fieldSize)
x := 1
for i := 0; i < fieldSize; i++ {
result.ALogTbl[i] = x
x = x * 2
if x >= fieldSize {
x = (x ... | go | func NewGaloisField(pp, fieldSize, b int) *GaloisField {
result := new(GaloisField)
result.Size = fieldSize
result.Base = b
result.ALogTbl = make([]int, fieldSize)
result.LogTbl = make([]int, fieldSize)
x := 1
for i := 0; i < fieldSize; i++ {
result.ALogTbl[i] = x
x = x * 2
if x >= fieldSize {
x = (x ... | [
"func",
"NewGaloisField",
"(",
"pp",
",",
"fieldSize",
",",
"b",
"int",
")",
"*",
"GaloisField",
"{",
"result",
":=",
"new",
"(",
"GaloisField",
")",
"\n\n",
"result",
".",
"Size",
"=",
"fieldSize",
"\n",
"result",
".",
"Base",
"=",
"b",
"\n",
"result"... | // NewGaloisField creates a new galois field | [
"NewGaloisField",
"creates",
"a",
"new",
"galois",
"field"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/galoisfield.go#L12-L34 | train |
boombuler/barcode | utils/galoisfield.go | Multiply | func (gf *GaloisField) Multiply(a, b int) int {
if a == 0 || b == 0 {
return 0
}
return gf.ALogTbl[(gf.LogTbl[a]+gf.LogTbl[b])%(gf.Size-1)]
} | go | func (gf *GaloisField) Multiply(a, b int) int {
if a == 0 || b == 0 {
return 0
}
return gf.ALogTbl[(gf.LogTbl[a]+gf.LogTbl[b])%(gf.Size-1)]
} | [
"func",
"(",
"gf",
"*",
"GaloisField",
")",
"Multiply",
"(",
"a",
",",
"b",
"int",
")",
"int",
"{",
"if",
"a",
"==",
"0",
"||",
"b",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"gf",
".",
"ALogTbl",
"[",
"(",
"gf",
".",
"LogTbl"... | // Multiply multiplys two numbers | [
"Multiply",
"multiplys",
"two",
"numbers"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/galoisfield.go#L46-L51 | train |
boombuler/barcode | utils/galoisfield.go | Divide | func (gf *GaloisField) Divide(a, b int) int {
if b == 0 {
panic("divide by zero")
} else if a == 0 {
return 0
}
return gf.ALogTbl[(gf.LogTbl[a]-gf.LogTbl[b])%(gf.Size-1)]
} | go | func (gf *GaloisField) Divide(a, b int) int {
if b == 0 {
panic("divide by zero")
} else if a == 0 {
return 0
}
return gf.ALogTbl[(gf.LogTbl[a]-gf.LogTbl[b])%(gf.Size-1)]
} | [
"func",
"(",
"gf",
"*",
"GaloisField",
")",
"Divide",
"(",
"a",
",",
"b",
"int",
")",
"int",
"{",
"if",
"b",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"a",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"retur... | // Divide divides two numbers | [
"Divide",
"divides",
"two",
"numbers"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/galoisfield.go#L54-L61 | train |
boombuler/barcode | utils/gfpoly.go | GetCoefficient | func (gp *GFPoly) GetCoefficient(degree int) int {
return gp.Coefficients[gp.Degree()-degree]
} | go | func (gp *GFPoly) GetCoefficient(degree int) int {
return gp.Coefficients[gp.Degree()-degree]
} | [
"func",
"(",
"gp",
"*",
"GFPoly",
")",
"GetCoefficient",
"(",
"degree",
"int",
")",
"int",
"{",
"return",
"gp",
".",
"Coefficients",
"[",
"gp",
".",
"Degree",
"(",
")",
"-",
"degree",
"]",
"\n",
"}"
] | // GetCoefficient returns the coefficient of x ^ degree | [
"GetCoefficient",
"returns",
"the",
"coefficient",
"of",
"x",
"^",
"degree"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/gfpoly.go#L17-L19 | train |
boombuler/barcode | utils/base1dcode.go | New1DCodeIntCheckSum | func New1DCodeIntCheckSum(codeKind, content string, bars *BitList, checksum int) barcode.BarcodeIntCS {
return &base1DCodeIntCS{base1DCode{bars, codeKind, content}, checksum}
} | go | func New1DCodeIntCheckSum(codeKind, content string, bars *BitList, checksum int) barcode.BarcodeIntCS {
return &base1DCodeIntCS{base1DCode{bars, codeKind, content}, checksum}
} | [
"func",
"New1DCodeIntCheckSum",
"(",
"codeKind",
",",
"content",
"string",
",",
"bars",
"*",
"BitList",
",",
"checksum",
"int",
")",
"barcode",
".",
"BarcodeIntCS",
"{",
"return",
"&",
"base1DCodeIntCS",
"{",
"base1DCode",
"{",
"bars",
",",
"codeKind",
",",
... | // New1DCodeIntCheckSum creates a new 1D barcode where the bars are represented by the bits in the bars BitList | [
"New1DCodeIntCheckSum",
"creates",
"a",
"new",
"1D",
"barcode",
"where",
"the",
"bars",
"are",
"represented",
"by",
"the",
"bits",
"in",
"the",
"bars",
"BitList"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/base1dcode.go#L50-L52 | train |
boombuler/barcode | utils/base1dcode.go | New1DCode | func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode {
return &base1DCode{bars, codeKind, content}
} | go | func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode {
return &base1DCode{bars, codeKind, content}
} | [
"func",
"New1DCode",
"(",
"codeKind",
",",
"content",
"string",
",",
"bars",
"*",
"BitList",
")",
"barcode",
".",
"Barcode",
"{",
"return",
"&",
"base1DCode",
"{",
"bars",
",",
"codeKind",
",",
"content",
"}",
"\n",
"}"
] | // New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList | [
"New1DCode",
"creates",
"a",
"new",
"1D",
"barcode",
"where",
"the",
"bars",
"are",
"represented",
"by",
"the",
"bits",
"in",
"the",
"bars",
"BitList"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/base1dcode.go#L55-L57 | train |
boombuler/barcode | code128/encode.go | Encode | func Encode(content string) (barcode.BarcodeIntCS, error) {
contentRunes := strToRunes(content)
if len(contentRunes) <= 0 || len(contentRunes) > 80 {
return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes))
}
idxList := getCodeIndexList(contentRunes)
if idxList == ... | go | func Encode(content string) (barcode.BarcodeIntCS, error) {
contentRunes := strToRunes(content)
if len(contentRunes) <= 0 || len(contentRunes) > 80 {
return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes))
}
idxList := getCodeIndexList(contentRunes)
if idxList == ... | [
"func",
"Encode",
"(",
"content",
"string",
")",
"(",
"barcode",
".",
"BarcodeIntCS",
",",
"error",
")",
"{",
"contentRunes",
":=",
"strToRunes",
"(",
"content",
")",
"\n",
"if",
"len",
"(",
"contentRunes",
")",
"<=",
"0",
"||",
"len",
"(",
"contentRunes... | // Encode creates a Code 128 barcode for the given content | [
"Encode",
"creates",
"a",
"Code",
"128",
"barcode",
"for",
"the",
"given",
"content"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/code128/encode.go#L159-L184 | train |
boombuler/barcode | utils/bitlist.go | NewBitList | func NewBitList(capacity int) *BitList {
bl := new(BitList)
bl.count = capacity
x := 0
if capacity%32 != 0 {
x = 1
}
bl.data = make([]int32, capacity/32+x)
return bl
} | go | func NewBitList(capacity int) *BitList {
bl := new(BitList)
bl.count = capacity
x := 0
if capacity%32 != 0 {
x = 1
}
bl.data = make([]int32, capacity/32+x)
return bl
} | [
"func",
"NewBitList",
"(",
"capacity",
"int",
")",
"*",
"BitList",
"{",
"bl",
":=",
"new",
"(",
"BitList",
")",
"\n",
"bl",
".",
"count",
"=",
"capacity",
"\n",
"x",
":=",
"0",
"\n",
"if",
"capacity",
"%",
"32",
"!=",
"0",
"{",
"x",
"=",
"1",
"... | // NewBitList returns a new BitList with the given length
// all bits are initialize with false | [
"NewBitList",
"returns",
"a",
"new",
"BitList",
"with",
"the",
"given",
"length",
"all",
"bits",
"are",
"initialize",
"with",
"false"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/bitlist.go#L11-L20 | train |
boombuler/barcode | utils/bitlist.go | AddBit | func (bl *BitList) AddBit(bits ...bool) {
for _, bit := range bits {
itmIndex := bl.count / 32
for itmIndex >= len(bl.data) {
bl.grow()
}
bl.SetBit(bl.count, bit)
bl.count++
}
} | go | func (bl *BitList) AddBit(bits ...bool) {
for _, bit := range bits {
itmIndex := bl.count / 32
for itmIndex >= len(bl.data) {
bl.grow()
}
bl.SetBit(bl.count, bit)
bl.count++
}
} | [
"func",
"(",
"bl",
"*",
"BitList",
")",
"AddBit",
"(",
"bits",
"...",
"bool",
")",
"{",
"for",
"_",
",",
"bit",
":=",
"range",
"bits",
"{",
"itmIndex",
":=",
"bl",
".",
"count",
"/",
"32",
"\n",
"for",
"itmIndex",
">=",
"len",
"(",
"bl",
".",
"... | // AddBit appends the given bits to the end of the list | [
"AddBit",
"appends",
"the",
"given",
"bits",
"to",
"the",
"end",
"of",
"the",
"list"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/bitlist.go#L41-L50 | train |
boombuler/barcode | utils/bitlist.go | SetBit | func (bl *BitList) SetBit(index int, value bool) {
itmIndex := index / 32
itmBitShift := 31 - (index % 32)
if value {
bl.data[itmIndex] = bl.data[itmIndex] | 1<<uint(itmBitShift)
} else {
bl.data[itmIndex] = bl.data[itmIndex] & ^(1 << uint(itmBitShift))
}
} | go | func (bl *BitList) SetBit(index int, value bool) {
itmIndex := index / 32
itmBitShift := 31 - (index % 32)
if value {
bl.data[itmIndex] = bl.data[itmIndex] | 1<<uint(itmBitShift)
} else {
bl.data[itmIndex] = bl.data[itmIndex] & ^(1 << uint(itmBitShift))
}
} | [
"func",
"(",
"bl",
"*",
"BitList",
")",
"SetBit",
"(",
"index",
"int",
",",
"value",
"bool",
")",
"{",
"itmIndex",
":=",
"index",
"/",
"32",
"\n",
"itmBitShift",
":=",
"31",
"-",
"(",
"index",
"%",
"32",
")",
"\n",
"if",
"value",
"{",
"bl",
".",
... | // SetBit sets the bit at the given index to the given value | [
"SetBit",
"sets",
"the",
"bit",
"at",
"the",
"given",
"index",
"to",
"the",
"given",
"value"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/bitlist.go#L53-L61 | train |
boombuler/barcode | utils/bitlist.go | GetBit | func (bl *BitList) GetBit(index int) bool {
itmIndex := index / 32
itmBitShift := 31 - (index % 32)
return ((bl.data[itmIndex] >> uint(itmBitShift)) & 1) == 1
} | go | func (bl *BitList) GetBit(index int) bool {
itmIndex := index / 32
itmBitShift := 31 - (index % 32)
return ((bl.data[itmIndex] >> uint(itmBitShift)) & 1) == 1
} | [
"func",
"(",
"bl",
"*",
"BitList",
")",
"GetBit",
"(",
"index",
"int",
")",
"bool",
"{",
"itmIndex",
":=",
"index",
"/",
"32",
"\n",
"itmBitShift",
":=",
"31",
"-",
"(",
"index",
"%",
"32",
")",
"\n",
"return",
"(",
"(",
"bl",
".",
"data",
"[",
... | // GetBit returns the bit at the given index | [
"GetBit",
"returns",
"the",
"bit",
"at",
"the",
"given",
"index"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/bitlist.go#L64-L68 | train |
boombuler/barcode | utils/bitlist.go | AddByte | func (bl *BitList) AddByte(b byte) {
for i := 7; i >= 0; i-- {
bl.AddBit(((b >> uint(i)) & 1) == 1)
}
} | go | func (bl *BitList) AddByte(b byte) {
for i := 7; i >= 0; i-- {
bl.AddBit(((b >> uint(i)) & 1) == 1)
}
} | [
"func",
"(",
"bl",
"*",
"BitList",
")",
"AddByte",
"(",
"b",
"byte",
")",
"{",
"for",
"i",
":=",
"7",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"bl",
".",
"AddBit",
"(",
"(",
"(",
"b",
">>",
"uint",
"(",
"i",
")",
")",
"&",
"1",
")",
"=... | // AddByte appends all 8 bits of the given byte to the end of the list | [
"AddByte",
"appends",
"all",
"8",
"bits",
"of",
"the",
"given",
"byte",
"to",
"the",
"end",
"of",
"the",
"list"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/bitlist.go#L71-L75 | train |
boombuler/barcode | utils/bitlist.go | IterateBytes | func (bl *BitList) IterateBytes() <-chan byte {
res := make(chan byte)
go func() {
c := bl.count
shift := 24
i := 0
for c > 0 {
res <- byte((bl.data[i] >> uint(shift)) & 0xFF)
shift -= 8
if shift < 0 {
shift = 24
i++
}
c -= 8
}
close(res)
}()
return res
} | go | func (bl *BitList) IterateBytes() <-chan byte {
res := make(chan byte)
go func() {
c := bl.count
shift := 24
i := 0
for c > 0 {
res <- byte((bl.data[i] >> uint(shift)) & 0xFF)
shift -= 8
if shift < 0 {
shift = 24
i++
}
c -= 8
}
close(res)
}()
return res
} | [
"func",
"(",
"bl",
"*",
"BitList",
")",
"IterateBytes",
"(",
")",
"<-",
"chan",
"byte",
"{",
"res",
":=",
"make",
"(",
"chan",
"byte",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"c",
":=",
"bl",
".",
"count",
"\n",
"shift",
":=",
"24",
"\n",
"i"... | // IterateBytes iterates through all bytes contained in the BitList | [
"IterateBytes",
"iterates",
"through",
"all",
"bytes",
"contained",
"in",
"the",
"BitList"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/utils/bitlist.go#L99-L119 | train |
boombuler/barcode | qr/encoder.go | Encode | func Encode(content string, level ErrorCorrectionLevel, mode Encoding) (barcode.Barcode, error) {
bits, vi, err := mode.getEncoder()(content, level)
if err != nil {
return nil, err
}
blocks := splitToBlocks(bits.IterateBytes(), vi)
data := blocks.interleave(vi)
result := render(data, vi)
result.content = cont... | go | func Encode(content string, level ErrorCorrectionLevel, mode Encoding) (barcode.Barcode, error) {
bits, vi, err := mode.getEncoder()(content, level)
if err != nil {
return nil, err
}
blocks := splitToBlocks(bits.IterateBytes(), vi)
data := blocks.interleave(vi)
result := render(data, vi)
result.content = cont... | [
"func",
"Encode",
"(",
"content",
"string",
",",
"level",
"ErrorCorrectionLevel",
",",
"mode",
"Encoding",
")",
"(",
"barcode",
".",
"Barcode",
",",
"error",
")",
"{",
"bits",
",",
"vi",
",",
"err",
":=",
"mode",
".",
"getEncoder",
"(",
")",
"(",
"cont... | // Encode returns a QR barcode with the given content, error correction level and uses the given encoding | [
"Encode",
"returns",
"a",
"QR",
"barcode",
"with",
"the",
"given",
"content",
"error",
"correction",
"level",
"and",
"uses",
"the",
"given",
"encoding"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/qr/encoder.go#L58-L69 | train |
boombuler/barcode | code93/encoder.go | Encode | func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.Barcode, error) {
if fullASCIIMode {
var err error
content, err = prepare(content)
if err != nil {
return nil, err
}
} else if strings.ContainsRune(content, '*') {
return nil, errors.New("invalid data! content may not contain ... | go | func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.Barcode, error) {
if fullASCIIMode {
var err error
content, err = prepare(content)
if err != nil {
return nil, err
}
} else if strings.ContainsRune(content, '*') {
return nil, errors.New("invalid data! content may not contain ... | [
"func",
"Encode",
"(",
"content",
"string",
",",
"includeChecksum",
"bool",
",",
"fullASCIIMode",
"bool",
")",
"(",
"barcode",
".",
"Barcode",
",",
"error",
")",
"{",
"if",
"fullASCIIMode",
"{",
"var",
"err",
"error",
"\n",
"content",
",",
"err",
"=",
"p... | // Encode returns a code93 barcode for the given content
// if includeChecksum is set to true, two checksum characters are calculated and added to the content | [
"Encode",
"returns",
"a",
"code93",
"barcode",
"for",
"the",
"given",
"content",
"if",
"includeChecksum",
"is",
"set",
"to",
"true",
"two",
"checksum",
"characters",
"are",
"calculated",
"and",
"added",
"to",
"the",
"content"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/code93/encoder.go#L79-L106 | train |
boombuler/barcode | aztec/highlevel.go | updateStateForChar | func updateStateForChar(s *state, data []byte, index int) stateSlice {
var result stateSlice = nil
ch := data[index]
charInCurrentTable := charMap[s.mode][ch] > 0
var stateNoBinary *state = nil
for mode := mode_upper; mode <= mode_punct; mode++ {
charInMode := charMap[mode][ch]
if charInMode > 0 {
if state... | go | func updateStateForChar(s *state, data []byte, index int) stateSlice {
var result stateSlice = nil
ch := data[index]
charInCurrentTable := charMap[s.mode][ch] > 0
var stateNoBinary *state = nil
for mode := mode_upper; mode <= mode_punct; mode++ {
charInMode := charMap[mode][ch]
if charInMode > 0 {
if state... | [
"func",
"updateStateForChar",
"(",
"s",
"*",
"state",
",",
"data",
"[",
"]",
"byte",
",",
"index",
"int",
")",
"stateSlice",
"{",
"var",
"result",
"stateSlice",
"=",
"nil",
"\n",
"ch",
":=",
"data",
"[",
"index",
"]",
"\n",
"charInCurrentTable",
":=",
... | // Return a set of states that represent the possible ways of updating this
// state for the next character. The resulting set of states are added to
// the "result" list. | [
"Return",
"a",
"set",
"of",
"states",
"that",
"represent",
"the",
"possible",
"ways",
"of",
"updating",
"this",
"state",
"for",
"the",
"next",
"character",
".",
"The",
"resulting",
"set",
"of",
"states",
"are",
"added",
"to",
"the",
"result",
"list",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/aztec/highlevel.go#L94-L133 | train |
boombuler/barcode | ean/encoder.go | Encode | func Encode(code string) (barcode.BarcodeIntCS, error) {
var checkSum int
if len(code) == 7 || len(code) == 12 {
code += string(calcCheckNum(code))
checkSum = utils.RuneToInt(calcCheckNum(code))
} else if len(code) == 8 || len(code) == 13 {
check := code[0 : len(code)-1]
check += string(calcCheckNum(check))
... | go | func Encode(code string) (barcode.BarcodeIntCS, error) {
var checkSum int
if len(code) == 7 || len(code) == 12 {
code += string(calcCheckNum(code))
checkSum = utils.RuneToInt(calcCheckNum(code))
} else if len(code) == 8 || len(code) == 13 {
check := code[0 : len(code)-1]
check += string(calcCheckNum(check))
... | [
"func",
"Encode",
"(",
"code",
"string",
")",
"(",
"barcode",
".",
"BarcodeIntCS",
",",
"error",
")",
"{",
"var",
"checkSum",
"int",
"\n",
"if",
"len",
"(",
"code",
")",
"==",
"7",
"||",
"len",
"(",
"code",
")",
"==",
"12",
"{",
"code",
"+=",
"st... | // Encode returns a EAN 8 or EAN 13 barcode for the given code | [
"Encode",
"returns",
"a",
"EAN",
"8",
"or",
"EAN",
"13",
"barcode",
"for",
"the",
"given",
"code"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/ean/encoder.go#L161-L187 | train |
boombuler/barcode | aztec/state.go | shiftAndAppend | func (s *state) shiftAndAppend(mode encodingMode, value int) *state {
tokens := s.tokens
// Shifts exist only to UPPER and PUNCT, both with tokens size 5.
tokens = newSimpleToken(tokens, shiftTable[s.mode][mode], s.mode.BitCount())
tokens = newSimpleToken(tokens, value, 5)
return &state{
mode: s.mod... | go | func (s *state) shiftAndAppend(mode encodingMode, value int) *state {
tokens := s.tokens
// Shifts exist only to UPPER and PUNCT, both with tokens size 5.
tokens = newSimpleToken(tokens, shiftTable[s.mode][mode], s.mode.BitCount())
tokens = newSimpleToken(tokens, value, 5)
return &state{
mode: s.mod... | [
"func",
"(",
"s",
"*",
"state",
")",
"shiftAndAppend",
"(",
"mode",
"encodingMode",
",",
"value",
"int",
")",
"*",
"state",
"{",
"tokens",
":=",
"s",
".",
"tokens",
"\n\n",
"// Shifts exist only to UPPER and PUNCT, both with tokens size 5.",
"tokens",
"=",
"newSim... | // Create a new state representing this state, with a temporary shift
// to a different mode to output a single value. | [
"Create",
"a",
"new",
"state",
"representing",
"this",
"state",
"with",
"a",
"temporary",
"shift",
"to",
"a",
"different",
"mode",
"to",
"output",
"a",
"single",
"value",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/aztec/state.go#L171-L184 | train |
boombuler/barcode | aztec/state.go | addBinaryShiftChar | func (s *state) addBinaryShiftChar(index int) *state {
tokens := s.tokens
mode := s.mode
bitCnt := s.bitCount
if s.mode == mode_punct || s.mode == mode_digit {
latch := latchTable[s.mode][mode_upper]
tokens = newSimpleToken(tokens, latch&0xFFFF, byte(latch>>16))
bitCnt += latch >> 16
mode = mode_upper
}
d... | go | func (s *state) addBinaryShiftChar(index int) *state {
tokens := s.tokens
mode := s.mode
bitCnt := s.bitCount
if s.mode == mode_punct || s.mode == mode_digit {
latch := latchTable[s.mode][mode_upper]
tokens = newSimpleToken(tokens, latch&0xFFFF, byte(latch>>16))
bitCnt += latch >> 16
mode = mode_upper
}
d... | [
"func",
"(",
"s",
"*",
"state",
")",
"addBinaryShiftChar",
"(",
"index",
"int",
")",
"*",
"state",
"{",
"tokens",
":=",
"s",
".",
"tokens",
"\n",
"mode",
":=",
"s",
".",
"mode",
"\n",
"bitCnt",
":=",
"s",
".",
"bitCount",
"\n",
"if",
"s",
".",
"m... | // Create a new state representing this state, but an additional character
// output in Binary Shift mode. | [
"Create",
"a",
"new",
"state",
"representing",
"this",
"state",
"but",
"an",
"additional",
"character",
"output",
"in",
"Binary",
"Shift",
"mode",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/aztec/state.go#L188-L216 | train |
boombuler/barcode | aztec/state.go | endBinaryShift | func (s *state) endBinaryShift(index int) *state {
if s.bShiftByteCount == 0 {
return s
}
tokens := newShiftToken(s.tokens, index-s.bShiftByteCount, s.bShiftByteCount)
return &state{
mode: s.mode,
tokens: tokens,
bShiftByteCount: 0,
bitCount: s.bitCount,
}
} | go | func (s *state) endBinaryShift(index int) *state {
if s.bShiftByteCount == 0 {
return s
}
tokens := newShiftToken(s.tokens, index-s.bShiftByteCount, s.bShiftByteCount)
return &state{
mode: s.mode,
tokens: tokens,
bShiftByteCount: 0,
bitCount: s.bitCount,
}
} | [
"func",
"(",
"s",
"*",
"state",
")",
"endBinaryShift",
"(",
"index",
"int",
")",
"*",
"state",
"{",
"if",
"s",
".",
"bShiftByteCount",
"==",
"0",
"{",
"return",
"s",
"\n",
"}",
"\n",
"tokens",
":=",
"newShiftToken",
"(",
"s",
".",
"tokens",
",",
"i... | // Create the state identical to this one, but we are no longer in
// Binary Shift mode. | [
"Create",
"the",
"state",
"identical",
"to",
"this",
"one",
"but",
"we",
"are",
"no",
"longer",
"in",
"Binary",
"Shift",
"mode",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/aztec/state.go#L220-L231 | train |
boombuler/barcode | datamatrix/encoder.go | Encode | func Encode(content string) (barcode.Barcode, error) {
data := encodeText(content)
var size *dmCodeSize
for _, s := range codeSizes {
if s.DataCodewords() >= len(data) {
size = s
break
}
}
if size == nil {
return nil, errors.New("to much data to encode")
}
data = addPadding(data, size.DataCodewords(... | go | func Encode(content string) (barcode.Barcode, error) {
data := encodeText(content)
var size *dmCodeSize
for _, s := range codeSizes {
if s.DataCodewords() >= len(data) {
size = s
break
}
}
if size == nil {
return nil, errors.New("to much data to encode")
}
data = addPadding(data, size.DataCodewords(... | [
"func",
"Encode",
"(",
"content",
"string",
")",
"(",
"barcode",
".",
"Barcode",
",",
"error",
")",
"{",
"data",
":=",
"encodeText",
"(",
"content",
")",
"\n\n",
"var",
"size",
"*",
"dmCodeSize",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"codeSizes",
... | // Encode returns a Datamatrix barcode for the given content | [
"Encode",
"returns",
"a",
"Datamatrix",
"barcode",
"for",
"the",
"given",
"content"
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/datamatrix/encoder.go#L11-L32 | train |
boombuler/barcode | pdf417/encoder.go | Encode | func Encode(data string, securityLevel byte) (barcode.Barcode, error) {
if securityLevel >= 9 {
return nil, fmt.Errorf("Invalid security level %d", securityLevel)
}
sl := securitylevel(securityLevel)
dataWords, err := highlevelEncode(data)
if err != nil {
return nil, err
}
columns, rows := calcDimensions(... | go | func Encode(data string, securityLevel byte) (barcode.Barcode, error) {
if securityLevel >= 9 {
return nil, fmt.Errorf("Invalid security level %d", securityLevel)
}
sl := securitylevel(securityLevel)
dataWords, err := highlevelEncode(data)
if err != nil {
return nil, err
}
columns, rows := calcDimensions(... | [
"func",
"Encode",
"(",
"data",
"string",
",",
"securityLevel",
"byte",
")",
"(",
"barcode",
".",
"Barcode",
",",
"error",
")",
"{",
"if",
"securityLevel",
">=",
"9",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"securityLevel"... | // Encodes the given data as PDF417 barcode.
// securityLevel should be between 0 and 8. The higher the number, the more
// additional error-correction codes are added. | [
"Encodes",
"the",
"given",
"data",
"as",
"PDF417",
"barcode",
".",
"securityLevel",
"should",
"be",
"between",
"0",
"and",
"8",
".",
"The",
"higher",
"the",
"number",
"the",
"more",
"additional",
"error",
"-",
"correction",
"codes",
"are",
"added",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/pdf417/encoder.go#L18-L71 | train |
boombuler/barcode | scaledbarcode.go | Scale | func Scale(bc Barcode, width, height int) (Barcode, error) {
switch bc.Metadata().Dimensions {
case 1:
return scale1DCode(bc, width, height)
case 2:
return scale2DCode(bc, width, height)
}
return nil, errors.New("unsupported barcode format")
} | go | func Scale(bc Barcode, width, height int) (Barcode, error) {
switch bc.Metadata().Dimensions {
case 1:
return scale1DCode(bc, width, height)
case 2:
return scale2DCode(bc, width, height)
}
return nil, errors.New("unsupported barcode format")
} | [
"func",
"Scale",
"(",
"bc",
"Barcode",
",",
"width",
",",
"height",
"int",
")",
"(",
"Barcode",
",",
"error",
")",
"{",
"switch",
"bc",
".",
"Metadata",
"(",
")",
".",
"Dimensions",
"{",
"case",
"1",
":",
"return",
"scale1DCode",
"(",
"bc",
",",
"w... | // Scale returns a resized barcode with the given width and height. | [
"Scale",
"returns",
"a",
"resized",
"barcode",
"with",
"the",
"given",
"width",
"and",
"height",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/scaledbarcode.go#L51-L60 | train |
boombuler/barcode | twooffive/encoder.go | AddCheckSum | func AddCheckSum(content string) (string, error) {
if content == "" {
return "", errors.New("content is empty")
}
even := len(content)%2 == 1
sum := 0
for _, r := range content {
if _, ok := encodingTable[r]; ok {
value := utils.RuneToInt(r)
if even {
sum += value * 3
} else {
sum += value
... | go | func AddCheckSum(content string) (string, error) {
if content == "" {
return "", errors.New("content is empty")
}
even := len(content)%2 == 1
sum := 0
for _, r := range content {
if _, ok := encodingTable[r]; ok {
value := utils.RuneToInt(r)
if even {
sum += value * 3
} else {
sum += value
... | [
"func",
"AddCheckSum",
"(",
"content",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"content",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"even",
":=",
"len",
"(... | // AddCheckSum calculates the correct check-digit and appends it to the given content. | [
"AddCheckSum",
"calculates",
"the",
"correct",
"check",
"-",
"digit",
"and",
"appends",
"it",
"to",
"the",
"given",
"content",
"."
] | 6c824513baccd76c674ce72112c29ef550187b08 | https://github.com/boombuler/barcode/blob/6c824513baccd76c674ce72112c29ef550187b08/twooffive/encoder.go#L57-L79 | train |
thoas/go-funk | zip.go | Zip | func Zip(slice1 interface{}, slice2 interface{}) []Tuple {
inValue1 := reflect.ValueOf(slice1)
inValue2 := reflect.ValueOf(slice2)
kind1 := inValue1.Type().Kind()
kind2 := inValue2.Type().Kind()
result := []Tuple{}
for _, kind := range []reflect.Kind{kind1, kind2} {
if kind != reflect.Slice && kind != reflect.... | go | func Zip(slice1 interface{}, slice2 interface{}) []Tuple {
inValue1 := reflect.ValueOf(slice1)
inValue2 := reflect.ValueOf(slice2)
kind1 := inValue1.Type().Kind()
kind2 := inValue2.Type().Kind()
result := []Tuple{}
for _, kind := range []reflect.Kind{kind1, kind2} {
if kind != reflect.Slice && kind != reflect.... | [
"func",
"Zip",
"(",
"slice1",
"interface",
"{",
"}",
",",
"slice2",
"interface",
"{",
"}",
")",
"[",
"]",
"Tuple",
"{",
"inValue1",
":=",
"reflect",
".",
"ValueOf",
"(",
"slice1",
")",
"\n",
"inValue2",
":=",
"reflect",
".",
"ValueOf",
"(",
"slice2",
... | // Zip returns a list of tuples, where the i-th tuple contains the i-th element
// from each of the input iterables. The returned list is truncated in length
// to the length of the shortest input iterable. | [
"Zip",
"returns",
"a",
"list",
"of",
"tuples",
"where",
"the",
"i",
"-",
"th",
"tuple",
"contains",
"the",
"i",
"-",
"th",
"element",
"from",
"each",
"of",
"the",
"input",
"iterables",
".",
"The",
"returned",
"list",
"is",
"truncated",
"in",
"length",
... | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/zip.go#L16-L46 | train |
thoas/go-funk | typesafe.go | FindFloat64 | func FindFloat64(s []float64, cb func(s float64) bool) (float64, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0.0, false
} | go | func FindFloat64(s []float64, cb func(s float64) bool) (float64, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0.0, false
} | [
"func",
"FindFloat64",
"(",
"s",
"[",
"]",
"float64",
",",
"cb",
"func",
"(",
"s",
"float64",
")",
"bool",
")",
"(",
"float64",
",",
"bool",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"cb",
"(",
"i",
")",
"\n\n",
... | // FindFloat64 iterates over a collection of float64, returning an array of
// all float64 elements predicate returns truthy for. | [
"FindFloat64",
"iterates",
"over",
"a",
"collection",
"of",
"float64",
"returning",
"an",
"array",
"of",
"all",
"float64",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L39-L49 | train |
thoas/go-funk | typesafe.go | FindFloat32 | func FindFloat32(s []float32, cb func(s float32) bool) (float32, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0.0, false
} | go | func FindFloat32(s []float32, cb func(s float32) bool) (float32, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0.0, false
} | [
"func",
"FindFloat32",
"(",
"s",
"[",
"]",
"float32",
",",
"cb",
"func",
"(",
"s",
"float32",
")",
"bool",
")",
"(",
"float32",
",",
"bool",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"cb",
"(",
"i",
")",
"\n\n",
... | // FindFloat32 iterates over a collection of float32, returning the first
// float32 element predicate returns truthy for. | [
"FindFloat32",
"iterates",
"over",
"a",
"collection",
"of",
"float32",
"returning",
"the",
"first",
"float32",
"element",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L53-L63 | train |
thoas/go-funk | typesafe.go | FindInt | func FindInt(s []int, cb func(s int) bool) (int, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0, false
} | go | func FindInt(s []int, cb func(s int) bool) (int, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0, false
} | [
"func",
"FindInt",
"(",
"s",
"[",
"]",
"int",
",",
"cb",
"func",
"(",
"s",
"int",
")",
"bool",
")",
"(",
"int",
",",
"bool",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"cb",
"(",
"i",
")",
"\n\n",
"if",
"result... | // FindInt iterates over a collection of int, returning the first
// int element predicate returns truthy for. | [
"FindInt",
"iterates",
"over",
"a",
"collection",
"of",
"int",
"returning",
"the",
"first",
"int",
"element",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L67-L77 | train |
thoas/go-funk | typesafe.go | FindInt32 | func FindInt32(s []int32, cb func(s int32) bool) (int32, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0, false
} | go | func FindInt32(s []int32, cb func(s int32) bool) (int32, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0, false
} | [
"func",
"FindInt32",
"(",
"s",
"[",
"]",
"int32",
",",
"cb",
"func",
"(",
"s",
"int32",
")",
"bool",
")",
"(",
"int32",
",",
"bool",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"cb",
"(",
"i",
")",
"\n\n",
"if",
... | // FindInt32 iterates over a collection of int32, returning the first
// int32 element predicate returns truthy for. | [
"FindInt32",
"iterates",
"over",
"a",
"collection",
"of",
"int32",
"returning",
"the",
"first",
"int32",
"element",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L81-L91 | train |
thoas/go-funk | typesafe.go | FindInt64 | func FindInt64(s []int64, cb func(s int64) bool) (int64, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0, false
} | go | func FindInt64(s []int64, cb func(s int64) bool) (int64, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return 0, false
} | [
"func",
"FindInt64",
"(",
"s",
"[",
"]",
"int64",
",",
"cb",
"func",
"(",
"s",
"int64",
")",
"bool",
")",
"(",
"int64",
",",
"bool",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"cb",
"(",
"i",
")",
"\n\n",
"if",
... | // FindInt64 iterates over a collection of int64, returning the first
// int64 element predicate returns truthy for. | [
"FindInt64",
"iterates",
"over",
"a",
"collection",
"of",
"int64",
"returning",
"the",
"first",
"int64",
"element",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L95-L105 | train |
thoas/go-funk | typesafe.go | FindString | func FindString(s []string, cb func(s string) bool) (string, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return "", false
} | go | func FindString(s []string, cb func(s string) bool) (string, bool) {
for _, i := range s {
result := cb(i)
if result {
return i, true
}
}
return "", false
} | [
"func",
"FindString",
"(",
"s",
"[",
"]",
"string",
",",
"cb",
"func",
"(",
"s",
"string",
")",
"bool",
")",
"(",
"string",
",",
"bool",
")",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"cb",
"(",
"i",
")",
"\n\n",
"if... | // FindString iterates over a collection of string, returning the first
// string element predicate returns truthy for. | [
"FindString",
"iterates",
"over",
"a",
"collection",
"of",
"string",
"returning",
"the",
"first",
"string",
"element",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L109-L119 | train |
thoas/go-funk | typesafe.go | FilterFloat64 | func FilterFloat64(s []float64, cb func(s float64) bool) []float64 {
results := []float64{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | go | func FilterFloat64(s []float64, cb func(s float64) bool) []float64 {
results := []float64{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | [
"func",
"FilterFloat64",
"(",
"s",
"[",
"]",
"float64",
",",
"cb",
"func",
"(",
"s",
"float64",
")",
"bool",
")",
"[",
"]",
"float64",
"{",
"results",
":=",
"[",
"]",
"float64",
"{",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"... | // FilterFloat64 iterates over a collection of float64, returning an array of
// all float64 elements predicate returns truthy for. | [
"FilterFloat64",
"iterates",
"over",
"a",
"collection",
"of",
"float64",
"returning",
"an",
"array",
"of",
"all",
"float64",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L123-L135 | train |
thoas/go-funk | typesafe.go | FilterFloat32 | func FilterFloat32(s []float32, cb func(s float32) bool) []float32 {
results := []float32{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | go | func FilterFloat32(s []float32, cb func(s float32) bool) []float32 {
results := []float32{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | [
"func",
"FilterFloat32",
"(",
"s",
"[",
"]",
"float32",
",",
"cb",
"func",
"(",
"s",
"float32",
")",
"bool",
")",
"[",
"]",
"float32",
"{",
"results",
":=",
"[",
"]",
"float32",
"{",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"... | // FilterFloat32 iterates over a collection of float32, returning an array of
// all float32 elements predicate returns truthy for. | [
"FilterFloat32",
"iterates",
"over",
"a",
"collection",
"of",
"float32",
"returning",
"an",
"array",
"of",
"all",
"float32",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L139-L151 | train |
thoas/go-funk | typesafe.go | FilterInt | func FilterInt(s []int, cb func(s int) bool) []int {
results := []int{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | go | func FilterInt(s []int, cb func(s int) bool) []int {
results := []int{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | [
"func",
"FilterInt",
"(",
"s",
"[",
"]",
"int",
",",
"cb",
"func",
"(",
"s",
"int",
")",
"bool",
")",
"[",
"]",
"int",
"{",
"results",
":=",
"[",
"]",
"int",
"{",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
":=",
"... | // FilterInt iterates over a collection of int, returning an array of
// all int elements predicate returns truthy for. | [
"FilterInt",
"iterates",
"over",
"a",
"collection",
"of",
"int",
"returning",
"an",
"array",
"of",
"all",
"int",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L155-L167 | train |
thoas/go-funk | typesafe.go | FilterInt32 | func FilterInt32(s []int32, cb func(s int32) bool) []int32 {
results := []int32{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | go | func FilterInt32(s []int32, cb func(s int32) bool) []int32 {
results := []int32{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | [
"func",
"FilterInt32",
"(",
"s",
"[",
"]",
"int32",
",",
"cb",
"func",
"(",
"s",
"int32",
")",
"bool",
")",
"[",
"]",
"int32",
"{",
"results",
":=",
"[",
"]",
"int32",
"{",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
... | // FilterInt32 iterates over a collection of int32, returning an array of
// all int32 elements predicate returns truthy for. | [
"FilterInt32",
"iterates",
"over",
"a",
"collection",
"of",
"int32",
"returning",
"an",
"array",
"of",
"all",
"int32",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L171-L183 | train |
thoas/go-funk | typesafe.go | FilterInt64 | func FilterInt64(s []int64, cb func(s int64) bool) []int64 {
results := []int64{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | go | func FilterInt64(s []int64, cb func(s int64) bool) []int64 {
results := []int64{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | [
"func",
"FilterInt64",
"(",
"s",
"[",
"]",
"int64",
",",
"cb",
"func",
"(",
"s",
"int64",
")",
"bool",
")",
"[",
"]",
"int64",
"{",
"results",
":=",
"[",
"]",
"int64",
"{",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"result",
... | // FilterInt64 iterates over a collection of int64, returning an array of
// all int64 elements predicate returns truthy for. | [
"FilterInt64",
"iterates",
"over",
"a",
"collection",
"of",
"int64",
"returning",
"an",
"array",
"of",
"all",
"int64",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L187-L199 | train |
thoas/go-funk | typesafe.go | FilterString | func FilterString(s []string, cb func(s string) bool) []string {
results := []string{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | go | func FilterString(s []string, cb func(s string) bool) []string {
results := []string{}
for _, i := range s {
result := cb(i)
if result {
results = append(results, i)
}
}
return results
} | [
"func",
"FilterString",
"(",
"s",
"[",
"]",
"string",
",",
"cb",
"func",
"(",
"s",
"string",
")",
"bool",
")",
"[",
"]",
"string",
"{",
"results",
":=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"s",
"{",
"resul... | // FilterString iterates over a collection of string, returning an array of
// all string elements predicate returns truthy for. | [
"FilterString",
"iterates",
"over",
"a",
"collection",
"of",
"string",
"returning",
"an",
"array",
"of",
"all",
"string",
"elements",
"predicate",
"returns",
"truthy",
"for",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L203-L215 | train |
thoas/go-funk | typesafe.go | ContainsInt | func ContainsInt(s []int, v int) bool {
for _, vv := range s {
if vv == v {
return true
}
}
return false
} | go | func ContainsInt(s []int, v int) bool {
for _, vv := range s {
if vv == v {
return true
}
}
return false
} | [
"func",
"ContainsInt",
"(",
"s",
"[",
"]",
"int",
",",
"v",
"int",
")",
"bool",
"{",
"for",
"_",
",",
"vv",
":=",
"range",
"s",
"{",
"if",
"vv",
"==",
"v",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // ContainsInt returns true if an int is present in a iteratee. | [
"ContainsInt",
"returns",
"true",
"if",
"an",
"int",
"is",
"present",
"in",
"a",
"iteratee",
"."
] | a0a199e85d6d961670e46df4998f8868a3e3309b | https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L218-L225 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.