id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
125,900 | benbjohnson/phantomjs | phantomjs.go | IncludeJS | func (p *WebPage) IncludeJS(url string) error {
return p.ref.process.doJSON("POST", "/webpage/IncludeJS", map[string]interface{}{"ref": p.ref.id, "url": url}, nil)
} | go | func (p *WebPage) IncludeJS(url string) error {
return p.ref.process.doJSON("POST", "/webpage/IncludeJS", map[string]interface{}{"ref": p.ref.id, "url": url}, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"IncludeJS",
"(",
"url",
"string",
")",
"error",
"{",
"return",
"p",
".",
"ref",
".",
"process",
".",
"doJSON",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
... | // IncludeJS includes an external script from url.
// Returns after the script has been loaded. | [
"IncludeJS",
"includes",
"an",
"external",
"script",
"from",
"url",
".",
"Returns",
"after",
"the",
"script",
"has",
"been",
"loaded",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L842-L844 |
125,901 | benbjohnson/phantomjs | phantomjs.go | RenderBase64 | func (p *WebPage) RenderBase64(format string) (string, error) {
var resp struct {
ReturnValue string `json:"returnValue"`
}
if err := p.ref.process.doJSON("POST", "/webpage/RenderBase64", map[string]interface{}{"ref": p.ref.id, "format": format}, &resp); err != nil {
return "", err
}
return resp.ReturnValue, n... | go | func (p *WebPage) RenderBase64(format string) (string, error) {
var resp struct {
ReturnValue string `json:"returnValue"`
}
if err := p.ref.process.doJSON("POST", "/webpage/RenderBase64", map[string]interface{}{"ref": p.ref.id, "format": format}, &resp); err != nil {
return "", err
}
return resp.ReturnValue, n... | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"RenderBase64",
"(",
"format",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"resp",
"struct",
"{",
"ReturnValue",
"string",
"`json:\"returnValue\"`",
"\n",
"}",
"\n",
"if",
"err",
":=",
"p",
".",
"... | // RenderBase64 renders the web page to a base64 encoded string. | [
"RenderBase64",
"renders",
"the",
"web",
"page",
"to",
"a",
"base64",
"encoded",
"string",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L869-L877 |
125,902 | benbjohnson/phantomjs | phantomjs.go | Render | func (p *WebPage) Render(filename, format string, quality int) error {
req := map[string]interface{}{"ref": p.ref.id, "filename": filename, "format": format, "quality": quality}
return p.ref.process.doJSON("POST", "/webpage/Render", req, nil)
} | go | func (p *WebPage) Render(filename, format string, quality int) error {
req := map[string]interface{}{"ref": p.ref.id, "filename": filename, "format": format, "quality": quality}
return p.ref.process.doJSON("POST", "/webpage/Render", req, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"Render",
"(",
"filename",
",",
"format",
"string",
",",
"quality",
"int",
")",
"error",
"{",
"req",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"p",
".",
"ref",
".",
"id",
... | // Render renders the web page to a file with the given format and quality settings.
// This supports the "PDF", "PNG", "JPEG", "BMP", "PPM", and "GIF" formats. | [
"Render",
"renders",
"the",
"web",
"page",
"to",
"a",
"file",
"with",
"the",
"given",
"format",
"and",
"quality",
"settings",
".",
"This",
"supports",
"the",
"PDF",
"PNG",
"JPEG",
"BMP",
"PPM",
"and",
"GIF",
"formats",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L881-L884 |
125,903 | benbjohnson/phantomjs | phantomjs.go | SetContentAndURL | func (p *WebPage) SetContentAndURL(content, url string) error {
return p.ref.process.doJSON("POST", "/webpage/SetContentAndURL", map[string]interface{}{"ref": p.ref.id, "content": content, "url": url}, nil)
} | go | func (p *WebPage) SetContentAndURL(content, url string) error {
return p.ref.process.doJSON("POST", "/webpage/SetContentAndURL", map[string]interface{}{"ref": p.ref.id, "content": content, "url": url}, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"SetContentAndURL",
"(",
"content",
",",
"url",
"string",
")",
"error",
"{",
"return",
"p",
".",
"ref",
".",
"process",
".",
"doJSON",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interfa... | // SetContentAndURL sets the content and URL of the page. | [
"SetContentAndURL",
"sets",
"the",
"content",
"and",
"URL",
"of",
"the",
"page",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L910-L912 |
125,904 | benbjohnson/phantomjs | phantomjs.go | SwitchToFrameName | func (p *WebPage) SwitchToFrameName(name string) error {
return p.ref.process.doJSON("POST", "/webpage/SwitchToFrameName", map[string]interface{}{"ref": p.ref.id, "name": name}, nil)
} | go | func (p *WebPage) SwitchToFrameName(name string) error {
return p.ref.process.doJSON("POST", "/webpage/SwitchToFrameName", map[string]interface{}{"ref": p.ref.id, "name": name}, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"SwitchToFrameName",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"p",
".",
"ref",
".",
"process",
".",
"doJSON",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",... | // SwitchToFrameName changes the current frame to a frame with a given name. | [
"SwitchToFrameName",
"changes",
"the",
"current",
"frame",
"to",
"a",
"frame",
"with",
"a",
"given",
"name",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L925-L927 |
125,905 | benbjohnson/phantomjs | phantomjs.go | SwitchToFramePosition | func (p *WebPage) SwitchToFramePosition(pos int) error {
return p.ref.process.doJSON("POST", "/webpage/SwitchToFramePosition", map[string]interface{}{"ref": p.ref.id, "position": pos}, nil)
} | go | func (p *WebPage) SwitchToFramePosition(pos int) error {
return p.ref.process.doJSON("POST", "/webpage/SwitchToFramePosition", map[string]interface{}{"ref": p.ref.id, "position": pos}, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"SwitchToFramePosition",
"(",
"pos",
"int",
")",
"error",
"{",
"return",
"p",
".",
"ref",
".",
"process",
".",
"doJSON",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",... | // SwitchToFramePosition changes the current frame to the frame at the given position. | [
"SwitchToFramePosition",
"changes",
"the",
"current",
"frame",
"to",
"the",
"frame",
"at",
"the",
"given",
"position",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L930-L932 |
125,906 | benbjohnson/phantomjs | phantomjs.go | SwitchToParentFrame | func (p *WebPage) SwitchToParentFrame() error {
return p.ref.process.doJSON("POST", "/webpage/SwitchToParentFrame", map[string]interface{}{"ref": p.ref.id}, nil)
} | go | func (p *WebPage) SwitchToParentFrame() error {
return p.ref.process.doJSON("POST", "/webpage/SwitchToParentFrame", map[string]interface{}{"ref": p.ref.id}, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"SwitchToParentFrame",
"(",
")",
"error",
"{",
"return",
"p",
".",
"ref",
".",
"process",
".",
"doJSON",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\... | // SwitchToParentFrame switches the current frame to the parent of the current frame. | [
"SwitchToParentFrame",
"switches",
"the",
"current",
"frame",
"to",
"the",
"parent",
"of",
"the",
"current",
"frame",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L940-L942 |
125,907 | benbjohnson/phantomjs | phantomjs.go | UploadFile | func (p *WebPage) UploadFile(selector, filename string) error {
return p.ref.process.doJSON("POST", "/webpage/UploadFile", map[string]interface{}{"ref": p.ref.id, "selector": selector, "filename": filename}, nil)
} | go | func (p *WebPage) UploadFile(selector, filename string) error {
return p.ref.process.doJSON("POST", "/webpage/UploadFile", map[string]interface{}{"ref": p.ref.id, "selector": selector, "filename": filename}, nil)
} | [
"func",
"(",
"p",
"*",
"WebPage",
")",
"UploadFile",
"(",
"selector",
",",
"filename",
"string",
")",
"error",
"{",
"return",
"p",
".",
"ref",
".",
"process",
".",
"doJSON",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interfa... | // UploadFile uploads a file to a form element specified by selector. | [
"UploadFile",
"uploads",
"a",
"file",
"to",
"a",
"form",
"element",
"specified",
"by",
"selector",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L945-L947 |
125,908 | benbjohnson/phantomjs | phantomjs.go | newRef | func newRef(p *Process, id string) *Ref {
return &Ref{process: p, id: id}
} | go | func newRef(p *Process, id string) *Ref {
return &Ref{process: p, id: id}
} | [
"func",
"newRef",
"(",
"p",
"*",
"Process",
",",
"id",
"string",
")",
"*",
"Ref",
"{",
"return",
"&",
"Ref",
"{",
"process",
":",
"p",
",",
"id",
":",
"id",
"}",
"\n",
"}"
] | // newRef returns a new instance of a referenced object within the process. | [
"newRef",
"returns",
"a",
"new",
"instance",
"of",
"a",
"referenced",
"object",
"within",
"the",
"process",
"."
] | 6499a20f5cd6e4264994b4d95e49b6f21aafef79 | https://github.com/benbjohnson/phantomjs/blob/6499a20f5cd6e4264994b4d95e49b6f21aafef79/phantomjs.go#L961-L963 |
125,909 | go-openapi/swag | util.go | split | func split(str string) []string {
// check if consecutive single char things make up an initialism
once.Do(func() {
splitRex1 = regexp.MustCompile(`(\p{Lu})`)
splitRex2 = regexp.MustCompile(`(\pL|\pM|\pN|\p{Pc})+`)
splitReplacer = strings.NewReplacer(
"@", "At ",
"&", "And ",
"|", "Pipe ",
"$", "Dol... | go | func split(str string) []string {
// check if consecutive single char things make up an initialism
once.Do(func() {
splitRex1 = regexp.MustCompile(`(\p{Lu})`)
splitRex2 = regexp.MustCompile(`(\pL|\pM|\pN|\p{Pc})+`)
splitReplacer = strings.NewReplacer(
"@", "At ",
"&", "And ",
"|", "Pipe ",
"$", "Dol... | [
"func",
"split",
"(",
"str",
"string",
")",
"[",
"]",
"string",
"{",
"// check if consecutive single char things make up an initialism",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"splitRex1",
"=",
"regexp",
".",
"MustCompile",
"(",
"`(\\p{Lu})`",
")",
"\n",... | // Prepares strings by splitting by caps, spaces, dashes, and underscore | [
"Prepares",
"strings",
"by",
"splitting",
"by",
"caps",
"spaces",
"dashes",
"and",
"underscore"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L179-L210 |
125,910 | go-openapi/swag | util.go | Camelize | func Camelize(word string) (camelized string) {
for pos, ru := range []rune(word) {
if pos > 0 {
camelized += string(unicode.ToLower(ru))
} else {
camelized += string(unicode.ToUpper(ru))
}
}
return
} | go | func Camelize(word string) (camelized string) {
for pos, ru := range []rune(word) {
if pos > 0 {
camelized += string(unicode.ToLower(ru))
} else {
camelized += string(unicode.ToUpper(ru))
}
}
return
} | [
"func",
"Camelize",
"(",
"word",
"string",
")",
"(",
"camelized",
"string",
")",
"{",
"for",
"pos",
",",
"ru",
":=",
"range",
"[",
"]",
"rune",
"(",
"word",
")",
"{",
"if",
"pos",
">",
"0",
"{",
"camelized",
"+=",
"string",
"(",
"unicode",
".",
"... | // Camelize an uppercased word | [
"Camelize",
"an",
"uppercased",
"word"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L228-L237 |
125,911 | go-openapi/swag | util.go | ToFileName | func ToFileName(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
out = append(out, lower(w))
}
return strings.Join(out, "_")
} | go | func ToFileName(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
out = append(out, lower(w))
}
return strings.Join(out, "_")
} | [
"func",
"ToFileName",
"(",
"name",
"string",
")",
"string",
"{",
"in",
":=",
"split",
"(",
"name",
")",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"in",
")",
")",
"\n\n",
"for",
"_",
",",
"w",
":=",
"range",
... | // ToFileName lowercases and underscores a go type name | [
"ToFileName",
"lowercases",
"and",
"underscores",
"a",
"go",
"type",
"name"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L240-L249 |
125,912 | go-openapi/swag | util.go | ToHumanNameLower | func ToHumanNameLower(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
if !isInitialism(upper(w)) {
out = append(out, lower(w))
} else {
out = append(out, w)
}
}
return strings.Join(out, " ")
} | go | func ToHumanNameLower(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
if !isInitialism(upper(w)) {
out = append(out, lower(w))
} else {
out = append(out, w)
}
}
return strings.Join(out, " ")
} | [
"func",
"ToHumanNameLower",
"(",
"name",
"string",
")",
"string",
"{",
"in",
":=",
"split",
"(",
"name",
")",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"in",
")",
")",
"\n\n",
"for",
"_",
",",
"w",
":=",
"ra... | // ToHumanNameLower represents a code name as a human series of words | [
"ToHumanNameLower",
"represents",
"a",
"code",
"name",
"as",
"a",
"human",
"series",
"of",
"words"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L263-L275 |
125,913 | go-openapi/swag | util.go | ToHumanNameTitle | func ToHumanNameTitle(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
uw := upper(w)
if !isInitialism(uw) {
out = append(out, Camelize(w))
} else {
out = append(out, w)
}
}
return strings.Join(out, " ")
} | go | func ToHumanNameTitle(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
uw := upper(w)
if !isInitialism(uw) {
out = append(out, Camelize(w))
} else {
out = append(out, w)
}
}
return strings.Join(out, " ")
} | [
"func",
"ToHumanNameTitle",
"(",
"name",
"string",
")",
"string",
"{",
"in",
":=",
"split",
"(",
"name",
")",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"in",
")",
")",
"\n\n",
"for",
"_",
",",
"w",
":=",
"ra... | // ToHumanNameTitle represents a code name as a human series of words with the first letters titleized | [
"ToHumanNameTitle",
"represents",
"a",
"code",
"name",
"as",
"a",
"human",
"series",
"of",
"words",
"with",
"the",
"first",
"letters",
"titleized"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L278-L291 |
125,914 | go-openapi/swag | util.go | ToJSONName | func ToJSONName(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for i, w := range in {
if i == 0 {
out = append(out, lower(w))
continue
}
out = append(out, Camelize(w))
}
return strings.Join(out, "")
} | go | func ToJSONName(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for i, w := range in {
if i == 0 {
out = append(out, lower(w))
continue
}
out = append(out, Camelize(w))
}
return strings.Join(out, "")
} | [
"func",
"ToJSONName",
"(",
"name",
"string",
")",
"string",
"{",
"in",
":=",
"split",
"(",
"name",
")",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"in",
")",
")",
"\n\n",
"for",
"i",
",",
"w",
":=",
"range",
... | // ToJSONName camelcases a name which can be underscored or pascal cased | [
"ToJSONName",
"camelcases",
"a",
"name",
"which",
"can",
"be",
"underscored",
"or",
"pascal",
"cased"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L294-L306 |
125,915 | go-openapi/swag | util.go | ToVarName | func ToVarName(name string) string {
res := ToGoName(name)
if isInitialism(res) {
return lower(res)
}
if len(res) <= 1 {
return lower(res)
}
return lower(res[:1]) + res[1:]
} | go | func ToVarName(name string) string {
res := ToGoName(name)
if isInitialism(res) {
return lower(res)
}
if len(res) <= 1 {
return lower(res)
}
return lower(res[:1]) + res[1:]
} | [
"func",
"ToVarName",
"(",
"name",
"string",
")",
"string",
"{",
"res",
":=",
"ToGoName",
"(",
"name",
")",
"\n",
"if",
"isInitialism",
"(",
"res",
")",
"{",
"return",
"lower",
"(",
"res",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"res",
")",
"<=",
... | // ToVarName camelcases a name which can be underscored or pascal cased | [
"ToVarName",
"camelcases",
"a",
"name",
"which",
"can",
"be",
"underscored",
"or",
"pascal",
"cased"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L309-L318 |
125,916 | go-openapi/swag | util.go | ToGoName | func ToGoName(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
uw := upper(w)
mod := int(math.Min(float64(len(uw)), 2))
if !isInitialism(uw) && !isInitialism(uw[:len(uw)-mod]) {
uw = Camelize(w)
}
out = append(out, uw)
}
result := strings.Join(out, "")... | go | func ToGoName(name string) string {
in := split(name)
out := make([]string, 0, len(in))
for _, w := range in {
uw := upper(w)
mod := int(math.Min(float64(len(uw)), 2))
if !isInitialism(uw) && !isInitialism(uw[:len(uw)-mod]) {
uw = Camelize(w)
}
out = append(out, uw)
}
result := strings.Join(out, "")... | [
"func",
"ToGoName",
"(",
"name",
"string",
")",
"string",
"{",
"in",
":=",
"split",
"(",
"name",
")",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"in",
")",
")",
"\n\n",
"for",
"_",
",",
"w",
":=",
"range",
... | // ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes | [
"ToGoName",
"translates",
"a",
"swagger",
"name",
"which",
"can",
"be",
"underscored",
"or",
"camel",
"cased",
"to",
"a",
"name",
"that",
"golint",
"likes"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L321-L341 |
125,917 | go-openapi/swag | util.go | ContainsStrings | func ContainsStrings(coll []string, item string) bool {
for _, a := range coll {
if a == item {
return true
}
}
return false
} | go | func ContainsStrings(coll []string, item string) bool {
for _, a := range coll {
if a == item {
return true
}
}
return false
} | [
"func",
"ContainsStrings",
"(",
"coll",
"[",
"]",
"string",
",",
"item",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"a",
":=",
"range",
"coll",
"{",
"if",
"a",
"==",
"item",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
... | // ContainsStrings searches a slice of strings for a case-sensitive match | [
"ContainsStrings",
"searches",
"a",
"slice",
"of",
"strings",
"for",
"a",
"case",
"-",
"sensitive",
"match"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L344-L351 |
125,918 | go-openapi/swag | util.go | ContainsStringsCI | func ContainsStringsCI(coll []string, item string) bool {
for _, a := range coll {
if strings.EqualFold(a, item) {
return true
}
}
return false
} | go | func ContainsStringsCI(coll []string, item string) bool {
for _, a := range coll {
if strings.EqualFold(a, item) {
return true
}
}
return false
} | [
"func",
"ContainsStringsCI",
"(",
"coll",
"[",
"]",
"string",
",",
"item",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"a",
":=",
"range",
"coll",
"{",
"if",
"strings",
".",
"EqualFold",
"(",
"a",
",",
"item",
")",
"{",
"return",
"true",
"\n",
"}"... | // ContainsStringsCI searches a slice of strings for a case-insensitive match | [
"ContainsStringsCI",
"searches",
"a",
"slice",
"of",
"strings",
"for",
"a",
"case",
"-",
"insensitive",
"match"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L354-L361 |
125,919 | go-openapi/swag | util.go | IsZero | func IsZero(data interface{}) bool {
// check for things that have an IsZero method instead
if vv, ok := data.(zeroable); ok {
return vv.IsZero()
}
// continue with slightly more complex reflection
v := reflect.ValueOf(data)
switch v.Kind() {
case reflect.String:
return v.Len() == 0
case reflect.Bool:
ret... | go | func IsZero(data interface{}) bool {
// check for things that have an IsZero method instead
if vv, ok := data.(zeroable); ok {
return vv.IsZero()
}
// continue with slightly more complex reflection
v := reflect.ValueOf(data)
switch v.Kind() {
case reflect.String:
return v.Len() == 0
case reflect.Bool:
ret... | [
"func",
"IsZero",
"(",
"data",
"interface",
"{",
"}",
")",
"bool",
"{",
"// check for things that have an IsZero method instead",
"if",
"vv",
",",
"ok",
":=",
"data",
".",
"(",
"zeroable",
")",
";",
"ok",
"{",
"return",
"vv",
".",
"IsZero",
"(",
")",
"\n",... | // IsZero returns true when the value passed into the function is a zero value.
// This allows for safer checking of interface values. | [
"IsZero",
"returns",
"true",
"when",
"the",
"value",
"passed",
"into",
"the",
"function",
"is",
"a",
"zero",
"value",
".",
"This",
"allows",
"for",
"safer",
"checking",
"of",
"interface",
"values",
"."
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L369-L395 |
125,920 | go-openapi/swag | util.go | AddInitialisms | func AddInitialisms(words ...string) {
for _, word := range words {
//commonInitialisms[upper(word)] = true
commonInitialisms.add(upper(word))
}
// sort again
initialisms = commonInitialisms.sorted()
} | go | func AddInitialisms(words ...string) {
for _, word := range words {
//commonInitialisms[upper(word)] = true
commonInitialisms.add(upper(word))
}
// sort again
initialisms = commonInitialisms.sorted()
} | [
"func",
"AddInitialisms",
"(",
"words",
"...",
"string",
")",
"{",
"for",
"_",
",",
"word",
":=",
"range",
"words",
"{",
"//commonInitialisms[upper(word)] = true",
"commonInitialisms",
".",
"add",
"(",
"upper",
"(",
"word",
")",
")",
"\n",
"}",
"\n",
"// sor... | // AddInitialisms add additional initialisms | [
"AddInitialisms",
"add",
"additional",
"initialisms"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/util.go#L398-L405 |
125,921 | go-openapi/swag | net.go | SplitHostPort | func SplitHostPort(addr string) (host string, port int, err error) {
h, p, err := net.SplitHostPort(addr)
if err != nil {
return "", -1, err
}
if p == "" {
return "", -1, &net.AddrError{Err: "missing port in address", Addr: addr}
}
pi, err := strconv.Atoi(p)
if err != nil {
return "", -1, err
}
return h... | go | func SplitHostPort(addr string) (host string, port int, err error) {
h, p, err := net.SplitHostPort(addr)
if err != nil {
return "", -1, err
}
if p == "" {
return "", -1, &net.AddrError{Err: "missing port in address", Addr: addr}
}
pi, err := strconv.Atoi(p)
if err != nil {
return "", -1, err
}
return h... | [
"func",
"SplitHostPort",
"(",
"addr",
"string",
")",
"(",
"host",
"string",
",",
"port",
"int",
",",
"err",
"error",
")",
"{",
"h",
",",
"p",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // SplitHostPort splits a network address into a host and a port.
// The port is -1 when there is no port to be found | [
"SplitHostPort",
"splits",
"a",
"network",
"address",
"into",
"a",
"host",
"and",
"a",
"port",
".",
"The",
"port",
"is",
"-",
"1",
"when",
"there",
"is",
"no",
"port",
"to",
"be",
"found"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/net.go#L24-L38 |
125,922 | go-openapi/swag | path.go | FindInSearchPath | func FindInSearchPath(searchPath, pkg string) string {
pathsList := filepath.SplitList(searchPath)
for _, path := range pathsList {
if evaluatedPath, err := filepath.EvalSymlinks(filepath.Join(path, "src", pkg)); err == nil {
if _, err := os.Stat(evaluatedPath); err == nil {
return evaluatedPath
}
}
}
... | go | func FindInSearchPath(searchPath, pkg string) string {
pathsList := filepath.SplitList(searchPath)
for _, path := range pathsList {
if evaluatedPath, err := filepath.EvalSymlinks(filepath.Join(path, "src", pkg)); err == nil {
if _, err := os.Stat(evaluatedPath); err == nil {
return evaluatedPath
}
}
}
... | [
"func",
"FindInSearchPath",
"(",
"searchPath",
",",
"pkg",
"string",
")",
"string",
"{",
"pathsList",
":=",
"filepath",
".",
"SplitList",
"(",
"searchPath",
")",
"\n",
"for",
"_",
",",
"path",
":=",
"range",
"pathsList",
"{",
"if",
"evaluatedPath",
",",
"e... | // FindInSearchPath finds a package in a provided lists of paths | [
"FindInSearchPath",
"finds",
"a",
"package",
"in",
"a",
"provided",
"lists",
"of",
"paths"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/path.go#L30-L40 |
125,923 | go-openapi/swag | path.go | FullGoSearchPath | func FullGoSearchPath() string {
allPaths := os.Getenv(GOPATHKey)
if allPaths == "" {
allPaths = filepath.Join(os.Getenv("HOME"), "go")
}
if allPaths != "" {
allPaths = strings.Join([]string{allPaths, runtime.GOROOT()}, ":")
} else {
allPaths = runtime.GOROOT()
}
return allPaths
} | go | func FullGoSearchPath() string {
allPaths := os.Getenv(GOPATHKey)
if allPaths == "" {
allPaths = filepath.Join(os.Getenv("HOME"), "go")
}
if allPaths != "" {
allPaths = strings.Join([]string{allPaths, runtime.GOROOT()}, ":")
} else {
allPaths = runtime.GOROOT()
}
return allPaths
} | [
"func",
"FullGoSearchPath",
"(",
")",
"string",
"{",
"allPaths",
":=",
"os",
".",
"Getenv",
"(",
"GOPATHKey",
")",
"\n",
"if",
"allPaths",
"==",
"\"",
"\"",
"{",
"allPaths",
"=",
"filepath",
".",
"Join",
"(",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")"... | // FullGoSearchPath gets the search paths for finding packages | [
"FullGoSearchPath",
"gets",
"the",
"search",
"paths",
"for",
"finding",
"packages"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/path.go#L48-L59 |
125,924 | go-openapi/swag | convert.go | ConvertBool | func ConvertBool(str string) (bool, error) {
_, ok := evaluatesAsTrue[strings.ToLower(str)]
return ok, nil
} | go | func ConvertBool(str string) (bool, error) {
_, ok := evaluatesAsTrue[strings.ToLower(str)]
return ok, nil
} | [
"func",
"ConvertBool",
"(",
"str",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"_",
",",
"ok",
":=",
"evaluatesAsTrue",
"[",
"strings",
".",
"ToLower",
"(",
"str",
")",
"]",
"\n",
"return",
"ok",
",",
"nil",
"\n",
"}"
] | // ConvertBool turn a string into a boolean | [
"ConvertBool",
"turn",
"a",
"string",
"into",
"a",
"boolean"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L71-L74 |
125,925 | go-openapi/swag | convert.go | ConvertFloat32 | func ConvertFloat32(str string) (float32, error) {
f, err := strconv.ParseFloat(str, 32)
if err != nil {
return 0, err
}
return float32(f), nil
} | go | func ConvertFloat32(str string) (float32, error) {
f, err := strconv.ParseFloat(str, 32)
if err != nil {
return 0, err
}
return float32(f), nil
} | [
"func",
"ConvertFloat32",
"(",
"str",
"string",
")",
"(",
"float32",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"str",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}... | // ConvertFloat32 turn a string into a float32 | [
"ConvertFloat32",
"turn",
"a",
"string",
"into",
"a",
"float32"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L77-L83 |
125,926 | go-openapi/swag | convert.go | ConvertInt8 | func ConvertInt8(str string) (int8, error) {
i, err := strconv.ParseInt(str, 10, 8)
if err != nil {
return 0, err
}
return int8(i), nil
} | go | func ConvertInt8(str string) (int8, error) {
i, err := strconv.ParseInt(str, 10, 8)
if err != nil {
return 0, err
}
return int8(i), nil
} | [
"func",
"ConvertInt8",
"(",
"str",
"string",
")",
"(",
"int8",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"str",
",",
"10",
",",
"8",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n"... | // ConvertInt8 turn a string into int8 boolean | [
"ConvertInt8",
"turn",
"a",
"string",
"into",
"int8",
"boolean"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L91-L97 |
125,927 | go-openapi/swag | convert.go | ConvertInt16 | func ConvertInt16(str string) (int16, error) {
i, err := strconv.ParseInt(str, 10, 16)
if err != nil {
return 0, err
}
return int16(i), nil
} | go | func ConvertInt16(str string) (int16, error) {
i, err := strconv.ParseInt(str, 10, 16)
if err != nil {
return 0, err
}
return int16(i), nil
} | [
"func",
"ConvertInt16",
"(",
"str",
"string",
")",
"(",
"int16",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"str",
",",
"10",
",",
"16",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"... | // ConvertInt16 turn a string into a int16 | [
"ConvertInt16",
"turn",
"a",
"string",
"into",
"a",
"int16"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L100-L106 |
125,928 | go-openapi/swag | convert.go | ConvertInt32 | func ConvertInt32(str string) (int32, error) {
i, err := strconv.ParseInt(str, 10, 32)
if err != nil {
return 0, err
}
return int32(i), nil
} | go | func ConvertInt32(str string) (int32, error) {
i, err := strconv.ParseInt(str, 10, 32)
if err != nil {
return 0, err
}
return int32(i), nil
} | [
"func",
"ConvertInt32",
"(",
"str",
"string",
")",
"(",
"int32",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"str",
",",
"10",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"... | // ConvertInt32 turn a string into a int32 | [
"ConvertInt32",
"turn",
"a",
"string",
"into",
"a",
"int32"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L109-L115 |
125,929 | go-openapi/swag | convert.go | ConvertUint8 | func ConvertUint8(str string) (uint8, error) {
i, err := strconv.ParseUint(str, 10, 8)
if err != nil {
return 0, err
}
return uint8(i), nil
} | go | func ConvertUint8(str string) (uint8, error) {
i, err := strconv.ParseUint(str, 10, 8)
if err != nil {
return 0, err
}
return uint8(i), nil
} | [
"func",
"ConvertUint8",
"(",
"str",
"string",
")",
"(",
"uint8",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"str",
",",
"10",
",",
"8",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"... | // ConvertUint8 turn a string into a uint8 | [
"ConvertUint8",
"turn",
"a",
"string",
"into",
"a",
"uint8"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L123-L129 |
125,930 | go-openapi/swag | convert.go | ConvertUint16 | func ConvertUint16(str string) (uint16, error) {
i, err := strconv.ParseUint(str, 10, 16)
if err != nil {
return 0, err
}
return uint16(i), nil
} | go | func ConvertUint16(str string) (uint16, error) {
i, err := strconv.ParseUint(str, 10, 16)
if err != nil {
return 0, err
}
return uint16(i), nil
} | [
"func",
"ConvertUint16",
"(",
"str",
"string",
")",
"(",
"uint16",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"str",
",",
"10",
",",
"16",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
... | // ConvertUint16 turn a string into a uint16 | [
"ConvertUint16",
"turn",
"a",
"string",
"into",
"a",
"uint16"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L132-L138 |
125,931 | go-openapi/swag | convert.go | ConvertUint32 | func ConvertUint32(str string) (uint32, error) {
i, err := strconv.ParseUint(str, 10, 32)
if err != nil {
return 0, err
}
return uint32(i), nil
} | go | func ConvertUint32(str string) (uint32, error) {
i, err := strconv.ParseUint(str, 10, 32)
if err != nil {
return 0, err
}
return uint32(i), nil
} | [
"func",
"ConvertUint32",
"(",
"str",
"string",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"str",
",",
"10",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
... | // ConvertUint32 turn a string into a uint32 | [
"ConvertUint32",
"turn",
"a",
"string",
"into",
"a",
"uint32"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert.go#L141-L147 |
125,932 | go-openapi/swag | json.go | WriteJSON | func WriteJSON(data interface{}) ([]byte, error) {
if d, ok := data.(ejMarshaler); ok {
jw := new(jwriter.Writer)
d.MarshalEasyJSON(jw)
return jw.BuildBytes()
}
if d, ok := data.(json.Marshaler); ok {
return d.MarshalJSON()
}
return json.Marshal(data)
} | go | func WriteJSON(data interface{}) ([]byte, error) {
if d, ok := data.(ejMarshaler); ok {
jw := new(jwriter.Writer)
d.MarshalEasyJSON(jw)
return jw.BuildBytes()
}
if d, ok := data.(json.Marshaler); ok {
return d.MarshalJSON()
}
return json.Marshal(data)
} | [
"func",
"WriteJSON",
"(",
"data",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"d",
",",
"ok",
":=",
"data",
".",
"(",
"ejMarshaler",
")",
";",
"ok",
"{",
"jw",
":=",
"new",
"(",
"jwriter",
".",
"Writer",
")"... | // WriteJSON writes json data, prefers finding an appropriate interface to short-circuit the marshaller
// so it takes the fastest option available. | [
"WriteJSON",
"writes",
"json",
"data",
"prefers",
"finding",
"an",
"appropriate",
"interface",
"to",
"short",
"-",
"circuit",
"the",
"marshaller",
"so",
"it",
"takes",
"the",
"fastest",
"option",
"available",
"."
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L56-L66 |
125,933 | go-openapi/swag | json.go | ReadJSON | func ReadJSON(data []byte, value interface{}) error {
trimmedData := bytes.Trim(data, "\x00")
if d, ok := value.(ejUnmarshaler); ok {
jl := &jlexer.Lexer{Data: trimmedData}
d.UnmarshalEasyJSON(jl)
return jl.Error()
}
if d, ok := value.(json.Unmarshaler); ok {
return d.UnmarshalJSON(trimmedData)
}
return j... | go | func ReadJSON(data []byte, value interface{}) error {
trimmedData := bytes.Trim(data, "\x00")
if d, ok := value.(ejUnmarshaler); ok {
jl := &jlexer.Lexer{Data: trimmedData}
d.UnmarshalEasyJSON(jl)
return jl.Error()
}
if d, ok := value.(json.Unmarshaler); ok {
return d.UnmarshalJSON(trimmedData)
}
return j... | [
"func",
"ReadJSON",
"(",
"data",
"[",
"]",
"byte",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"trimmedData",
":=",
"bytes",
".",
"Trim",
"(",
"data",
",",
"\"",
"\\x00",
"\"",
")",
"\n",
"if",
"d",
",",
"ok",
":=",
"value",
".",
"(",... | // ReadJSON reads json data, prefers finding an appropriate interface to short-circuit the unmarshaller
// so it takes the fastes option available | [
"ReadJSON",
"reads",
"json",
"data",
"prefers",
"finding",
"an",
"appropriate",
"interface",
"to",
"short",
"-",
"circuit",
"the",
"unmarshaller",
"so",
"it",
"takes",
"the",
"fastes",
"option",
"available"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L70-L81 |
125,934 | go-openapi/swag | json.go | DynamicJSONToStruct | func DynamicJSONToStruct(data interface{}, target interface{}) error {
// TODO: convert straight to a json typed map (mergo + iterate?)
b, err := WriteJSON(data)
if err != nil {
return err
}
return ReadJSON(b, target)
} | go | func DynamicJSONToStruct(data interface{}, target interface{}) error {
// TODO: convert straight to a json typed map (mergo + iterate?)
b, err := WriteJSON(data)
if err != nil {
return err
}
return ReadJSON(b, target)
} | [
"func",
"DynamicJSONToStruct",
"(",
"data",
"interface",
"{",
"}",
",",
"target",
"interface",
"{",
"}",
")",
"error",
"{",
"// TODO: convert straight to a json typed map (mergo + iterate?)",
"b",
",",
"err",
":=",
"WriteJSON",
"(",
"data",
")",
"\n",
"if",
"err"... | // DynamicJSONToStruct converts an untyped json structure into a struct | [
"DynamicJSONToStruct",
"converts",
"an",
"untyped",
"json",
"structure",
"into",
"a",
"struct"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L84-L91 |
125,935 | go-openapi/swag | json.go | ConcatJSON | func ConcatJSON(blobs ...[]byte) []byte {
if len(blobs) == 0 {
return nil
}
last := len(blobs) - 1
for blobs[last] == nil || bytes.Equal(blobs[last], nullJSON) {
// strips trailing null objects
last = last - 1
if last < 0 {
// there was nothing but "null"s or nil...
return nil
}
}
if last == 0 {
... | go | func ConcatJSON(blobs ...[]byte) []byte {
if len(blobs) == 0 {
return nil
}
last := len(blobs) - 1
for blobs[last] == nil || bytes.Equal(blobs[last], nullJSON) {
// strips trailing null objects
last = last - 1
if last < 0 {
// there was nothing but "null"s or nil...
return nil
}
}
if last == 0 {
... | [
"func",
"ConcatJSON",
"(",
"blobs",
"...",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"blobs",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"last",
":=",
"len",
"(",
"blobs",
")",
"-",
"1",
"\n",
"for",
"blobs",... | // ConcatJSON concatenates multiple json objects efficiently | [
"ConcatJSON",
"concatenates",
"multiple",
"json",
"objects",
"efficiently"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L94-L167 |
125,936 | go-openapi/swag | json.go | ToDynamicJSON | func ToDynamicJSON(data interface{}) interface{} {
// TODO: convert straight to a json typed map (mergo + iterate?)
b, err := json.Marshal(data)
if err != nil {
log.Println(err)
}
var res interface{}
if err := json.Unmarshal(b, &res); err != nil {
log.Println(err)
}
return res
} | go | func ToDynamicJSON(data interface{}) interface{} {
// TODO: convert straight to a json typed map (mergo + iterate?)
b, err := json.Marshal(data)
if err != nil {
log.Println(err)
}
var res interface{}
if err := json.Unmarshal(b, &res); err != nil {
log.Println(err)
}
return res
} | [
"func",
"ToDynamicJSON",
"(",
"data",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"// TODO: convert straight to a json typed map (mergo + iterate?)",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // ToDynamicJSON turns an object into a properly JSON typed structure | [
"ToDynamicJSON",
"turns",
"an",
"object",
"into",
"a",
"properly",
"JSON",
"typed",
"structure"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L170-L181 |
125,937 | go-openapi/swag | json.go | FromDynamicJSON | func FromDynamicJSON(data, target interface{}) error {
b, err := json.Marshal(data)
if err != nil {
log.Println(err)
}
return json.Unmarshal(b, target)
} | go | func FromDynamicJSON(data, target interface{}) error {
b, err := json.Marshal(data)
if err != nil {
log.Println(err)
}
return json.Unmarshal(b, target)
} | [
"func",
"FromDynamicJSON",
"(",
"data",
",",
"target",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"... | // FromDynamicJSON turns an object into a properly JSON typed structure | [
"FromDynamicJSON",
"turns",
"an",
"object",
"into",
"a",
"properly",
"JSON",
"typed",
"structure"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L184-L190 |
125,938 | go-openapi/swag | json.go | NewNameProvider | func NewNameProvider() *NameProvider {
return &NameProvider{
lock: &sync.Mutex{},
index: make(map[reflect.Type]nameIndex),
}
} | go | func NewNameProvider() *NameProvider {
return &NameProvider{
lock: &sync.Mutex{},
index: make(map[reflect.Type]nameIndex),
}
} | [
"func",
"NewNameProvider",
"(",
")",
"*",
"NameProvider",
"{",
"return",
"&",
"NameProvider",
"{",
"lock",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
",",
"index",
":",
"make",
"(",
"map",
"[",
"reflect",
".",
"Type",
"]",
"nameIndex",
")",
",",
"}",
... | // NewNameProvider creates a new name provider | [
"NewNameProvider",
"creates",
"a",
"new",
"name",
"provider"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L206-L211 |
125,939 | go-openapi/swag | json.go | GetJSONNames | func (n *NameProvider) GetJSONNames(subject interface{}) []string {
n.lock.Lock()
defer n.lock.Unlock()
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
names, ok := n.index[tpe]
if !ok {
names = n.makeNameIndex(tpe)
}
res := make([]string, 0, len(names.jsonNames))
for k := range names.jsonNames {
... | go | func (n *NameProvider) GetJSONNames(subject interface{}) []string {
n.lock.Lock()
defer n.lock.Unlock()
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
names, ok := n.index[tpe]
if !ok {
names = n.makeNameIndex(tpe)
}
res := make([]string, 0, len(names.jsonNames))
for k := range names.jsonNames {
... | [
"func",
"(",
"n",
"*",
"NameProvider",
")",
"GetJSONNames",
"(",
"subject",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"n",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"tpe",
":=",... | // GetJSONNames gets all the json property names for a type | [
"GetJSONNames",
"gets",
"all",
"the",
"json",
"property",
"names",
"for",
"a",
"type"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L256-L270 |
125,940 | go-openapi/swag | json.go | GetJSONName | func (n *NameProvider) GetJSONName(subject interface{}, name string) (string, bool) {
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
return n.GetJSONNameForType(tpe, name)
} | go | func (n *NameProvider) GetJSONName(subject interface{}, name string) (string, bool) {
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
return n.GetJSONNameForType(tpe, name)
} | [
"func",
"(",
"n",
"*",
"NameProvider",
")",
"GetJSONName",
"(",
"subject",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"tpe",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"subject",... | // GetJSONName gets the json name for a go property name | [
"GetJSONName",
"gets",
"the",
"json",
"name",
"for",
"a",
"go",
"property",
"name"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L273-L276 |
125,941 | go-openapi/swag | json.go | GetJSONNameForType | func (n *NameProvider) GetJSONNameForType(tpe reflect.Type, name string) (string, bool) {
n.lock.Lock()
defer n.lock.Unlock()
names, ok := n.index[tpe]
if !ok {
names = n.makeNameIndex(tpe)
}
nme, ok := names.goNames[name]
return nme, ok
} | go | func (n *NameProvider) GetJSONNameForType(tpe reflect.Type, name string) (string, bool) {
n.lock.Lock()
defer n.lock.Unlock()
names, ok := n.index[tpe]
if !ok {
names = n.makeNameIndex(tpe)
}
nme, ok := names.goNames[name]
return nme, ok
} | [
"func",
"(",
"n",
"*",
"NameProvider",
")",
"GetJSONNameForType",
"(",
"tpe",
"reflect",
".",
"Type",
",",
"name",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"n",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"lock",
".",
... | // GetJSONNameForType gets the json name for a go property name on a given type | [
"GetJSONNameForType",
"gets",
"the",
"json",
"name",
"for",
"a",
"go",
"property",
"name",
"on",
"a",
"given",
"type"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L279-L288 |
125,942 | go-openapi/swag | json.go | GetGoName | func (n *NameProvider) GetGoName(subject interface{}, name string) (string, bool) {
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
return n.GetGoNameForType(tpe, name)
} | go | func (n *NameProvider) GetGoName(subject interface{}, name string) (string, bool) {
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
return n.GetGoNameForType(tpe, name)
} | [
"func",
"(",
"n",
"*",
"NameProvider",
")",
"GetGoName",
"(",
"subject",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"tpe",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"subject",
... | // GetGoName gets the go name for a json property name | [
"GetGoName",
"gets",
"the",
"go",
"name",
"for",
"a",
"json",
"property",
"name"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/json.go#L297-L300 |
125,943 | go-openapi/swag | yaml.go | YAMLMatcher | func YAMLMatcher(path string) bool {
ext := filepath.Ext(path)
return ext == ".yaml" || ext == ".yml"
} | go | func YAMLMatcher(path string) bool {
ext := filepath.Ext(path)
return ext == ".yaml" || ext == ".yml"
} | [
"func",
"YAMLMatcher",
"(",
"path",
"string",
")",
"bool",
"{",
"ext",
":=",
"filepath",
".",
"Ext",
"(",
"path",
")",
"\n",
"return",
"ext",
"==",
"\"",
"\"",
"||",
"ext",
"==",
"\"",
"\"",
"\n",
"}"
] | // YAMLMatcher matches yaml | [
"YAMLMatcher",
"matches",
"yaml"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L29-L32 |
125,944 | go-openapi/swag | yaml.go | YAMLToJSON | func YAMLToJSON(data interface{}) (json.RawMessage, error) {
jm, err := transformData(data)
if err != nil {
return nil, err
}
b, err := WriteJSON(jm)
return json.RawMessage(b), err
} | go | func YAMLToJSON(data interface{}) (json.RawMessage, error) {
jm, err := transformData(data)
if err != nil {
return nil, err
}
b, err := WriteJSON(jm)
return json.RawMessage(b), err
} | [
"func",
"YAMLToJSON",
"(",
"data",
"interface",
"{",
"}",
")",
"(",
"json",
".",
"RawMessage",
",",
"error",
")",
"{",
"jm",
",",
"err",
":=",
"transformData",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n"... | // YAMLToJSON converts YAML unmarshaled data into json compatible data | [
"YAMLToJSON",
"converts",
"YAML",
"unmarshaled",
"data",
"into",
"json",
"compatible",
"data"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L35-L42 |
125,945 | go-openapi/swag | yaml.go | BytesToYAMLDoc | func BytesToYAMLDoc(data []byte) (interface{}, error) {
var canary map[interface{}]interface{} // validate this is an object and not a different type
if err := yaml.Unmarshal(data, &canary); err != nil {
return nil, err
}
var document yaml.MapSlice // preserve order that is present in the document
if err := yam... | go | func BytesToYAMLDoc(data []byte) (interface{}, error) {
var canary map[interface{}]interface{} // validate this is an object and not a different type
if err := yaml.Unmarshal(data, &canary); err != nil {
return nil, err
}
var document yaml.MapSlice // preserve order that is present in the document
if err := yam... | [
"func",
"BytesToYAMLDoc",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"canary",
"map",
"[",
"interface",
"{",
"}",
"]",
"interface",
"{",
"}",
"// validate this is an object and not a different type",
"\n",
... | // BytesToYAMLDoc converts a byte slice into a YAML document | [
"BytesToYAMLDoc",
"converts",
"a",
"byte",
"slice",
"into",
"a",
"YAML",
"document"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L45-L56 |
125,946 | go-openapi/swag | yaml.go | MarshalJSON | func (s JSONMapSlice) MarshalJSON() ([]byte, error) {
w := &jwriter.Writer{Flags: jwriter.NilMapAsEmpty | jwriter.NilSliceAsEmpty}
s.MarshalEasyJSON(w)
return w.BuildBytes()
} | go | func (s JSONMapSlice) MarshalJSON() ([]byte, error) {
w := &jwriter.Writer{Flags: jwriter.NilMapAsEmpty | jwriter.NilSliceAsEmpty}
s.MarshalEasyJSON(w)
return w.BuildBytes()
} | [
"func",
"(",
"s",
"JSONMapSlice",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"&",
"jwriter",
".",
"Writer",
"{",
"Flags",
":",
"jwriter",
".",
"NilMapAsEmpty",
"|",
"jwriter",
".",
"NilSliceAsEmpty",
"}",
... | // MarshalJSON renders a JSONMapSlice as JSON | [
"MarshalJSON",
"renders",
"a",
"JSONMapSlice",
"as",
"JSON"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L62-L66 |
125,947 | go-openapi/swag | yaml.go | MarshalEasyJSON | func (s JSONMapSlice) MarshalEasyJSON(w *jwriter.Writer) {
w.RawByte('{')
ln := len(s)
last := ln - 1
for i := 0; i < ln; i++ {
s[i].MarshalEasyJSON(w)
if i != last { // last item
w.RawByte(',')
}
}
w.RawByte('}')
} | go | func (s JSONMapSlice) MarshalEasyJSON(w *jwriter.Writer) {
w.RawByte('{')
ln := len(s)
last := ln - 1
for i := 0; i < ln; i++ {
s[i].MarshalEasyJSON(w)
if i != last { // last item
w.RawByte(',')
}
}
w.RawByte('}')
} | [
"func",
"(",
"s",
"JSONMapSlice",
")",
"MarshalEasyJSON",
"(",
"w",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"w",
".",
"RawByte",
"(",
"'{'",
")",
"\n\n",
"ln",
":=",
"len",
"(",
"s",
")",
"\n",
"last",
":=",
"ln",
"-",
"1",
"\n",
"for",
"i",
"... | // MarshalEasyJSON renders a JSONMapSlice as JSON, using easyJSON | [
"MarshalEasyJSON",
"renders",
"a",
"JSONMapSlice",
"as",
"JSON",
"using",
"easyJSON"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L69-L82 |
125,948 | go-openapi/swag | yaml.go | UnmarshalEasyJSON | func (s *JSONMapSlice) UnmarshalEasyJSON(in *jlexer.Lexer) {
if in.IsNull() {
in.Skip()
return
}
var result JSONMapSlice
in.Delim('{')
for !in.IsDelim('}') {
var mi JSONMapItem
mi.UnmarshalEasyJSON(in)
result = append(result, mi)
}
*s = result
} | go | func (s *JSONMapSlice) UnmarshalEasyJSON(in *jlexer.Lexer) {
if in.IsNull() {
in.Skip()
return
}
var result JSONMapSlice
in.Delim('{')
for !in.IsDelim('}') {
var mi JSONMapItem
mi.UnmarshalEasyJSON(in)
result = append(result, mi)
}
*s = result
} | [
"func",
"(",
"s",
"*",
"JSONMapSlice",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"if",
"in",
".",
"IsNull",
"(",
")",
"{",
"in",
".",
"Skip",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"result",
"JSONMapSl... | // UnmarshalEasyJSON makes a JSONMapSlice from JSON, using easyJSON | [
"UnmarshalEasyJSON",
"makes",
"a",
"JSONMapSlice",
"from",
"JSON",
"using",
"easyJSON"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L92-L106 |
125,949 | go-openapi/swag | yaml.go | MarshalEasyJSON | func (s JSONMapItem) MarshalEasyJSON(w *jwriter.Writer) {
w.String(s.Key)
w.RawByte(':')
w.Raw(WriteJSON(s.Value))
} | go | func (s JSONMapItem) MarshalEasyJSON(w *jwriter.Writer) {
w.String(s.Key)
w.RawByte(':')
w.Raw(WriteJSON(s.Value))
} | [
"func",
"(",
"s",
"JSONMapItem",
")",
"MarshalEasyJSON",
"(",
"w",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"w",
".",
"String",
"(",
"s",
".",
"Key",
")",
"\n",
"w",
".",
"RawByte",
"(",
"':'",
")",
"\n",
"w",
".",
"Raw",
"(",
"WriteJSON",
"(",
... | // MarshalEasyJSON renders a JSONMapItem as JSON, using easyJSON | [
"MarshalEasyJSON",
"renders",
"a",
"JSONMapItem",
"as",
"JSON",
"using",
"easyJSON"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L122-L126 |
125,950 | go-openapi/swag | yaml.go | UnmarshalJSON | func (s *JSONMapItem) UnmarshalJSON(data []byte) error {
l := jlexer.Lexer{Data: data}
s.UnmarshalEasyJSON(&l)
return l.Error()
} | go | func (s *JSONMapItem) UnmarshalJSON(data []byte) error {
l := jlexer.Lexer{Data: data}
s.UnmarshalEasyJSON(&l)
return l.Error()
} | [
"func",
"(",
"s",
"*",
"JSONMapItem",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"l",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"s",
".",
"UnmarshalEasyJSON",
"(",
"&",
"l",
")",
"\n",
"return",... | // UnmarshalJSON makes a JSONMapItem from JSON | [
"UnmarshalJSON",
"makes",
"a",
"JSONMapItem",
"from",
"JSON"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L129-L133 |
125,951 | go-openapi/swag | yaml.go | UnmarshalEasyJSON | func (s *JSONMapItem) UnmarshalEasyJSON(in *jlexer.Lexer) {
key := in.UnsafeString()
in.WantColon()
value := in.Interface()
in.WantComma()
s.Key = key
s.Value = value
} | go | func (s *JSONMapItem) UnmarshalEasyJSON(in *jlexer.Lexer) {
key := in.UnsafeString()
in.WantColon()
value := in.Interface()
in.WantComma()
s.Key = key
s.Value = value
} | [
"func",
"(",
"s",
"*",
"JSONMapItem",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"key",
":=",
"in",
".",
"UnsafeString",
"(",
")",
"\n",
"in",
".",
"WantColon",
"(",
")",
"\n",
"value",
":=",
"in",
".",
"Interface",
... | // UnmarshalEasyJSON makes a JSONMapItem from JSON, using easyJSON | [
"UnmarshalEasyJSON",
"makes",
"a",
"JSONMapItem",
"from",
"JSON",
"using",
"easyJSON"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L136-L143 |
125,952 | go-openapi/swag | yaml.go | YAMLDoc | func YAMLDoc(path string) (json.RawMessage, error) {
yamlDoc, err := YAMLData(path)
if err != nil {
return nil, err
}
data, err := YAMLToJSON(yamlDoc)
if err != nil {
return nil, err
}
return data, nil
} | go | func YAMLDoc(path string) (json.RawMessage, error) {
yamlDoc, err := YAMLData(path)
if err != nil {
return nil, err
}
data, err := YAMLToJSON(yamlDoc)
if err != nil {
return nil, err
}
return data, nil
} | [
"func",
"YAMLDoc",
"(",
"path",
"string",
")",
"(",
"json",
".",
"RawMessage",
",",
"error",
")",
"{",
"yamlDoc",
",",
"err",
":=",
"YAMLData",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
... | // YAMLDoc loads a yaml document from either http or a file and converts it to json | [
"YAMLDoc",
"loads",
"a",
"yaml",
"document",
"from",
"either",
"http",
"or",
"a",
"file",
"and",
"converts",
"it",
"to",
"json"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L205-L217 |
125,953 | go-openapi/swag | yaml.go | YAMLData | func YAMLData(path string) (interface{}, error) {
data, err := LoadFromFileOrHTTP(path)
if err != nil {
return nil, err
}
return BytesToYAMLDoc(data)
} | go | func YAMLData(path string) (interface{}, error) {
data, err := LoadFromFileOrHTTP(path)
if err != nil {
return nil, err
}
return BytesToYAMLDoc(data)
} | [
"func",
"YAMLData",
"(",
"path",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"LoadFromFileOrHTTP",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n... | // YAMLData loads a yaml document from either http or a file | [
"YAMLData",
"loads",
"a",
"yaml",
"document",
"from",
"either",
"http",
"or",
"a",
"file"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/yaml.go#L220-L227 |
125,954 | go-openapi/swag | loading.go | LoadFromFileOrHTTP | func LoadFromFileOrHTTP(path string) ([]byte, error) {
return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(LoadHTTPTimeout))(path)
} | go | func LoadFromFileOrHTTP(path string) ([]byte, error) {
return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(LoadHTTPTimeout))(path)
} | [
"func",
"LoadFromFileOrHTTP",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"LoadStrategy",
"(",
"path",
",",
"ioutil",
".",
"ReadFile",
",",
"loadHTTPBytes",
"(",
"LoadHTTPTimeout",
")",
")",
"(",
"path",
")",
"\n"... | // LoadFromFileOrHTTP loads the bytes from a file or a remote http server based on the path passed in | [
"LoadFromFileOrHTTP",
"loads",
"the",
"bytes",
"from",
"a",
"file",
"or",
"a",
"remote",
"http",
"server",
"based",
"on",
"the",
"path",
"passed",
"in"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/loading.go#L31-L33 |
125,955 | go-openapi/swag | loading.go | LoadFromFileOrHTTPWithTimeout | func LoadFromFileOrHTTPWithTimeout(path string, timeout time.Duration) ([]byte, error) {
return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(timeout))(path)
} | go | func LoadFromFileOrHTTPWithTimeout(path string, timeout time.Duration) ([]byte, error) {
return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(timeout))(path)
} | [
"func",
"LoadFromFileOrHTTPWithTimeout",
"(",
"path",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"LoadStrategy",
"(",
"path",
",",
"ioutil",
".",
"ReadFile",
",",
"loadHTTPBytes",
"(",
"... | // LoadFromFileOrHTTPWithTimeout loads the bytes from a file or a remote http server based on the path passed in
// timeout arg allows for per request overriding of the request timeout | [
"LoadFromFileOrHTTPWithTimeout",
"loads",
"the",
"bytes",
"from",
"a",
"file",
"or",
"a",
"remote",
"http",
"server",
"based",
"on",
"the",
"path",
"passed",
"in",
"timeout",
"arg",
"allows",
"for",
"per",
"request",
"overriding",
"of",
"the",
"request",
"time... | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/loading.go#L37-L39 |
125,956 | go-openapi/swag | loading.go | LoadStrategy | func LoadStrategy(path string, local, remote func(string) ([]byte, error)) func(string) ([]byte, error) {
if strings.HasPrefix(path, "http") {
return remote
}
return func(pth string) ([]byte, error) {
upth, err := pathUnescape(pth)
if err != nil {
return nil, err
}
return local(filepath.FromSlash(upth))... | go | func LoadStrategy(path string, local, remote func(string) ([]byte, error)) func(string) ([]byte, error) {
if strings.HasPrefix(path, "http") {
return remote
}
return func(pth string) ([]byte, error) {
upth, err := pathUnescape(pth)
if err != nil {
return nil, err
}
return local(filepath.FromSlash(upth))... | [
"func",
"LoadStrategy",
"(",
"path",
"string",
",",
"local",
",",
"remote",
"func",
"(",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
")",
"func",
"(",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"strings",
"."... | // LoadStrategy returns a loader function for a given path or uri | [
"LoadStrategy",
"returns",
"a",
"loader",
"function",
"for",
"a",
"given",
"path",
"or",
"uri"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/loading.go#L42-L53 |
125,957 | go-openapi/swag | convert_types.go | Int32Slice | func Int32Slice(src []int32) []*int32 {
dst := make([]*int32, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | go | func Int32Slice(src []int32) []*int32 {
dst := make([]*int32, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | [
"func",
"Int32Slice",
"(",
"src",
"[",
"]",
"int32",
")",
"[",
"]",
"*",
"int32",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"*",
"int32",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")",
... | // Int32Slice converts a slice of int64 values into a slice of
// int32 pointers | [
"Int32Slice",
"converts",
"a",
"slice",
"of",
"int64",
"values",
"into",
"a",
"slice",
"of",
"int32",
"pointers"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L200-L206 |
125,958 | go-openapi/swag | convert_types.go | Int32ValueSlice | func Int32ValueSlice(src []*int32) []int32 {
dst := make([]int32, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | go | func Int32ValueSlice(src []*int32) []int32 {
dst := make([]int32, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | [
"func",
"Int32ValueSlice",
"(",
"src",
"[",
"]",
"*",
"int32",
")",
"[",
"]",
"int32",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"int32",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")",
"... | // Int32ValueSlice converts a slice of int32 pointers into a slice of
// int32 values | [
"Int32ValueSlice",
"converts",
"a",
"slice",
"of",
"int32",
"pointers",
"into",
"a",
"slice",
"of",
"int32",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L210-L218 |
125,959 | go-openapi/swag | convert_types.go | Int32Map | func Int32Map(src map[string]int32) map[string]*int32 {
dst := make(map[string]*int32)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | go | func Int32Map(src map[string]int32) map[string]*int32 {
dst := make(map[string]*int32)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | [
"func",
"Int32Map",
"(",
"src",
"map",
"[",
"string",
"]",
"int32",
")",
"map",
"[",
"string",
"]",
"*",
"int32",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"int32",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",
"... | // Int32Map converts a string map of int32 values into a string
// map of int32 pointers | [
"Int32Map",
"converts",
"a",
"string",
"map",
"of",
"int32",
"values",
"into",
"a",
"string",
"map",
"of",
"int32",
"pointers"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L222-L229 |
125,960 | go-openapi/swag | convert_types.go | Int32ValueMap | func Int32ValueMap(src map[string]*int32) map[string]int32 {
dst := make(map[string]int32)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | go | func Int32ValueMap(src map[string]*int32) map[string]int32 {
dst := make(map[string]int32)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | [
"func",
"Int32ValueMap",
"(",
"src",
"map",
"[",
"string",
"]",
"*",
"int32",
")",
"map",
"[",
"string",
"]",
"int32",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int32",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",
"{"... | // Int32ValueMap converts a string map of int32 pointers into a string
// map of int32 values | [
"Int32ValueMap",
"converts",
"a",
"string",
"map",
"of",
"int32",
"pointers",
"into",
"a",
"string",
"map",
"of",
"int32",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L233-L241 |
125,961 | go-openapi/swag | convert_types.go | UintSlice | func UintSlice(src []uint) []*uint {
dst := make([]*uint, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | go | func UintSlice(src []uint) []*uint {
dst := make([]*uint, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | [
"func",
"UintSlice",
"(",
"src",
"[",
"]",
"uint",
")",
"[",
"]",
"*",
"uint",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"*",
"uint",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")",
";"... | // UintSlice converts a slice of uint values uinto a slice of
// uint pouinters | [
"UintSlice",
"converts",
"a",
"slice",
"of",
"uint",
"values",
"uinto",
"a",
"slice",
"of",
"uint",
"pouinters"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L318-L324 |
125,962 | go-openapi/swag | convert_types.go | UintValueSlice | func UintValueSlice(src []*uint) []uint {
dst := make([]uint, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | go | func UintValueSlice(src []*uint) []uint {
dst := make([]uint, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | [
"func",
"UintValueSlice",
"(",
"src",
"[",
"]",
"*",
"uint",
")",
"[",
"]",
"uint",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"uint",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")",
";",
... | // UintValueSlice converts a slice of uint pouinters uinto a slice of
// uint values | [
"UintValueSlice",
"converts",
"a",
"slice",
"of",
"uint",
"pouinters",
"uinto",
"a",
"slice",
"of",
"uint",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L328-L336 |
125,963 | go-openapi/swag | convert_types.go | UintMap | func UintMap(src map[string]uint) map[string]*uint {
dst := make(map[string]*uint)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | go | func UintMap(src map[string]uint) map[string]*uint {
dst := make(map[string]*uint)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | [
"func",
"UintMap",
"(",
"src",
"map",
"[",
"string",
"]",
"uint",
")",
"map",
"[",
"string",
"]",
"*",
"uint",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"uint",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",
"{",
... | // UintMap converts a string map of uint values uinto a string
// map of uint pouinters | [
"UintMap",
"converts",
"a",
"string",
"map",
"of",
"uint",
"values",
"uinto",
"a",
"string",
"map",
"of",
"uint",
"pouinters"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L340-L347 |
125,964 | go-openapi/swag | convert_types.go | UintValueMap | func UintValueMap(src map[string]*uint) map[string]uint {
dst := make(map[string]uint)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | go | func UintValueMap(src map[string]*uint) map[string]uint {
dst := make(map[string]uint)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | [
"func",
"UintValueMap",
"(",
"src",
"map",
"[",
"string",
"]",
"*",
"uint",
")",
"map",
"[",
"string",
"]",
"uint",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"uint",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",
"{",
... | // UintValueMap converts a string map of uint pouinters uinto a string
// map of uint values | [
"UintValueMap",
"converts",
"a",
"string",
"map",
"of",
"uint",
"pouinters",
"uinto",
"a",
"string",
"map",
"of",
"uint",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L351-L359 |
125,965 | go-openapi/swag | convert_types.go | Uint32Slice | func Uint32Slice(src []uint32) []*uint32 {
dst := make([]*uint32, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | go | func Uint32Slice(src []uint32) []*uint32 {
dst := make([]*uint32, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | [
"func",
"Uint32Slice",
"(",
"src",
"[",
"]",
"uint32",
")",
"[",
"]",
"*",
"uint32",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"*",
"uint32",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")... | // Uint32Slice converts a slice of uint64 values uinto a slice of
// uint32 pouinters | [
"Uint32Slice",
"converts",
"a",
"slice",
"of",
"uint64",
"values",
"uinto",
"a",
"slice",
"of",
"uint32",
"pouinters"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L377-L383 |
125,966 | go-openapi/swag | convert_types.go | Uint32ValueSlice | func Uint32ValueSlice(src []*uint32) []uint32 {
dst := make([]uint32, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | go | func Uint32ValueSlice(src []*uint32) []uint32 {
dst := make([]uint32, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | [
"func",
"Uint32ValueSlice",
"(",
"src",
"[",
"]",
"*",
"uint32",
")",
"[",
"]",
"uint32",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"uint32",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")",... | // Uint32ValueSlice converts a slice of uint32 pouinters uinto a slice of
// uint32 values | [
"Uint32ValueSlice",
"converts",
"a",
"slice",
"of",
"uint32",
"pouinters",
"uinto",
"a",
"slice",
"of",
"uint32",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L387-L395 |
125,967 | go-openapi/swag | convert_types.go | Uint32Map | func Uint32Map(src map[string]uint32) map[string]*uint32 {
dst := make(map[string]*uint32)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | go | func Uint32Map(src map[string]uint32) map[string]*uint32 {
dst := make(map[string]*uint32)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | [
"func",
"Uint32Map",
"(",
"src",
"map",
"[",
"string",
"]",
"uint32",
")",
"map",
"[",
"string",
"]",
"*",
"uint32",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"uint32",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",... | // Uint32Map converts a string map of uint32 values uinto a string
// map of uint32 pouinters | [
"Uint32Map",
"converts",
"a",
"string",
"map",
"of",
"uint32",
"values",
"uinto",
"a",
"string",
"map",
"of",
"uint32",
"pouinters"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L399-L406 |
125,968 | go-openapi/swag | convert_types.go | Uint32ValueMap | func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
dst := make(map[string]uint32)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | go | func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
dst := make(map[string]uint32)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | [
"func",
"Uint32ValueMap",
"(",
"src",
"map",
"[",
"string",
"]",
"*",
"uint32",
")",
"map",
"[",
"string",
"]",
"uint32",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"uint32",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",
... | // Uint32ValueMap converts a string map of uint32 pouinters uinto a string
// map of uint32 values | [
"Uint32ValueMap",
"converts",
"a",
"string",
"map",
"of",
"uint32",
"pouinters",
"uinto",
"a",
"string",
"map",
"of",
"uint32",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L410-L418 |
125,969 | go-openapi/swag | convert_types.go | Uint64Slice | func Uint64Slice(src []uint64) []*uint64 {
dst := make([]*uint64, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | go | func Uint64Slice(src []uint64) []*uint64 {
dst := make([]*uint64, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
} | [
"func",
"Uint64Slice",
"(",
"src",
"[",
"]",
"uint64",
")",
"[",
"]",
"*",
"uint64",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"*",
"uint64",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")... | // Uint64Slice converts a slice of uint64 values uinto a slice of
// uint64 pouinters | [
"Uint64Slice",
"converts",
"a",
"slice",
"of",
"uint64",
"values",
"uinto",
"a",
"slice",
"of",
"uint64",
"pouinters"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L436-L442 |
125,970 | go-openapi/swag | convert_types.go | Uint64ValueSlice | func Uint64ValueSlice(src []*uint64) []uint64 {
dst := make([]uint64, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | go | func Uint64ValueSlice(src []*uint64) []uint64 {
dst := make([]uint64, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
} | [
"func",
"Uint64ValueSlice",
"(",
"src",
"[",
"]",
"*",
"uint64",
")",
"[",
"]",
"uint64",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"len",
"(",
"src",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"src",
")",... | // Uint64ValueSlice converts a slice of uint64 pouinters uinto a slice of
// uint64 values | [
"Uint64ValueSlice",
"converts",
"a",
"slice",
"of",
"uint64",
"pouinters",
"uinto",
"a",
"slice",
"of",
"uint64",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L446-L454 |
125,971 | go-openapi/swag | convert_types.go | Uint64Map | func Uint64Map(src map[string]uint64) map[string]*uint64 {
dst := make(map[string]*uint64)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | go | func Uint64Map(src map[string]uint64) map[string]*uint64 {
dst := make(map[string]*uint64)
for k, val := range src {
v := val
dst[k] = &v
}
return dst
} | [
"func",
"Uint64Map",
"(",
"src",
"map",
"[",
"string",
"]",
"uint64",
")",
"map",
"[",
"string",
"]",
"*",
"uint64",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"uint64",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",... | // Uint64Map converts a string map of uint64 values uinto a string
// map of uint64 pouinters | [
"Uint64Map",
"converts",
"a",
"string",
"map",
"of",
"uint64",
"values",
"uinto",
"a",
"string",
"map",
"of",
"uint64",
"pouinters"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L458-L465 |
125,972 | go-openapi/swag | convert_types.go | Uint64ValueMap | func Uint64ValueMap(src map[string]*uint64) map[string]uint64 {
dst := make(map[string]uint64)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | go | func Uint64ValueMap(src map[string]*uint64) map[string]uint64 {
dst := make(map[string]uint64)
for k, val := range src {
if val != nil {
dst[k] = *val
}
}
return dst
} | [
"func",
"Uint64ValueMap",
"(",
"src",
"map",
"[",
"string",
"]",
"*",
"uint64",
")",
"map",
"[",
"string",
"]",
"uint64",
"{",
"dst",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"uint64",
")",
"\n",
"for",
"k",
",",
"val",
":=",
"range",
"src",
... | // Uint64ValueMap converts a string map of uint64 pouinters uinto a string
// map of uint64 values | [
"Uint64ValueMap",
"converts",
"a",
"string",
"map",
"of",
"uint64",
"pouinters",
"uinto",
"a",
"string",
"map",
"of",
"uint64",
"values"
] | b3e2804c8535ee0d1b89320afd98474d5b8e9e3b | https://github.com/go-openapi/swag/blob/b3e2804c8535ee0d1b89320afd98474d5b8e9e3b/convert_types.go#L469-L477 |
125,973 | robfig/soy | soymsg/pomsg/msgid.go | pluralCase | func pluralCase(n *ast.MsgPluralNode, singular bool) ast.ParentNode {
if singular {
return n.Cases[0].Body
}
return n.Default
} | go | func pluralCase(n *ast.MsgPluralNode, singular bool) ast.ParentNode {
if singular {
return n.Cases[0].Body
}
return n.Default
} | [
"func",
"pluralCase",
"(",
"n",
"*",
"ast",
".",
"MsgPluralNode",
",",
"singular",
"bool",
")",
"ast",
".",
"ParentNode",
"{",
"if",
"singular",
"{",
"return",
"n",
".",
"Cases",
"[",
"0",
"]",
".",
"Body",
"\n",
"}",
"\n",
"return",
"n",
".",
"Def... | // pluralCase returns the singular or plural message body. | [
"pluralCase",
"returns",
"the",
"singular",
"or",
"plural",
"message",
"body",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soymsg/pomsg/msgid.go#L59-L64 |
125,974 | robfig/soy | soymsg/pomsg/msgid.go | writeph | func writeph(buf *bytes.Buffer, child ast.Node) {
switch child := child.(type) {
case *ast.RawTextNode:
buf.Write(child.Text)
case *ast.MsgPlaceholderNode:
buf.WriteString("{" + child.Name + "}")
}
} | go | func writeph(buf *bytes.Buffer, child ast.Node) {
switch child := child.(type) {
case *ast.RawTextNode:
buf.Write(child.Text)
case *ast.MsgPlaceholderNode:
buf.WriteString("{" + child.Name + "}")
}
} | [
"func",
"writeph",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"child",
"ast",
".",
"Node",
")",
"{",
"switch",
"child",
":=",
"child",
".",
"(",
"type",
")",
"{",
"case",
"*",
"ast",
".",
"RawTextNode",
":",
"buf",
".",
"Write",
"(",
"child",
... | // writeph writes the placeholder string for the given node to the given buffer. | [
"writeph",
"writes",
"the",
"placeholder",
"string",
"for",
"the",
"given",
"node",
"to",
"the",
"given",
"buffer",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soymsg/pomsg/msgid.go#L67-L74 |
125,975 | robfig/soy | ast/node.go | Placeholder | func (n *MsgNode) Placeholder(name string) *MsgPlaceholderNode {
var q = n.Body.Children()
for len(q) > 0 {
var node Node
node, q = q[0], q[1:]
switch node := node.(type) {
case *MsgPlaceholderNode:
if node.Name == name {
return node
}
default:
if node, ok := node.(ParentNode); ok {
q = app... | go | func (n *MsgNode) Placeholder(name string) *MsgPlaceholderNode {
var q = n.Body.Children()
for len(q) > 0 {
var node Node
node, q = q[0], q[1:]
switch node := node.(type) {
case *MsgPlaceholderNode:
if node.Name == name {
return node
}
default:
if node, ok := node.(ParentNode); ok {
q = app... | [
"func",
"(",
"n",
"*",
"MsgNode",
")",
"Placeholder",
"(",
"name",
"string",
")",
"*",
"MsgPlaceholderNode",
"{",
"var",
"q",
"=",
"n",
".",
"Body",
".",
"Children",
"(",
")",
"\n",
"for",
"len",
"(",
"q",
")",
">",
"0",
"{",
"var",
"node",
"Node... | // Placeholder returns a placeholder node with the given name within this
// message node. It requires placeholder names to have been calculated. | [
"Placeholder",
"returns",
"a",
"placeholder",
"node",
"with",
"the",
"given",
"name",
"within",
"this",
"message",
"node",
".",
"It",
"requires",
"placeholder",
"names",
"to",
"have",
"been",
"calculated",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/ast/node.go#L324-L341 |
125,976 | robfig/soy | soyhtml/exec.go | renderBlock | func (s *state) renderBlock(node ast.Node) []byte {
var buf bytes.Buffer
origWriter := s.wr
s.wr = &buf
s.walk(node)
s.wr = origWriter
return buf.Bytes()
} | go | func (s *state) renderBlock(node ast.Node) []byte {
var buf bytes.Buffer
origWriter := s.wr
s.wr = &buf
s.walk(node)
s.wr = origWriter
return buf.Bytes()
} | [
"func",
"(",
"s",
"*",
"state",
")",
"renderBlock",
"(",
"node",
"ast",
".",
"Node",
")",
"[",
"]",
"byte",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"origWriter",
":=",
"s",
".",
"wr",
"\n",
"s",
".",
"wr",
"=",
"&",
"buf",
"\n",
"s",
... | // renderBlock is a helper that renders the given node to a temporary output
// buffer and returns that result. nothing is written to the main output. | [
"renderBlock",
"is",
"a",
"helper",
"that",
"renders",
"the",
"given",
"node",
"to",
"a",
"temporary",
"output",
"buffer",
"and",
"returns",
"that",
"result",
".",
"nothing",
"is",
"written",
"to",
"the",
"main",
"output",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/exec.go#L524-L531 |
125,977 | robfig/soy | soyhtml/exec.go | isNullSafeAccess | func isNullSafeAccess(n ast.Node) bool {
switch node := n.(type) {
case *ast.DataRefIndexNode:
return node.NullSafe
case *ast.DataRefKeyNode:
return node.NullSafe
case *ast.DataRefExprNode:
return node.NullSafe
}
panic("unexpected")
} | go | func isNullSafeAccess(n ast.Node) bool {
switch node := n.(type) {
case *ast.DataRefIndexNode:
return node.NullSafe
case *ast.DataRefKeyNode:
return node.NullSafe
case *ast.DataRefExprNode:
return node.NullSafe
}
panic("unexpected")
} | [
"func",
"isNullSafeAccess",
"(",
"n",
"ast",
".",
"Node",
")",
"bool",
"{",
"switch",
"node",
":=",
"n",
".",
"(",
"type",
")",
"{",
"case",
"*",
"ast",
".",
"DataRefIndexNode",
":",
"return",
"node",
".",
"NullSafe",
"\n",
"case",
"*",
"ast",
".",
... | // isNullSafeAccess returns true if the data ref access node is a nullsafe
// access. | [
"isNullSafeAccess",
"returns",
"true",
"if",
"the",
"data",
"ref",
"access",
"node",
"is",
"a",
"nullsafe",
"access",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/exec.go#L640-L650 |
125,978 | robfig/soy | soyhtml/exec.go | eval2def | func (s *state) eval2def(n1, n2 ast.Node) (data.Value, data.Value) {
return s.evaldef(n1), s.evaldef(n2)
} | go | func (s *state) eval2def(n1, n2 ast.Node) (data.Value, data.Value) {
return s.evaldef(n1), s.evaldef(n2)
} | [
"func",
"(",
"s",
"*",
"state",
")",
"eval2def",
"(",
"n1",
",",
"n2",
"ast",
".",
"Node",
")",
"(",
"data",
".",
"Value",
",",
"data",
".",
"Value",
")",
"{",
"return",
"s",
".",
"evaldef",
"(",
"n1",
")",
",",
"s",
".",
"evaldef",
"(",
"n2"... | // eval2def is a helper for binary ops. it evaluates the two given nodes and
// requires the result of each to not be Undefined. | [
"eval2def",
"is",
"a",
"helper",
"for",
"binary",
"ops",
".",
"it",
"evaluates",
"the",
"two",
"given",
"nodes",
"and",
"requires",
"the",
"result",
"of",
"each",
"to",
"not",
"be",
"Undefined",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/exec.go#L654-L656 |
125,979 | robfig/soy | soyhtml/exec.go | htmlEscapeString | func htmlEscapeString(w io.Writer, str string) {
last := 0
for i := 0; i < len(str); i++ {
var html []byte
switch str[i] {
case '"':
html = htmlQuot
case '\'':
html = htmlApos
case '&':
html = htmlAmp
case '<':
html = htmlLt
case '>':
html = htmlGt
default:
continue
}
io.WriteStr... | go | func htmlEscapeString(w io.Writer, str string) {
last := 0
for i := 0; i < len(str); i++ {
var html []byte
switch str[i] {
case '"':
html = htmlQuot
case '\'':
html = htmlApos
case '&':
html = htmlAmp
case '<':
html = htmlLt
case '>':
html = htmlGt
default:
continue
}
io.WriteStr... | [
"func",
"htmlEscapeString",
"(",
"w",
"io",
".",
"Writer",
",",
"str",
"string",
")",
"{",
"last",
":=",
"0",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"str",
")",
";",
"i",
"++",
"{",
"var",
"html",
"[",
"]",
"byte",
"\n",
"swi... | // htmlEscapeString is a modified veresion of the stdlib HTMLEscape routine
// escapes a string without making copies. | [
"htmlEscapeString",
"is",
"a",
"modified",
"veresion",
"of",
"the",
"stdlib",
"HTMLEscape",
"routine",
"escapes",
"a",
"string",
"without",
"making",
"copies",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/exec.go#L683-L706 |
125,980 | robfig/soy | soyhtml/scope.go | push | func (s *scope) push() {
*s = append(*s, scopeframe{make(data.Map), false})
} | go | func (s *scope) push() {
*s = append(*s, scopeframe{make(data.Map), false})
} | [
"func",
"(",
"s",
"*",
"scope",
")",
"push",
"(",
")",
"{",
"*",
"s",
"=",
"append",
"(",
"*",
"s",
",",
"scopeframe",
"{",
"make",
"(",
"data",
".",
"Map",
")",
",",
"false",
"}",
")",
"\n",
"}"
] | // push creates a new scope | [
"push",
"creates",
"a",
"new",
"scope"
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/scope.go#L21-L23 |
125,981 | robfig/soy | soyhtml/scope.go | set | func (s scope) set(k string, v data.Value) {
s[len(s)-1].vars[k] = v
} | go | func (s scope) set(k string, v data.Value) {
s[len(s)-1].vars[k] = v
} | [
"func",
"(",
"s",
"scope",
")",
"set",
"(",
"k",
"string",
",",
"v",
"data",
".",
"Value",
")",
"{",
"s",
"[",
"len",
"(",
"s",
")",
"-",
"1",
"]",
".",
"vars",
"[",
"k",
"]",
"=",
"v",
"\n",
"}"
] | // set adds a new binding to the deepest scope | [
"set",
"adds",
"a",
"new",
"binding",
"to",
"the",
"deepest",
"scope"
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/scope.go#L31-L33 |
125,982 | robfig/soy | soyhtml/scope.go | lookup | func (s scope) lookup(k string) data.Value {
for i := range s {
var elem = s[len(s)-i-1].vars
if val, ok := elem[k]; ok {
return val
}
}
return data.Undefined{}
} | go | func (s scope) lookup(k string) data.Value {
for i := range s {
var elem = s[len(s)-i-1].vars
if val, ok := elem[k]; ok {
return val
}
}
return data.Undefined{}
} | [
"func",
"(",
"s",
"scope",
")",
"lookup",
"(",
"k",
"string",
")",
"data",
".",
"Value",
"{",
"for",
"i",
":=",
"range",
"s",
"{",
"var",
"elem",
"=",
"s",
"[",
"len",
"(",
"s",
")",
"-",
"i",
"-",
"1",
"]",
".",
"vars",
"\n",
"if",
"val",
... | // lookup checks the variable scopes, deepest out, for the given key | [
"lookup",
"checks",
"the",
"variable",
"scopes",
"deepest",
"out",
"for",
"the",
"given",
"key"
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/scope.go#L36-L44 |
125,983 | robfig/soy | soyhtml/scope.go | alldata | func (s scope) alldata() scope {
for i := range s {
var ri = len(s) - i - 1
if s[ri].entered {
return s[:ri+1 : ri+1]
}
}
panic("impossible")
} | go | func (s scope) alldata() scope {
for i := range s {
var ri = len(s) - i - 1
if s[ri].entered {
return s[:ri+1 : ri+1]
}
}
panic("impossible")
} | [
"func",
"(",
"s",
"scope",
")",
"alldata",
"(",
")",
"scope",
"{",
"for",
"i",
":=",
"range",
"s",
"{",
"var",
"ri",
"=",
"len",
"(",
"s",
")",
"-",
"i",
"-",
"1",
"\n",
"if",
"s",
"[",
"ri",
"]",
".",
"entered",
"{",
"return",
"s",
"[",
... | // alldata returns a new scope for use when passing data="all" to a template. | [
"alldata",
"returns",
"a",
"new",
"scope",
"for",
"use",
"when",
"passing",
"data",
"=",
"all",
"to",
"a",
"template",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/scope.go#L47-L55 |
125,984 | robfig/soy | soyhtml/scope.go | enter | func (s *scope) enter() {
(*s)[len(*s)-1].entered = true
s.push()
} | go | func (s *scope) enter() {
(*s)[len(*s)-1].entered = true
s.push()
} | [
"func",
"(",
"s",
"*",
"scope",
")",
"enter",
"(",
")",
"{",
"(",
"*",
"s",
")",
"[",
"len",
"(",
"*",
"s",
")",
"-",
"1",
"]",
".",
"entered",
"=",
"true",
"\n",
"s",
".",
"push",
"(",
")",
"\n",
"}"
] | // enter records that this is the frame where we enter a template.
// only the frames up to here will be passed in the next data="all" | [
"enter",
"records",
"that",
"this",
"is",
"the",
"frame",
"where",
"we",
"enter",
"a",
"template",
".",
"only",
"the",
"frames",
"up",
"to",
"here",
"will",
"be",
"passed",
"in",
"the",
"next",
"data",
"=",
"all"
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/soyhtml/scope.go#L59-L62 |
125,985 | robfig/soy | parse/lexer.go | String | func (t itemType) String() string {
for k, v := range builtinIdents {
if v == t {
return k
}
}
for k, v := range arithmeticItemsBySymbol {
if v == t {
return k
}
}
var r, ok = map[itemType]string{
itemEOF: "<eof>",
itemEquals: "=",
itemError: "<error>",
itemT... | go | func (t itemType) String() string {
for k, v := range builtinIdents {
if v == t {
return k
}
}
for k, v := range arithmeticItemsBySymbol {
if v == t {
return k
}
}
var r, ok = map[itemType]string{
itemEOF: "<eof>",
itemEquals: "=",
itemError: "<error>",
itemT... | [
"func",
"(",
"t",
"itemType",
")",
"String",
"(",
")",
"string",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"builtinIdents",
"{",
"if",
"v",
"==",
"t",
"{",
"return",
"k",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"arithme... | // String converts the itemType into its source string.
// It is fantastically inefficient and should only be used for error messages. | [
"String",
"converts",
"the",
"itemType",
"into",
"its",
"source",
"string",
".",
"It",
"is",
"fantastically",
"inefficient",
"and",
"should",
"only",
"be",
"used",
"for",
"error",
"messages",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L253-L286 |
125,986 | robfig/soy | parse/lexer.go | lexExpr | func lexExpr(name, input string) *lexer {
l := &lexer{
name: name,
input: input,
items: make(chan item),
state: lexInsideTag,
}
go l.run()
return l
} | go | func lexExpr(name, input string) *lexer {
l := &lexer{
name: name,
input: input,
items: make(chan item),
state: lexInsideTag,
}
go l.run()
return l
} | [
"func",
"lexExpr",
"(",
"name",
",",
"input",
"string",
")",
"*",
"lexer",
"{",
"l",
":=",
"&",
"lexer",
"{",
"name",
":",
"name",
",",
"input",
":",
"input",
",",
"items",
":",
"make",
"(",
"chan",
"item",
")",
",",
"state",
":",
"lexInsideTag",
... | // lexExpr lexes a single expression. | [
"lexExpr",
"lexes",
"a",
"single",
"expression",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L342-L351 |
125,987 | robfig/soy | parse/lexer.go | lineNumber | func (l *lexer) lineNumber(pos ast.Pos) int {
return 1 + strings.Count(l.input[:pos], "\n")
} | go | func (l *lexer) lineNumber(pos ast.Pos) int {
return 1 + strings.Count(l.input[:pos], "\n")
} | [
"func",
"(",
"l",
"*",
"lexer",
")",
"lineNumber",
"(",
"pos",
"ast",
".",
"Pos",
")",
"int",
"{",
"return",
"1",
"+",
"strings",
".",
"Count",
"(",
"l",
".",
"input",
"[",
":",
"pos",
"]",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}"
] | // lineNumber reports which line we're on. Doing it this way
// means we don't have to worry about peek double counting. | [
"lineNumber",
"reports",
"which",
"line",
"we",
"re",
"on",
".",
"Doing",
"it",
"this",
"way",
"means",
"we",
"don",
"t",
"have",
"to",
"worry",
"about",
"peek",
"double",
"counting",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L419-L421 |
125,988 | robfig/soy | parse/lexer.go | columnNumber | func (l *lexer) columnNumber(pos ast.Pos) int {
n := strings.LastIndex(l.input[:pos], "\n")
if n == -1 {
n = 0
}
return int(pos) - n
} | go | func (l *lexer) columnNumber(pos ast.Pos) int {
n := strings.LastIndex(l.input[:pos], "\n")
if n == -1 {
n = 0
}
return int(pos) - n
} | [
"func",
"(",
"l",
"*",
"lexer",
")",
"columnNumber",
"(",
"pos",
"ast",
".",
"Pos",
")",
"int",
"{",
"n",
":=",
"strings",
".",
"LastIndex",
"(",
"l",
".",
"input",
"[",
":",
"pos",
"]",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"if",
"n",
"==",
"-"... | // columnNumber reports which column in the current line we're on. | [
"columnNumber",
"reports",
"which",
"column",
"in",
"the",
"current",
"line",
"we",
"re",
"on",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L424-L430 |
125,989 | robfig/soy | parse/lexer.go | lexLeftDelim | func lexLeftDelim(l *lexer) stateFn {
l.next() // read the first {
// check the next character to see if it's a double delimiter
if r := l.next(); r == '{' {
l.doubleDelim = true
} else {
l.backup()
l.doubleDelim = false
}
l.emit(itemLeftDelim)
return lexBeginTag
} | go | func lexLeftDelim(l *lexer) stateFn {
l.next() // read the first {
// check the next character to see if it's a double delimiter
if r := l.next(); r == '{' {
l.doubleDelim = true
} else {
l.backup()
l.doubleDelim = false
}
l.emit(itemLeftDelim)
return lexBeginTag
} | [
"func",
"lexLeftDelim",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"l",
".",
"next",
"(",
")",
"// read the first {",
"\n",
"// check the next character to see if it's a double delimiter",
"if",
"r",
":=",
"l",
".",
"next",
"(",
")",
";",
"r",
"==",
"'{'",
... | // lexLeftDelim scans the left template tag delimiter
//
// If there are brace characters within a template tag, double braces must
// be used, so we differentiate them to match double closing braces later.
// Double braces are also optional for other cases. | [
"lexLeftDelim",
"scans",
"the",
"left",
"template",
"tag",
"delimiter",
"If",
"there",
"are",
"brace",
"characters",
"within",
"a",
"template",
"tag",
"double",
"braces",
"must",
"be",
"used",
"so",
"we",
"differentiate",
"them",
"to",
"match",
"double",
"clos... | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L511-L522 |
125,990 | robfig/soy | parse/lexer.go | lexRightDelim | func lexRightDelim(l *lexer) stateFn {
if l.doubleDelim && l.next() != '}' {
return l.errorf("expected double closing braces in tag")
}
l.emit(itemRightDelim)
return lexText
} | go | func lexRightDelim(l *lexer) stateFn {
if l.doubleDelim && l.next() != '}' {
return l.errorf("expected double closing braces in tag")
}
l.emit(itemRightDelim)
return lexText
} | [
"func",
"lexRightDelim",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"if",
"l",
".",
"doubleDelim",
"&&",
"l",
".",
"next",
"(",
")",
"!=",
"'}'",
"{",
"return",
"l",
".",
"errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"l",
".",
"emit",
"(",... | // lexRightDelim scans the right template tag delimiter
// } has already been read. | [
"lexRightDelim",
"scans",
"the",
"right",
"template",
"tag",
"delimiter",
"}",
"has",
"already",
"been",
"read",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L526-L532 |
125,991 | robfig/soy | parse/lexer.go | lexInsideTag | func lexInsideTag(l *lexer) stateFn {
switch r := l.next(); {
case isSpaceEOL(r):
l.ignore()
case r == '/' && l.peek() == '}':
return lexRightDelimEnd
case r == '$', r == '.':
l.backup()
return lexIdent
case r == '[':
l.emit(itemLeftBracket)
case r == ']':
l.emit(itemRightBracket)
case r == '?': // u... | go | func lexInsideTag(l *lexer) stateFn {
switch r := l.next(); {
case isSpaceEOL(r):
l.ignore()
case r == '/' && l.peek() == '}':
return lexRightDelimEnd
case r == '$', r == '.':
l.backup()
return lexIdent
case r == '[':
l.emit(itemLeftBracket)
case r == ']':
l.emit(itemRightBracket)
case r == '?': // u... | [
"func",
"lexInsideTag",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"switch",
"r",
":=",
"l",
".",
"next",
"(",
")",
";",
"{",
"case",
"isSpaceEOL",
"(",
"r",
")",
":",
"l",
".",
"ignore",
"(",
")",
"\n",
"case",
"r",
"==",
"'/'",
"&&",
"l",
... | // lexInsideTag is called repeatedly to scan elements inside a template tag.
// itemLeftDelim has just been emitted. | [
"lexInsideTag",
"is",
"called",
"repeatedly",
"to",
"scan",
"elements",
"inside",
"a",
"template",
"tag",
".",
"itemLeftDelim",
"has",
"just",
"been",
"emitted",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L557-L620 |
125,992 | robfig/soy | parse/lexer.go | stringLexer | func stringLexer(quoteChar rune) stateFn {
// the quote char has already been read.
return func(l *lexer) stateFn {
for {
switch l.next() {
case eof:
l.errorf("unexpected eof while scanning string")
case '\\':
l.next() // skip escape sequences
case quoteChar:
l.emit(itemString)
return le... | go | func stringLexer(quoteChar rune) stateFn {
// the quote char has already been read.
return func(l *lexer) stateFn {
for {
switch l.next() {
case eof:
l.errorf("unexpected eof while scanning string")
case '\\':
l.next() // skip escape sequences
case quoteChar:
l.emit(itemString)
return le... | [
"func",
"stringLexer",
"(",
"quoteChar",
"rune",
")",
"stateFn",
"{",
"// the quote char has already been read.",
"return",
"func",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"for",
"{",
"switch",
"l",
".",
"next",
"(",
")",
"{",
"case",
"eof",
":",
"l",... | // stringLexer returns a stateFn that lexes strings surrounded by the given quote character. | [
"stringLexer",
"returns",
"a",
"stateFn",
"that",
"lexes",
"strings",
"surrounded",
"by",
"the",
"given",
"quote",
"character",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L763-L778 |
125,993 | robfig/soy | parse/lexer.go | lexIdent | func lexIdent(l *lexer) stateFn {
// the different idents start with different unique characters.
// peel those off.
var itemType = itemIdent
switch l.next() {
case '.':
if isDigit(l.next()) {
itemType = itemDotIndex
} else {
itemType = itemDotIdent
}
l.backup()
case '$':
itemType = itemDollarIden... | go | func lexIdent(l *lexer) stateFn {
// the different idents start with different unique characters.
// peel those off.
var itemType = itemIdent
switch l.next() {
case '.':
if isDigit(l.next()) {
itemType = itemDotIndex
} else {
itemType = itemDotIdent
}
l.backup()
case '$':
itemType = itemDollarIden... | [
"func",
"lexIdent",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"// the different idents start with different unique characters.",
"// peel those off.",
"var",
"itemType",
"=",
"itemIdent",
"\n",
"switch",
"l",
".",
"next",
"(",
")",
"{",
"case",
"'.'",
":",
"if"... | // lexIdent recognizes the various kinds of identifiers | [
"lexIdent",
"recognizes",
"the",
"various",
"kinds",
"of",
"identifiers"
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L781-L840 |
125,994 | robfig/soy | parse/lexer.go | allSpaceWithNewline | func allSpaceWithNewline(str string) bool {
var seenNewline = false
for _, ch := range str {
if !unicode.IsSpace(ch) {
return false
}
if isEndOfLine(ch) {
seenNewline = true
}
}
return seenNewline
} | go | func allSpaceWithNewline(str string) bool {
var seenNewline = false
for _, ch := range str {
if !unicode.IsSpace(ch) {
return false
}
if isEndOfLine(ch) {
seenNewline = true
}
}
return seenNewline
} | [
"func",
"allSpaceWithNewline",
"(",
"str",
"string",
")",
"bool",
"{",
"var",
"seenNewline",
"=",
"false",
"\n",
"for",
"_",
",",
"ch",
":=",
"range",
"str",
"{",
"if",
"!",
"unicode",
".",
"IsSpace",
"(",
"ch",
")",
"{",
"return",
"false",
"\n",
"}"... | // allSpaceWithNewline returns true if the entire string consists of whitespace,
// with at least one newline. | [
"allSpaceWithNewline",
"returns",
"true",
"if",
"the",
"entire",
"string",
"consists",
"of",
"whitespace",
"with",
"at",
"least",
"one",
"newline",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/lexer.go#L1024-L1035 |
125,995 | robfig/soy | parse/parse.go | textOrTag | func (t *tree) textOrTag(token item, until []itemType) (node ast.Node, halt bool) {
var seenComment = token.typ == itemComment
for token.typ == itemComment {
token = t.next() // skip any comments
}
// Two ways to end a list:
// 1. We found the until token (e.g. EOF)
if isOneOf(token.typ, until) {
return nil,... | go | func (t *tree) textOrTag(token item, until []itemType) (node ast.Node, halt bool) {
var seenComment = token.typ == itemComment
for token.typ == itemComment {
token = t.next() // skip any comments
}
// Two ways to end a list:
// 1. We found the until token (e.g. EOF)
if isOneOf(token.typ, until) {
return nil,... | [
"func",
"(",
"t",
"*",
"tree",
")",
"textOrTag",
"(",
"token",
"item",
",",
"until",
"[",
"]",
"itemType",
")",
"(",
"node",
"ast",
".",
"Node",
",",
"halt",
"bool",
")",
"{",
"var",
"seenComment",
"=",
"token",
".",
"typ",
"==",
"itemComment",
"\n... | // textOrTag reads raw text or recognizes the start of tags until the end tag. | [
"textOrTag",
"reads",
"raw",
"text",
"or",
"recognizes",
"the",
"start",
"of",
"tags",
"until",
"the",
"end",
"tag",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/parse.go#L71-L115 |
125,996 | robfig/soy | parse/parse.go | parseLet | func (t *tree) parseLet(token item) ast.Node {
var name = t.expect(itemDollarIdent, "let")
if t.peek().typ == itemColon {
t.next()
var node = &ast.LetValueNode{token.pos, name.val[1:], t.parseExpr(0)}
t.expect(itemRightDelimEnd, "let")
return node
}
t.parseAttrs("kind")
switch next := t.next(); next.typ {
... | go | func (t *tree) parseLet(token item) ast.Node {
var name = t.expect(itemDollarIdent, "let")
if t.peek().typ == itemColon {
t.next()
var node = &ast.LetValueNode{token.pos, name.val[1:], t.parseExpr(0)}
t.expect(itemRightDelimEnd, "let")
return node
}
t.parseAttrs("kind")
switch next := t.next(); next.typ {
... | [
"func",
"(",
"t",
"*",
"tree",
")",
"parseLet",
"(",
"token",
"item",
")",
"ast",
".",
"Node",
"{",
"var",
"name",
"=",
"t",
".",
"expect",
"(",
"itemDollarIdent",
",",
"\"",
"\"",
")",
"\n",
"if",
"t",
".",
"peek",
"(",
")",
".",
"typ",
"==",
... | // "let" has just been read. | [
"let",
"has",
"just",
"been",
"read",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/parse.go#L240-L258 |
125,997 | robfig/soy | parse/parse.go | parseCss | func (t *tree) parseCss(token item) ast.Node {
var cmdText = t.expect(itemText, "css")
t.expect(itemRightDelim, "css")
var lastComma = strings.LastIndex(cmdText.val, ",")
if lastComma == -1 {
return &ast.CssNode{token.pos, nil, strings.TrimSpace(cmdText.val)}
}
var exprText = strings.TrimSpace(cmdText.val[:last... | go | func (t *tree) parseCss(token item) ast.Node {
var cmdText = t.expect(itemText, "css")
t.expect(itemRightDelim, "css")
var lastComma = strings.LastIndex(cmdText.val, ",")
if lastComma == -1 {
return &ast.CssNode{token.pos, nil, strings.TrimSpace(cmdText.val)}
}
var exprText = strings.TrimSpace(cmdText.val[:last... | [
"func",
"(",
"t",
"*",
"tree",
")",
"parseCss",
"(",
"token",
"item",
")",
"ast",
".",
"Node",
"{",
"var",
"cmdText",
"=",
"t",
".",
"expect",
"(",
"itemText",
",",
"\"",
"\"",
")",
"\n",
"t",
".",
"expect",
"(",
"itemRightDelim",
",",
"\"",
"\""... | // "css" has just been read. | [
"css",
"has",
"just",
"been",
"read",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/parse.go#L261-L274 |
125,998 | robfig/soy | parse/parse.go | parseCall | func (t *tree) parseCall(token item) ast.Node {
var templateName string
switch tok := t.next(); tok.typ {
case itemDotIdent:
templateName = tok.val
case itemIdent:
// this ident could either be {call fully.qualified.name} or attributes.
switch tok2 := t.next(); tok2.typ {
case itemDotIdent:
templateName ... | go | func (t *tree) parseCall(token item) ast.Node {
var templateName string
switch tok := t.next(); tok.typ {
case itemDotIdent:
templateName = tok.val
case itemIdent:
// this ident could either be {call fully.qualified.name} or attributes.
switch tok2 := t.next(); tok2.typ {
case itemDotIdent:
templateName ... | [
"func",
"(",
"t",
"*",
"tree",
")",
"parseCall",
"(",
"token",
"item",
")",
"ast",
".",
"Node",
"{",
"var",
"templateName",
"string",
"\n",
"switch",
"tok",
":=",
"t",
".",
"next",
"(",
")",
";",
"tok",
".",
"typ",
"{",
"case",
"itemDotIdent",
":",... | // "call" has just been read. | [
"call",
"has",
"just",
"been",
"read",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/parse.go#L277-L338 |
125,999 | robfig/soy | parse/parse.go | parseSwitch | func (t *tree) parseSwitch(token item, end itemType) ast.Node {
const ctx = "switch"
var switchValue = t.parseExpr(0)
t.expect(itemRightDelim, ctx)
var cases []*ast.SwitchCaseNode
for {
switch tok := t.next(); tok.typ {
case itemLeftDelim:
case itemText: // ignore spaces between tags. text is an error thoug... | go | func (t *tree) parseSwitch(token item, end itemType) ast.Node {
const ctx = "switch"
var switchValue = t.parseExpr(0)
t.expect(itemRightDelim, ctx)
var cases []*ast.SwitchCaseNode
for {
switch tok := t.next(); tok.typ {
case itemLeftDelim:
case itemText: // ignore spaces between tags. text is an error thoug... | [
"func",
"(",
"t",
"*",
"tree",
")",
"parseSwitch",
"(",
"token",
"item",
",",
"end",
"itemType",
")",
"ast",
".",
"Node",
"{",
"const",
"ctx",
"=",
"\"",
"\"",
"\n",
"var",
"switchValue",
"=",
"t",
".",
"parseExpr",
"(",
"0",
")",
"\n",
"t",
".",... | // "switch" has just been read. | [
"switch",
"has",
"just",
"been",
"read",
"."
] | 6b9d0368d4265c382c3e11fe774d93aa8d431064 | https://github.com/robfig/soy/blob/6b9d0368d4265c382c3e11fe774d93aa8d431064/parse/parse.go#L423-L444 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.