repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
janos/web | templates/templates.go | WithTemplateFromStrings | func WithTemplateFromStrings(name string, strings ...string) Option {
return func(o *Options) { o.strings[name] = strings }
} | go | func WithTemplateFromStrings(name string, strings ...string) Option {
return func(o *Options) { o.strings[name] = strings }
} | [
"func",
"WithTemplateFromStrings",
"(",
"name",
"string",
",",
"strings",
"...",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"strings",
"[",
"name",
"]",
"=",
"strings",
"}",
"\n",
"}"
] | // WithTemplateFromStrings adds a template parsed from string. | [
"WithTemplateFromStrings",
"adds",
"a",
"template",
"parsed",
"from",
"string",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L101-L103 | test |
janos/web | templates/templates.go | WithTemplatesFromStrings | func WithTemplatesFromStrings(ts map[string][]string) Option {
return func(o *Options) {
for name, strings := range ts {
o.strings[name] = strings
}
}
} | go | func WithTemplatesFromStrings(ts map[string][]string) Option {
return func(o *Options) {
for name, strings := range ts {
o.strings[name] = strings
}
}
} | [
"func",
"WithTemplatesFromStrings",
"(",
"ts",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"for",
"name",
",",
"strings",
":=",
"range",
"ts",
"{",
"o",
".",
"strings",
"[",... | // WithTemplatesFromStrings adds a map of templates parsed from strings. | [
"WithTemplatesFromStrings",
"adds",
"a",
"map",
"of",
"templates",
"parsed",
"from",
"strings",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L106-L112 | test |
janos/web | templates/templates.go | WithFunction | func WithFunction(name string, fn interface{}) Option {
return func(o *Options) { o.functions[name] = fn }
} | go | func WithFunction(name string, fn interface{}) Option {
return func(o *Options) { o.functions[name] = fn }
} | [
"func",
"WithFunction",
"(",
"name",
"string",
",",
"fn",
"interface",
"{",
"}",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"functions",
"[",
"name",
"]",
"=",
"fn",
"}",
"\n",
"}"
] | // WithFunction adds a function to templates. | [
"WithFunction",
"adds",
"a",
"function",
"to",
"templates",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L115-L117 | test |
janos/web | templates/templates.go | WithFunctions | func WithFunctions(fns template.FuncMap) Option {
return func(o *Options) {
for name, fn := range fns {
o.functions[name] = fn
}
}
} | go | func WithFunctions(fns template.FuncMap) Option {
return func(o *Options) {
for name, fn := range fns {
o.functions[name] = fn
}
}
} | [
"func",
"WithFunctions",
"(",
"fns",
"template",
".",
"FuncMap",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"for",
"name",
",",
"fn",
":=",
"range",
"fns",
"{",
"o",
".",
"functions",
"[",
"name",
"]",
"=",
"fn",
"\n"... | // WithFunctions adds function map to templates. | [
"WithFunctions",
"adds",
"function",
"map",
"to",
"templates",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L120-L126 | test |
janos/web | templates/templates.go | WithDelims | func WithDelims(open, close string) Option {
return func(o *Options) {
o.delimOpen = open
o.delimClose = close
}
} | go | func WithDelims(open, close string) Option {
return func(o *Options) {
o.delimOpen = open
o.delimClose = close
}
} | [
"func",
"WithDelims",
"(",
"open",
",",
"close",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"delimOpen",
"=",
"open",
"\n",
"o",
".",
"delimClose",
"=",
"close",
"\n",
"}",
"\n",
"}"
] | // WithDelims sets the delimiters used in templates. | [
"WithDelims",
"sets",
"the",
"delimiters",
"used",
"in",
"templates",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L129-L134 | test |
janos/web | templates/templates.go | New | func New(opts ...Option) (t *Templates, err error) {
functions := template.FuncMap{}
for name, fn := range defaultFunctions {
functions[name] = fn
}
o := &Options{
fileFindFunc: func(f string) string {
return f
},
fileReadFunc: ioutil.ReadFile,
files: map[string][]string{},
functions: funct... | go | func New(opts ...Option) (t *Templates, err error) {
functions := template.FuncMap{}
for name, fn := range defaultFunctions {
functions[name] = fn
}
o := &Options{
fileFindFunc: func(f string) string {
return f
},
fileReadFunc: ioutil.ReadFile,
files: map[string][]string{},
functions: funct... | [
"func",
"New",
"(",
"opts",
"...",
"Option",
")",
"(",
"t",
"*",
"Templates",
",",
"err",
"error",
")",
"{",
"functions",
":=",
"template",
".",
"FuncMap",
"{",
"}",
"\n",
"for",
"name",
",",
"fn",
":=",
"range",
"defaultFunctions",
"{",
"functions",
... | // New creates a new instance of Templates and parses
// provided files and strings. | [
"New",
"creates",
"a",
"new",
"instance",
"of",
"Templates",
"and",
"parses",
"provided",
"files",
"and",
"strings",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L152-L196 | test |
janos/web | templates/templates.go | RespondWithStatus | func (t Templates) RespondWithStatus(w http.ResponseWriter, name string, data interface{}, status int) {
buf := bytes.Buffer{}
tpl, ok := t.templates[name]
if !ok {
panic(&Error{Err: ErrUnknownTemplate, Template: name})
}
if err := tpl.Execute(&buf, data); err != nil {
panic(err)
}
if t.contentType != "" {
... | go | func (t Templates) RespondWithStatus(w http.ResponseWriter, name string, data interface{}, status int) {
buf := bytes.Buffer{}
tpl, ok := t.templates[name]
if !ok {
panic(&Error{Err: ErrUnknownTemplate, Template: name})
}
if err := tpl.Execute(&buf, data); err != nil {
panic(err)
}
if t.contentType != "" {
... | [
"func",
"(",
"t",
"Templates",
")",
"RespondWithStatus",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"name",
"string",
",",
"data",
"interface",
"{",
"}",
",",
"status",
"int",
")",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"tpl",
"... | // RespondWithStatus executes a template with provided data into buffer,
// then writes the the status and body to the response writer.
// A panic will be raised if the template does not exist or fails to execute. | [
"RespondWithStatus",
"executes",
"a",
"template",
"with",
"provided",
"data",
"into",
"buffer",
"then",
"writes",
"the",
"the",
"status",
"and",
"body",
"to",
"the",
"response",
"writer",
".",
"A",
"panic",
"will",
"be",
"raised",
"if",
"the",
"template",
"d... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L224-L242 | test |
janos/web | templates/templates.go | RespondTemplate | func (t Templates) RespondTemplate(w http.ResponseWriter, name, templateName string, data interface{}) {
t.RespondTemplateWithStatus(w, name, templateName, data, 0)
} | go | func (t Templates) RespondTemplate(w http.ResponseWriter, name, templateName string, data interface{}) {
t.RespondTemplateWithStatus(w, name, templateName, data, 0)
} | [
"func",
"(",
"t",
"Templates",
")",
"RespondTemplate",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"name",
",",
"templateName",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"RespondTemplateWithStatus",
"(",
"w",
",",
"name",
",",
"... | // RespondTemplate executes a named template with provided data into buffer,
// then writes the the body to the response writer.
// A panic will be raised if the template does not exist or fails to execute. | [
"RespondTemplate",
"executes",
"a",
"named",
"template",
"with",
"provided",
"data",
"into",
"buffer",
"then",
"writes",
"the",
"the",
"body",
"to",
"the",
"response",
"writer",
".",
"A",
"panic",
"will",
"be",
"raised",
"if",
"the",
"template",
"does",
"not... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L247-L249 | test |
janos/web | templates/templates.go | Respond | func (t Templates) Respond(w http.ResponseWriter, name string, data interface{}) {
t.RespondWithStatus(w, name, data, 0)
} | go | func (t Templates) Respond(w http.ResponseWriter, name string, data interface{}) {
t.RespondWithStatus(w, name, data, 0)
} | [
"func",
"(",
"t",
"Templates",
")",
"Respond",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"name",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"RespondWithStatus",
"(",
"w",
",",
"name",
",",
"data",
",",
"0",
")",
"\n",
"}"... | // Respond executes template with provided data into buffer,
// then writes the the body to the response writer.
// A panic will be raised if the template does not exist or fails to execute. | [
"Respond",
"executes",
"template",
"with",
"provided",
"data",
"into",
"buffer",
"then",
"writes",
"the",
"the",
"body",
"to",
"the",
"response",
"writer",
".",
"A",
"panic",
"will",
"be",
"raised",
"if",
"the",
"template",
"does",
"not",
"exist",
"or",
"f... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L254-L256 | test |
janos/web | templates/templates.go | RenderTemplate | func (t Templates) RenderTemplate(name, templateName string, data interface{}) (s string, err error) {
buf := bytes.Buffer{}
tpl, ok := t.templates[name]
if !ok {
return "", &Error{Err: ErrUnknownTemplate, Template: name}
}
if err := tpl.ExecuteTemplate(&buf, templateName, data); err != nil {
return "", err
}... | go | func (t Templates) RenderTemplate(name, templateName string, data interface{}) (s string, err error) {
buf := bytes.Buffer{}
tpl, ok := t.templates[name]
if !ok {
return "", &Error{Err: ErrUnknownTemplate, Template: name}
}
if err := tpl.ExecuteTemplate(&buf, templateName, data); err != nil {
return "", err
}... | [
"func",
"(",
"t",
"Templates",
")",
"RenderTemplate",
"(",
"name",
",",
"templateName",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"s",
"string",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"tpl",
... | // RenderTemplate executes a named template and returns the string. | [
"RenderTemplate",
"executes",
"a",
"named",
"template",
"and",
"returns",
"the",
"string",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L259-L269 | test |
janos/web | servers/quic/quic.go | New | func New(handler http.Handler, opts ...Option) (s *Server) {
o := &Options{}
for _, opt := range opts {
opt(o)
}
s = &Server{
Server: &h2quic.Server{
Server: &http.Server{
Handler: handler,
TLSConfig: o.tlsConfig,
},
},
}
return
} | go | func New(handler http.Handler, opts ...Option) (s *Server) {
o := &Options{}
for _, opt := range opts {
opt(o)
}
s = &Server{
Server: &h2quic.Server{
Server: &http.Server{
Handler: handler,
TLSConfig: o.tlsConfig,
},
},
}
return
} | [
"func",
"New",
"(",
"handler",
"http",
".",
"Handler",
",",
"opts",
"...",
"Option",
")",
"(",
"s",
"*",
"Server",
")",
"{",
"o",
":=",
"&",
"Options",
"{",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"o",
")",
... | // New creates a new instance of Server. | [
"New",
"creates",
"a",
"new",
"instance",
"of",
"Server",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/quic/quic.go#L44-L58 | test |
janos/web | servers/quic/quic.go | ServeUDP | func (s *Server) ServeUDP(conn *net.UDPConn) (err error) {
s.Server.Server.Addr = conn.LocalAddr().String()
return s.Server.Serve(conn)
} | go | func (s *Server) ServeUDP(conn *net.UDPConn) (err error) {
s.Server.Server.Addr = conn.LocalAddr().String()
return s.Server.Serve(conn)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ServeUDP",
"(",
"conn",
"*",
"net",
".",
"UDPConn",
")",
"(",
"err",
"error",
")",
"{",
"s",
".",
"Server",
".",
"Server",
".",
"Addr",
"=",
"conn",
".",
"LocalAddr",
"(",
")",
".",
"String",
"(",
")",
"\n... | // ServeUDP serves requests over UDP connection. | [
"ServeUDP",
"serves",
"requests",
"over",
"UDP",
"connection",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/quic/quic.go#L61-L64 | test |
janos/web | servers/quic/quic.go | Shutdown | func (s *Server) Shutdown(_ context.Context) (err error) {
return s.Server.Close()
} | go | func (s *Server) Shutdown(_ context.Context) (err error) {
return s.Server.Close()
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Shutdown",
"(",
"_",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"s",
".",
"Server",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Shutdown calls h2quic.Server.Close method. | [
"Shutdown",
"calls",
"h2quic",
".",
"Server",
".",
"Close",
"method",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/quic/quic.go#L67-L69 | test |
janos/web | servers/quic/quic.go | QuicHeadersHandler | func (s *Server) QuicHeadersHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s.SetQuicHeaders(w.Header())
h.ServeHTTP(w, r)
})
} | go | func (s *Server) QuicHeadersHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s.SetQuicHeaders(w.Header())
h.ServeHTTP(w, r)
})
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"QuicHeadersHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"R... | // QuicHeadersHandler should be used as a middleware to set
// quic related headers to TCP server that suggest alternative svc. | [
"QuicHeadersHandler",
"should",
"be",
"used",
"as",
"a",
"middleware",
"to",
"set",
"quic",
"related",
"headers",
"to",
"TCP",
"server",
"that",
"suggest",
"alternative",
"svc",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/quic/quic.go#L73-L78 | test |
janos/web | request.go | GetRequestIPs | func GetRequestIPs(r *http.Request) string {
ip, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
ip = r.RemoteAddr
}
ips := []string{ip}
xfr := r.Header.Get("X-Forwarded-For")
if xfr != "" {
ips = append(ips, xfr)
}
xri := r.Header.Get("X-Real-Ip")
if xri != "" {
ips = append(ips, xri)
}
retu... | go | func GetRequestIPs(r *http.Request) string {
ip, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
ip = r.RemoteAddr
}
ips := []string{ip}
xfr := r.Header.Get("X-Forwarded-For")
if xfr != "" {
ips = append(ips, xfr)
}
xri := r.Header.Get("X-Real-Ip")
if xri != "" {
ips = append(ips, xri)
}
retu... | [
"func",
"GetRequestIPs",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"ip",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"r",
".",
"RemoteAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ip",
"=",
"r",
".",
"Remote... | // GetRequestIPs returns all possible IPs found in HTTP request. | [
"GetRequestIPs",
"returns",
"all",
"possible",
"IPs",
"found",
"in",
"HTTP",
"request",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/request.go#L15-L30 | test |
janos/web | domain_redirect.go | DomainRedirectHandler | func DomainRedirectHandler(h http.Handler, domain, httpsPort string) http.Handler {
if domain == "" && httpsPort == "" {
return h
}
scheme := "http"
port := ""
if httpsPort != "" {
if _, err := strconv.Atoi(httpsPort); err == nil {
scheme = "https"
port = httpsPort
}
if _, p, err := net.SplitHostPor... | go | func DomainRedirectHandler(h http.Handler, domain, httpsPort string) http.Handler {
if domain == "" && httpsPort == "" {
return h
}
scheme := "http"
port := ""
if httpsPort != "" {
if _, err := strconv.Atoi(httpsPort); err == nil {
scheme = "https"
port = httpsPort
}
if _, p, err := net.SplitHostPor... | [
"func",
"DomainRedirectHandler",
"(",
"h",
"http",
".",
"Handler",
",",
"domain",
",",
"httpsPort",
"string",
")",
"http",
".",
"Handler",
"{",
"if",
"domain",
"==",
"\"\"",
"&&",
"httpsPort",
"==",
"\"\"",
"{",
"return",
"h",
"\n",
"}",
"\n",
"scheme",
... | // DomainRedirectHandler responds with redirect url based on
// domain and httpsPort, othervise it executes the handler. | [
"DomainRedirectHandler",
"responds",
"with",
"redirect",
"url",
"based",
"on",
"domain",
"and",
"httpsPort",
"othervise",
"it",
"executes",
"the",
"handler",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/domain_redirect.go#L17-L76 | test |
janos/web | servers/servers.go | New | func New(opts ...Option) (s *Servers) {
s = &Servers{
logger: stdLogger{},
recover: func() {},
}
for _, opt := range opts {
opt(s)
}
return
} | go | func New(opts ...Option) (s *Servers) {
s = &Servers{
logger: stdLogger{},
recover: func() {},
}
for _, opt := range opts {
opt(s)
}
return
} | [
"func",
"New",
"(",
"opts",
"...",
"Option",
")",
"(",
"s",
"*",
"Servers",
")",
"{",
"s",
"=",
"&",
"Servers",
"{",
"logger",
":",
"stdLogger",
"{",
"}",
",",
"recover",
":",
"func",
"(",
")",
"{",
"}",
",",
"}",
"\n",
"for",
"_",
",",
"opt"... | // New creates a new instance of Servers with applied options. | [
"New",
"creates",
"a",
"new",
"instance",
"of",
"Servers",
"with",
"applied",
"options",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L55-L64 | test |
janos/web | servers/servers.go | Add | func (s *Servers) Add(name, address string, srv Server) {
s.mu.Lock()
s.servers = append(s.servers, &server{
Server: srv,
name: name,
address: address,
})
s.mu.Unlock()
} | go | func (s *Servers) Add(name, address string, srv Server) {
s.mu.Lock()
s.servers = append(s.servers, &server{
Server: srv,
name: name,
address: address,
})
s.mu.Unlock()
} | [
"func",
"(",
"s",
"*",
"Servers",
")",
"Add",
"(",
"name",
",",
"address",
"string",
",",
"srv",
"Server",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"servers",
"=",
"append",
"(",
"s",
".",
"servers",
",",
"&",
"server",
... | // Add adds a new server instance by a custom name and with
// address to listen to. | [
"Add",
"adds",
"a",
"new",
"server",
"instance",
"by",
"a",
"custom",
"name",
"and",
"with",
"address",
"to",
"listen",
"to",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L123-L131 | test |
janos/web | servers/servers.go | TCPAddr | func (s *Servers) TCPAddr(name string) (a *net.TCPAddr) {
s.mu.Lock()
defer s.mu.Unlock()
for _, srv := range s.servers {
if srv.name == name {
return srv.tcpAddr
}
}
return nil
} | go | func (s *Servers) TCPAddr(name string) (a *net.TCPAddr) {
s.mu.Lock()
defer s.mu.Unlock()
for _, srv := range s.servers {
if srv.name == name {
return srv.tcpAddr
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Servers",
")",
"TCPAddr",
"(",
"name",
"string",
")",
"(",
"a",
"*",
"net",
".",
"TCPAddr",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
"... | // TCPAddr returns a TCP address of the listener that a server
// with a specific name is using. If there are more servers
// with the same name, the address of the first started server
// is returned. | [
"TCPAddr",
"returns",
"a",
"TCP",
"address",
"of",
"the",
"listener",
"that",
"a",
"server",
"with",
"a",
"specific",
"name",
"is",
"using",
".",
"If",
"there",
"are",
"more",
"servers",
"with",
"the",
"same",
"name",
"the",
"address",
"of",
"the",
"firs... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L203-L213 | test |
janos/web | servers/servers.go | UDPAddr | func (s *Servers) UDPAddr(name string) (a *net.UDPAddr) {
s.mu.Lock()
defer s.mu.Unlock()
for _, srv := range s.servers {
if srv.name == name {
return srv.udpAddr
}
}
return nil
} | go | func (s *Servers) UDPAddr(name string) (a *net.UDPAddr) {
s.mu.Lock()
defer s.mu.Unlock()
for _, srv := range s.servers {
if srv.name == name {
return srv.udpAddr
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Servers",
")",
"UDPAddr",
"(",
"name",
"string",
")",
"(",
"a",
"*",
"net",
".",
"UDPAddr",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
"... | // UDPAddr returns a UDP address of the listener that a server
// with a specific name is using. If there are more servers
// with the same name, the address of the first started server
// is returned. | [
"UDPAddr",
"returns",
"a",
"UDP",
"address",
"of",
"the",
"listener",
"that",
"a",
"server",
"with",
"a",
"specific",
"name",
"is",
"using",
".",
"If",
"there",
"are",
"more",
"servers",
"with",
"the",
"same",
"name",
"the",
"address",
"of",
"the",
"firs... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L219-L229 | test |
janos/web | servers/servers.go | Close | func (s *Servers) Close() {
wg := &sync.WaitGroup{}
for _, srv := range s.servers {
wg.Add(1)
go func(srv *server) {
defer s.recover()
defer wg.Done()
s.logger.Infof("%s closing", srv.label())
if err := srv.Close(); err != nil {
s.logger.Errorf("%s close: %v", srv.label(), err)
}
}(srv)
}
... | go | func (s *Servers) Close() {
wg := &sync.WaitGroup{}
for _, srv := range s.servers {
wg.Add(1)
go func(srv *server) {
defer s.recover()
defer wg.Done()
s.logger.Infof("%s closing", srv.label())
if err := srv.Close(); err != nil {
s.logger.Errorf("%s close: %v", srv.label(), err)
}
}(srv)
}
... | [
"func",
"(",
"s",
"*",
"Servers",
")",
"Close",
"(",
")",
"{",
"wg",
":=",
"&",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"for",
"_",
",",
"srv",
":=",
"range",
"s",
".",
"servers",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
... | // Close stops all servers, by calling Close method on each of them. | [
"Close",
"stops",
"all",
"servers",
"by",
"calling",
"Close",
"method",
"on",
"each",
"of",
"them",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L232-L248 | test |
janos/web | servers/servers.go | Shutdown | func (s *Servers) Shutdown(ctx context.Context) {
wg := &sync.WaitGroup{}
for _, srv := range s.servers {
wg.Add(1)
go func(srv *server) {
defer s.recover()
defer wg.Done()
s.logger.Infof("%s shutting down", srv.label())
if err := srv.Shutdown(ctx); err != nil {
s.logger.Errorf("%s shutdown: %v",... | go | func (s *Servers) Shutdown(ctx context.Context) {
wg := &sync.WaitGroup{}
for _, srv := range s.servers {
wg.Add(1)
go func(srv *server) {
defer s.recover()
defer wg.Done()
s.logger.Infof("%s shutting down", srv.label())
if err := srv.Shutdown(ctx); err != nil {
s.logger.Errorf("%s shutdown: %v",... | [
"func",
"(",
"s",
"*",
"Servers",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"wg",
":=",
"&",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"for",
"_",
",",
"srv",
":=",
"range",
"s",
".",
"servers",
"{",
"wg",
".",
"Add",
"(... | // Shutdown gracefully stops all servers, by calling Shutdown method on each of them. | [
"Shutdown",
"gracefully",
"stops",
"all",
"servers",
"by",
"calling",
"Shutdown",
"method",
"on",
"each",
"of",
"them",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/servers.go#L251-L267 | test |
janos/web | https_redirect.go | Accept | func (l TLSListener) Accept() (net.Conn, error) {
c, err := l.AcceptTCP()
if err != nil {
return nil, err
}
c.SetKeepAlive(true)
c.SetKeepAlivePeriod(3 * time.Minute)
b := make([]byte, 1)
_, err = c.Read(b)
if err != nil {
c.Close()
if err != io.EOF {
return nil, err
}
}
con := &conn{
Conn: c,
... | go | func (l TLSListener) Accept() (net.Conn, error) {
c, err := l.AcceptTCP()
if err != nil {
return nil, err
}
c.SetKeepAlive(true)
c.SetKeepAlivePeriod(3 * time.Minute)
b := make([]byte, 1)
_, err = c.Read(b)
if err != nil {
c.Close()
if err != io.EOF {
return nil, err
}
}
con := &conn{
Conn: c,
... | [
"func",
"(",
"l",
"TLSListener",
")",
"Accept",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"l",
".",
"AcceptTCP",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\... | // Accept accepts TCP connection, sets keep alive and checks if a client
// requested an encrypted connection. | [
"Accept",
"accepts",
"TCP",
"connection",
"sets",
"keep",
"alive",
"and",
"checks",
"if",
"a",
"client",
"requested",
"an",
"encrypted",
"connection",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/https_redirect.go#L52-L81 | test |
janos/web | static_files.go | NewStaticFilesHandler | func NewStaticFilesHandler(h http.Handler, prefix string, fs http.FileSystem) http.Handler {
fileserver := http.StripPrefix(prefix, http.FileServer(fs))
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
filename := strings.TrimPrefix(r.URL.Path, prefix)
_, err := fs.Open(filename)
if err !=... | go | func NewStaticFilesHandler(h http.Handler, prefix string, fs http.FileSystem) http.Handler {
fileserver := http.StripPrefix(prefix, http.FileServer(fs))
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
filename := strings.TrimPrefix(r.URL.Path, prefix)
_, err := fs.Open(filename)
if err !=... | [
"func",
"NewStaticFilesHandler",
"(",
"h",
"http",
".",
"Handler",
",",
"prefix",
"string",
",",
"fs",
"http",
".",
"FileSystem",
")",
"http",
".",
"Handler",
"{",
"fileserver",
":=",
"http",
".",
"StripPrefix",
"(",
"prefix",
",",
"http",
".",
"FileServer... | // NewStaticFilesHandler serves a file under specified filesystem if it
// can be opened, otherwise it serves HTTP from a specified handler. | [
"NewStaticFilesHandler",
"serves",
"a",
"file",
"under",
"specified",
"filesystem",
"if",
"it",
"can",
"be",
"opened",
"otherwise",
"it",
"serves",
"HTTP",
"from",
"a",
"specified",
"handler",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/static_files.go#L15-L26 | test |
janos/web | auth.go | ServeHTTP | func (h AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
valid, entity, err := h.authenticate(r)
if err != nil {
h.error(w, r, err)
return
}
if h.PostAuthFunc != nil {
rr, err := h.PostAuthFunc(w, r, valid, entity)
if err != nil {
h.error(w, r, err)
return
}
if rr != nil {
r = r... | go | func (h AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
valid, entity, err := h.authenticate(r)
if err != nil {
h.error(w, r, err)
return
}
if h.PostAuthFunc != nil {
rr, err := h.PostAuthFunc(w, r, valid, entity)
if err != nil {
h.error(w, r, err)
return
}
if rr != nil {
r = r... | [
"func",
"(",
"h",
"AuthHandler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"valid",
",",
"entity",
",",
"err",
":=",
"h",
".",
"authenticate",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",... | // ServeHTTP serves an HTTP response for a request. | [
"ServeHTTP",
"serves",
"an",
"HTTP",
"response",
"for",
"a",
"request",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/auth.go#L64-L88 | test |
janos/web | client/http/http_client.go | MarshalJSON | func (o Options) MarshalJSON() ([]byte, error) {
return json.Marshal(optionsJSON{
Timeout: marshal.Duration(o.Timeout),
KeepAlive: marshal.Duration(o.KeepAlive),
TLSHandshakeTimeout: marshal.Duration(o.TLSHandshakeTimeout),
TLSSkipVerify: o.TLSSkipVerify,
RetryTimeMax: mars... | go | func (o Options) MarshalJSON() ([]byte, error) {
return json.Marshal(optionsJSON{
Timeout: marshal.Duration(o.Timeout),
KeepAlive: marshal.Duration(o.KeepAlive),
TLSHandshakeTimeout: marshal.Duration(o.TLSHandshakeTimeout),
TLSSkipVerify: o.TLSSkipVerify,
RetryTimeMax: mars... | [
"func",
"(",
"o",
"Options",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"optionsJSON",
"{",
"Timeout",
":",
"marshal",
".",
"Duration",
"(",
"o",
".",
"Timeout",
")",
",",
"Ke... | // MarshalJSON implements of json.Marshaler interface.
// It marshals string representations of time.Duration. | [
"MarshalJSON",
"implements",
"of",
"json",
".",
"Marshaler",
"interface",
".",
"It",
"marshals",
"string",
"representations",
"of",
"time",
".",
"Duration",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/http/http_client.go#L137-L147 | test |
janos/web | client/http/http_client.go | UnmarshalJSON | func (o *Options) UnmarshalJSON(data []byte) error {
v := &optionsJSON{}
if err := json.Unmarshal(data, v); err != nil {
return err
}
*o = Options{
Timeout: v.Timeout.Duration(),
KeepAlive: v.KeepAlive.Duration(),
TLSHandshakeTimeout: v.TLSHandshakeTimeout.Duration(),
TLSSkipVerify: ... | go | func (o *Options) UnmarshalJSON(data []byte) error {
v := &optionsJSON{}
if err := json.Unmarshal(data, v); err != nil {
return err
}
*o = Options{
Timeout: v.Timeout.Duration(),
KeepAlive: v.KeepAlive.Duration(),
TLSHandshakeTimeout: v.TLSHandshakeTimeout.Duration(),
TLSSkipVerify: ... | [
"func",
"(",
"o",
"*",
"Options",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"v",
":=",
"&",
"optionsJSON",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"v",
")",
";",
"err",
"!=",
... | // UnmarshalJSON implements json.Unamrshaler interface.
// It parses time.Duration as strings. | [
"UnmarshalJSON",
"implements",
"json",
".",
"Unamrshaler",
"interface",
".",
"It",
"parses",
"time",
".",
"Duration",
"as",
"strings",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/http/http_client.go#L151-L166 | test |
janos/web | client/http/http_client.go | MarshalYAML | func (o Options) MarshalYAML() (interface{}, error) {
return optionsJSON{
Timeout: marshal.Duration(o.Timeout),
KeepAlive: marshal.Duration(o.KeepAlive),
TLSHandshakeTimeout: marshal.Duration(o.TLSHandshakeTimeout),
TLSSkipVerify: o.TLSSkipVerify,
RetryTimeMax: marshal.Dura... | go | func (o Options) MarshalYAML() (interface{}, error) {
return optionsJSON{
Timeout: marshal.Duration(o.Timeout),
KeepAlive: marshal.Duration(o.KeepAlive),
TLSHandshakeTimeout: marshal.Duration(o.TLSHandshakeTimeout),
TLSSkipVerify: o.TLSSkipVerify,
RetryTimeMax: marshal.Dura... | [
"func",
"(",
"o",
"Options",
")",
"MarshalYAML",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"optionsJSON",
"{",
"Timeout",
":",
"marshal",
".",
"Duration",
"(",
"o",
".",
"Timeout",
")",
",",
"KeepAlive",
":",
"marshal",
... | // MarshalYAML implements of yaml.Marshaler interface.
// It marshals string representations of time.Duration. | [
"MarshalYAML",
"implements",
"of",
"yaml",
".",
"Marshaler",
"interface",
".",
"It",
"marshals",
"string",
"representations",
"of",
"time",
".",
"Duration",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/http/http_client.go#L170-L180 | test |
janos/web | client/http/http_client.go | UnmarshalYAML | func (o *Options) UnmarshalYAML(unmarshal func(interface{}) error) error {
v := &optionsJSON{}
if err := unmarshal(v); err != nil {
return err
}
*o = Options{
Timeout: v.Timeout.Duration(),
KeepAlive: v.KeepAlive.Duration(),
TLSHandshakeTimeout: v.TLSHandshakeTimeout.Duration(),
TLSS... | go | func (o *Options) UnmarshalYAML(unmarshal func(interface{}) error) error {
v := &optionsJSON{}
if err := unmarshal(v); err != nil {
return err
}
*o = Options{
Timeout: v.Timeout.Duration(),
KeepAlive: v.KeepAlive.Duration(),
TLSHandshakeTimeout: v.TLSHandshakeTimeout.Duration(),
TLSS... | [
"func",
"(",
"o",
"*",
"Options",
")",
"UnmarshalYAML",
"(",
"unmarshal",
"func",
"(",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"v",
":=",
"&",
"optionsJSON",
"{",
"}",
"\n",
"if",
"err",
":=",
"unmarshal",
"(",
"v",
")",
";",
"err",... | // UnmarshalYAML implements yaml.Unamrshaler interface.
// It parses time.Duration as strings. | [
"UnmarshalYAML",
"implements",
"yaml",
".",
"Unamrshaler",
"interface",
".",
"It",
"parses",
"time",
".",
"Duration",
"as",
"strings",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/http/http_client.go#L184-L199 | test |
janos/web | log/access/access_log.go | NewHandler | func NewHandler(h http.Handler, logger *logging.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
startTime := time.Now()
rl := &responseLogger{w, 0, 0}
h.ServeHTTP(rl, r)
referrer := r.Referer()
if referrer == "" {
referrer = "-"
}
userAgent := r.UserAgent(... | go | func NewHandler(h http.Handler, logger *logging.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
startTime := time.Now()
rl := &responseLogger{w, 0, 0}
h.ServeHTTP(rl, r)
referrer := r.Referer()
if referrer == "" {
referrer = "-"
}
userAgent := r.UserAgent(... | [
"func",
"NewHandler",
"(",
"h",
"http",
".",
"Handler",
",",
"logger",
"*",
"logging",
".",
"Logger",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
... | // NewHandler returns a handler that logs HTTP requests.
// It logs information about remote address, X-Forwarded-For or X-Real-Ip,
// HTTP method, request URI, HTTP protocol, HTTP response status, total bytes
// written to http.ResponseWriter, response duration, HTTP referrer and
// HTTP client user agent. | [
"NewHandler",
"returns",
"a",
"handler",
"that",
"logs",
"HTTP",
"requests",
".",
"It",
"logs",
"information",
"about",
"remote",
"address",
"X",
"-",
"Forwarded",
"-",
"For",
"or",
"X",
"-",
"Real",
"-",
"Ip",
"HTTP",
"method",
"request",
"URI",
"HTTP",
... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/log/access/access_log.go#L58-L99 | test |
janos/web | recovery/recovery.go | WithPanicResponse | func WithPanicResponse(body, contentType string) Option {
return func(o *Handler) {
o.panicBody = body
o.panicContentType = contentType
}
} | go | func WithPanicResponse(body, contentType string) Option {
return func(o *Handler) {
o.panicBody = body
o.panicContentType = contentType
}
} | [
"func",
"WithPanicResponse",
"(",
"body",
",",
"contentType",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Handler",
")",
"{",
"o",
".",
"panicBody",
"=",
"body",
"\n",
"o",
".",
"panicContentType",
"=",
"contentType",
"\n",
"}",
"\n",... | // WithPanicResponse sets a fixed body and its content type HTTP header
// that will be returned as HTTP response on panic event.
// If WithPanicResponseHandler is defined, this options are ignored. | [
"WithPanicResponse",
"sets",
"a",
"fixed",
"body",
"and",
"its",
"content",
"type",
"HTTP",
"header",
"that",
"will",
"be",
"returned",
"as",
"HTTP",
"response",
"on",
"panic",
"event",
".",
"If",
"WithPanicResponseHandler",
"is",
"defined",
"this",
"options",
... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/recovery/recovery.go#L38-L43 | test |
janos/web | recovery/recovery.go | WithPanicResponseHandler | func WithPanicResponseHandler(h http.Handler) Option {
return func(o *Handler) { o.panicResponseHandler = h }
} | go | func WithPanicResponseHandler(h http.Handler) Option {
return func(o *Handler) { o.panicResponseHandler = h }
} | [
"func",
"WithPanicResponseHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Handler",
")",
"{",
"o",
".",
"panicResponseHandler",
"=",
"h",
"}",
"\n",
"}"
] | // WithPanicResponseHandler sets http.Handler that will be executed on
// panic event. It is useful when the response has dynamic content.
// If the content is static it is better to use WithPanicResponse option
// instead. This option has a precedence upon WithPanicResponse. | [
"WithPanicResponseHandler",
"sets",
"http",
".",
"Handler",
"that",
"will",
"be",
"executed",
"on",
"panic",
"event",
".",
"It",
"is",
"useful",
"when",
"the",
"response",
"has",
"dynamic",
"content",
".",
"If",
"the",
"content",
"is",
"static",
"it",
"is",
... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/recovery/recovery.go#L49-L51 | test |
janos/web | recovery/recovery.go | New | func New(handler http.Handler, options ...Option) (h *Handler) {
h = &Handler{
handler: handler,
logf: log.Printf,
}
for _, option := range options {
option(h)
}
return
} | go | func New(handler http.Handler, options ...Option) (h *Handler) {
h = &Handler{
handler: handler,
logf: log.Printf,
}
for _, option := range options {
option(h)
}
return
} | [
"func",
"New",
"(",
"handler",
"http",
".",
"Handler",
",",
"options",
"...",
"Option",
")",
"(",
"h",
"*",
"Handler",
")",
"{",
"h",
"=",
"&",
"Handler",
"{",
"handler",
":",
"handler",
",",
"logf",
":",
"log",
".",
"Printf",
",",
"}",
"\n",
"fo... | // New creates a new Handler from the handler that is wrapped and
// protected with recover function. | [
"New",
"creates",
"a",
"new",
"Handler",
"from",
"the",
"handler",
"that",
"is",
"wrapped",
"and",
"protected",
"with",
"recover",
"function",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/recovery/recovery.go#L65-L74 | test |
janos/web | recovery/recovery.go | ServeHTTP | func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
debugMsg := fmt.Sprintf(
"%s\n\n%#v\n\n%#v",
debug.Stack(),
r.URL,
r.Header,
)
if h.label != "" {
debugMsg = h.label + "\n\n" + debugMsg
}
h.logf("http recovery han... | go | func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
debugMsg := fmt.Sprintf(
"%s\n\n%#v\n\n%#v",
debug.Stack(),
r.URL,
r.Header,
)
if h.label != "" {
debugMsg = h.label + "\n\n" + debugMsg
}
h.logf("http recovery han... | [
"func",
"(",
"h",
"Handler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"recover",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"debugM... | // ServeHTTP implements http.Handler interface. | [
"ServeHTTP",
"implements",
"http",
".",
"Handler",
"interface",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/recovery/recovery.go#L77-L130 | test |
janos/web | templates/functions.go | NewContextFunc | func NewContextFunc(m map[string]interface{}) func(string) interface{} {
return func(key string) interface{} {
if value, ok := m[key]; ok {
return value
}
return nil
}
} | go | func NewContextFunc(m map[string]interface{}) func(string) interface{} {
return func(key string) interface{} {
if value, ok := m[key]; ok {
return value
}
return nil
}
} | [
"func",
"NewContextFunc",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"func",
"(",
"string",
")",
"interface",
"{",
"}",
"{",
"return",
"func",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"if",
"value",
",",
"ok",
":... | // NewContextFunc creates a new function that can be used to store
// and access arbitrary data by keys. | [
"NewContextFunc",
"creates",
"a",
"new",
"function",
"that",
"can",
"be",
"used",
"to",
"store",
"and",
"access",
"arbitrary",
"data",
"by",
"keys",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/functions.go#L18-L25 | test |
janos/web | client/api/error_registry.go | NewMapErrorRegistry | func NewMapErrorRegistry(errors map[int]error, handlers map[int]func(body []byte) error) *MapErrorRegistry {
if errors == nil {
errors = map[int]error{}
}
if handlers == nil {
handlers = map[int]func(body []byte) error{}
}
return &MapErrorRegistry{
errors: errors,
handlers: handlers,
}
} | go | func NewMapErrorRegistry(errors map[int]error, handlers map[int]func(body []byte) error) *MapErrorRegistry {
if errors == nil {
errors = map[int]error{}
}
if handlers == nil {
handlers = map[int]func(body []byte) error{}
}
return &MapErrorRegistry{
errors: errors,
handlers: handlers,
}
} | [
"func",
"NewMapErrorRegistry",
"(",
"errors",
"map",
"[",
"int",
"]",
"error",
",",
"handlers",
"map",
"[",
"int",
"]",
"func",
"(",
"body",
"[",
"]",
"byte",
")",
"error",
")",
"*",
"MapErrorRegistry",
"{",
"if",
"errors",
"==",
"nil",
"{",
"errors",
... | // NewMapErrorRegistry creates a new instance of MapErrorRegistry. | [
"NewMapErrorRegistry",
"creates",
"a",
"new",
"instance",
"of",
"MapErrorRegistry",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L32-L43 | test |
janos/web | client/api/error_registry.go | AddError | func (r *MapErrorRegistry) AddError(code int, err error) error {
if _, ok := r.errors[code]; ok {
return ErrErrorAlreadyRegistered
}
if _, ok := r.handlers[code]; ok {
return ErrErrorAlreadyRegistered
}
r.errors[code] = err
return nil
} | go | func (r *MapErrorRegistry) AddError(code int, err error) error {
if _, ok := r.errors[code]; ok {
return ErrErrorAlreadyRegistered
}
if _, ok := r.handlers[code]; ok {
return ErrErrorAlreadyRegistered
}
r.errors[code] = err
return nil
} | [
"func",
"(",
"r",
"*",
"MapErrorRegistry",
")",
"AddError",
"(",
"code",
"int",
",",
"err",
"error",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"r",
".",
"errors",
"[",
"code",
"]",
";",
"ok",
"{",
"return",
"ErrErrorAlreadyRegistered",
"\n",
"}"... | // AddError adds a new error with a code to the registry.
// It there already is an error or handler with the same code,
// ErrErrorAlreadyRegistered will be returned. | [
"AddError",
"adds",
"a",
"new",
"error",
"with",
"a",
"code",
"to",
"the",
"registry",
".",
"It",
"there",
"already",
"is",
"an",
"error",
"or",
"handler",
"with",
"the",
"same",
"code",
"ErrErrorAlreadyRegistered",
"will",
"be",
"returned",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L48-L57 | test |
janos/web | client/api/error_registry.go | AddMessageError | func (r *MapErrorRegistry) AddMessageError(code int, message string) (*Error, error) {
if _, ok := r.errors[code]; ok {
return nil, ErrErrorAlreadyRegistered
}
if _, ok := r.handlers[code]; ok {
return nil, ErrErrorAlreadyRegistered
}
err := &Error{
Message: message,
Code: code,
}
r.errors[code] = err... | go | func (r *MapErrorRegistry) AddMessageError(code int, message string) (*Error, error) {
if _, ok := r.errors[code]; ok {
return nil, ErrErrorAlreadyRegistered
}
if _, ok := r.handlers[code]; ok {
return nil, ErrErrorAlreadyRegistered
}
err := &Error{
Message: message,
Code: code,
}
r.errors[code] = err... | [
"func",
"(",
"r",
"*",
"MapErrorRegistry",
")",
"AddMessageError",
"(",
"code",
"int",
",",
"message",
"string",
")",
"(",
"*",
"Error",
",",
"error",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"r",
".",
"errors",
"[",
"code",
"]",
";",
"ok",
"{",
"re... | // AddMessageError adds a new Error isntance with a code and message
// to the registry.
// It there already is an error or handler with the same code,
// ErrErrorAlreadyRegistered will be returned. | [
"AddMessageError",
"adds",
"a",
"new",
"Error",
"isntance",
"with",
"a",
"code",
"and",
"message",
"to",
"the",
"registry",
".",
"It",
"there",
"already",
"is",
"an",
"error",
"or",
"handler",
"with",
"the",
"same",
"code",
"ErrErrorAlreadyRegistered",
"will",... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L63-L76 | test |
janos/web | client/api/error_registry.go | MustAddError | func (r *MapErrorRegistry) MustAddError(code int, err error) {
if e := r.AddError(code, err); e != nil {
panic(e)
}
} | go | func (r *MapErrorRegistry) MustAddError(code int, err error) {
if e := r.AddError(code, err); e != nil {
panic(e)
}
} | [
"func",
"(",
"r",
"*",
"MapErrorRegistry",
")",
"MustAddError",
"(",
"code",
"int",
",",
"err",
"error",
")",
"{",
"if",
"e",
":=",
"r",
".",
"AddError",
"(",
"code",
",",
"err",
")",
";",
"e",
"!=",
"nil",
"{",
"panic",
"(",
"e",
")",
"\n",
"}... | // MustAddError calls AddError and panics in case of an error. | [
"MustAddError",
"calls",
"AddError",
"and",
"panics",
"in",
"case",
"of",
"an",
"error",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L79-L83 | test |
janos/web | client/api/error_registry.go | MustAddMessageError | func (r *MapErrorRegistry) MustAddMessageError(code int, message string) *Error {
err, e := r.AddMessageError(code, message)
if e != nil {
panic(e)
}
return err
} | go | func (r *MapErrorRegistry) MustAddMessageError(code int, message string) *Error {
err, e := r.AddMessageError(code, message)
if e != nil {
panic(e)
}
return err
} | [
"func",
"(",
"r",
"*",
"MapErrorRegistry",
")",
"MustAddMessageError",
"(",
"code",
"int",
",",
"message",
"string",
")",
"*",
"Error",
"{",
"err",
",",
"e",
":=",
"r",
".",
"AddMessageError",
"(",
"code",
",",
"message",
")",
"\n",
"if",
"e",
"!=",
... | // MustAddMessageError calls AddMessageError and panics in case of an error. | [
"MustAddMessageError",
"calls",
"AddMessageError",
"and",
"panics",
"in",
"case",
"of",
"an",
"error",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L86-L92 | test |
janos/web | client/api/error_registry.go | AddHandler | func (r *MapErrorRegistry) AddHandler(code int, handler func(body []byte) error) error {
if _, ok := r.errors[code]; ok {
return ErrErrorAlreadyRegistered
}
if _, ok := r.handlers[code]; ok {
return ErrErrorAlreadyRegistered
}
r.handlers[code] = handler
return nil
} | go | func (r *MapErrorRegistry) AddHandler(code int, handler func(body []byte) error) error {
if _, ok := r.errors[code]; ok {
return ErrErrorAlreadyRegistered
}
if _, ok := r.handlers[code]; ok {
return ErrErrorAlreadyRegistered
}
r.handlers[code] = handler
return nil
} | [
"func",
"(",
"r",
"*",
"MapErrorRegistry",
")",
"AddHandler",
"(",
"code",
"int",
",",
"handler",
"func",
"(",
"body",
"[",
"]",
"byte",
")",
"error",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"r",
".",
"errors",
"[",
"code",
"]",
";",
"ok",... | // AddHandler adds a new error handler with a code to the registry.
// It there already is an error or handler with the same code,
// ErrErrorAlreadyRegistered will be returned. | [
"AddHandler",
"adds",
"a",
"new",
"error",
"handler",
"with",
"a",
"code",
"to",
"the",
"registry",
".",
"It",
"there",
"already",
"is",
"an",
"error",
"or",
"handler",
"with",
"the",
"same",
"code",
"ErrErrorAlreadyRegistered",
"will",
"be",
"returned",
"."... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L102-L111 | test |
janos/web | client/api/error_registry.go | MustAddHandler | func (r *MapErrorRegistry) MustAddHandler(code int, handler func(body []byte) error) {
if err := r.AddHandler(code, handler); err != nil {
panic(err)
}
} | go | func (r *MapErrorRegistry) MustAddHandler(code int, handler func(body []byte) error) {
if err := r.AddHandler(code, handler); err != nil {
panic(err)
}
} | [
"func",
"(",
"r",
"*",
"MapErrorRegistry",
")",
"MustAddHandler",
"(",
"code",
"int",
",",
"handler",
"func",
"(",
"body",
"[",
"]",
"byte",
")",
"error",
")",
"{",
"if",
"err",
":=",
"r",
".",
"AddHandler",
"(",
"code",
",",
"handler",
")",
";",
"... | // MustAddHandler calls AddHandler and panics in case of an error. | [
"MustAddHandler",
"calls",
"AddHandler",
"and",
"panics",
"in",
"case",
"of",
"an",
"error",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L114-L118 | test |
janos/web | client/api/error_registry.go | Handler | func (r MapErrorRegistry) Handler(code int) func(body []byte) error {
return r.handlers[code]
} | go | func (r MapErrorRegistry) Handler(code int) func(body []byte) error {
return r.handlers[code]
} | [
"func",
"(",
"r",
"MapErrorRegistry",
")",
"Handler",
"(",
"code",
"int",
")",
"func",
"(",
"body",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"r",
".",
"handlers",
"[",
"code",
"]",
"\n",
"}"
] | // Handler returns a handler that is registered under the provided code. | [
"Handler",
"returns",
"a",
"handler",
"that",
"is",
"registered",
"under",
"the",
"provided",
"code",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/error_registry.go#L121-L123 | test |
janos/web | client/api/api_client.go | New | func New(endpoint string, errorRegistry ErrorRegistry) *Client {
return &Client{
Endpoint: endpoint,
ErrorRegistry: errorRegistry,
KeyHeader: DefaultKeyHeader,
HTTPClient: http.DefaultClient,
}
} | go | func New(endpoint string, errorRegistry ErrorRegistry) *Client {
return &Client{
Endpoint: endpoint,
ErrorRegistry: errorRegistry,
KeyHeader: DefaultKeyHeader,
HTTPClient: http.DefaultClient,
}
} | [
"func",
"New",
"(",
"endpoint",
"string",
",",
"errorRegistry",
"ErrorRegistry",
")",
"*",
"Client",
"{",
"return",
"&",
"Client",
"{",
"Endpoint",
":",
"endpoint",
",",
"ErrorRegistry",
":",
"errorRegistry",
",",
"KeyHeader",
":",
"DefaultKeyHeader",
",",
"HT... | // New returns a new instance of Client with default values. | [
"New",
"returns",
"a",
"new",
"instance",
"of",
"Client",
"with",
"default",
"values",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/api_client.go#L57-L64 | test |
janos/web | client/api/api_client.go | Request | func (c Client) Request(method, path string, query url.Values, body io.Reader, accept []string) (resp *http.Response, err error) {
return c.RequestContext(nil, method, path, query, body, accept)
} | go | func (c Client) Request(method, path string, query url.Values, body io.Reader, accept []string) (resp *http.Response, err error) {
return c.RequestContext(nil, method, path, query, body, accept)
} | [
"func",
"(",
"c",
"Client",
")",
"Request",
"(",
"method",
",",
"path",
"string",
",",
"query",
"url",
".",
"Values",
",",
"body",
"io",
".",
"Reader",
",",
"accept",
"[",
"]",
"string",
")",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
... | // Request makes a HTTP request based on Client configuration and
// arguments provided. | [
"Request",
"makes",
"a",
"HTTP",
"request",
"based",
"on",
"Client",
"configuration",
"and",
"arguments",
"provided",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/api_client.go#L169-L171 | test |
janos/web | client/api/api_client.go | JSONContext | func (c Client) JSONContext(ctx context.Context, method, path string, query url.Values, body io.Reader, response interface{}) (err error) {
resp, err := c.RequestContext(ctx, method, path, query, body, []string{"application/json"})
if err != nil {
return
}
defer func() {
io.Copy(ioutil.Discard, resp.Body)
res... | go | func (c Client) JSONContext(ctx context.Context, method, path string, query url.Values, body io.Reader, response interface{}) (err error) {
resp, err := c.RequestContext(ctx, method, path, query, body, []string{"application/json"})
if err != nil {
return
}
defer func() {
io.Copy(ioutil.Discard, resp.Body)
res... | [
"func",
"(",
"c",
"Client",
")",
"JSONContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"method",
",",
"path",
"string",
",",
"query",
"url",
".",
"Values",
",",
"body",
"io",
".",
"Reader",
",",
"response",
"interface",
"{",
"}",
")",
"(",
"err"... | // JSONContext provides the same functionality as JSON with Context instance passing to http.Request. | [
"JSONContext",
"provides",
"the",
"same",
"functionality",
"as",
"JSON",
"with",
"Context",
"instance",
"passing",
"to",
"http",
".",
"Request",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/api_client.go#L174-L203 | test |
janos/web | client/api/api_client.go | StreamContext | func (c Client) StreamContext(ctx context.Context, method, path string, query url.Values, body io.Reader, accept []string) (data io.ReadCloser, contentType string, err error) {
resp, err := c.RequestContext(ctx, method, path, query, body, accept)
if err != nil {
return
}
contentType = resp.Header.Get("Content-Ty... | go | func (c Client) StreamContext(ctx context.Context, method, path string, query url.Values, body io.Reader, accept []string) (data io.ReadCloser, contentType string, err error) {
resp, err := c.RequestContext(ctx, method, path, query, body, accept)
if err != nil {
return
}
contentType = resp.Header.Get("Content-Ty... | [
"func",
"(",
"c",
"Client",
")",
"StreamContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"method",
",",
"path",
"string",
",",
"query",
"url",
".",
"Values",
",",
"body",
"io",
".",
"Reader",
",",
"accept",
"[",
"]",
"string",
")",
"(",
"data",
... | // StreamContext provides the same functionality as Stream with Context instance passing to http.Request. | [
"StreamContext",
"provides",
"the",
"same",
"functionality",
"as",
"Stream",
"with",
"Context",
"instance",
"passing",
"to",
"http",
".",
"Request",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/api_client.go#L212-L221 | test |
janos/web | client/api/api_client.go | Stream | func (c Client) Stream(method, path string, query url.Values, body io.Reader, accept []string) (data io.ReadCloser, contentType string, err error) {
return c.StreamContext(nil, method, path, query, body, accept)
} | go | func (c Client) Stream(method, path string, query url.Values, body io.Reader, accept []string) (data io.ReadCloser, contentType string, err error) {
return c.StreamContext(nil, method, path, query, body, accept)
} | [
"func",
"(",
"c",
"Client",
")",
"Stream",
"(",
"method",
",",
"path",
"string",
",",
"query",
"url",
".",
"Values",
",",
"body",
"io",
".",
"Reader",
",",
"accept",
"[",
"]",
"string",
")",
"(",
"data",
"io",
".",
"ReadCloser",
",",
"contentType",
... | // Stream makes a HTTP request and returns request body as io.ReadCloser,
// to be able to read long running responses. Returned io.ReadCloser must be
// closed at the end of read. To reuse HTTP connection, make sure that the
// whole data is read before closing the reader. | [
"Stream",
"makes",
"a",
"HTTP",
"request",
"and",
"returns",
"request",
"body",
"as",
"io",
".",
"ReadCloser",
"to",
"be",
"able",
"to",
"read",
"long",
"running",
"responses",
".",
"Returned",
"io",
".",
"ReadCloser",
"must",
"be",
"closed",
"at",
"the",
... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/api_client.go#L227-L229 | test |
janos/web | client/api/api_client.go | JSONUnmarshal | func JSONUnmarshal(data []byte, v interface{}) error {
if err := json.Unmarshal(data, v); err != nil {
switch e := err.(type) {
case *json.SyntaxError:
line, col := getLineColFromOffset(data, e.Offset)
return fmt.Errorf("json %s, line: %d, column: %d", e, line, col)
case *json.UnmarshalTypeError:
line, ... | go | func JSONUnmarshal(data []byte, v interface{}) error {
if err := json.Unmarshal(data, v); err != nil {
switch e := err.(type) {
case *json.SyntaxError:
line, col := getLineColFromOffset(data, e.Offset)
return fmt.Errorf("json %s, line: %d, column: %d", e, line, col)
case *json.UnmarshalTypeError:
line, ... | [
"func",
"JSONUnmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"switch",
"e",
":=",
"err",
".",
... | // JSONUnmarshal decodes data into v and returns json.SyntaxError and
// json.UnmarshalTypeError formated with additional information. | [
"JSONUnmarshal",
"decodes",
"data",
"into",
"v",
"and",
"returns",
"json",
".",
"SyntaxError",
"and",
"json",
".",
"UnmarshalTypeError",
"formated",
"with",
"additional",
"information",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/client/api/api_client.go#L233-L246 | test |
janos/web | servers/http/http.go | ServeTCP | func (s *Server) ServeTCP(ln net.Listener) (err error) {
if l, ok := ln.(*net.TCPListener); ok {
ln = tcpKeepAliveListener{TCPListener: l}
}
if s.TLSConfig != nil {
ln = tls.NewListener(ln, s.TLSConfig)
}
err = s.Server.Serve(ln)
if err == http.ErrServerClosed {
return nil
}
return
} | go | func (s *Server) ServeTCP(ln net.Listener) (err error) {
if l, ok := ln.(*net.TCPListener); ok {
ln = tcpKeepAliveListener{TCPListener: l}
}
if s.TLSConfig != nil {
ln = tls.NewListener(ln, s.TLSConfig)
}
err = s.Server.Serve(ln)
if err == http.ErrServerClosed {
return nil
}
return
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ServeTCP",
"(",
"ln",
"net",
".",
"Listener",
")",
"(",
"err",
"error",
")",
"{",
"if",
"l",
",",
"ok",
":=",
"ln",
".",
"(",
"*",
"net",
".",
"TCPListener",
")",
";",
"ok",
"{",
"ln",
"=",
"tcpKeepAliveLi... | // ServeTCP executes http.Server.Serve method.
// If the provided listener is net.TCPListener, keep alive
// will be enabled. If server is configured with TLS,
// a tls.Listener will be created with provided listener. | [
"ServeTCP",
"executes",
"http",
".",
"Server",
".",
"Serve",
"method",
".",
"If",
"the",
"provided",
"listener",
"is",
"net",
".",
"TCPListener",
"keep",
"alive",
"will",
"be",
"enabled",
".",
"If",
"server",
"is",
"configured",
"with",
"TLS",
"a",
"tls",
... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/http/http.go#L61-L74 | test |
janos/web | servers/grpc/grpc.go | ServeTCP | func (s *Server) ServeTCP(ln net.Listener) (err error) {
return s.Server.Serve(ln)
} | go | func (s *Server) ServeTCP(ln net.Listener) (err error) {
return s.Server.Serve(ln)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ServeTCP",
"(",
"ln",
"net",
".",
"Listener",
")",
"(",
"err",
"error",
")",
"{",
"return",
"s",
".",
"Server",
".",
"Serve",
"(",
"ln",
")",
"\n",
"}"
] | // ServeTCP serves request on TCP listener. | [
"ServeTCP",
"serves",
"request",
"on",
"TCP",
"listener",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/grpc/grpc.go#L35-L37 | test |
janos/web | servers/grpc/grpc.go | Shutdown | func (s *Server) Shutdown(ctx context.Context) (err error) {
s.Server.GracefulStop()
return
} | go | func (s *Server) Shutdown(ctx context.Context) (err error) {
s.Server.GracefulStop()
return
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"s",
".",
"Server",
".",
"GracefulStop",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Shutdown executes grpc.Server.GracefulStop method. | [
"Shutdown",
"executes",
"grpc",
".",
"Server",
".",
"GracefulStop",
"method",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/servers/grpc/grpc.go#L46-L49 | test |
janos/web | method.go | HandleMethods | func HandleMethods(methods map[string]http.Handler, body string, contentType string, w http.ResponseWriter, r *http.Request) {
if handler, ok := methods[r.Method]; ok {
handler.ServeHTTP(w, r)
} else {
allow := []string{}
for k := range methods {
allow = append(allow, k)
}
sort.Strings(allow)
w.Header(... | go | func HandleMethods(methods map[string]http.Handler, body string, contentType string, w http.ResponseWriter, r *http.Request) {
if handler, ok := methods[r.Method]; ok {
handler.ServeHTTP(w, r)
} else {
allow := []string{}
for k := range methods {
allow = append(allow, k)
}
sort.Strings(allow)
w.Header(... | [
"func",
"HandleMethods",
"(",
"methods",
"map",
"[",
"string",
"]",
"http",
".",
"Handler",
",",
"body",
"string",
",",
"contentType",
"string",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"handler",
... | // HandleMethods uses a corresponding Handler based on HTTP request method.
// If Handler is not found, a method not allowed HTTP response is returned
// with specified body and Content-Type header. | [
"HandleMethods",
"uses",
"a",
"corresponding",
"Handler",
"based",
"on",
"HTTP",
"request",
"method",
".",
"If",
"Handler",
"is",
"not",
"found",
"a",
"method",
"not",
"allowed",
"HTTP",
"response",
"is",
"returned",
"with",
"specified",
"body",
"and",
"Conten... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/method.go#L18-L36 | test |
janos/web | set_headers.go | NewSetHeadersHandler | func NewSetHeadersHandler(h http.Handler, headers map[string]string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for header, value := range headers {
w.Header().Set(header, value)
}
h.ServeHTTP(w, r)
})
} | go | func NewSetHeadersHandler(h http.Handler, headers map[string]string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for header, value := range headers {
w.Header().Set(header, value)
}
h.ServeHTTP(w, r)
})
} | [
"func",
"NewSetHeadersHandler",
"(",
"h",
"http",
".",
"Handler",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",... | // NewSetHeadersHandler sets provied headers on HTTP response. | [
"NewSetHeadersHandler",
"sets",
"provied",
"headers",
"on",
"HTTP",
"response",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/set_headers.go#L23-L30 | test |
janos/web | file-server/server.go | New | func New(root, dir string, options *Options) *Server {
if options == nil {
options = &Options{}
}
return &Server{
Options: *options,
root: root,
dir: dir,
hashes: map[string]string{},
mu: &sync.RWMutex{},
}
} | go | func New(root, dir string, options *Options) *Server {
if options == nil {
options = &Options{}
}
return &Server{
Options: *options,
root: root,
dir: dir,
hashes: map[string]string{},
mu: &sync.RWMutex{},
}
} | [
"func",
"New",
"(",
"root",
",",
"dir",
"string",
",",
"options",
"*",
"Options",
")",
"*",
"Server",
"{",
"if",
"options",
"==",
"nil",
"{",
"options",
"=",
"&",
"Options",
"{",
"}",
"\n",
"}",
"\n",
"return",
"&",
"Server",
"{",
"Options",
":",
... | // New initializes a new instance of Server. | [
"New",
"initializes",
"a",
"new",
"instance",
"of",
"Server",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/file-server/server.go#L29-L42 | test |
janos/web | file-server/server.go | HashedPath | func (s *Server) HashedPath(p string) (string, error) {
if s.Hasher == nil {
return path.Join(s.root, p), nil
}
h, cont, err := s.hash(p)
if err != nil {
if cont {
h, _, err = s.hashFromFilename(p)
}
if err != nil {
return "", err
}
}
return path.Join(s.root, s.hashedPath(p, h)), nil
} | go | func (s *Server) HashedPath(p string) (string, error) {
if s.Hasher == nil {
return path.Join(s.root, p), nil
}
h, cont, err := s.hash(p)
if err != nil {
if cont {
h, _, err = s.hashFromFilename(p)
}
if err != nil {
return "", err
}
}
return path.Join(s.root, s.hashedPath(p, h)), nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"HashedPath",
"(",
"p",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"s",
".",
"Hasher",
"==",
"nil",
"{",
"return",
"path",
".",
"Join",
"(",
"s",
".",
"root",
",",
"p",
")",
",",
"nil",
"... | // HashedPath returns a URL path with hash injected into the filename. | [
"HashedPath",
"returns",
"a",
"URL",
"path",
"with",
"hash",
"injected",
"into",
"the",
"filename",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/file-server/server.go#L140-L154 | test |
janos/web | maintenance/maintenance.go | New | func New(options ...Option) (s *Service) {
s = &Service{
logger: stdLogger{},
}
for _, option := range options {
option(s)
}
if s.store == nil {
s.store = NewMemoryStore()
}
return
} | go | func New(options ...Option) (s *Service) {
s = &Service{
logger: stdLogger{},
}
for _, option := range options {
option(s)
}
if s.store == nil {
s.store = NewMemoryStore()
}
return
} | [
"func",
"New",
"(",
"options",
"...",
"Option",
")",
"(",
"s",
"*",
"Service",
")",
"{",
"s",
"=",
"&",
"Service",
"{",
"logger",
":",
"stdLogger",
"{",
"}",
",",
"}",
"\n",
"for",
"_",
",",
"option",
":=",
"range",
"options",
"{",
"option",
"(",... | // New creates a new instance of Handler.
// The first argument is the handler that will be executed
// when maintenance mode is off. | [
"New",
"creates",
"a",
"new",
"instance",
"of",
"Handler",
".",
"The",
"first",
"argument",
"is",
"the",
"handler",
"that",
"will",
"be",
"executed",
"when",
"maintenance",
"mode",
"is",
"off",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/maintenance/maintenance.go#L197-L208 | test |
janos/web | maintenance/maintenance.go | HTMLHandler | func (s Service) HTMLHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
on, err := s.store.Status()
if err != nil {
s.logger.Errorf("maintenance status: %v", err)
}
if on || err != nil {
if s.HTML.Handler != nil {
s.HTML.Handler.ServeHTTP(w, ... | go | func (s Service) HTMLHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
on, err := s.store.Status()
if err != nil {
s.logger.Errorf("maintenance status: %v", err)
}
if on || err != nil {
if s.HTML.Handler != nil {
s.HTML.Handler.ServeHTTP(w, ... | [
"func",
"(",
"s",
"Service",
")",
"HTMLHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")... | // HTMLHandler is a HTTP middleware that should be used
// alongide HTML pages. | [
"HTMLHandler",
"is",
"a",
"HTTP",
"middleware",
"that",
"should",
"be",
"used",
"alongide",
"HTML",
"pages",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/maintenance/maintenance.go#L212-L230 | test |
janos/web | maintenance/maintenance.go | Status | func (s Service) Status() (on bool, err error) {
return s.store.Status()
} | go | func (s Service) Status() (on bool, err error) {
return s.store.Status()
} | [
"func",
"(",
"s",
"Service",
")",
"Status",
"(",
")",
"(",
"on",
"bool",
",",
"err",
"error",
")",
"{",
"return",
"s",
".",
"store",
".",
"Status",
"(",
")",
"\n",
"}"
] | // Status returns whether the maintenance mode is enabled. | [
"Status",
"returns",
"whether",
"the",
"maintenance",
"mode",
"is",
"enabled",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/maintenance/maintenance.go#L277-L279 | test |
janos/web | maintenance/maintenance.go | StatusHandler | func (s Service) StatusHandler(w http.ResponseWriter, r *http.Request) {
on, err := s.store.Status()
if err != nil {
s.logger.Errorf("maintenance status: %s", err)
jsonInternalServerErrorResponse(w)
return
}
jsonStatusResponse(w, on)
} | go | func (s Service) StatusHandler(w http.ResponseWriter, r *http.Request) {
on, err := s.store.Status()
if err != nil {
s.logger.Errorf("maintenance status: %s", err)
jsonInternalServerErrorResponse(w)
return
}
jsonStatusResponse(w, on)
} | [
"func",
"(",
"s",
"Service",
")",
"StatusHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"on",
",",
"err",
":=",
"s",
".",
"store",
".",
"Status",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // StatusHandler can be used in JSON-encoded HTTP API
// to check the status of maintenance. | [
"StatusHandler",
"can",
"be",
"used",
"in",
"JSON",
"-",
"encoded",
"HTTP",
"API",
"to",
"check",
"the",
"status",
"of",
"maintenance",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/maintenance/maintenance.go#L283-L291 | test |
janos/web | maintenance/maintenance.go | OnHandler | func (s Service) OnHandler(w http.ResponseWriter, r *http.Request) {
changed, err := s.store.On()
if err != nil {
s.logger.Errorf("maintenance on: %s", err)
jsonInternalServerErrorResponse(w)
return
}
if changed {
s.logger.Infof("maintenance on")
jsonCreatedResponse(w)
return
}
jsonOKResponse(w)
} | go | func (s Service) OnHandler(w http.ResponseWriter, r *http.Request) {
changed, err := s.store.On()
if err != nil {
s.logger.Errorf("maintenance on: %s", err)
jsonInternalServerErrorResponse(w)
return
}
if changed {
s.logger.Infof("maintenance on")
jsonCreatedResponse(w)
return
}
jsonOKResponse(w)
} | [
"func",
"(",
"s",
"Service",
")",
"OnHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"changed",
",",
"err",
":=",
"s",
".",
"store",
".",
"On",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // OnHandler can be used in JSON-encoded HTTP API to enable maintenance.
// It returns HTTP Status Created if the maintenance is enabled.
// If the maintenance is already enabled, it returns HTTP Status OK. | [
"OnHandler",
"can",
"be",
"used",
"in",
"JSON",
"-",
"encoded",
"HTTP",
"API",
"to",
"enable",
"maintenance",
".",
"It",
"returns",
"HTTP",
"Status",
"Created",
"if",
"the",
"maintenance",
"is",
"enabled",
".",
"If",
"the",
"maintenance",
"is",
"already",
... | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/maintenance/maintenance.go#L296-L309 | test |
janos/web | maintenance/maintenance.go | OffHandler | func (s Service) OffHandler(w http.ResponseWriter, r *http.Request) {
changed, err := s.store.Off()
if err != nil {
s.logger.Errorf("maintenance off: %s", err)
jsonInternalServerErrorResponse(w)
return
}
if changed {
s.logger.Infof("maintenance off")
}
jsonOKResponse(w)
} | go | func (s Service) OffHandler(w http.ResponseWriter, r *http.Request) {
changed, err := s.store.Off()
if err != nil {
s.logger.Errorf("maintenance off: %s", err)
jsonInternalServerErrorResponse(w)
return
}
if changed {
s.logger.Infof("maintenance off")
}
jsonOKResponse(w)
} | [
"func",
"(",
"s",
"Service",
")",
"OffHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"changed",
",",
"err",
":=",
"s",
".",
"store",
".",
"Off",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // OffHandler can be used in JSON-encoded HTTP API to disable maintenance. | [
"OffHandler",
"can",
"be",
"used",
"in",
"JSON",
"-",
"encoded",
"HTTP",
"API",
"to",
"disable",
"maintenance",
"."
] | 0fb0203103deb84424510a8d5166ac00700f2b0e | https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/maintenance/maintenance.go#L312-L323 | test |
taskcluster/taskcluster-client-go | tcnotify/types.go | MarshalJSON | func (this *PostIRCMessageRequest) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *PostIRCMessageRequest) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"PostIRCMessageRequest",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"("... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// PostIRCMessageRequest is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"PostIRCMessageRequest",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcnotify/types.go#L194-L197 | test |
taskcluster/taskcluster-client-go | tcqueue/types.go | MarshalJSON | func (this *PostArtifactRequest) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *PostArtifactRequest) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"PostArtifactRequest",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// PostArtifactRequest is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"PostArtifactRequest",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcqueue/types.go#L2457-L2460 | test |
taskcluster/taskcluster-client-go | tcqueue/types.go | MarshalJSON | func (this *PostArtifactResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *PostArtifactResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"PostArtifactResponse",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// PostArtifactResponse is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"PostArtifactResponse",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcqueue/types.go#L2473-L2476 | test |
taskcluster/taskcluster-client-go | tchooksevents/types.go | MarshalJSON | func (this *HookChangedMessage) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *HookChangedMessage) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"HookChangedMessage",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// HookChangedMessage is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"HookChangedMessage",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tchooksevents/types.go#L36-L39 | test |
taskcluster/taskcluster-client-go | tchooks/types.go | MarshalJSON | func (this *TriggerHookRequest) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *TriggerHookRequest) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"TriggerHookRequest",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// TriggerHookRequest is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"TriggerHookRequest",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tchooks/types.go#L598-L601 | test |
taskcluster/taskcluster-client-go | tchooks/types.go | MarshalJSON | func (this *TriggerHookResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *TriggerHookResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"TriggerHookResponse",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// TriggerHookResponse is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"TriggerHookResponse",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tchooks/types.go#L614-L617 | test |
taskcluster/taskcluster-client-go | tchooks/types.go | UnmarshalJSON | func (this *TriggerHookResponse) UnmarshalJSON(data []byte) error {
if this == nil {
return errors.New("TriggerHookResponse: UnmarshalJSON on nil pointer")
}
*this = append((*this)[0:0], data...)
return nil
} | go | func (this *TriggerHookResponse) UnmarshalJSON(data []byte) error {
if this == nil {
return errors.New("TriggerHookResponse: UnmarshalJSON on nil pointer")
}
*this = append((*this)[0:0], data...)
return nil
} | [
"func",
"(",
"this",
"*",
"TriggerHookResponse",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"this",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"TriggerHookResponse: UnmarshalJSON on nil pointer\"",
")",
"\n",
"}... | // UnmarshalJSON is a copy of the json.RawMessage implementation. | [
"UnmarshalJSON",
"is",
"a",
"copy",
"of",
"the",
"json",
".",
"RawMessage",
"implementation",
"."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tchooks/types.go#L620-L626 | test |
taskcluster/taskcluster-client-go | tcec2manager/types.go | MarshalJSON | func (this *LaunchInfo) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *LaunchInfo) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"LaunchInfo",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
")",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// LaunchInfo is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"LaunchInfo",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcec2manager/types.go#L494-L497 | test |
taskcluster/taskcluster-client-go | tcec2manager/types.go | MarshalJSON | func (this *Var) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *Var) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"Var",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
")",
"\n",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// Var is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"Var",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcec2manager/types.go#L510-L513 | test |
taskcluster/taskcluster-client-go | tcec2manager/types.go | MarshalJSON | func (this *Var1) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *Var1) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"Var1",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
")",
"\n",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// Var1 is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"Var1",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcec2manager/types.go#L526-L529 | test |
taskcluster/taskcluster-client-go | tcec2manager/types.go | MarshalJSON | func (this *Var3) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *Var3) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"Var3",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
")",
"\n",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// Var3 is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"Var3",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcec2manager/types.go#L542-L545 | test |
taskcluster/taskcluster-client-go | time.go | MarshalJSON | func (t Time) MarshalJSON() ([]byte, error) {
if y := time.Time(t).Year(); y < 0 || y >= 10000 {
// RFC 3339 is clear that years are 4 digits exactly.
// See golang.org/issue/4556#c15 for more discussion.
return nil, errors.New("queue.Time.MarshalJSON: year outside of range [0,9999]")
}
return []byte(`"` + t.S... | go | func (t Time) MarshalJSON() ([]byte, error) {
if y := time.Time(t).Year(); y < 0 || y >= 10000 {
// RFC 3339 is clear that years are 4 digits exactly.
// See golang.org/issue/4556#c15 for more discussion.
return nil, errors.New("queue.Time.MarshalJSON: year outside of range [0,9999]")
}
return []byte(`"` + t.S... | [
"func",
"(",
"t",
"Time",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"y",
":=",
"time",
".",
"Time",
"(",
"t",
")",
".",
"Year",
"(",
")",
";",
"y",
"<",
"0",
"||",
"y",
">=",
"10000",
"{",
"return",
... | // MarshalJSON implements the json.Marshaler interface.
// The time is a quoted string in RFC 3339 format, with sub-second precision added if present. | [
"MarshalJSON",
"implements",
"the",
"json",
".",
"Marshaler",
"interface",
".",
"The",
"time",
"is",
"a",
"quoted",
"string",
"in",
"RFC",
"3339",
"format",
"with",
"sub",
"-",
"second",
"precision",
"added",
"if",
"present",
"."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/time.go#L19-L26 | test |
taskcluster/taskcluster-client-go | time.go | UnmarshalJSON | func (t *Time) UnmarshalJSON(data []byte) (err error) {
// Fractional seconds are handled implicitly by Parse.
x := new(time.Time)
*x, err = time.Parse(`"`+time.RFC3339+`"`, string(data))
*t = Time(*x)
return
} | go | func (t *Time) UnmarshalJSON(data []byte) (err error) {
// Fractional seconds are handled implicitly by Parse.
x := new(time.Time)
*x, err = time.Parse(`"`+time.RFC3339+`"`, string(data))
*t = Time(*x)
return
} | [
"func",
"(",
"t",
"*",
"Time",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"x",
":=",
"new",
"(",
"time",
".",
"Time",
")",
"\n",
"*",
"x",
",",
"err",
"=",
"time",
".",
"Parse",
"(",
"`\"`",
"+",
... | // UnmarshalJSON implements the json.Unmarshaler interface.
// The time is expected to be a quoted string in RFC 3339 format. | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
".",
"The",
"time",
"is",
"expected",
"to",
"be",
"a",
"quoted",
"string",
"in",
"RFC",
"3339",
"format",
"."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/time.go#L30-L36 | test |
taskcluster/taskcluster-client-go | readwriteseeker/readwriteseeker.go | Write | func (rws *ReadWriteSeeker) Write(p []byte) (n int, err error) {
minCap := rws.pos + len(p)
if minCap > cap(rws.buf) { // Make sure buf has enough capacity:
buf2 := make([]byte, len(rws.buf), minCap+len(p)) // add some extra
copy(buf2, rws.buf)
rws.buf = buf2
}
if minCap > len(rws.buf) {
rws.buf = rws.buf[:... | go | func (rws *ReadWriteSeeker) Write(p []byte) (n int, err error) {
minCap := rws.pos + len(p)
if minCap > cap(rws.buf) { // Make sure buf has enough capacity:
buf2 := make([]byte, len(rws.buf), minCap+len(p)) // add some extra
copy(buf2, rws.buf)
rws.buf = buf2
}
if minCap > len(rws.buf) {
rws.buf = rws.buf[:... | [
"func",
"(",
"rws",
"*",
"ReadWriteSeeker",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"minCap",
":=",
"rws",
".",
"pos",
"+",
"len",
"(",
"p",
")",
"\n",
"if",
"minCap",
">",
"cap",
"(",
"r... | // Write implements the io.Writer interface | [
"Write",
"implements",
"the",
"io",
".",
"Writer",
"interface"
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/readwriteseeker/readwriteseeker.go#L15-L28 | test |
taskcluster/taskcluster-client-go | readwriteseeker/readwriteseeker.go | Seek | func (rws *ReadWriteSeeker) Seek(offset int64, whence int) (int64, error) {
newPos, offs := 0, int(offset)
switch whence {
case io.SeekStart:
newPos = offs
case io.SeekCurrent:
newPos = rws.pos + offs
case io.SeekEnd:
newPos = len(rws.buf) + offs
}
if newPos < 0 {
return 0, errors.New("negative result po... | go | func (rws *ReadWriteSeeker) Seek(offset int64, whence int) (int64, error) {
newPos, offs := 0, int(offset)
switch whence {
case io.SeekStart:
newPos = offs
case io.SeekCurrent:
newPos = rws.pos + offs
case io.SeekEnd:
newPos = len(rws.buf) + offs
}
if newPos < 0 {
return 0, errors.New("negative result po... | [
"func",
"(",
"rws",
"*",
"ReadWriteSeeker",
")",
"Seek",
"(",
"offset",
"int64",
",",
"whence",
"int",
")",
"(",
"int64",
",",
"error",
")",
"{",
"newPos",
",",
"offs",
":=",
"0",
",",
"int",
"(",
"offset",
")",
"\n",
"switch",
"whence",
"{",
"case... | // Seek implements the io.Seeker interface | [
"Seek",
"implements",
"the",
"io",
".",
"Seeker",
"interface"
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/readwriteseeker/readwriteseeker.go#L31-L46 | test |
taskcluster/taskcluster-client-go | readwriteseeker/readwriteseeker.go | Read | func (rws *ReadWriteSeeker) Read(b []byte) (n int, err error) {
if rws.pos >= len(rws.buf) {
return 0, io.EOF
}
n = copy(b, rws.buf[rws.pos:])
rws.pos += n
return
} | go | func (rws *ReadWriteSeeker) Read(b []byte) (n int, err error) {
if rws.pos >= len(rws.buf) {
return 0, io.EOF
}
n = copy(b, rws.buf[rws.pos:])
rws.pos += n
return
} | [
"func",
"(",
"rws",
"*",
"ReadWriteSeeker",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"rws",
".",
"pos",
">=",
"len",
"(",
"rws",
".",
"buf",
")",
"{",
"return",
"0",
",",
"io",
".",
... | // Read implements the io.Reader interface | [
"Read",
"implements",
"the",
"io",
".",
"Reader",
"interface"
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/readwriteseeker/readwriteseeker.go#L54-L61 | test |
taskcluster/taskcluster-client-go | tcawsprovisioner/types.go | MarshalJSON | func (this *LaunchSpecsResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *LaunchSpecsResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"LaunchSpecsResponse",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// LaunchSpecsResponse is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"LaunchSpecsResponse",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcawsprovisioner/types.go#L555-L558 | test |
taskcluster/taskcluster-client-go | tcawsprovisioner/types.go | MarshalJSON | func (this *RegionLaunchSpec) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *RegionLaunchSpec) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"RegionLaunchSpec",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
"... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// RegionLaunchSpec is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"RegionLaunchSpec",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcawsprovisioner/types.go#L571-L574 | test |
taskcluster/taskcluster-client-go | codegenerator/model/model.go | GenerateCode | func (apiDefs APIDefinitions) GenerateCode(goOutputDir, modelData string, downloaded time.Time) {
downloadedTime = downloaded
for i := range apiDefs {
apiDefs[i].PackageName = "tc" + strings.ToLower(apiDefs[i].Data.Name())
// Used throughout docs, and also methods that use the class, we need a
// variable name ... | go | func (apiDefs APIDefinitions) GenerateCode(goOutputDir, modelData string, downloaded time.Time) {
downloadedTime = downloaded
for i := range apiDefs {
apiDefs[i].PackageName = "tc" + strings.ToLower(apiDefs[i].Data.Name())
// Used throughout docs, and also methods that use the class, we need a
// variable name ... | [
"func",
"(",
"apiDefs",
"APIDefinitions",
")",
"GenerateCode",
"(",
"goOutputDir",
",",
"modelData",
"string",
",",
"downloaded",
"time",
".",
"Time",
")",
"{",
"downloadedTime",
"=",
"downloaded",
"\n",
"for",
"i",
":=",
"range",
"apiDefs",
"{",
"apiDefs",
... | // GenerateCode takes the objects loaded into memory in LoadAPIs
// and writes them out as go code. | [
"GenerateCode",
"takes",
"the",
"objects",
"loaded",
"into",
"memory",
"in",
"LoadAPIs",
"and",
"writes",
"them",
"out",
"as",
"go",
"code",
"."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/codegenerator/model/model.go#L200-L266 | test |
taskcluster/taskcluster-client-go | codegenerator/model/api.go | postPopulate | func (entry *APIEntry) postPopulate(apiDef *APIDefinition) {
if x := &entry.Parent.apiDef.schemaURLs; entry.Input != "" {
entry.InputURL = tcurls.Schema(tcclient.RootURLFromEnvVars(), entry.Parent.ServiceName, entry.Input)
*x = append(*x, entry.InputURL)
}
if x := &entry.Parent.apiDef.schemaURLs; entry.Output !=... | go | func (entry *APIEntry) postPopulate(apiDef *APIDefinition) {
if x := &entry.Parent.apiDef.schemaURLs; entry.Input != "" {
entry.InputURL = tcurls.Schema(tcclient.RootURLFromEnvVars(), entry.Parent.ServiceName, entry.Input)
*x = append(*x, entry.InputURL)
}
if x := &entry.Parent.apiDef.schemaURLs; entry.Output !=... | [
"func",
"(",
"entry",
"*",
"APIEntry",
")",
"postPopulate",
"(",
"apiDef",
"*",
"APIDefinition",
")",
"{",
"if",
"x",
":=",
"&",
"entry",
".",
"Parent",
".",
"apiDef",
".",
"schemaURLs",
";",
"entry",
".",
"Input",
"!=",
"\"\"",
"{",
"entry",
".",
"I... | // Add entry.Input and entry.Output to schemaURLs, if they are set | [
"Add",
"entry",
".",
"Input",
"and",
"entry",
".",
"Output",
"to",
"schemaURLs",
"if",
"they",
"are",
"set"
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/codegenerator/model/api.go#L244-L253 | test |
taskcluster/taskcluster-client-go | creds.go | CreateTemporaryCredentials | func (permaCreds *Credentials) CreateTemporaryCredentials(duration time.Duration, scopes ...string) (tempCreds *Credentials, err error) {
return permaCreds.CreateNamedTemporaryCredentials("", duration, scopes...)
} | go | func (permaCreds *Credentials) CreateTemporaryCredentials(duration time.Duration, scopes ...string) (tempCreds *Credentials, err error) {
return permaCreds.CreateNamedTemporaryCredentials("", duration, scopes...)
} | [
"func",
"(",
"permaCreds",
"*",
"Credentials",
")",
"CreateTemporaryCredentials",
"(",
"duration",
"time",
".",
"Duration",
",",
"scopes",
"...",
"string",
")",
"(",
"tempCreds",
"*",
"Credentials",
",",
"err",
"error",
")",
"{",
"return",
"permaCreds",
".",
... | // CreateTemporaryCredentials is an alias for CreateNamedTemporaryCredentials
// with an empty name. | [
"CreateTemporaryCredentials",
"is",
"an",
"alias",
"for",
"CreateNamedTemporaryCredentials",
"with",
"an",
"empty",
"name",
"."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/creds.go#L153-L155 | test |
taskcluster/taskcluster-client-go | http.go | setURL | func setURL(client *Client, route string, query url.Values) (u *url.URL, err error) {
URL := client.BaseURL
// See https://bugzil.la/1484702
// Avoid double separator; routes must start with `/`, so baseURL shouldn't
// end with `/`.
if strings.HasSuffix(URL, "/") {
URL = URL[:len(URL)-1]
}
URL += route
u, er... | go | func setURL(client *Client, route string, query url.Values) (u *url.URL, err error) {
URL := client.BaseURL
// See https://bugzil.la/1484702
// Avoid double separator; routes must start with `/`, so baseURL shouldn't
// end with `/`.
if strings.HasSuffix(URL, "/") {
URL = URL[:len(URL)-1]
}
URL += route
u, er... | [
"func",
"setURL",
"(",
"client",
"*",
"Client",
",",
"route",
"string",
",",
"query",
"url",
".",
"Values",
")",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"err",
"error",
")",
"{",
"URL",
":=",
"client",
".",
"BaseURL",
"\n",
"if",
"strings",
".",
"... | // utility function to create a URL object based on given data | [
"utility",
"function",
"to",
"create",
"a",
"URL",
"object",
"based",
"on",
"given",
"data"
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/http.go#L85-L102 | test |
taskcluster/taskcluster-client-go | http.go | SignRequest | func (c *Credentials) SignRequest(req *http.Request) (err error) {
// s, err := c.SignHeader(req.Method, req.URL.String(), hash)
// req.Header.Set("Authorization", s)
// return err
credentials := &hawk.Credentials{
ID: c.ClientID,
Key: c.AccessToken,
Hash: sha256.New,
}
reqAuth := hawk.NewRequestAuth(re... | go | func (c *Credentials) SignRequest(req *http.Request) (err error) {
// s, err := c.SignHeader(req.Method, req.URL.String(), hash)
// req.Header.Set("Authorization", s)
// return err
credentials := &hawk.Credentials{
ID: c.ClientID,
Key: c.AccessToken,
Hash: sha256.New,
}
reqAuth := hawk.NewRequestAuth(re... | [
"func",
"(",
"c",
"*",
"Credentials",
")",
"SignRequest",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"err",
"error",
")",
"{",
"credentials",
":=",
"&",
"hawk",
".",
"Credentials",
"{",
"ID",
":",
"c",
".",
"ClientID",
",",
"Key",
":",
"c",... | // SignRequest will add an Authorization header | [
"SignRequest",
"will",
"add",
"an",
"Authorization",
"header"
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/http.go#L175-L192 | test |
taskcluster/taskcluster-client-go | http.go | APICall | func (client *Client) APICall(payload interface{}, method, route string, result interface{}, query url.Values) (interface{}, *CallSummary, error) {
rawPayload := []byte{}
var err error
if reflect.ValueOf(payload).IsValid() && !reflect.ValueOf(payload).IsNil() {
rawPayload, err = json.Marshal(payload)
if err != n... | go | func (client *Client) APICall(payload interface{}, method, route string, result interface{}, query url.Values) (interface{}, *CallSummary, error) {
rawPayload := []byte{}
var err error
if reflect.ValueOf(payload).IsValid() && !reflect.ValueOf(payload).IsNil() {
rawPayload, err = json.Marshal(payload)
if err != n... | [
"func",
"(",
"client",
"*",
"Client",
")",
"APICall",
"(",
"payload",
"interface",
"{",
"}",
",",
"method",
",",
"route",
"string",
",",
"result",
"interface",
"{",
"}",
",",
"query",
"url",
".",
"Values",
")",
"(",
"interface",
"{",
"}",
",",
"*",
... | // APICall is the generic REST API calling method which performs all REST API
// calls for this library. Each auto-generated REST API method simply is a
// wrapper around this method, calling it with specific specific arguments. | [
"APICall",
"is",
"the",
"generic",
"REST",
"API",
"calling",
"method",
"which",
"performs",
"all",
"REST",
"API",
"calls",
"for",
"this",
"library",
".",
"Each",
"auto",
"-",
"generated",
"REST",
"API",
"method",
"simply",
"is",
"a",
"wrapper",
"around",
"... | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/http.go#L206-L252 | test |
taskcluster/taskcluster-client-go | http.go | SignedURL | func (client *Client) SignedURL(route string, query url.Values, duration time.Duration) (u *url.URL, err error) {
u, err = setURL(client, route, query)
if err != nil {
return
}
credentials := &hawk.Credentials{
ID: client.Credentials.ClientID,
Key: client.Credentials.AccessToken,
Hash: sha256.New,
}
re... | go | func (client *Client) SignedURL(route string, query url.Values, duration time.Duration) (u *url.URL, err error) {
u, err = setURL(client, route, query)
if err != nil {
return
}
credentials := &hawk.Credentials{
ID: client.Credentials.ClientID,
Key: client.Credentials.AccessToken,
Hash: sha256.New,
}
re... | [
"func",
"(",
"client",
"*",
"Client",
")",
"SignedURL",
"(",
"route",
"string",
",",
"query",
"url",
".",
"Values",
",",
"duration",
"time",
".",
"Duration",
")",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"err",
"error",
")",
"{",
"u",
",",
"err",
"... | // SignedURL creates a signed URL using the given Client, where route is the
// url path relative to the BaseURL stored in the Client, query is the set of
// query string parameters, if any, and duration is the amount of time that the
// signed URL should remain valid for. | [
"SignedURL",
"creates",
"a",
"signed",
"URL",
"using",
"the",
"given",
"Client",
"where",
"route",
"is",
"the",
"url",
"path",
"relative",
"to",
"the",
"BaseURL",
"stored",
"in",
"the",
"Client",
"query",
"is",
"the",
"set",
"of",
"query",
"string",
"param... | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/http.go#L258-L283 | test |
taskcluster/taskcluster-client-go | tcauth/types.go | MarshalJSON | func (this *HawkSignatureAuthenticationResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | go | func (this *HawkSignatureAuthenticationResponse) MarshalJSON() ([]byte, error) {
x := json.RawMessage(*this)
return (&x).MarshalJSON()
} | [
"func",
"(",
"this",
"*",
"HawkSignatureAuthenticationResponse",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"Marsh... | // MarshalJSON calls json.RawMessage method of the same name. Required since
// HawkSignatureAuthenticationResponse is of type json.RawMessage... | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"HawkSignatureAuthenticationResponse",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | ef6acd428ae5844a933792ed6479d0e7dca61ef8 | https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcauth/types.go#L912-L915 | test |
bitgoin/lyra2rev2 | bmw.go | bmw256 | func bmw256(input []byte) []byte {
b := new()
buf := make([]byte, 64)
copy(buf, input)
buf[len(input)] = 0x80
bitLen := uint64(len(input)) << 3
binary.LittleEndian.PutUint64(buf[56:], bitLen)
for i := 0; i < 16; i++ {
b.m[i] = binary.LittleEndian.Uint32(buf[i*4:])
}
b.compress(b.m)
b.h, b.h2 = b.h2, b.h
co... | go | func bmw256(input []byte) []byte {
b := new()
buf := make([]byte, 64)
copy(buf, input)
buf[len(input)] = 0x80
bitLen := uint64(len(input)) << 3
binary.LittleEndian.PutUint64(buf[56:], bitLen)
for i := 0; i < 16; i++ {
b.m[i] = binary.LittleEndian.Uint32(buf[i*4:])
}
b.compress(b.m)
b.h, b.h2 = b.h2, b.h
co... | [
"func",
"bmw256",
"(",
"input",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"new",
"(",
"type_identifier",
")",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"64",
")",
"\n",
"copy",
"(",
"buf",
",",
"input",
")",
"\n",
... | //bmw256 calculates and returns bmw256 of input.
//length of input must be 32 bytes. | [
"bmw256",
"calculates",
"and",
"returns",
"bmw256",
"of",
"input",
".",
"length",
"of",
"input",
"must",
"be",
"32",
"bytes",
"."
] | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/bmw.go#L131-L152 | test |
bitgoin/lyra2rev2 | cubehash.go | NewCubeHash | func NewCubeHash() *CubeHash {
c := &CubeHash{}
c.x0 = iv[0]
c.x1 = iv[1]
c.x2 = iv[2]
c.x3 = iv[3]
c.x4 = iv[4]
c.x5 = iv[5]
c.x6 = iv[6]
c.x7 = iv[7]
c.x8 = iv[8]
c.x9 = iv[9]
c.xa = iv[10]
c.xb = iv[11]
c.xc = iv[12]
c.xd = iv[13]
c.xe = iv[14]
c.xf = iv[15]
c.xg = iv[16]
c.xh = iv[17]
c.xi = iv[... | go | func NewCubeHash() *CubeHash {
c := &CubeHash{}
c.x0 = iv[0]
c.x1 = iv[1]
c.x2 = iv[2]
c.x3 = iv[3]
c.x4 = iv[4]
c.x5 = iv[5]
c.x6 = iv[6]
c.x7 = iv[7]
c.x8 = iv[8]
c.x9 = iv[9]
c.xa = iv[10]
c.xb = iv[11]
c.xc = iv[12]
c.xd = iv[13]
c.xe = iv[14]
c.xf = iv[15]
c.xg = iv[16]
c.xh = iv[17]
c.xi = iv[... | [
"func",
"NewCubeHash",
"(",
")",
"*",
"CubeHash",
"{",
"c",
":=",
"&",
"CubeHash",
"{",
"}",
"\n",
"c",
".",
"x0",
"=",
"iv",
"[",
"0",
"]",
"\n",
"c",
".",
"x1",
"=",
"iv",
"[",
"1",
"]",
"\n",
"c",
".",
"x2",
"=",
"iv",
"[",
"2",
"]",
... | //NewCubeHash initializes anrd retuns Cubuhash struct. | [
"NewCubeHash",
"initializes",
"anrd",
"retuns",
"Cubuhash",
"struct",
"."
] | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/cubehash.go#L88-L124 | test |
bitgoin/lyra2rev2 | cubehash.go | cubehash256 | func cubehash256(data []byte) []byte {
c := NewCubeHash()
buf := make([]byte, 32)
buf[0] = 0x80
c.inputBlock(data)
c.sixteenRounds()
c.inputBlock(buf)
c.sixteenRounds()
c.xv ^= 1
for j := 0; j < 10; j++ {
c.sixteenRounds()
}
out := make([]byte, 32)
binary.LittleEndian.PutUint32(out[0:], c.x0)
binary.Litt... | go | func cubehash256(data []byte) []byte {
c := NewCubeHash()
buf := make([]byte, 32)
buf[0] = 0x80
c.inputBlock(data)
c.sixteenRounds()
c.inputBlock(buf)
c.sixteenRounds()
c.xv ^= 1
for j := 0; j < 10; j++ {
c.sixteenRounds()
}
out := make([]byte, 32)
binary.LittleEndian.PutUint32(out[0:], c.x0)
binary.Litt... | [
"func",
"cubehash256",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"c",
":=",
"NewCubeHash",
"(",
")",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32",
")",
"\n",
"buf",
"[",
"0",
"]",
"=",
"0x80",
"\n",
"c",
".",
... | //cubehash56 calculates cubuhash256.
//length of data must be 32 bytes. | [
"cubehash56",
"calculates",
"cubuhash256",
".",
"length",
"of",
"data",
"must",
"be",
"32",
"bytes",
"."
] | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/cubehash.go#L337-L359 | test |
bitgoin/lyra2rev2 | lyra2re2.go | Sum | func Sum(data []byte) ([]byte, error) {
blake := blake256.New()
if _, err := blake.Write(data); err != nil {
return nil, err
}
resultBlake := blake.Sum(nil)
keccak := sha3.NewKeccak256()
if _, err := keccak.Write(resultBlake); err != nil {
return nil, err
}
resultkeccak := keccak.Sum(nil)
resultcube := c... | go | func Sum(data []byte) ([]byte, error) {
blake := blake256.New()
if _, err := blake.Write(data); err != nil {
return nil, err
}
resultBlake := blake.Sum(nil)
keccak := sha3.NewKeccak256()
if _, err := keccak.Write(resultBlake); err != nil {
return nil, err
}
resultkeccak := keccak.Sum(nil)
resultcube := c... | [
"func",
"Sum",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"blake",
":=",
"blake256",
".",
"New",
"(",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"blake",
".",
"Write",
"(",
"data",
")",
";",
"err",
"!=",
... | //Sum returns the result of Lyra2re2 hash. | [
"Sum",
"returns",
"the",
"result",
"of",
"Lyra2re2",
"hash",
"."
] | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/lyra2re2.go#L38-L59 | test |
bitgoin/lyra2rev2 | lyra2.go | squeeze | func squeeze(state []uint64, out []byte) {
tmp := make([]byte, blockLenBytes)
for j := 0; j < len(out)/blockLenBytes+1; j++ {
for i := 0; i < blockLenInt64; i++ {
binary.LittleEndian.PutUint64(tmp[i*8:], state[i])
}
copy(out[j*blockLenBytes:], tmp) //be care in case of len(out[i:])<len(tmp)
blake2bLyra(sta... | go | func squeeze(state []uint64, out []byte) {
tmp := make([]byte, blockLenBytes)
for j := 0; j < len(out)/blockLenBytes+1; j++ {
for i := 0; i < blockLenInt64; i++ {
binary.LittleEndian.PutUint64(tmp[i*8:], state[i])
}
copy(out[j*blockLenBytes:], tmp) //be care in case of len(out[i:])<len(tmp)
blake2bLyra(sta... | [
"func",
"squeeze",
"(",
"state",
"[",
"]",
"uint64",
",",
"out",
"[",
"]",
"byte",
")",
"{",
"tmp",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"blockLenBytes",
")",
"\n",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"len",
"(",
"out",
")",
"/",
"bloc... | /**
* squeeze Performs a squeeze operation, using Blake2b's G function as the
* internal permutation
*
* @param state The current state of the sponge
* @param out Array that will receive the data squeezed
* @param len The number of bytes to be squeezed into the "out" array
*/ | [
"squeeze",
"Performs",
"a",
"squeeze",
"operation",
"using",
"Blake2b",
"s",
"G",
"function",
"as",
"the",
"internal",
"permutation"
] | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/lyra2.go#L135-L144 | test |
bitgoin/lyra2rev2 | lyra2.go | reducedSqueezeRow0 | func reducedSqueezeRow0(state []uint64, rowOut []uint64, nCols int) {
ptr := (nCols - 1) * blockLenInt64
//M[row][C-1-col] = H.reduced_squeeze()
for i := 0; i < nCols; i++ {
ptrWord := rowOut[ptr:] //In Lyra2: pointer to M[0][C-1]
ptrWord[0] = state[0]
ptrWord[1] = state[1]
ptrWord[2] = state[2]
ptrWord[3]... | go | func reducedSqueezeRow0(state []uint64, rowOut []uint64, nCols int) {
ptr := (nCols - 1) * blockLenInt64
//M[row][C-1-col] = H.reduced_squeeze()
for i := 0; i < nCols; i++ {
ptrWord := rowOut[ptr:] //In Lyra2: pointer to M[0][C-1]
ptrWord[0] = state[0]
ptrWord[1] = state[1]
ptrWord[2] = state[2]
ptrWord[3]... | [
"func",
"reducedSqueezeRow0",
"(",
"state",
"[",
"]",
"uint64",
",",
"rowOut",
"[",
"]",
"uint64",
",",
"nCols",
"int",
")",
"{",
"ptr",
":=",
"(",
"nCols",
"-",
"1",
")",
"*",
"blockLenInt64",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"nCols",
... | /**
* reducedSqueezeRow0 erforms a reduced squeeze operation for a single row, from the highest to
* the lowest index, using the reduced-round Blake2b's G function as the
* internal permutation
*
* @param state The current state of the sponge
* @param rowOut Row to receive the data squeezed
*/ | [
"reducedSqueezeRow0",
"erforms",
"a",
"reduced",
"squeeze",
"operation",
"for",
"a",
"single",
"row",
"from",
"the",
"highest",
"to",
"the",
"lowest",
"index",
"using",
"the",
"reduced",
"-",
"round",
"Blake2b",
"s",
"G",
"function",
"as",
"the",
"internal",
... | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/lyra2.go#L204-L228 | test |
bitgoin/lyra2rev2 | lyra2.go | reducedDuplexRow1 | func reducedDuplexRow1(state []uint64, rowIn []uint64, rowOut []uint64, nCols int) {
ptrIn := 0
ptrOut := (nCols - 1) * blockLenInt64
for i := 0; i < nCols; i++ {
ptrWordIn := rowIn[ptrIn:] //In Lyra2: pointer to prev
ptrWordOut := rowOut[ptrOut:] //In Lyra2: pointer to row
//Absorbing "M[prev][col]"
sta... | go | func reducedDuplexRow1(state []uint64, rowIn []uint64, rowOut []uint64, nCols int) {
ptrIn := 0
ptrOut := (nCols - 1) * blockLenInt64
for i := 0; i < nCols; i++ {
ptrWordIn := rowIn[ptrIn:] //In Lyra2: pointer to prev
ptrWordOut := rowOut[ptrOut:] //In Lyra2: pointer to row
//Absorbing "M[prev][col]"
sta... | [
"func",
"reducedDuplexRow1",
"(",
"state",
"[",
"]",
"uint64",
",",
"rowIn",
"[",
"]",
"uint64",
",",
"rowOut",
"[",
"]",
"uint64",
",",
"nCols",
"int",
")",
"{",
"ptrIn",
":=",
"0",
"\n",
"ptrOut",
":=",
"(",
"nCols",
"-",
"1",
")",
"*",
"blockLen... | /**
* reducedDuplexRow1 Performs a reduced duplex operation for a single row, from the highest to
* the lowest index, using the reduced-round Blake2b's G function as the
* internal permutation
*
* @param state The current state of the sponge
* @param rowIn Row to feed the sponge
* @param rowOut Row to receive ... | [
"reducedDuplexRow1",
"Performs",
"a",
"reduced",
"duplex",
"operation",
"for",
"a",
"single",
"row",
"from",
"the",
"highest",
"to",
"the",
"lowest",
"index",
"using",
"the",
"reduced",
"-",
"round",
"Blake2b",
"s",
"G",
"function",
"as",
"the",
"internal",
... | bae9ad2043bb55facb14c4918e909f88a7d3ed84 | https://github.com/bitgoin/lyra2rev2/blob/bae9ad2043bb55facb14c4918e909f88a7d3ed84/lyra2.go#L239-L282 | test |
lestrrat-go/xslate | loader/reader.go | NewReaderByteCodeLoader | func NewReaderByteCodeLoader(p parser.Parser, c compiler.Compiler) *ReaderByteCodeLoader {
return &ReaderByteCodeLoader{NewFlags(), p, c}
} | go | func NewReaderByteCodeLoader(p parser.Parser, c compiler.Compiler) *ReaderByteCodeLoader {
return &ReaderByteCodeLoader{NewFlags(), p, c}
} | [
"func",
"NewReaderByteCodeLoader",
"(",
"p",
"parser",
".",
"Parser",
",",
"c",
"compiler",
".",
"Compiler",
")",
"*",
"ReaderByteCodeLoader",
"{",
"return",
"&",
"ReaderByteCodeLoader",
"{",
"NewFlags",
"(",
")",
",",
"p",
",",
"c",
"}",
"\n",
"}"
] | // NewReaderByteCodeLoader creates a new object | [
"NewReaderByteCodeLoader",
"creates",
"a",
"new",
"object"
] | 6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8 | https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/loader/reader.go#L14-L16 | test |
lestrrat-go/xslate | loader/reader.go | LoadReader | func (l *ReaderByteCodeLoader) LoadReader(name string, rdr io.Reader) (*vm.ByteCode, error) {
ast, err := l.Parser.ParseReader(name, rdr)
if err != nil {
return nil, err
}
if l.ShouldDumpAST() {
fmt.Fprintf(os.Stderr, "AST:\n%s\n", ast)
}
bc, err := l.Compiler.Compile(ast)
if err != nil {
return nil, err... | go | func (l *ReaderByteCodeLoader) LoadReader(name string, rdr io.Reader) (*vm.ByteCode, error) {
ast, err := l.Parser.ParseReader(name, rdr)
if err != nil {
return nil, err
}
if l.ShouldDumpAST() {
fmt.Fprintf(os.Stderr, "AST:\n%s\n", ast)
}
bc, err := l.Compiler.Compile(ast)
if err != nil {
return nil, err... | [
"func",
"(",
"l",
"*",
"ReaderByteCodeLoader",
")",
"LoadReader",
"(",
"name",
"string",
",",
"rdr",
"io",
".",
"Reader",
")",
"(",
"*",
"vm",
".",
"ByteCode",
",",
"error",
")",
"{",
"ast",
",",
"err",
":=",
"l",
".",
"Parser",
".",
"ParseReader",
... | // LoadReader takes a io.Reader and compiles it into vm.ByteCode | [
"LoadReader",
"takes",
"a",
"io",
".",
"Reader",
"and",
"compiles",
"it",
"into",
"vm",
".",
"ByteCode"
] | 6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8 | https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/loader/reader.go#L19-L35 | test |
fgrid/uuid | v3.go | NewV3 | func NewV3(namespace *UUID, name []byte) *UUID {
uuid := newByHash(md5.New(), namespace, name)
uuid[6] = (uuid[6] & 0x0f) | 0x30
return uuid
} | go | func NewV3(namespace *UUID, name []byte) *UUID {
uuid := newByHash(md5.New(), namespace, name)
uuid[6] = (uuid[6] & 0x0f) | 0x30
return uuid
} | [
"func",
"NewV3",
"(",
"namespace",
"*",
"UUID",
",",
"name",
"[",
"]",
"byte",
")",
"*",
"UUID",
"{",
"uuid",
":=",
"newByHash",
"(",
"md5",
".",
"New",
"(",
")",
",",
"namespace",
",",
"name",
")",
"\n",
"uuid",
"[",
"6",
"]",
"=",
"(",
"uuid"... | // NewV3 creates a new UUID with variant 3 as described in RFC 4122.
// Variant 3 based namespace-uuid and name and MD-5 hash calculation. | [
"NewV3",
"creates",
"a",
"new",
"UUID",
"with",
"variant",
"3",
"as",
"described",
"in",
"RFC",
"4122",
".",
"Variant",
"3",
"based",
"namespace",
"-",
"uuid",
"and",
"name",
"and",
"MD",
"-",
"5",
"hash",
"calculation",
"."
] | 6f72a2d331c927473b9b19f590d43ccb5018c844 | https://github.com/fgrid/uuid/blob/6f72a2d331c927473b9b19f590d43ccb5018c844/v3.go#L10-L14 | test |
lestrrat-go/xslate | vm/ops.go | txLiteral | func txLiteral(st *State) {
st.sa = st.CurrentOp().Arg()
st.Advance()
} | go | func txLiteral(st *State) {
st.sa = st.CurrentOp().Arg()
st.Advance()
} | [
"func",
"txLiteral",
"(",
"st",
"*",
"State",
")",
"{",
"st",
".",
"sa",
"=",
"st",
".",
"CurrentOp",
"(",
")",
".",
"Arg",
"(",
")",
"\n",
"st",
".",
"Advance",
"(",
")",
"\n",
"}"
] | // Sets literal in op arg to register sa | [
"Sets",
"literal",
"in",
"op",
"arg",
"to",
"register",
"sa"
] | 6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8 | https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/vm/ops.go#L207-L210 | test |
lestrrat-go/xslate | vm/ops.go | txFetchSymbol | func txFetchSymbol(st *State) {
// Need to handle local vars?
key := st.CurrentOp().Arg()
vars := st.Vars()
if v, ok := vars.Get(key); ok {
st.sa = v
} else {
st.sa = nil
}
st.Advance()
} | go | func txFetchSymbol(st *State) {
// Need to handle local vars?
key := st.CurrentOp().Arg()
vars := st.Vars()
if v, ok := vars.Get(key); ok {
st.sa = v
} else {
st.sa = nil
}
st.Advance()
} | [
"func",
"txFetchSymbol",
"(",
"st",
"*",
"State",
")",
"{",
"key",
":=",
"st",
".",
"CurrentOp",
"(",
")",
".",
"Arg",
"(",
")",
"\n",
"vars",
":=",
"st",
".",
"Vars",
"(",
")",
"\n",
"if",
"v",
",",
"ok",
":=",
"vars",
".",
"Get",
"(",
"key"... | // Fetches a symbol specified in op arg from template variables.
// XXX need to handle local vars? | [
"Fetches",
"a",
"symbol",
"specified",
"in",
"op",
"arg",
"from",
"template",
"variables",
".",
"XXX",
"need",
"to",
"handle",
"local",
"vars?"
] | 6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8 | https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/vm/ops.go#L214-L224 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.