id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
143,600 | asticode/go-astitools | sync/mutex.go | Unlock | func (m *RWMutex) Unlock() {
m.mutex.Unlock()
if m.log {
astilog.Debugf("Unlock executed for %s", m.name)
}
} | go | func (m *RWMutex) Unlock() {
m.mutex.Unlock()
if m.log {
astilog.Debugf("Unlock executed for %s", m.name)
}
} | [
"func",
"(",
"m",
"*",
"RWMutex",
")",
"Unlock",
"(",
")",
"{",
"m",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"if",
"m",
".",
"log",
"{",
"astilog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"m",
".",
"name",
")",
"\n",
"}",
"\n",
"}"
] | // Unlock write unlocks the mutex | [
"Unlock",
"write",
"unlocks",
"the",
"mutex"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/mutex.go#L46-L51 |
143,601 | asticode/go-astitools | sync/mutex.go | RUnlock | func (m *RWMutex) RUnlock() {
m.mutex.RUnlock()
if m.log {
astilog.Debugf("RUnlock executed for %s", m.name)
}
} | go | func (m *RWMutex) RUnlock() {
m.mutex.RUnlock()
if m.log {
astilog.Debugf("RUnlock executed for %s", m.name)
}
} | [
"func",
"(",
"m",
"*",
"RWMutex",
")",
"RUnlock",
"(",
")",
"{",
"m",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"m",
".",
"log",
"{",
"astilog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"m",
".",
"name",
")",
"\n",
"}",
"\n",
"}"
] | // RUnlock read unlocks the mutex | [
"RUnlock",
"read",
"unlocks",
"the",
"mutex"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/mutex.go#L70-L75 |
143,602 | asticode/go-astitools | sync/mutex.go | IsDeadlocked | func (m *RWMutex) IsDeadlocked(timeout time.Duration) (o bool, c string) {
o = true
c = m.lastSuccessfulLockCaller
var channelLockAcquired = make(chan bool)
go func() {
m.mutex.Lock()
defer m.mutex.Unlock()
close(channelLockAcquired)
}()
for {
select {
case <-channelLockAcquired:
o = false
return
... | go | func (m *RWMutex) IsDeadlocked(timeout time.Duration) (o bool, c string) {
o = true
c = m.lastSuccessfulLockCaller
var channelLockAcquired = make(chan bool)
go func() {
m.mutex.Lock()
defer m.mutex.Unlock()
close(channelLockAcquired)
}()
for {
select {
case <-channelLockAcquired:
o = false
return
... | [
"func",
"(",
"m",
"*",
"RWMutex",
")",
"IsDeadlocked",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"o",
"bool",
",",
"c",
"string",
")",
"{",
"o",
"=",
"true",
"\n",
"c",
"=",
"m",
".",
"lastSuccessfulLockCaller",
"\n",
"var",
"channelLockAcquir... | // IsDeadlocked checks whether the mutex is deadlocked with a given timeout and returns the last caller | [
"IsDeadlocked",
"checks",
"whether",
"the",
"mutex",
"is",
"deadlocked",
"with",
"a",
"given",
"timeout",
"and",
"returns",
"the",
"last",
"caller"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/mutex.go#L78-L97 |
143,603 | asticode/go-astitools | template/templater.go | NewTemplater | func NewTemplater(templatesPath, layoutsPath, ext string) (t *Templater, err error) {
// Create templater
t = &Templater{templates: make(map[string]*template.Template)}
// Get layouts
if err = filepath.Walk(layoutsPath, func(path string, info os.FileInfo, e error) (err error) {
// Check input error
if e != nil... | go | func NewTemplater(templatesPath, layoutsPath, ext string) (t *Templater, err error) {
// Create templater
t = &Templater{templates: make(map[string]*template.Template)}
// Get layouts
if err = filepath.Walk(layoutsPath, func(path string, info os.FileInfo, e error) (err error) {
// Check input error
if e != nil... | [
"func",
"NewTemplater",
"(",
"templatesPath",
",",
"layoutsPath",
",",
"ext",
"string",
")",
"(",
"t",
"*",
"Templater",
",",
"err",
"error",
")",
"{",
"// Create templater",
"t",
"=",
"&",
"Templater",
"{",
"templates",
":",
"make",
"(",
"map",
"[",
"st... | // NewTemplater creates a new templater | [
"NewTemplater",
"creates",
"a",
"new",
"templater"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/template/templater.go#L22-L89 |
143,604 | asticode/go-astitools | template/templater.go | Add | func (t *Templater) Add(path, content string) (err error) {
// Lock
t.m.Lock()
defer t.m.Unlock()
// Parse content
var tpl = template.New("root")
if tpl, err = tpl.Parse(content); err != nil {
err = errors.Wrapf(err, "astitemplate: parsing template content for path %s failed", path)
return
}
// Parse file... | go | func (t *Templater) Add(path, content string) (err error) {
// Lock
t.m.Lock()
defer t.m.Unlock()
// Parse content
var tpl = template.New("root")
if tpl, err = tpl.Parse(content); err != nil {
err = errors.Wrapf(err, "astitemplate: parsing template content for path %s failed", path)
return
}
// Parse file... | [
"func",
"(",
"t",
"*",
"Templater",
")",
"Add",
"(",
"path",
",",
"content",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Lock",
"t",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"// Parse... | // Add adds a new template | [
"Add",
"adds",
"a",
"new",
"template"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/template/templater.go#L92-L113 |
143,605 | asticode/go-astitools | template/templater.go | Del | func (t *Templater) Del(path string) {
t.m.Lock()
defer t.m.Unlock()
delete(t.templates, path)
} | go | func (t *Templater) Del(path string) {
t.m.Lock()
defer t.m.Unlock()
delete(t.templates, path)
} | [
"func",
"(",
"t",
"*",
"Templater",
")",
"Del",
"(",
"path",
"string",
")",
"{",
"t",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"t",
".",
"templates",
",",
"path",
")",
"\n",
... | // Del deletes a template | [
"Del",
"deletes",
"a",
"template"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/template/templater.go#L116-L120 |
143,606 | asticode/go-astitools | template/templater.go | Template | func (t *Templater) Template(path string) (tpl *template.Template, ok bool) {
t.m.Lock()
defer t.m.Unlock()
tpl, ok = t.templates[path]
return
} | go | func (t *Templater) Template(path string) (tpl *template.Template, ok bool) {
t.m.Lock()
defer t.m.Unlock()
tpl, ok = t.templates[path]
return
} | [
"func",
"(",
"t",
"*",
"Templater",
")",
"Template",
"(",
"path",
"string",
")",
"(",
"tpl",
"*",
"template",
".",
"Template",
",",
"ok",
"bool",
")",
"{",
"t",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"m",
".",
"Unlock",
"(",
... | // Template retrieves a templates | [
"Template",
"retrieves",
"a",
"templates"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/template/templater.go#L123-L128 |
143,607 | asticode/go-astitools | map/map.go | A | func (m *Map) A(b interface{}) interface{} {
if a, ok := m.mapBToA[b]; ok {
return a
}
return m.defaultA
} | go | func (m *Map) A(b interface{}) interface{} {
if a, ok := m.mapBToA[b]; ok {
return a
}
return m.defaultA
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"A",
"(",
"b",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"if",
"a",
",",
"ok",
":=",
"m",
".",
"mapBToA",
"[",
"b",
"]",
";",
"ok",
"{",
"return",
"a",
"\n",
"}",
"\n",
"return",
"m",
".",
... | // A retrieves a based on b | [
"A",
"retrieves",
"a",
"based",
"on",
"b"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/map/map.go#L22-L27 |
143,608 | asticode/go-astitools | map/map.go | B | func (m *Map) B(a interface{}) interface{} {
if b, ok := m.mapAToB[a]; ok {
return b
}
return m.defaultB
} | go | func (m *Map) B(a interface{}) interface{} {
if b, ok := m.mapAToB[a]; ok {
return b
}
return m.defaultB
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"B",
"(",
"a",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"if",
"b",
",",
"ok",
":=",
"m",
".",
"mapAToB",
"[",
"a",
"]",
";",
"ok",
"{",
"return",
"b",
"\n",
"}",
"\n",
"return",
"m",
".",
... | // B retrieves b based on a | [
"B",
"retrieves",
"b",
"based",
"on",
"a"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/map/map.go#L30-L35 |
143,609 | asticode/go-astitools | map/map.go | InA | func (m *Map) InA(a interface{}) (ok bool) {
_, ok = m.mapAToB[a]
return
} | go | func (m *Map) InA(a interface{}) (ok bool) {
_, ok = m.mapAToB[a]
return
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"InA",
"(",
"a",
"interface",
"{",
"}",
")",
"(",
"ok",
"bool",
")",
"{",
"_",
",",
"ok",
"=",
"m",
".",
"mapAToB",
"[",
"a",
"]",
"\n",
"return",
"\n",
"}"
] | // InA checks whether a exists | [
"InA",
"checks",
"whether",
"a",
"exists"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/map/map.go#L38-L41 |
143,610 | asticode/go-astitools | map/map.go | InB | func (m *Map) InB(b interface{}) (ok bool) {
_, ok = m.mapBToA[b]
return
} | go | func (m *Map) InB(b interface{}) (ok bool) {
_, ok = m.mapBToA[b]
return
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"InB",
"(",
"b",
"interface",
"{",
"}",
")",
"(",
"ok",
"bool",
")",
"{",
"_",
",",
"ok",
"=",
"m",
".",
"mapBToA",
"[",
"b",
"]",
"\n",
"return",
"\n",
"}"
] | // InB checks whether b exists | [
"InB",
"checks",
"whether",
"b",
"exists"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/map/map.go#L44-L47 |
143,611 | asticode/go-astitools | http/middleware.go | ChainMiddlewares | func ChainMiddlewares(h http.Handler, ms ...Middleware) http.Handler {
return ChainMiddlewaresWithPrefix(h, []string{}, ms...)
} | go | func ChainMiddlewares(h http.Handler, ms ...Middleware) http.Handler {
return ChainMiddlewaresWithPrefix(h, []string{}, ms...)
} | [
"func",
"ChainMiddlewares",
"(",
"h",
"http",
".",
"Handler",
",",
"ms",
"...",
"Middleware",
")",
"http",
".",
"Handler",
"{",
"return",
"ChainMiddlewaresWithPrefix",
"(",
"h",
",",
"[",
"]",
"string",
"{",
"}",
",",
"ms",
"...",
")",
"\n",
"}"
] | // ChainMiddlewares chains middlewares | [
"ChainMiddlewares",
"chains",
"middlewares"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L15-L17 |
143,612 | asticode/go-astitools | http/middleware.go | ChainMiddlewaresWithPrefix | func ChainMiddlewaresWithPrefix(h http.Handler, prefixes []string, ms ...Middleware) http.Handler {
for _, m := range ms {
if len(prefixes) == 0 {
h = m(h)
} else {
t := h
h = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
for _, prefix := range prefixes {
if strings.HasPrefix(r... | go | func ChainMiddlewaresWithPrefix(h http.Handler, prefixes []string, ms ...Middleware) http.Handler {
for _, m := range ms {
if len(prefixes) == 0 {
h = m(h)
} else {
t := h
h = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
for _, prefix := range prefixes {
if strings.HasPrefix(r... | [
"func",
"ChainMiddlewaresWithPrefix",
"(",
"h",
"http",
".",
"Handler",
",",
"prefixes",
"[",
"]",
"string",
",",
"ms",
"...",
"Middleware",
")",
"http",
".",
"Handler",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"ms",
"{",
"if",
"len",
"(",
"prefixes",... | // ChainMiddlewaresWithPrefix chains middlewares if one of prefixes is present | [
"ChainMiddlewaresWithPrefix",
"chains",
"middlewares",
"if",
"one",
"of",
"prefixes",
"is",
"present"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L20-L38 |
143,613 | asticode/go-astitools | http/middleware.go | ChainRouterMiddlewares | func ChainRouterMiddlewares(h httprouter.Handle, ms ...RouterMiddleware) httprouter.Handle {
return ChainRouterMiddlewaresWithPrefix(h, []string{}, ms...)
} | go | func ChainRouterMiddlewares(h httprouter.Handle, ms ...RouterMiddleware) httprouter.Handle {
return ChainRouterMiddlewaresWithPrefix(h, []string{}, ms...)
} | [
"func",
"ChainRouterMiddlewares",
"(",
"h",
"httprouter",
".",
"Handle",
",",
"ms",
"...",
"RouterMiddleware",
")",
"httprouter",
".",
"Handle",
"{",
"return",
"ChainRouterMiddlewaresWithPrefix",
"(",
"h",
",",
"[",
"]",
"string",
"{",
"}",
",",
"ms",
"...",
... | // ChainRouterMiddlewares chains router middlewares | [
"ChainRouterMiddlewares",
"chains",
"router",
"middlewares"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L41-L43 |
143,614 | asticode/go-astitools | http/middleware.go | ChainRouterMiddlewaresWithPrefix | func ChainRouterMiddlewaresWithPrefix(h httprouter.Handle, prefixes []string, ms ...RouterMiddleware) httprouter.Handle {
for _, m := range ms {
if len(prefixes) == 0 {
h = m(h)
} else {
t := h
h = func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
for _, prefix := range prefixes {
... | go | func ChainRouterMiddlewaresWithPrefix(h httprouter.Handle, prefixes []string, ms ...RouterMiddleware) httprouter.Handle {
for _, m := range ms {
if len(prefixes) == 0 {
h = m(h)
} else {
t := h
h = func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
for _, prefix := range prefixes {
... | [
"func",
"ChainRouterMiddlewaresWithPrefix",
"(",
"h",
"httprouter",
".",
"Handle",
",",
"prefixes",
"[",
"]",
"string",
",",
"ms",
"...",
"RouterMiddleware",
")",
"httprouter",
".",
"Handle",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"ms",
"{",
"if",
"len"... | // ChainRouterMiddlewares chains router middlewares if one of prefixes is present | [
"ChainRouterMiddlewares",
"chains",
"router",
"middlewares",
"if",
"one",
"of",
"prefixes",
"is",
"present"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L46-L64 |
143,615 | asticode/go-astitools | http/middleware.go | MiddlewareBasicAuth | func MiddlewareBasicAuth(username, password string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Basic auth
if handleBasicAuth(username, password, rw, r) {
return
}
// Next handler
h.ServeHTTP(rw, r)
})
}
} | go | func MiddlewareBasicAuth(username, password string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Basic auth
if handleBasicAuth(username, password, rw, r) {
return
}
// Next handler
h.ServeHTTP(rw, r)
})
}
} | [
"func",
"MiddlewareBasicAuth",
"(",
"username",
",",
"password",
"string",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"rw",
"http",
... | // MiddlewareBasicAuth adds basic HTTP auth to a handler | [
"MiddlewareBasicAuth",
"adds",
"basic",
"HTTP",
"auth",
"to",
"a",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L84-L96 |
143,616 | asticode/go-astitools | http/middleware.go | RouterMiddlewareBasicAuth | func RouterMiddlewareBasicAuth(username, password string) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Basic auth
if handleBasicAuth(username, password, rw, r) {
return
}
// Next handler
h(rw... | go | func RouterMiddlewareBasicAuth(username, password string) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Basic auth
if handleBasicAuth(username, password, rw, r) {
return
}
// Next handler
h(rw... | [
"func",
"RouterMiddlewareBasicAuth",
"(",
"username",
",",
"password",
"string",
")",
"RouterMiddleware",
"{",
"return",
"func",
"(",
"h",
"httprouter",
".",
"Handle",
")",
"httprouter",
".",
"Handle",
"{",
"return",
"func",
"(",
"rw",
"http",
".",
"ResponseWr... | // RouterMiddlewareBasicAuth adds basic HTTP auth to a router handler | [
"RouterMiddlewareBasicAuth",
"adds",
"basic",
"HTTP",
"auth",
"to",
"a",
"router",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L99-L111 |
143,617 | asticode/go-astitools | http/middleware.go | MiddlewareContentType | func MiddlewareContentType(contentType string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Content type
handleContentType(contentType, rw)
// Next handler
h.ServeHTTP(rw, r)
})
}
} | go | func MiddlewareContentType(contentType string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Content type
handleContentType(contentType, rw)
// Next handler
h.ServeHTTP(rw, r)
})
}
} | [
"func",
"MiddlewareContentType",
"(",
"contentType",
"string",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"rw",
"http",
".",
"Respons... | // MiddlewareContentType adds a content type to a handler | [
"MiddlewareContentType",
"adds",
"a",
"content",
"type",
"to",
"a",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L118-L128 |
143,618 | asticode/go-astitools | http/middleware.go | RouterMiddlewareContentType | func RouterMiddlewareContentType(contentType string) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Content type
handleContentType(contentType, rw)
// Next handler
h(rw, r, p)
}
}
} | go | func RouterMiddlewareContentType(contentType string) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Content type
handleContentType(contentType, rw)
// Next handler
h(rw, r, p)
}
}
} | [
"func",
"RouterMiddlewareContentType",
"(",
"contentType",
"string",
")",
"RouterMiddleware",
"{",
"return",
"func",
"(",
"h",
"httprouter",
".",
"Handle",
")",
"httprouter",
".",
"Handle",
"{",
"return",
"func",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
... | // RouterMiddlewareContentType adds a content type to a router handler | [
"RouterMiddlewareContentType",
"adds",
"a",
"content",
"type",
"to",
"a",
"router",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L131-L141 |
143,619 | asticode/go-astitools | http/middleware.go | MiddlewareHeaders | func MiddlewareHeaders(vs map[string]string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Add headers
handleHeaders(vs, rw)
// Next handler
h.ServeHTTP(rw, r)
})
}
} | go | func MiddlewareHeaders(vs map[string]string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Add headers
handleHeaders(vs, rw)
// Next handler
h.ServeHTTP(rw, r)
})
}
} | [
"func",
"MiddlewareHeaders",
"(",
"vs",
"map",
"[",
"string",
"]",
"string",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"rw",
"ht... | // MiddlewareHeaders adds headers to a handler | [
"MiddlewareHeaders",
"adds",
"headers",
"to",
"a",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L150-L160 |
143,620 | asticode/go-astitools | http/middleware.go | RouterMiddlewareHeaders | func RouterMiddlewareHeaders(vs map[string]string) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Add headers
handleHeaders(vs, rw)
// Next handler
h(rw, r, p)
}
}
} | go | func RouterMiddlewareHeaders(vs map[string]string) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
// Add headers
handleHeaders(vs, rw)
// Next handler
h(rw, r, p)
}
}
} | [
"func",
"RouterMiddlewareHeaders",
"(",
"vs",
"map",
"[",
"string",
"]",
"string",
")",
"RouterMiddleware",
"{",
"return",
"func",
"(",
"h",
"httprouter",
".",
"Handle",
")",
"httprouter",
".",
"Handle",
"{",
"return",
"func",
"(",
"rw",
"http",
".",
"Resp... | // RouterMiddlewareHeaders adds headers to a router handler | [
"RouterMiddlewareHeaders",
"adds",
"headers",
"to",
"a",
"router",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L163-L173 |
143,621 | asticode/go-astitools | http/middleware.go | MiddlewareTimeout | func MiddlewareTimeout(timeout time.Duration) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
handleTimeout(timeout, rw, func() { h.ServeHTTP(rw, r) })
})
}
} | go | func MiddlewareTimeout(timeout time.Duration) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
handleTimeout(timeout, rw, func() { h.ServeHTTP(rw, r) })
})
}
} | [
"func",
"MiddlewareTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"rw",
"http",
".",... | // MiddlewareTimeout adds a timeout to a handler | [
"MiddlewareTimeout",
"adds",
"a",
"timeout",
"to",
"a",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L201-L207 |
143,622 | asticode/go-astitools | http/middleware.go | RouterMiddlewareTimeout | func RouterMiddlewareTimeout(timeout time.Duration) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
handleTimeout(timeout, rw, func() { h(rw, r, p) })
}
}
} | go | func RouterMiddlewareTimeout(timeout time.Duration) RouterMiddleware {
return func(h httprouter.Handle) httprouter.Handle {
return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
handleTimeout(timeout, rw, func() { h(rw, r, p) })
}
}
} | [
"func",
"RouterMiddlewareTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"RouterMiddleware",
"{",
"return",
"func",
"(",
"h",
"httprouter",
".",
"Handle",
")",
"httprouter",
".",
"Handle",
"{",
"return",
"func",
"(",
"rw",
"http",
".",
"ResponseWriter"... | // RouterMiddlewareTimeout adds a timeout to a router handler | [
"RouterMiddlewareTimeout",
"adds",
"a",
"timeout",
"to",
"a",
"router",
"handler"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/middleware.go#L210-L216 |
143,623 | asticode/go-astitools | stat/increment.go | Add | func (s *IncrementStat) Add(delta int64) {
s.m.Lock()
defer s.m.Unlock()
if !s.isStarted {
return
}
s.c += delta
} | go | func (s *IncrementStat) Add(delta int64) {
s.m.Lock()
defer s.m.Unlock()
if !s.isStarted {
return
}
s.c += delta
} | [
"func",
"(",
"s",
"*",
"IncrementStat",
")",
"Add",
"(",
"delta",
"int64",
")",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
"s",
".",
"isStarted",
"{",
"return",
"\n",
"}"... | // Add increments the stat | [
"Add",
"increments",
"the",
"stat"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/increment.go#L21-L28 |
143,624 | asticode/go-astitools | slice/slice.go | InStringSlice | func InStringSlice(i string, s []string) (found bool) {
for _, v := range s {
if v == i {
return true
}
}
return
} | go | func InStringSlice(i string, s []string) (found bool) {
for _, v := range s {
if v == i {
return true
}
}
return
} | [
"func",
"InStringSlice",
"(",
"i",
"string",
",",
"s",
"[",
"]",
"string",
")",
"(",
"found",
"bool",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
"{",
"if",
"v",
"==",
"i",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
... | // InStringSlice checks whether a string is in a string slice | [
"InStringSlice",
"checks",
"whether",
"a",
"string",
"is",
"in",
"a",
"string",
"slice"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/slice/slice.go#L4-L11 |
143,625 | asticode/go-astitools | worker/server.go | Serve | func (w *Worker) Serve(addr string, h http.Handler) {
// Create server
s := &http.Server{Addr: addr, Handler: h}
// Create task
t := w.NewTask()
// Execute the rest in a goroutine
astilog.Infof("astiworker: serving on %s", addr)
go func() {
// Serve
var chanDone = make(chan error)
go func() {
if err :... | go | func (w *Worker) Serve(addr string, h http.Handler) {
// Create server
s := &http.Server{Addr: addr, Handler: h}
// Create task
t := w.NewTask()
// Execute the rest in a goroutine
astilog.Infof("astiworker: serving on %s", addr)
go func() {
// Serve
var chanDone = make(chan error)
go func() {
if err :... | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Serve",
"(",
"addr",
"string",
",",
"h",
"http",
".",
"Handler",
")",
"{",
"// Create server",
"s",
":=",
"&",
"http",
".",
"Server",
"{",
"Addr",
":",
"addr",
",",
"Handler",
":",
"h",
"}",
"\n\n",
"// Create... | // Serve spawns a server | [
"Serve",
"spawns",
"a",
"server"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/server.go#L12-L51 |
143,626 | asticode/go-astitools | stat/duration.go | NewDurationRatioStat | func NewDurationRatioStat() *DurationRatioStat {
return &DurationRatioStat{
startedAt: make(map[interface{}]time.Time),
m: &sync.Mutex{},
}
} | go | func NewDurationRatioStat() *DurationRatioStat {
return &DurationRatioStat{
startedAt: make(map[interface{}]time.Time),
m: &sync.Mutex{},
}
} | [
"func",
"NewDurationRatioStat",
"(",
")",
"*",
"DurationRatioStat",
"{",
"return",
"&",
"DurationRatioStat",
"{",
"startedAt",
":",
"make",
"(",
"map",
"[",
"interface",
"{",
"}",
"]",
"time",
".",
"Time",
")",
",",
"m",
":",
"&",
"sync",
".",
"Mutex",
... | // NewDurationRatioStat creates a new duration ratio stat | [
"NewDurationRatioStat",
"creates",
"a",
"new",
"duration",
"ratio",
"stat"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/duration.go#L17-L22 |
143,627 | asticode/go-astitools | stat/duration.go | Add | func (s *DurationRatioStat) Add(k interface{}) {
s.m.Lock()
defer s.m.Unlock()
if !s.isStarted {
return
}
s.startedAt[k] = time.Now()
} | go | func (s *DurationRatioStat) Add(k interface{}) {
s.m.Lock()
defer s.m.Unlock()
if !s.isStarted {
return
}
s.startedAt[k] = time.Now()
} | [
"func",
"(",
"s",
"*",
"DurationRatioStat",
")",
"Add",
"(",
"k",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
"s",
".",
"isStarted",
"{",
"retu... | // Add starts recording a new duration | [
"Add",
"starts",
"recording",
"a",
"new",
"duration"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/duration.go#L25-L32 |
143,628 | asticode/go-astitools | stat/duration.go | Done | func (s *DurationRatioStat) Done(k interface{}) {
s.m.Lock()
defer s.m.Unlock()
if !s.isStarted {
return
}
s.d += time.Now().Sub(s.startedAt[k])
delete(s.startedAt, k)
} | go | func (s *DurationRatioStat) Done(k interface{}) {
s.m.Lock()
defer s.m.Unlock()
if !s.isStarted {
return
}
s.d += time.Now().Sub(s.startedAt[k])
delete(s.startedAt, k)
} | [
"func",
"(",
"s",
"*",
"DurationRatioStat",
")",
"Done",
"(",
"k",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
"s",
".",
"isStarted",
"{",
"ret... | // Done indicates the duration is now done | [
"Done",
"indicates",
"the",
"duration",
"is",
"now",
"done"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/duration.go#L35-L43 |
143,629 | asticode/go-astitools | float/rational.go | NewRational | func NewRational(num, den int) *Rational {
return &Rational{
den: den,
num: num,
}
} | go | func NewRational(num, den int) *Rational {
return &Rational{
den: den,
num: num,
}
} | [
"func",
"NewRational",
"(",
"num",
",",
"den",
"int",
")",
"*",
"Rational",
"{",
"return",
"&",
"Rational",
"{",
"den",
":",
"den",
",",
"num",
":",
"num",
",",
"}",
"\n",
"}"
] | // NewRational creates a new rational | [
"NewRational",
"creates",
"a",
"new",
"rational"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/float/rational.go#L16-L21 |
143,630 | asticode/go-astitools | float/rational.go | ToFloat64 | func (r *Rational) ToFloat64() float64 {
return float64(r.num) / float64(r.den)
} | go | func (r *Rational) ToFloat64() float64 {
return float64(r.num) / float64(r.den)
} | [
"func",
"(",
"r",
"*",
"Rational",
")",
"ToFloat64",
"(",
")",
"float64",
"{",
"return",
"float64",
"(",
"r",
".",
"num",
")",
"/",
"float64",
"(",
"r",
".",
"den",
")",
"\n",
"}"
] | // ToFloat64 returns the rational as a float64 | [
"ToFloat64",
"returns",
"the",
"rational",
"as",
"a",
"float64"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/float/rational.go#L34-L36 |
143,631 | asticode/go-astitools | time/sleep.go | Sleep | func Sleep(ctx context.Context, d time.Duration) (err error) {
for {
select {
case <-time.After(d):
return
case <-ctx.Done():
err = ctx.Err()
return
}
}
return
} | go | func Sleep(ctx context.Context, d time.Duration) (err error) {
for {
select {
case <-time.After(d):
return
case <-ctx.Done():
err = ctx.Err()
return
}
}
return
} | [
"func",
"Sleep",
"(",
"ctx",
"context",
".",
"Context",
",",
"d",
"time",
".",
"Duration",
")",
"(",
"err",
"error",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"time",
".",
"After",
"(",
"d",
")",
":",
"return",
"\n",
"case",
"<-",
"ctx",... | // Sleep is a cancellable sleep | [
"Sleep",
"is",
"a",
"cancellable",
"sleep"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/time/sleep.go#L9-L20 |
143,632 | asticode/go-astitools | io/reader.go | NewReader | func NewReader(ctx context.Context, r io.Reader) *Reader {
return &Reader{
ctx: ctx,
reader: r,
}
} | go | func NewReader(ctx context.Context, r io.Reader) *Reader {
return &Reader{
ctx: ctx,
reader: r,
}
} | [
"func",
"NewReader",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"io",
".",
"Reader",
")",
"*",
"Reader",
"{",
"return",
"&",
"Reader",
"{",
"ctx",
":",
"ctx",
",",
"reader",
":",
"r",
",",
"}",
"\n",
"}"
] | // NewReader creates a new Reader | [
"NewReader",
"creates",
"a",
"new",
"Reader"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/io/reader.go#L15-L20 |
143,633 | asticode/go-astitools | io/reader.go | Read | func (r *Reader) Read(p []byte) (n int, err error) {
// Check context
if err = r.ctx.Err(); err != nil {
return
}
// Read
return r.reader.Read(p)
} | go | func (r *Reader) Read(p []byte) (n int, err error) {
// Check context
if err = r.ctx.Err(); err != nil {
return
}
// Read
return r.reader.Read(p)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"// Check context",
"if",
"err",
"=",
"r",
".",
"ctx",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return"... | // Read allows Reader to implement the io.Reader interface | [
"Read",
"allows",
"Reader",
"to",
"implement",
"the",
"io",
".",
"Reader",
"interface"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/io/reader.go#L23-L31 |
143,634 | asticode/go-astitools | stat/stater.go | NewStater | func NewStater(period time.Duration, fn StatsHandleFunc) *Stater {
return &Stater{
fn: fn,
oStart: &sync.Once{},
oStop: &sync.Once{},
period: period,
}
} | go | func NewStater(period time.Duration, fn StatsHandleFunc) *Stater {
return &Stater{
fn: fn,
oStart: &sync.Once{},
oStop: &sync.Once{},
period: period,
}
} | [
"func",
"NewStater",
"(",
"period",
"time",
".",
"Duration",
",",
"fn",
"StatsHandleFunc",
")",
"*",
"Stater",
"{",
"return",
"&",
"Stater",
"{",
"fn",
":",
"fn",
",",
"oStart",
":",
"&",
"sync",
".",
"Once",
"{",
"}",
",",
"oStop",
":",
"&",
"sync... | // NewStater creates a new stater | [
"NewStater",
"creates",
"a",
"new",
"stater"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/stater.go#L49-L56 |
143,635 | asticode/go-astitools | stat/stater.go | Start | func (s *Stater) Start(ctx context.Context) {
// Make sure the stater can only be started once
s.oStart.Do(func() {
// Check context
if ctx.Err() != nil {
return
}
// Reset context
s.ctx, s.cancel = context.WithCancel(ctx)
// Reset once
s.oStop = &sync.Once{}
// Start stats
for _, v := range s... | go | func (s *Stater) Start(ctx context.Context) {
// Make sure the stater can only be started once
s.oStart.Do(func() {
// Check context
if ctx.Err() != nil {
return
}
// Reset context
s.ctx, s.cancel = context.WithCancel(ctx)
// Reset once
s.oStop = &sync.Once{}
// Start stats
for _, v := range s... | [
"func",
"(",
"s",
"*",
"Stater",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"// Make sure the stater can only be started once",
"s",
".",
"oStart",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"// Check context",
"if",
"ctx",
".",
"Err",
"(",... | // Start starts the stater | [
"Start",
"starts",
"the",
"stater"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/stater.go#L59-L115 |
143,636 | asticode/go-astitools | stat/stater.go | AddStat | func (s *Stater) AddStat(m StatMetadata, h StatHandler) {
s.ss = append(s.ss, stat{
h: h,
m: m,
})
} | go | func (s *Stater) AddStat(m StatMetadata, h StatHandler) {
s.ss = append(s.ss, stat{
h: h,
m: m,
})
} | [
"func",
"(",
"s",
"*",
"Stater",
")",
"AddStat",
"(",
"m",
"StatMetadata",
",",
"h",
"StatHandler",
")",
"{",
"s",
".",
"ss",
"=",
"append",
"(",
"s",
".",
"ss",
",",
"stat",
"{",
"h",
":",
"h",
",",
"m",
":",
"m",
",",
"}",
")",
"\n",
"}"
... | // AddStat adds a stat | [
"AddStat",
"adds",
"a",
"stat"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/stater.go#L118-L123 |
143,637 | asticode/go-astitools | stat/stater.go | Stop | func (s *Stater) Stop() {
// Make sure the stater can only be stopped once
s.oStop.Do(func() {
// Cancel context
if s.cancel != nil {
s.cancel()
}
// Reset once
s.oStart = &sync.Once{}
})
} | go | func (s *Stater) Stop() {
// Make sure the stater can only be stopped once
s.oStop.Do(func() {
// Cancel context
if s.cancel != nil {
s.cancel()
}
// Reset once
s.oStart = &sync.Once{}
})
} | [
"func",
"(",
"s",
"*",
"Stater",
")",
"Stop",
"(",
")",
"{",
"// Make sure the stater can only be stopped once",
"s",
".",
"oStop",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"// Cancel context",
"if",
"s",
".",
"cancel",
"!=",
"nil",
"{",
"s",
".",
"cancel"... | // Stop stops the stater | [
"Stop",
"stops",
"the",
"stater"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/stater.go#L126-L137 |
143,638 | asticode/go-astitools | stat/stater.go | StatsMetadata | func (s *Stater) StatsMetadata() (ms []StatMetadata) {
ms = []StatMetadata{}
for _, v := range s.ss {
ms = append(ms, v.m)
}
return
} | go | func (s *Stater) StatsMetadata() (ms []StatMetadata) {
ms = []StatMetadata{}
for _, v := range s.ss {
ms = append(ms, v.m)
}
return
} | [
"func",
"(",
"s",
"*",
"Stater",
")",
"StatsMetadata",
"(",
")",
"(",
"ms",
"[",
"]",
"StatMetadata",
")",
"{",
"ms",
"=",
"[",
"]",
"StatMetadata",
"{",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"ss",
"{",
"ms",
"=",
"append",
... | // StatsMetadata returns the stats metadata | [
"StatsMetadata",
"returns",
"the",
"stats",
"metadata"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/stat/stater.go#L140-L146 |
143,639 | asticode/go-astitools | audio/silence.go | NewSilenceDetector | func NewSilenceDetector(c SilenceDetectorConfiguration) (d *SilenceDetector) {
// Create
d = &SilenceDetector{c: c}
d.Reset()
// Default configuration values
if d.c.SilenceMinDuration == 0 {
d.c.SilenceMinDuration = time.Second
}
if d.c.StepDuration == 0 {
d.c.StepDuration = 30 * time.Millisecond
}
return... | go | func NewSilenceDetector(c SilenceDetectorConfiguration) (d *SilenceDetector) {
// Create
d = &SilenceDetector{c: c}
d.Reset()
// Default configuration values
if d.c.SilenceMinDuration == 0 {
d.c.SilenceMinDuration = time.Second
}
if d.c.StepDuration == 0 {
d.c.StepDuration = 30 * time.Millisecond
}
return... | [
"func",
"NewSilenceDetector",
"(",
"c",
"SilenceDetectorConfiguration",
")",
"(",
"d",
"*",
"SilenceDetector",
")",
"{",
"// Create",
"d",
"=",
"&",
"SilenceDetector",
"{",
"c",
":",
"c",
"}",
"\n",
"d",
".",
"Reset",
"(",
")",
"\n\n",
"// Default configurat... | // NewSilenceDetector creates a new silence detector | [
"NewSilenceDetector",
"creates",
"a",
"new",
"silence",
"detector"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/audio/silence.go#L22-L35 |
143,640 | asticode/go-astitools | audio/silence.go | Add | func (d *SilenceDetector) Add(samples []int32, sampleRate int, silenceMaxAudioLevel float64) (validSamples [][]int32) {
// Append new samples
*d.samples = append(*d.samples, samples...)
// Get number of samples per audio level analysis
var audioLevelAnalysisSamplesCount = int(math.Floor(float64(sampleRate) * d.c.S... | go | func (d *SilenceDetector) Add(samples []int32, sampleRate int, silenceMaxAudioLevel float64) (validSamples [][]int32) {
// Append new samples
*d.samples = append(*d.samples, samples...)
// Get number of samples per audio level analysis
var audioLevelAnalysisSamplesCount = int(math.Floor(float64(sampleRate) * d.c.S... | [
"func",
"(",
"d",
"*",
"SilenceDetector",
")",
"Add",
"(",
"samples",
"[",
"]",
"int32",
",",
"sampleRate",
"int",
",",
"silenceMaxAudioLevel",
"float64",
")",
"(",
"validSamples",
"[",
"]",
"[",
"]",
"int32",
")",
"{",
"// Append new samples",
"*",
"d",
... | // Add adds samples to the buffer and checks whether there are valid samples between silences | [
"Add",
"adds",
"samples",
"to",
"the",
"buffer",
"and",
"checks",
"whether",
"there",
"are",
"valid",
"samples",
"between",
"silences"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/audio/silence.go#L44-L113 |
143,641 | asticode/go-astitools | audio/silence.go | processSilencesInTheMiddle | func (d *SilenceDetector) processSilencesInTheMiddle(audioLevelAnalysisSamplesCount, i, silencesCount int, validSamples *[][]int32) {
// Too many silences, we have valid samples!
if time.Duration(silencesCount)*d.c.StepDuration >= d.c.SilenceMinDuration {
// Keep 1 silence at the end
end := (i - silencesCount) * ... | go | func (d *SilenceDetector) processSilencesInTheMiddle(audioLevelAnalysisSamplesCount, i, silencesCount int, validSamples *[][]int32) {
// Too many silences, we have valid samples!
if time.Duration(silencesCount)*d.c.StepDuration >= d.c.SilenceMinDuration {
// Keep 1 silence at the end
end := (i - silencesCount) * ... | [
"func",
"(",
"d",
"*",
"SilenceDetector",
")",
"processSilencesInTheMiddle",
"(",
"audioLevelAnalysisSamplesCount",
",",
"i",
",",
"silencesCount",
"int",
",",
"validSamples",
"*",
"[",
"]",
"[",
"]",
"int32",
")",
"{",
"// Too many silences, we have valid samples!",
... | // processSilencesInTheMiddle processes silences in the middle | [
"processSilencesInTheMiddle",
"processes",
"silences",
"in",
"the",
"middle"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/audio/silence.go#L116-L131 |
143,642 | asticode/go-astitools | os/checksum.go | Checksum | func Checksum(path string) (checksum string, err error) {
// Open executable
var f *os.File
if f, err = os.Open(path); err != nil {
err = errors.Wrapf(err, "opening %s failed", path)
return
}
defer f.Close()
// Compute checksum
var h = sha1.New()
if _, err = io.Copy(h, f); err != nil {
err = errors.Wrap(... | go | func Checksum(path string) (checksum string, err error) {
// Open executable
var f *os.File
if f, err = os.Open(path); err != nil {
err = errors.Wrapf(err, "opening %s failed", path)
return
}
defer f.Close()
// Compute checksum
var h = sha1.New()
if _, err = io.Copy(h, f); err != nil {
err = errors.Wrap(... | [
"func",
"Checksum",
"(",
"path",
"string",
")",
"(",
"checksum",
"string",
",",
"err",
"error",
")",
"{",
"// Open executable",
"var",
"f",
"*",
"os",
".",
"File",
"\n",
"if",
"f",
",",
"err",
"=",
"os",
".",
"Open",
"(",
"path",
")",
";",
"err",
... | // Checksum computes the checksum of a file | [
"Checksum",
"computes",
"the",
"checksum",
"of",
"a",
"file"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/os/checksum.go#L13-L30 |
143,643 | asticode/go-astitools | template/template.go | ParseDirectory | func ParseDirectory(i, ext string) (t *template.Template, err error) {
// Parse templates
i = filepath.Clean(i)
t = template.New("Root")
return t, filepath.Walk(i, func(path string, info os.FileInfo, e error) (err error) {
// Check input error
if e != nil {
err = e
return
}
// Only process files
if... | go | func ParseDirectory(i, ext string) (t *template.Template, err error) {
// Parse templates
i = filepath.Clean(i)
t = template.New("Root")
return t, filepath.Walk(i, func(path string, info os.FileInfo, e error) (err error) {
// Check input error
if e != nil {
err = e
return
}
// Only process files
if... | [
"func",
"ParseDirectory",
"(",
"i",
",",
"ext",
"string",
")",
"(",
"t",
"*",
"template",
".",
"Template",
",",
"err",
"error",
")",
"{",
"// Parse templates",
"i",
"=",
"filepath",
".",
"Clean",
"(",
"i",
")",
"\n",
"t",
"=",
"template",
".",
"New",... | // ParseDirectory parses a directory recursively | [
"ParseDirectory",
"parses",
"a",
"directory",
"recursively"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/template/template.go#L13-L47 |
143,644 | asticode/go-astitools | worker/worker.go | NewWorker | func NewWorker() (w *Worker) {
astilog.Info("astiworker: starting worker...")
w = &Worker{wg: &sync.WaitGroup{}}
w.ctx, w.cancel = context.WithCancel(context.Background())
w.wg.Add(1)
return
} | go | func NewWorker() (w *Worker) {
astilog.Info("astiworker: starting worker...")
w = &Worker{wg: &sync.WaitGroup{}}
w.ctx, w.cancel = context.WithCancel(context.Background())
w.wg.Add(1)
return
} | [
"func",
"NewWorker",
"(",
")",
"(",
"w",
"*",
"Worker",
")",
"{",
"astilog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"w",
"=",
"&",
"Worker",
"{",
"wg",
":",
"&",
"sync",
".",
"WaitGroup",
"{",
"}",
"}",
"\n",
"w",
".",
"ctx",
",",
"w",
".... | // NewWorker builds a new worker | [
"NewWorker",
"builds",
"a",
"new",
"worker"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/worker.go#L22-L28 |
143,645 | asticode/go-astitools | worker/worker.go | Stop | func (w *Worker) Stop() {
w.os.Do(func() {
astilog.Info("astiworker: stopping worker...")
w.cancel()
w.wg.Done()
})
} | go | func (w *Worker) Stop() {
w.os.Do(func() {
astilog.Info("astiworker: stopping worker...")
w.cancel()
w.wg.Done()
})
} | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Stop",
"(",
")",
"{",
"w",
".",
"os",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"astilog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"w",
".",
"cancel",
"(",
")",
"\n",
"w",
".",
"wg",
".",
"Done",
"(",
... | // Stop stops the Worker | [
"Stop",
"stops",
"the",
"Worker"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/worker.go#L45-L51 |
143,646 | asticode/go-astitools | worker/worker.go | Wait | func (w *Worker) Wait() {
w.ow.Do(func() {
astilog.Info("astiworker: worker is now waiting...")
w.wg.Wait()
})
} | go | func (w *Worker) Wait() {
w.ow.Do(func() {
astilog.Info("astiworker: worker is now waiting...")
w.wg.Wait()
})
} | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Wait",
"(",
")",
"{",
"w",
".",
"ow",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"astilog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"w",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Wait is a blocking pattern | [
"Wait",
"is",
"a",
"blocking",
"pattern"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/worker.go#L54-L59 |
143,647 | asticode/go-astitools | worker/amqp.go | Consume | func (w *Worker) Consume(a *astiamqp.AMQP, cs ...ConfigurationConsumer) (err error) {
// Create task
t := w.NewTask()
// Loop through configurations
for idxConf, c := range cs {
// Loop through workers
for idxWorker := 0; idxWorker < int(math.Max(1, float64(c.WorkerCount))); idxWorker++ {
if err = a.AddCons... | go | func (w *Worker) Consume(a *astiamqp.AMQP, cs ...ConfigurationConsumer) (err error) {
// Create task
t := w.NewTask()
// Loop through configurations
for idxConf, c := range cs {
// Loop through workers
for idxWorker := 0; idxWorker < int(math.Max(1, float64(c.WorkerCount))); idxWorker++ {
if err = a.AddCons... | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Consume",
"(",
"a",
"*",
"astiamqp",
".",
"AMQP",
",",
"cs",
"...",
"ConfigurationConsumer",
")",
"(",
"err",
"error",
")",
"{",
"// Create task",
"t",
":=",
"w",
".",
"NewTask",
"(",
")",
"\n\n",
"// Loop through... | // Consume consumes AMQP events | [
"Consume",
"consumes",
"AMQP",
"events"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/amqp.go#L17-L44 |
143,648 | asticode/go-astitools | sync/do.go | NewDo | func NewDo() (d *Do) {
// Create do
d = &Do{
mc: &sync.Mutex{},
mq: &sync.Mutex{},
}
// Create cond
d.cond = sync.NewCond(d.mc)
// Create context
d.ctx, d.cancel = context.WithCancel(context.Background())
// Do
go d.do()
return
} | go | func NewDo() (d *Do) {
// Create do
d = &Do{
mc: &sync.Mutex{},
mq: &sync.Mutex{},
}
// Create cond
d.cond = sync.NewCond(d.mc)
// Create context
d.ctx, d.cancel = context.WithCancel(context.Background())
// Do
go d.do()
return
} | [
"func",
"NewDo",
"(",
")",
"(",
"d",
"*",
"Do",
")",
"{",
"// Create do",
"d",
"=",
"&",
"Do",
"{",
"mc",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
",",
"mq",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
",",
"}",
"\n\n",
"// Create cond",
"d",
... | // NewDo creates a new Do | [
"NewDo",
"creates",
"a",
"new",
"Do"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/do.go#L19-L35 |
143,649 | asticode/go-astitools | sync/do.go | Do | func (d *Do) Do(fn func()) {
// Add job
d.mq.Lock()
d.queue = append(d.queue, fn)
d.mq.Unlock()
// Broadcast
d.cond.L.Lock()
d.cond.Broadcast()
d.cond.L.Unlock()
} | go | func (d *Do) Do(fn func()) {
// Add job
d.mq.Lock()
d.queue = append(d.queue, fn)
d.mq.Unlock()
// Broadcast
d.cond.L.Lock()
d.cond.Broadcast()
d.cond.L.Unlock()
} | [
"func",
"(",
"d",
"*",
"Do",
")",
"Do",
"(",
"fn",
"func",
"(",
")",
")",
"{",
"// Add job",
"d",
".",
"mq",
".",
"Lock",
"(",
")",
"\n",
"d",
".",
"queue",
"=",
"append",
"(",
"d",
".",
"queue",
",",
"fn",
")",
"\n",
"d",
".",
"mq",
".",... | // Do execute a new func | [
"Do",
"execute",
"a",
"new",
"func"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/do.go#L44-L54 |
143,650 | asticode/go-astitools | sync/do.go | do | func (d *Do) do() {
for {
// Check context
if d.ctx.Err() != nil {
return
}
// Lock cond here in case a func is added between retrieving l and doing the if on it
d.cond.L.Lock()
// Get number of funcs in queue
d.mq.Lock()
l := len(d.queue)
d.mq.Unlock()
// No queued funcs
if l == 0 {
d.c... | go | func (d *Do) do() {
for {
// Check context
if d.ctx.Err() != nil {
return
}
// Lock cond here in case a func is added between retrieving l and doing the if on it
d.cond.L.Lock()
// Get number of funcs in queue
d.mq.Lock()
l := len(d.queue)
d.mq.Unlock()
// No queued funcs
if l == 0 {
d.c... | [
"func",
"(",
"d",
"*",
"Do",
")",
"do",
"(",
")",
"{",
"for",
"{",
"// Check context",
"if",
"d",
".",
"ctx",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// Lock cond here in case a func is added between retrieving l and doing the if ... | // do loops through funcs in queue and executes them if any, or wait for a new one otherwise | [
"do",
"loops",
"through",
"funcs",
"in",
"queue",
"and",
"executes",
"them",
"if",
"any",
"or",
"wait",
"for",
"a",
"new",
"one",
"otherwise"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/do.go#L57-L93 |
143,651 | asticode/go-astitools | exec/writer.go | NewStdWriter | func NewStdWriter(fn func(i []byte)) *StdWriter {
return &StdWriter{buffer: &bytes.Buffer{}, fn: fn}
} | go | func NewStdWriter(fn func(i []byte)) *StdWriter {
return &StdWriter{buffer: &bytes.Buffer{}, fn: fn}
} | [
"func",
"NewStdWriter",
"(",
"fn",
"func",
"(",
"i",
"[",
"]",
"byte",
")",
")",
"*",
"StdWriter",
"{",
"return",
"&",
"StdWriter",
"{",
"buffer",
":",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
",",
"fn",
":",
"fn",
"}",
"\n",
"}"
] | // NewStdWriter creates a new StdWriter | [
"NewStdWriter",
"creates",
"a",
"new",
"StdWriter"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/exec/writer.go#L17-L19 |
143,652 | asticode/go-astitools | os/file.go | TempFile | func TempFile(i []byte) (name string, err error) {
// Create temp file
var f *os.File
if f, err = ioutil.TempFile(os.TempDir(), "astitools"); err != nil {
err = errors.Wrap(err, "creating temp file failed")
return
}
name = f.Name()
defer f.Close()
// Write
if _, err = f.Write(i); err != nil {
err = error... | go | func TempFile(i []byte) (name string, err error) {
// Create temp file
var f *os.File
if f, err = ioutil.TempFile(os.TempDir(), "astitools"); err != nil {
err = errors.Wrap(err, "creating temp file failed")
return
}
name = f.Name()
defer f.Close()
// Write
if _, err = f.Write(i); err != nil {
err = error... | [
"func",
"TempFile",
"(",
"i",
"[",
"]",
"byte",
")",
"(",
"name",
"string",
",",
"err",
"error",
")",
"{",
"// Create temp file",
"var",
"f",
"*",
"os",
".",
"File",
"\n",
"if",
"f",
",",
"err",
"=",
"ioutil",
".",
"TempFile",
"(",
"os",
".",
"Te... | // TempFile writes a content to a temp file | [
"TempFile",
"writes",
"a",
"content",
"to",
"a",
"temp",
"file"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/os/file.go#L11-L27 |
143,653 | asticode/go-astitools | io/copy.go | Copy | func Copy(ctx context.Context, src io.Reader, dst io.Writer) (int64, error) {
return io.Copy(dst, NewReader(ctx, src))
} | go | func Copy(ctx context.Context, src io.Reader, dst io.Writer) (int64, error) {
return io.Copy(dst, NewReader(ctx, src))
} | [
"func",
"Copy",
"(",
"ctx",
"context",
".",
"Context",
",",
"src",
"io",
".",
"Reader",
",",
"dst",
"io",
".",
"Writer",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"io",
".",
"Copy",
"(",
"dst",
",",
"NewReader",
"(",
"ctx",
",",
"src",... | // Copy represents a cancellable copy | [
"Copy",
"represents",
"a",
"cancellable",
"copy"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/io/copy.go#L9-L11 |
143,654 | asticode/go-astitools | flag/flag.go | Subcommand | func Subcommand() (o string) {
if len(os.Args) >= 2 && os.Args[1][0] != '-' {
o = os.Args[1]
os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
}
return
} | go | func Subcommand() (o string) {
if len(os.Args) >= 2 && os.Args[1][0] != '-' {
o = os.Args[1]
os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
}
return
} | [
"func",
"Subcommand",
"(",
")",
"(",
"o",
"string",
")",
"{",
"if",
"len",
"(",
"os",
".",
"Args",
")",
">=",
"2",
"&&",
"os",
".",
"Args",
"[",
"1",
"]",
"[",
"0",
"]",
"!=",
"'-'",
"{",
"o",
"=",
"os",
".",
"Args",
"[",
"1",
"]",
"\n",
... | // Subcommand retrieves the subcommand from the input Args | [
"Subcommand",
"retrieves",
"the",
"subcommand",
"from",
"the",
"input",
"Args"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/flag/flag.go#L9-L15 |
143,655 | asticode/go-astitools | flag/flag.go | String | func (f StringsMap) String() string {
var s []string
for k := range f {
s = append(s, k)
}
return strings.Join(s, ",")
} | go | func (f StringsMap) String() string {
var s []string
for k := range f {
s = append(s, k)
}
return strings.Join(s, ",")
} | [
"func",
"(",
"f",
"StringsMap",
")",
"String",
"(",
")",
"string",
"{",
"var",
"s",
"[",
"]",
"string",
"\n",
"for",
"k",
":=",
"range",
"f",
"{",
"s",
"=",
"append",
"(",
"s",
",",
"k",
")",
"\n",
"}",
"\n",
"return",
"strings",
".",
"Join",
... | // String implements the flag.Value interface | [
"String",
"implements",
"the",
"flag",
".",
"Value",
"interface"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/flag/flag.go#L40-L46 |
143,656 | asticode/go-astitools | regexp/replace.go | ReplaceAll | func ReplaceAll(rgx *regexp.Regexp, src *[]byte, rpl []byte) {
// Find all matches
var start, end, delta, offset, i int
var l = len(rpl)
for _, indexes := range rgx.FindAllIndex(*src, -1) {
// Update indexes
start = indexes[0] + offset
end = indexes[1] + offset
delta = (end - start) - l
offset -= delta
... | go | func ReplaceAll(rgx *regexp.Regexp, src *[]byte, rpl []byte) {
// Find all matches
var start, end, delta, offset, i int
var l = len(rpl)
for _, indexes := range rgx.FindAllIndex(*src, -1) {
// Update indexes
start = indexes[0] + offset
end = indexes[1] + offset
delta = (end - start) - l
offset -= delta
... | [
"func",
"ReplaceAll",
"(",
"rgx",
"*",
"regexp",
".",
"Regexp",
",",
"src",
"*",
"[",
"]",
"byte",
",",
"rpl",
"[",
"]",
"byte",
")",
"{",
"// Find all matches",
"var",
"start",
",",
"end",
",",
"delta",
",",
"offset",
",",
"i",
"int",
"\n",
"var",... | // ReplaceAll replaces all matches from a source | [
"ReplaceAll",
"replaces",
"all",
"matches",
"from",
"a",
"source"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/regexp/replace.go#L6-L31 |
143,657 | asticode/go-astitools | archive/tar.go | Untar | func Untar(ctx context.Context, src, dst string) (err error) {
// Open src
var srcFile *os.File
if srcFile, err = os.Open(src); err != nil {
return errors.Wrapf(err, "astiarchive: opening %s failed", src)
}
defer srcFile.Close()
// Create gzip reader
var gzr *gzip.Reader
if gzr, err = gzip.NewReader(srcFile)... | go | func Untar(ctx context.Context, src, dst string) (err error) {
// Open src
var srcFile *os.File
if srcFile, err = os.Open(src); err != nil {
return errors.Wrapf(err, "astiarchive: opening %s failed", src)
}
defer srcFile.Close()
// Create gzip reader
var gzr *gzip.Reader
if gzr, err = gzip.NewReader(srcFile)... | [
"func",
"Untar",
"(",
"ctx",
"context",
".",
"Context",
",",
"src",
",",
"dst",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Open src",
"var",
"srcFile",
"*",
"os",
".",
"File",
"\n",
"if",
"srcFile",
",",
"err",
"=",
"os",
".",
"Open",
"(",
... | // Untar untars a src into a dst | [
"Untar",
"untars",
"a",
"src",
"into",
"a",
"dst"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/archive/tar.go#L18-L69 |
143,658 | asticode/go-astitools | os/move.go | Move | func Move(ctx context.Context, src, dst string) (err error) {
// Check context
if err = ctx.Err(); err != nil {
return
}
// Copy
if err = Copy(ctx, src, dst); err != nil {
return
}
// Check context
if err = ctx.Err(); err != nil {
return
}
// Delete
err = os.Remove(src)
return
} | go | func Move(ctx context.Context, src, dst string) (err error) {
// Check context
if err = ctx.Err(); err != nil {
return
}
// Copy
if err = Copy(ctx, src, dst); err != nil {
return
}
// Check context
if err = ctx.Err(); err != nil {
return
}
// Delete
err = os.Remove(src)
return
} | [
"func",
"Move",
"(",
"ctx",
"context",
".",
"Context",
",",
"src",
",",
"dst",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Check context",
"if",
"err",
"=",
"ctx",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n... | // Move is a cross partitions cancellable move even if files are on different partitions | [
"Move",
"is",
"a",
"cross",
"partitions",
"cancellable",
"move",
"even",
"if",
"files",
"are",
"on",
"different",
"partitions"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/os/move.go#L9-L28 |
143,659 | asticode/go-astitools | worker/dial.go | Dial | func (w *Worker) Dial(o DialOptions) {
// Create task
t := w.NewTask()
// Execute the rest in a goroutine
go func() {
// Dial
go func() {
const sleepError = 5 * time.Second
for {
// Check context error
if w.ctx.Err() != nil {
break
}
// Dial
astilog.Infof("astiworker: dialing %s... | go | func (w *Worker) Dial(o DialOptions) {
// Create task
t := w.NewTask()
// Execute the rest in a goroutine
go func() {
// Dial
go func() {
const sleepError = 5 * time.Second
for {
// Check context error
if w.ctx.Err() != nil {
break
}
// Dial
astilog.Infof("astiworker: dialing %s... | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Dial",
"(",
"o",
"DialOptions",
")",
"{",
"// Create task",
"t",
":=",
"w",
".",
"NewTask",
"(",
")",
"\n\n",
"// Execute the rest in a goroutine",
"go",
"func",
"(",
")",
"{",
"// Dial",
"go",
"func",
"(",
")",
"... | // Dial dials with options | [
"Dial",
"dials",
"with",
"options"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/dial.go#L22-L79 |
143,660 | asticode/go-astitools | binary/writer.go | Write | func (w *Writer) Write(i interface{}) {
var s string
switch i.(type) {
case string:
s = i.(string)
case []byte:
for _, b := range i.([]byte) {
s += fmt.Sprintf("%.8b", b)
}
case bool:
if i.(bool) {
s = "1"
} else {
s = "0"
}
case uint8:
s = fmt.Sprintf("%.8b", i)
case uint16:
s = fmt.Spr... | go | func (w *Writer) Write(i interface{}) {
var s string
switch i.(type) {
case string:
s = i.(string)
case []byte:
for _, b := range i.([]byte) {
s += fmt.Sprintf("%.8b", b)
}
case bool:
if i.(bool) {
s = "1"
} else {
s = "0"
}
case uint8:
s = fmt.Sprintf("%.8b", i)
case uint16:
s = fmt.Spr... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"var",
"s",
"string",
"\n",
"switch",
"i",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"s",
"=",
"i",
".",
"(",
"string",
")",
"\n",
"case",
"[",... | // Write writes binary stuff | [
"Write",
"writes",
"binary",
"stuff"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/binary/writer.go#L25-L67 |
143,661 | asticode/go-astitools | config/config.go | New | func New(global interface{}, localPath string, flag interface{}) (_ interface{}, err error) {
// Local config
if localPath != "" {
if _, err = toml.DecodeFile(localPath, global); err != nil {
err = errors.Wrapf(err, "asticonfig: toml decoding %s failed", localPath)
return
}
}
// Merge configs
if err = m... | go | func New(global interface{}, localPath string, flag interface{}) (_ interface{}, err error) {
// Local config
if localPath != "" {
if _, err = toml.DecodeFile(localPath, global); err != nil {
err = errors.Wrapf(err, "asticonfig: toml decoding %s failed", localPath)
return
}
}
// Merge configs
if err = m... | [
"func",
"New",
"(",
"global",
"interface",
"{",
"}",
",",
"localPath",
"string",
",",
"flag",
"interface",
"{",
"}",
")",
"(",
"_",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"// Local config",
"if",
"localPath",
"!=",
"\"",
"\"",
"{",
"if... | // New builds a new configuration based on a ptr to the global configuration, the path to the optional toml local
// configuration and a ptr to the flag configuration | [
"New",
"builds",
"a",
"new",
"configuration",
"based",
"on",
"a",
"ptr",
"to",
"the",
"global",
"configuration",
"the",
"path",
"to",
"the",
"optional",
"toml",
"local",
"configuration",
"and",
"a",
"ptr",
"to",
"the",
"flag",
"configuration"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/config/config.go#L11-L26 |
143,662 | asticode/go-astitools | debug/stack.go | NewStack | func NewStack() (o Stack) {
var i = &StackItem{}
for _, line := range bytes.Split(DebugStack(), byteLineDelimiter) {
// Trim line
line = bytes.TrimSpace(line)
// Check line type
var r [][]string
if r = regexpFunction.FindAllStringSubmatch(string(line), -1); len(r) > 0 && len(r[0]) > 1 {
i.Function = r[0... | go | func NewStack() (o Stack) {
var i = &StackItem{}
for _, line := range bytes.Split(DebugStack(), byteLineDelimiter) {
// Trim line
line = bytes.TrimSpace(line)
// Check line type
var r [][]string
if r = regexpFunction.FindAllStringSubmatch(string(line), -1); len(r) > 0 && len(r[0]) > 1 {
i.Function = r[0... | [
"func",
"NewStack",
"(",
")",
"(",
"o",
"Stack",
")",
"{",
"var",
"i",
"=",
"&",
"StackItem",
"{",
"}",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"bytes",
".",
"Split",
"(",
"DebugStack",
"(",
")",
",",
"byteLineDelimiter",
")",
"{",
"// Trim l... | // NewStack returns a new stack | [
"NewStack",
"returns",
"a",
"new",
"stack"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/debug/stack.go#L34-L52 |
143,663 | asticode/go-astitools | debug/stack.go | String | func (i StackItem) String() string {
return fmt.Sprintf("function %s at %s:%d", i.Function, i.Filename, i.Line)
} | go | func (i StackItem) String() string {
return fmt.Sprintf("function %s at %s:%d", i.Function, i.Filename, i.Line)
} | [
"func",
"(",
"i",
"StackItem",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"Function",
",",
"i",
".",
"Filename",
",",
"i",
".",
"Line",
")",
"\n",
"}"
] | // String allows StackItem to implement the Stringer interface | [
"String",
"allows",
"StackItem",
"to",
"implement",
"the",
"Stringer",
"interface"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/debug/stack.go#L55-L57 |
143,664 | asticode/go-astitools | io/linearizer.go | NewLinearizer | func NewLinearizer(ctx context.Context, r io.Reader, readSize, bufferSize int) (l *Linearizer) {
l = &Linearizer{
bufferSize: bufferSize,
bytesPool: sync.Pool{New: func() interface{} { return make([]byte, readSize) }},
r: r,
}
l.ctx, l.cancel = context.WithCancel(ctx)
return
} | go | func NewLinearizer(ctx context.Context, r io.Reader, readSize, bufferSize int) (l *Linearizer) {
l = &Linearizer{
bufferSize: bufferSize,
bytesPool: sync.Pool{New: func() interface{} { return make([]byte, readSize) }},
r: r,
}
l.ctx, l.cancel = context.WithCancel(ctx)
return
} | [
"func",
"NewLinearizer",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"io",
".",
"Reader",
",",
"readSize",
",",
"bufferSize",
"int",
")",
"(",
"l",
"*",
"Linearizer",
")",
"{",
"l",
"=",
"&",
"Linearizer",
"{",
"bufferSize",
":",
"bufferSize",
","... | // NewLinearizer creates a new linearizer that will read readSize bytes at each iteration, write it in its internal
// buffer capped at bufferSize bytes and allow reading this linearized data. | [
"NewLinearizer",
"creates",
"a",
"new",
"linearizer",
"that",
"will",
"read",
"readSize",
"bytes",
"at",
"each",
"iteration",
"write",
"it",
"in",
"its",
"internal",
"buffer",
"capped",
"at",
"bufferSize",
"bytes",
"and",
"allow",
"reading",
"this",
"linearized"... | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/io/linearizer.go#L34-L42 |
143,665 | asticode/go-astitools | io/linearizer.go | Start | func (l *Linearizer) Start() {
for {
// Check context error
if l.ctx.Err() != nil {
l.md.Lock()
l.dispatchEvent(&event{err: l.ctx.Err()})
return
}
// Get bytes from pool
var b = l.bytesPool.Get().([]byte)
// Read
n, err := l.r.Read(b)
if err != nil {
l.md.Lock()
l.dispatchEvent(&event{... | go | func (l *Linearizer) Start() {
for {
// Check context error
if l.ctx.Err() != nil {
l.md.Lock()
l.dispatchEvent(&event{err: l.ctx.Err()})
return
}
// Get bytes from pool
var b = l.bytesPool.Get().([]byte)
// Read
n, err := l.r.Read(b)
if err != nil {
l.md.Lock()
l.dispatchEvent(&event{... | [
"func",
"(",
"l",
"*",
"Linearizer",
")",
"Start",
"(",
")",
"{",
"for",
"{",
"// Check context error",
"if",
"l",
".",
"ctx",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"l",
".",
"md",
".",
"Lock",
"(",
")",
"\n",
"l",
".",
"dispatchEvent",
"(",
... | // Start reads the reader and dispatches events accordingly | [
"Start",
"reads",
"the",
"reader",
"and",
"dispatches",
"events",
"accordingly"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/io/linearizer.go#L54-L78 |
143,666 | asticode/go-astitools | io/linearizer.go | dispatchEvent | func (l *Linearizer) dispatchEvent(e *event) {
defer l.md.Unlock()
l.me.Lock()
defer l.me.Unlock()
if e.n+l.eventsSize > l.bufferSize {
return
}
l.events = append(l.events, e)
l.eventsSize += e.n
} | go | func (l *Linearizer) dispatchEvent(e *event) {
defer l.md.Unlock()
l.me.Lock()
defer l.me.Unlock()
if e.n+l.eventsSize > l.bufferSize {
return
}
l.events = append(l.events, e)
l.eventsSize += e.n
} | [
"func",
"(",
"l",
"*",
"Linearizer",
")",
"dispatchEvent",
"(",
"e",
"*",
"event",
")",
"{",
"defer",
"l",
".",
"md",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"me",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"me",
".",
"Unlock",
"(",
")"... | // dispatchEvent dispatches an event if it doesn't make the buffer overflow based on the bufferSize
// Assumption is made that l.md is locked | [
"dispatchEvent",
"dispatches",
"an",
"event",
"if",
"it",
"doesn",
"t",
"make",
"the",
"buffer",
"overflow",
"based",
"on",
"the",
"bufferSize",
"Assumption",
"is",
"made",
"that",
"l",
".",
"md",
"is",
"locked"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/io/linearizer.go#L82-L91 |
143,667 | asticode/go-astitools | limiter/limiter.go | New | func New() *Limiter {
return &Limiter{
buckets: make(map[string]*Bucket),
m: &sync.Mutex{},
}
} | go | func New() *Limiter {
return &Limiter{
buckets: make(map[string]*Bucket),
m: &sync.Mutex{},
}
} | [
"func",
"New",
"(",
")",
"*",
"Limiter",
"{",
"return",
"&",
"Limiter",
"{",
"buckets",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Bucket",
")",
",",
"m",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
",",
"}",
"\n",
"}"
] | // New creates a new limiter | [
"New",
"creates",
"a",
"new",
"limiter"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/limiter.go#L15-L20 |
143,668 | asticode/go-astitools | limiter/limiter.go | Add | func (l *Limiter) Add(name string, cap int, period time.Duration) *Bucket {
l.m.Lock()
defer l.m.Unlock()
if _, ok := l.buckets[name]; !ok {
l.buckets[name] = newBucket(cap, period)
}
return l.buckets[name]
} | go | func (l *Limiter) Add(name string, cap int, period time.Duration) *Bucket {
l.m.Lock()
defer l.m.Unlock()
if _, ok := l.buckets[name]; !ok {
l.buckets[name] = newBucket(cap, period)
}
return l.buckets[name]
} | [
"func",
"(",
"l",
"*",
"Limiter",
")",
"Add",
"(",
"name",
"string",
",",
"cap",
"int",
",",
"period",
"time",
".",
"Duration",
")",
"*",
"Bucket",
"{",
"l",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"m",
".",
"Unlock",
"(",
"... | // Add adds a new bucket | [
"Add",
"adds",
"a",
"new",
"bucket"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/limiter.go#L23-L30 |
143,669 | asticode/go-astitools | limiter/limiter.go | Bucket | func (l *Limiter) Bucket(name string) (b *Bucket, ok bool) {
l.m.Lock()
defer l.m.Unlock()
b, ok = l.buckets[name]
return
} | go | func (l *Limiter) Bucket(name string) (b *Bucket, ok bool) {
l.m.Lock()
defer l.m.Unlock()
b, ok = l.buckets[name]
return
} | [
"func",
"(",
"l",
"*",
"Limiter",
")",
"Bucket",
"(",
"name",
"string",
")",
"(",
"b",
"*",
"Bucket",
",",
"ok",
"bool",
")",
"{",
"l",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"b",
",",
... | // Bucket retrieves a bucket from the limiter | [
"Bucket",
"retrieves",
"a",
"bucket",
"from",
"the",
"limiter"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/limiter.go#L33-L38 |
143,670 | asticode/go-astitools | os/dir.go | TempDir | func TempDir(prefix string) (path string, err error) {
// Create temp file
var f *os.File
if f, err = ioutil.TempFile(os.TempDir(), prefix); err != nil {
err = errors.Wrap(err, "creating temporary file failed")
return
}
path = f.Name()
// Close temp file
if err = f.Close(); err != nil {
err = errors.Wrapf... | go | func TempDir(prefix string) (path string, err error) {
// Create temp file
var f *os.File
if f, err = ioutil.TempFile(os.TempDir(), prefix); err != nil {
err = errors.Wrap(err, "creating temporary file failed")
return
}
path = f.Name()
// Close temp file
if err = f.Close(); err != nil {
err = errors.Wrapf... | [
"func",
"TempDir",
"(",
"prefix",
"string",
")",
"(",
"path",
"string",
",",
"err",
"error",
")",
"{",
"// Create temp file",
"var",
"f",
"*",
"os",
".",
"File",
"\n",
"if",
"f",
",",
"err",
"=",
"ioutil",
".",
"TempFile",
"(",
"os",
".",
"TempDir",
... | // TempDir creates a temp dir | [
"TempDir",
"creates",
"a",
"temp",
"dir"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/os/dir.go#L11-L38 |
143,671 | asticode/go-astitools | limiter/bucket.go | newBucket | func newBucket(cap int, period time.Duration) (b *Bucket) {
b = &Bucket{
cap: cap,
channelQuit: make(chan bool),
count: 0,
period: period,
}
go b.tick()
return
} | go | func newBucket(cap int, period time.Duration) (b *Bucket) {
b = &Bucket{
cap: cap,
channelQuit: make(chan bool),
count: 0,
period: period,
}
go b.tick()
return
} | [
"func",
"newBucket",
"(",
"cap",
"int",
",",
"period",
"time",
".",
"Duration",
")",
"(",
"b",
"*",
"Bucket",
")",
"{",
"b",
"=",
"&",
"Bucket",
"{",
"cap",
":",
"cap",
",",
"channelQuit",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"count",
":",... | // newBucket creates a new bucket | [
"newBucket",
"creates",
"a",
"new",
"bucket"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/bucket.go#L16-L25 |
143,672 | asticode/go-astitools | limiter/bucket.go | Inc | func (b *Bucket) Inc() bool {
if b.count >= b.cap {
return false
}
b.count++
return true
} | go | func (b *Bucket) Inc() bool {
if b.count >= b.cap {
return false
}
b.count++
return true
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"Inc",
"(",
")",
"bool",
"{",
"if",
"b",
".",
"count",
">=",
"b",
".",
"cap",
"{",
"return",
"false",
"\n",
"}",
"\n",
"b",
".",
"count",
"++",
"\n",
"return",
"true",
"\n",
"}"
] | // Inc increments the bucket count | [
"Inc",
"increments",
"the",
"bucket",
"count"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/bucket.go#L28-L34 |
143,673 | asticode/go-astitools | limiter/bucket.go | tick | func (b *Bucket) tick() {
var t = time.NewTicker(b.period)
defer t.Stop()
for {
select {
case <-t.C:
b.count = 0
case <-b.channelQuit:
return
}
}
} | go | func (b *Bucket) tick() {
var t = time.NewTicker(b.period)
defer t.Stop()
for {
select {
case <-t.C:
b.count = 0
case <-b.channelQuit:
return
}
}
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"tick",
"(",
")",
"{",
"var",
"t",
"=",
"time",
".",
"NewTicker",
"(",
"b",
".",
"period",
")",
"\n",
"defer",
"t",
".",
"Stop",
"(",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"t",
".",
"C",
"... | // tick runs a ticker to purge the bucket | [
"tick",
"runs",
"a",
"ticker",
"to",
"purge",
"the",
"bucket"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/bucket.go#L37-L48 |
143,674 | asticode/go-astitools | limiter/bucket.go | close | func (b *Bucket) close() {
if b.channelQuit != nil {
close(b.channelQuit)
b.channelQuit = nil
}
} | go | func (b *Bucket) close() {
if b.channelQuit != nil {
close(b.channelQuit)
b.channelQuit = nil
}
} | [
"func",
"(",
"b",
"*",
"Bucket",
")",
"close",
"(",
")",
"{",
"if",
"b",
".",
"channelQuit",
"!=",
"nil",
"{",
"close",
"(",
"b",
".",
"channelQuit",
")",
"\n",
"b",
".",
"channelQuit",
"=",
"nil",
"\n",
"}",
"\n",
"}"
] | // close closes the bucket properly | [
"close",
"closes",
"the",
"bucket",
"properly"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/limiter/bucket.go#L51-L56 |
143,675 | asticode/go-astitools | context/canceller.go | NewCanceller | func NewCanceller() (c *Canceller) {
c = &Canceller{mutex: &sync.RWMutex{}}
c.Reset()
return
} | go | func NewCanceller() (c *Canceller) {
c = &Canceller{mutex: &sync.RWMutex{}}
c.Reset()
return
} | [
"func",
"NewCanceller",
"(",
")",
"(",
"c",
"*",
"Canceller",
")",
"{",
"c",
"=",
"&",
"Canceller",
"{",
"mutex",
":",
"&",
"sync",
".",
"RWMutex",
"{",
"}",
"}",
"\n",
"c",
".",
"Reset",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // NewCanceller returns a new canceller | [
"NewCanceller",
"returns",
"a",
"new",
"canceller"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/context/canceller.go#L16-L20 |
143,676 | asticode/go-astitools | context/canceller.go | Cancel | func (c *Canceller) Cancel() {
c.mutex.Lock()
defer c.mutex.Unlock()
c.cancel()
} | go | func (c *Canceller) Cancel() {
c.mutex.Lock()
defer c.mutex.Unlock()
c.cancel()
} | [
"func",
"(",
"c",
"*",
"Canceller",
")",
"Cancel",
"(",
")",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"cancel",
"(",
")",
"\n",
"}"
] | // Cancel cancels the canceller context | [
"Cancel",
"cancels",
"the",
"canceller",
"context"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/context/canceller.go#L23-L27 |
143,677 | asticode/go-astitools | context/canceller.go | NewContext | func (c *Canceller) NewContext() (context.Context, context.CancelFunc) {
return context.WithCancel(c.ctx)
} | go | func (c *Canceller) NewContext() (context.Context, context.CancelFunc) {
return context.WithCancel(c.ctx)
} | [
"func",
"(",
"c",
"*",
"Canceller",
")",
"NewContext",
"(",
")",
"(",
"context",
".",
"Context",
",",
"context",
".",
"CancelFunc",
")",
"{",
"return",
"context",
".",
"WithCancel",
"(",
"c",
".",
"ctx",
")",
"\n",
"}"
] | // Lock locks the canceller mutex | [
"Lock",
"locks",
"the",
"canceller",
"mutex"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/context/canceller.go#L40-L42 |
143,678 | asticode/go-astitools | context/canceller.go | Reset | func (c *Canceller) Reset() {
c.ctx, c.cancel = context.WithCancel(context.Background())
} | go | func (c *Canceller) Reset() {
c.ctx, c.cancel = context.WithCancel(context.Background())
} | [
"func",
"(",
"c",
"*",
"Canceller",
")",
"Reset",
"(",
")",
"{",
"c",
".",
"ctx",
",",
"c",
".",
"cancel",
"=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"}"
] | // Reset resets the canceller context | [
"Reset",
"resets",
"the",
"canceller",
"context"
] | e078684fbd9fa6697ab3f018a9e089a06c7b6f51 | https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/context/canceller.go#L45-L47 |
143,679 | beamly/go-gocd | cli/error.go | NewCliError | func NewCliError(reqType string, hr *gocd.APIResponse, err error) (jerr JSONCliError) {
data := dataJSONCliError{
"error": err.Error(),
}
if hr != nil {
data["status"] = hr.HTTP.StatusCode
data["response-body"] = hr.Body
data["request-endpoint"] = hr.Request.HTTP.URL.String()
if hr.HTTP.StatusCode == 404 ... | go | func NewCliError(reqType string, hr *gocd.APIResponse, err error) (jerr JSONCliError) {
data := dataJSONCliError{
"error": err.Error(),
}
if hr != nil {
data["status"] = hr.HTTP.StatusCode
data["response-body"] = hr.Body
data["request-endpoint"] = hr.Request.HTTP.URL.String()
if hr.HTTP.StatusCode == 404 ... | [
"func",
"NewCliError",
"(",
"reqType",
"string",
",",
"hr",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"(",
"jerr",
"JSONCliError",
")",
"{",
"data",
":=",
"dataJSONCliError",
"{",
"\"",
"\"",
":",
"err",
".",
"Error",
"(",
")",
",",
... | // NewCliError creates an error which can be returned from a cli action | [
"NewCliError",
"creates",
"an",
"error",
"which",
"can",
"be",
"returned",
"from",
"a",
"cli",
"action"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/error.go#L23-L49 |
143,680 | beamly/go-gocd | cli/error.go | Error | func (e JSONCliError) Error() string {
b, err := json.MarshalIndent(e.data, "", " ")
if err != nil {
panic(err)
}
return string(b)
} | go | func (e JSONCliError) Error() string {
b, err := json.MarshalIndent(e.data, "", " ")
if err != nil {
panic(err)
}
return string(b)
} | [
"func",
"(",
"e",
"JSONCliError",
")",
"Error",
"(",
")",
"string",
"{",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"e",
".",
"data",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err"... | // Error encodes the error as a JSON string | [
"Error",
"encodes",
"the",
"error",
"as",
"a",
"JSON",
"string"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/error.go#L52-L59 |
143,681 | beamly/go-gocd | cli/error.go | ExitCode | func (e JSONCliError) ExitCode() int {
if e.resp == nil {
return 1
}
code := e.resp.HTTP.StatusCode
if code >= 100 && code < 200 {
return 10
} else if code >= 200 && code < 300 {
return 20
} else if code >= 300 && code < 400 {
return 30
} else if code >= 400 && code < 500 {
return 40
} else if code >=... | go | func (e JSONCliError) ExitCode() int {
if e.resp == nil {
return 1
}
code := e.resp.HTTP.StatusCode
if code >= 100 && code < 200 {
return 10
} else if code >= 200 && code < 300 {
return 20
} else if code >= 300 && code < 400 {
return 30
} else if code >= 400 && code < 500 {
return 40
} else if code >=... | [
"func",
"(",
"e",
"JSONCliError",
")",
"ExitCode",
"(",
")",
"int",
"{",
"if",
"e",
".",
"resp",
"==",
"nil",
"{",
"return",
"1",
"\n",
"}",
"\n",
"code",
":=",
"e",
".",
"resp",
".",
"HTTP",
".",
"StatusCode",
"\n",
"if",
"code",
">=",
"100",
... | // ExitCode returns the cli statusin the event of an error | [
"ExitCode",
"returns",
"the",
"cli",
"statusin",
"the",
"event",
"of",
"an",
"error"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/error.go#L62-L79 |
143,682 | beamly/go-gocd | cli/pipelineconfig.go | createPipelineConfigAction | func createPipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
group := c.String("group")
if group == "" {
return nil, nil, NewFlagError("group")
}
pipeline := c.String("pipeline-json")
pipelineFile := c.String("pipeline-file")
if pipeline == "" && pip... | go | func createPipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
group := c.String("group")
if group == "" {
return nil, nil, NewFlagError("group")
}
pipeline := c.String("pipeline-json")
pipelineFile := c.String("pipeline-file")
if pipeline == "" && pip... | [
"func",
"createPipelineConfigAction",
"(",
"client",
"*",
"gocd",
".",
"Client",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"(",
"r",
"interface",
"{",
"}",
",",
"resp",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"{",
"group",
":=",
"... | // CreatePipelineConfigAction handles the interaction between the cli flags and the action handler for
// create-pipeline-config-action | [
"CreatePipelineConfigAction",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"create",
"-",
"pipeline",
"-",
"config",
"-",
"action"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L27-L59 |
143,683 | beamly/go-gocd | cli/pipelineconfig.go | updatePipelineConfigAction | func updatePipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var name, version string
if name = c.String("name"); name == "" {
return nil, nil, NewFlagError("name")
}
if version = c.String("pipeline-version"); version == "" {
return nil, nil, NewFla... | go | func updatePipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var name, version string
if name = c.String("name"); name == "" {
return nil, nil, NewFlagError("name")
}
if version = c.String("pipeline-version"); version == "" {
return nil, nil, NewFla... | [
"func",
"updatePipelineConfigAction",
"(",
"client",
"*",
"gocd",
".",
"Client",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"(",
"r",
"interface",
"{",
"}",
",",
"resp",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"{",
"var",
"name",
"... | // UpdatePipelineConfigAction handles the interaction between the cli flags and the action handler for
// update-pipeline-config-action | [
"UpdatePipelineConfigAction",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"update",
"-",
"pipeline",
"-",
"config",
"-",
"action"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L63-L102 |
143,684 | beamly/go-gocd | cli/pipelineconfig.go | deletePipelineConfigAction | func deletePipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
name := c.String("name")
if name == "" {
return nil, nil, NewFlagError("name")
}
deleteResponse, resp, err := client.PipelineConfigs.Delete(context.Background(), name)
if resp.HTTP.StatusCod... | go | func deletePipelineConfigAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
name := c.String("name")
if name == "" {
return nil, nil, NewFlagError("name")
}
deleteResponse, resp, err := client.PipelineConfigs.Delete(context.Background(), name)
if resp.HTTP.StatusCod... | [
"func",
"deletePipelineConfigAction",
"(",
"client",
"*",
"gocd",
".",
"Client",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"(",
"r",
"interface",
"{",
"}",
",",
"resp",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"{",
"name",
":=",
"c... | // DeletePipelineConfigAction handles the interaction between the cli flags and the action handler for
// delete-pipeline-config-action | [
"DeletePipelineConfigAction",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"delete",
"-",
"pipeline",
"-",
"config",
"-",
"action"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L106-L117 |
143,685 | beamly/go-gocd | cli/pipelineconfig.go | createPipelineConfigCommand | func createPipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: CreatePipelineConfigCommandName,
Usage: CreatePipelineConfigCommandUsage,
Action: ActionWrapper(createPipelineConfigAction),
Category: "Pipeline Configs",
Flags: []cli.Flag{
cli.StringFlag{Name: "group"},
cli.StringFl... | go | func createPipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: CreatePipelineConfigCommandName,
Usage: CreatePipelineConfigCommandUsage,
Action: ActionWrapper(createPipelineConfigAction),
Category: "Pipeline Configs",
Flags: []cli.Flag{
cli.StringFlag{Name: "group"},
cli.StringFl... | [
"func",
"createPipelineConfigCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"CreatePipelineConfigCommandName",
",",
"Usage",
":",
"CreatePipelineConfigCommandUsage",
",",
"Action",
":",
"ActionWrapper",
... | // CreatePipelineConfigCommand handles the interaction between the cli flags and the action handler for create-pipeline-config | [
"CreatePipelineConfigCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"create",
"-",
"pipeline",
"-",
"config"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L134-L146 |
143,686 | beamly/go-gocd | cli/pipelineconfig.go | updatePipelineConfigCommand | func updatePipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: UpdatePipelineConfigCommandName,
Usage: UpdatePipelineConfigCommandUsage,
Action: ActionWrapper(updatePipelineConfigAction),
Category: "Pipeline Configs",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
cli.StringFla... | go | func updatePipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: UpdatePipelineConfigCommandName,
Usage: UpdatePipelineConfigCommandUsage,
Action: ActionWrapper(updatePipelineConfigAction),
Category: "Pipeline Configs",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
cli.StringFla... | [
"func",
"updatePipelineConfigCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"UpdatePipelineConfigCommandName",
",",
"Usage",
":",
"UpdatePipelineConfigCommandUsage",
",",
"Action",
":",
"ActionWrapper",
... | // UpdatePipelineConfigCommand handles the interaction between the cli flags and the action handler for update-pipeline-config | [
"UpdatePipelineConfigCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"update",
"-",
"pipeline",
"-",
"config"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L149-L162 |
143,687 | beamly/go-gocd | cli/pipelineconfig.go | deletePipelineConfigCommand | func deletePipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: DeletePipelineConfigCommandName,
Usage: DeletePipelineConfigCommandUsage,
Category: "Pipeline Configs",
Action: ActionWrapper(deletePipelineConfigAction),
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
}
} | go | func deletePipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: DeletePipelineConfigCommandName,
Usage: DeletePipelineConfigCommandUsage,
Category: "Pipeline Configs",
Action: ActionWrapper(deletePipelineConfigAction),
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
}
} | [
"func",
"deletePipelineConfigCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"DeletePipelineConfigCommandName",
",",
"Usage",
":",
"DeletePipelineConfigCommandUsage",
",",
"Category",
":",
"\"",
"\"",
... | // DeletePipelineConfigCommand handles the interaction between the cli flags and the action handler for delete-pipeline-config | [
"DeletePipelineConfigCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"delete",
"-",
"pipeline",
"-",
"config"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L165-L175 |
143,688 | beamly/go-gocd | cli/pipelineconfig.go | getPipelineConfigCommand | func getPipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineConfigCommandName,
Usage: GetPipelineConfigCommandUsage,
Action: ActionWrapper(getPipelineConfigAction),
Category: "Pipeline Configs",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
}
} | go | func getPipelineConfigCommand() *cli.Command {
return &cli.Command{
Name: GetPipelineConfigCommandName,
Usage: GetPipelineConfigCommandUsage,
Action: ActionWrapper(getPipelineConfigAction),
Category: "Pipeline Configs",
Flags: []cli.Flag{
cli.StringFlag{Name: "name"},
},
}
} | [
"func",
"getPipelineConfigCommand",
"(",
")",
"*",
"cli",
".",
"Command",
"{",
"return",
"&",
"cli",
".",
"Command",
"{",
"Name",
":",
"GetPipelineConfigCommandName",
",",
"Usage",
":",
"GetPipelineConfigCommandUsage",
",",
"Action",
":",
"ActionWrapper",
"(",
"... | // GetPipelineConfigCommand handles the interaction between the cli flags and the action handler for get-pipeline-config | [
"GetPipelineConfigCommand",
"handles",
"the",
"interaction",
"between",
"the",
"cli",
"flags",
"and",
"the",
"action",
"handler",
"for",
"get",
"-",
"pipeline",
"-",
"config"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/pipelineconfig.go#L178-L188 |
143,689 | beamly/go-gocd | gocd/pipeline.go | GetStatus | func (pgs *PipelinesService) GetStatus(ctx context.Context, name string, offset int) (ps *PipelineStatus, resp *APIResponse, err error) {
ps = &PipelineStatus{}
_, resp, err = pgs.client.getAction(ctx, &APIClientRequest{
Path: fmt.Sprintf("pipelines/%s/status", name),
ResponseBody: ps,
})
return
} | go | func (pgs *PipelinesService) GetStatus(ctx context.Context, name string, offset int) (ps *PipelineStatus, resp *APIResponse, err error) {
ps = &PipelineStatus{}
_, resp, err = pgs.client.getAction(ctx, &APIClientRequest{
Path: fmt.Sprintf("pipelines/%s/status", name),
ResponseBody: ps,
})
return
} | [
"func",
"(",
"pgs",
"*",
"PipelinesService",
")",
"GetStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"offset",
"int",
")",
"(",
"ps",
"*",
"PipelineStatus",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"p... | // GetStatus returns a list of pipeline instanves describing the pipeline history. | [
"GetStatus",
"returns",
"a",
"list",
"of",
"pipeline",
"instanves",
"describing",
"the",
"pipeline",
"history",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/pipeline.go#L145-L153 |
143,690 | beamly/go-gocd | gocd/pipeline.go | Pause | func (pgs *PipelinesService) Pause(ctx context.Context, name string) (bool, *APIResponse, error) {
return pgs.pipelineAction(ctx, name, "pause")
} | go | func (pgs *PipelinesService) Pause(ctx context.Context, name string) (bool, *APIResponse, error) {
return pgs.pipelineAction(ctx, name, "pause")
} | [
"func",
"(",
"pgs",
"*",
"PipelinesService",
")",
"Pause",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"bool",
",",
"*",
"APIResponse",
",",
"error",
")",
"{",
"return",
"pgs",
".",
"pipelineAction",
"(",
"ctx",
",",
"name",... | // Pause allows a pipeline to handle new build events | [
"Pause",
"allows",
"a",
"pipeline",
"to",
"handle",
"new",
"build",
"events"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/pipeline.go#L156-L158 |
143,691 | beamly/go-gocd | gocd/pipeline.go | GetInstance | func (pgs *PipelinesService) GetInstance(ctx context.Context, name string, offset int) (pt *PipelineInstance, resp *APIResponse, err error) {
pt = &PipelineInstance{}
_, resp, err = pgs.client.getAction(ctx, &APIClientRequest{
Path: pgs.buildPaginatedStub("admin/pipelines/%s/instance", name, offset),
Res... | go | func (pgs *PipelinesService) GetInstance(ctx context.Context, name string, offset int) (pt *PipelineInstance, resp *APIResponse, err error) {
pt = &PipelineInstance{}
_, resp, err = pgs.client.getAction(ctx, &APIClientRequest{
Path: pgs.buildPaginatedStub("admin/pipelines/%s/instance", name, offset),
Res... | [
"func",
"(",
"pgs",
"*",
"PipelinesService",
")",
"GetInstance",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"offset",
"int",
")",
"(",
"pt",
"*",
"PipelineInstance",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
... | // GetInstance of a pipeline run. | [
"GetInstance",
"of",
"a",
"pipeline",
"run",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/pipeline.go#L171-L180 |
143,692 | beamly/go-gocd | gocd/plugin.go | List | func (ps *PluginsService) List(ctx context.Context) (*PluginsResponse, *APIResponse, error) {
apiVersion, err := ps.client.getAPIVersion(ctx, "admin/plugin_info")
if err != nil {
return nil, nil, err
}
pr := PluginsResponse{}
_, resp, err := ps.client.getAction(ctx, &APIClientRequest{
Path: "admin/plug... | go | func (ps *PluginsService) List(ctx context.Context) (*PluginsResponse, *APIResponse, error) {
apiVersion, err := ps.client.getAPIVersion(ctx, "admin/plugin_info")
if err != nil {
return nil, nil, err
}
pr := PluginsResponse{}
_, resp, err := ps.client.getAction(ctx, &APIClientRequest{
Path: "admin/plug... | [
"func",
"(",
"ps",
"*",
"PluginsService",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"PluginsResponse",
",",
"*",
"APIResponse",
",",
"error",
")",
"{",
"apiVersion",
",",
"err",
":=",
"ps",
".",
"client",
".",
"getAPIVersion",
... | // List retrieves all plugins | [
"List",
"retrieves",
"all",
"plugins"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/plugin.go#L155-L168 |
143,693 | beamly/go-gocd | gocd/config.go | LoadConfigByName | func LoadConfigByName(name string, cfg *Configuration) (err error) {
cfgs, err := LoadConfigFromFile()
if err == nil {
newCfg, hasCfg := cfgs[name]
if !hasCfg {
return fmt.Errorf("could not find configuration profile '%s'", name)
}
*cfg = *newCfg
} else {
return err
}
if server := os.Getenv(EnvVarS... | go | func LoadConfigByName(name string, cfg *Configuration) (err error) {
cfgs, err := LoadConfigFromFile()
if err == nil {
newCfg, hasCfg := cfgs[name]
if !hasCfg {
return fmt.Errorf("could not find configuration profile '%s'", name)
}
*cfg = *newCfg
} else {
return err
}
if server := os.Getenv(EnvVarS... | [
"func",
"LoadConfigByName",
"(",
"name",
"string",
",",
"cfg",
"*",
"Configuration",
")",
"(",
"err",
"error",
")",
"{",
"cfgs",
",",
"err",
":=",
"LoadConfigFromFile",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"newCfg",
",",
"hasCfg",
":=",
"cfgs... | // LoadConfigByName loads configurations from yaml at the default file location | [
"LoadConfigByName",
"loads",
"configurations",
"from",
"yaml",
"at",
"the",
"default",
"file",
"location"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config.go#L34-L61 |
143,694 | beamly/go-gocd | gocd/config.go | LoadConfigFromFile | func LoadConfigFromFile() (cfgs map[string]*Configuration, err error) {
var b []byte
cfgs = make(map[string]*Configuration)
p, err := ConfigFilePath()
if err != nil {
return
}
if _, err = os.Stat(p); !os.IsNotExist(err) {
if b, err = ioutil.ReadFile(p); err != nil {
return
}
if err = yaml.Unmarshal(b... | go | func LoadConfigFromFile() (cfgs map[string]*Configuration, err error) {
var b []byte
cfgs = make(map[string]*Configuration)
p, err := ConfigFilePath()
if err != nil {
return
}
if _, err = os.Stat(p); !os.IsNotExist(err) {
if b, err = ioutil.ReadFile(p); err != nil {
return
}
if err = yaml.Unmarshal(b... | [
"func",
"LoadConfigFromFile",
"(",
")",
"(",
"cfgs",
"map",
"[",
"string",
"]",
"*",
"Configuration",
",",
"err",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"cfgs",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Configuration",
")",
... | // LoadConfigFromFile on disk and return it as a Configuration item | [
"LoadConfigFromFile",
"on",
"disk",
"and",
"return",
"it",
"as",
"a",
"Configuration",
"item"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config.go#L64-L85 |
143,695 | beamly/go-gocd | gocd/config.go | ConfigFilePath | func ConfigFilePath() (configPath string, err error) {
var usr *user.User
if configPath = os.Getenv("GOCD_CONFIG_PATH"); configPath != "" {
return
}
// @TODO Make it work for windows. Maybe...
if usr, err = user.Current(); err != nil {
return
}
configPath = strings.Replace(ConfigDirectoryPath, "~", usr.Ho... | go | func ConfigFilePath() (configPath string, err error) {
var usr *user.User
if configPath = os.Getenv("GOCD_CONFIG_PATH"); configPath != "" {
return
}
// @TODO Make it work for windows. Maybe...
if usr, err = user.Current(); err != nil {
return
}
configPath = strings.Replace(ConfigDirectoryPath, "~", usr.Ho... | [
"func",
"ConfigFilePath",
"(",
")",
"(",
"configPath",
"string",
",",
"err",
"error",
")",
"{",
"var",
"usr",
"*",
"user",
".",
"User",
"\n\n",
"if",
"configPath",
"=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"configPath",
"!=",
"\"",
"\"",
... | // ConfigFilePath specifies the default path to a config file | [
"ConfigFilePath",
"specifies",
"the",
"default",
"path",
"to",
"a",
"config",
"file"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/config.go#L88-L102 |
143,696 | beamly/go-gocd | gocd/resource_pipeline_material_pkg.go | unmarshallMaterialAttributesPackage | func unmarshallMaterialAttributesPackage(mapk *MaterialAttributesPackage, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "ref":
mapk.Ref = value.(string)
}
}
} | go | func unmarshallMaterialAttributesPackage(mapk *MaterialAttributesPackage, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "ref":
mapk.Ref = value.(string)
}
}
} | [
"func",
"unmarshallMaterialAttributesPackage",
"(",
"mapk",
"*",
"MaterialAttributesPackage",
",",
"i",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"i",
"{",
"if",
"value",
"==",
"nil",
"{",
"conti... | // UnmarshallInterface from a JSON string to a MaterialAttributesPackage struct | [
"UnmarshallInterface",
"from",
"a",
"JSON",
"string",
"to",
"a",
"MaterialAttributesPackage",
"struct"
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/resource_pipeline_material_pkg.go#L32-L42 |
143,697 | beamly/go-gocd | gocd/configuration.go | Get | func (cs *ConfigurationService) Get(ctx context.Context) (cx *ConfigXML, resp *APIResponse, err error) {
cx = &ConfigXML{}
_, resp, err = cs.client.getAction(ctx, &APIClientRequest{
Path: "admin/config.xml",
ResponseBody: cx,
ResponseType: responseTypeXML,
})
return
} | go | func (cs *ConfigurationService) Get(ctx context.Context) (cx *ConfigXML, resp *APIResponse, err error) {
cx = &ConfigXML{}
_, resp, err = cs.client.getAction(ctx, &APIClientRequest{
Path: "admin/config.xml",
ResponseBody: cx,
ResponseType: responseTypeXML,
})
return
} | [
"func",
"(",
"cs",
"*",
"ConfigurationService",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"cx",
"*",
"ConfigXML",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"cx",
"=",
"&",
"ConfigXML",
"{",
"}",
"\n",
"_",
"... | // Get the config.xml document from the server and... render it as JSON... 'cause... eyugh. | [
"Get",
"the",
"config",
".",
"xml",
"document",
"from",
"the",
"server",
"and",
"...",
"render",
"it",
"as",
"JSON",
"...",
"cause",
"...",
"eyugh",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/configuration.go#L223-L231 |
143,698 | beamly/go-gocd | gocd/configuration.go | GetVersion | func (cs *ConfigurationService) GetVersion(ctx context.Context) (v *Version, resp *APIResponse, err error) {
v = &Version{}
_, resp, err = cs.client.getAction(ctx, &APIClientRequest{
Path: "version",
ResponseBody: v,
APIVersion: apiV1,
})
return
} | go | func (cs *ConfigurationService) GetVersion(ctx context.Context) (v *Version, resp *APIResponse, err error) {
v = &Version{}
_, resp, err = cs.client.getAction(ctx, &APIClientRequest{
Path: "version",
ResponseBody: v,
APIVersion: apiV1,
})
return
} | [
"func",
"(",
"cs",
"*",
"ConfigurationService",
")",
"GetVersion",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"v",
"*",
"Version",
",",
"resp",
"*",
"APIResponse",
",",
"err",
"error",
")",
"{",
"v",
"=",
"&",
"Version",
"{",
"}",
"\n",
"_",
... | // GetVersion of the GoCD server and other metadata about the software version. | [
"GetVersion",
"of",
"the",
"GoCD",
"server",
"and",
"other",
"metadata",
"about",
"the",
"software",
"version",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/gocd/configuration.go#L234-L242 |
143,699 | beamly/go-gocd | cli/encrypt.go | encryptAction | func encryptAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var value string
if value = c.String("value"); value == "" {
return nil, nil, NewFlagError("value")
}
return client.Encryption.Encrypt(context.Background(), value)
} | go | func encryptAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
var value string
if value = c.String("value"); value == "" {
return nil, nil, NewFlagError("value")
}
return client.Encryption.Encrypt(context.Background(), value)
} | [
"func",
"encryptAction",
"(",
"client",
"*",
"gocd",
".",
"Client",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"(",
"r",
"interface",
"{",
"}",
",",
"resp",
"*",
"gocd",
".",
"APIResponse",
",",
"err",
"error",
")",
"{",
"var",
"value",
"string",
"... | // EncryptAction gets a list of agents and return them. | [
"EncryptAction",
"gets",
"a",
"list",
"of",
"agents",
"and",
"return",
"them",
"."
] | 683f1a09c81e7911e899ef194fc4dc3392505636 | https://github.com/beamly/go-gocd/blob/683f1a09c81e7911e899ef194fc4dc3392505636/cli/encrypt.go#L16-L23 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.