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
130,500
gocolly/colly
queue/queue.go
Run
func (q *Queue) Run(c *colly.Collector) error { wg := &sync.WaitGroup{} for i := 0; i < q.Threads; i++ { wg.Add(1) go func(c *colly.Collector, wg *sync.WaitGroup) { defer wg.Done() for { if q.IsEmpty() { if q.activeThreadCount == 0 { break } ch := make(chan bool) q.lock.Lock() ...
go
func (q *Queue) Run(c *colly.Collector) error { wg := &sync.WaitGroup{} for i := 0; i < q.Threads; i++ { wg.Add(1) go func(c *colly.Collector, wg *sync.WaitGroup) { defer wg.Done() for { if q.IsEmpty() { if q.activeThreadCount == 0 { break } ch := make(chan bool) q.lock.Lock() ...
[ "func", "(", "q", "*", "Queue", ")", "Run", "(", "c", "*", "colly", ".", "Collector", ")", "error", "{", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "q", ".", "Threads", ";", "i", "++", "...
// Run starts consumer threads and calls the Collector // to perform requests. Run blocks while the queue has active requests
[ "Run", "starts", "consumer", "threads", "and", "calls", "the", "Collector", "to", "perform", "requests", ".", "Run", "blocks", "while", "the", "queue", "has", "active", "requests" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/queue/queue.go#L119-L159
130,501
gocolly/colly
colly.go
NewCollector
func NewCollector(options ...func(*Collector)) *Collector { c := &Collector{} c.Init() for _, f := range options { f(c) } c.parseSettingsFromEnv() return c }
go
func NewCollector(options ...func(*Collector)) *Collector { c := &Collector{} c.Init() for _, f := range options { f(c) } c.parseSettingsFromEnv() return c }
[ "func", "NewCollector", "(", "options", "...", "func", "(", "*", "Collector", ")", ")", "*", "Collector", "{", "c", ":=", "&", "Collector", "{", "}", "\n", "c", ".", "Init", "(", ")", "\n\n", "for", "_", ",", "f", ":=", "range", "options", "{", "...
// NewCollector creates a new Collector instance with default configuration
[ "NewCollector", "creates", "a", "new", "Collector", "instance", "with", "default", "configuration" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L243-L254
130,502
gocolly/colly
colly.go
DisallowedURLFilters
func DisallowedURLFilters(filters ...*regexp.Regexp) func(*Collector) { return func(c *Collector) { c.DisallowedURLFilters = filters } }
go
func DisallowedURLFilters(filters ...*regexp.Regexp) func(*Collector) { return func(c *Collector) { c.DisallowedURLFilters = filters } }
[ "func", "DisallowedURLFilters", "(", "filters", "...", "*", "regexp", ".", "Regexp", ")", "func", "(", "*", "Collector", ")", "{", "return", "func", "(", "c", "*", "Collector", ")", "{", "c", ".", "DisallowedURLFilters", "=", "filters", "\n", "}", "\n", ...
// DisallowedURLFilters sets the list of regular expressions which restricts // visiting URLs. If any of the rules matches to a URL the request will be stopped.
[ "DisallowedURLFilters", "sets", "the", "list", "of", "regular", "expressions", "which", "restricts", "visiting", "URLs", ".", "If", "any", "of", "the", "rules", "matches", "to", "a", "URL", "the", "request", "will", "be", "stopped", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L293-L297
130,503
gocolly/colly
colly.go
URLFilters
func URLFilters(filters ...*regexp.Regexp) func(*Collector) { return func(c *Collector) { c.URLFilters = filters } }
go
func URLFilters(filters ...*regexp.Regexp) func(*Collector) { return func(c *Collector) { c.URLFilters = filters } }
[ "func", "URLFilters", "(", "filters", "...", "*", "regexp", ".", "Regexp", ")", "func", "(", "*", "Collector", ")", "{", "return", "func", "(", "c", "*", "Collector", ")", "{", "c", ".", "URLFilters", "=", "filters", "\n", "}", "\n", "}" ]
// URLFilters sets the list of regular expressions which restricts // visiting URLs. If any of the rules matches to a URL the request won't be stopped.
[ "URLFilters", "sets", "the", "list", "of", "regular", "expressions", "which", "restricts", "visiting", "URLs", ".", "If", "any", "of", "the", "rules", "matches", "to", "a", "URL", "the", "request", "won", "t", "be", "stopped", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L301-L305
130,504
gocolly/colly
colly.go
Debugger
func Debugger(d debug.Debugger) func(*Collector) { return func(c *Collector) { d.Init() c.debugger = d } }
go
func Debugger(d debug.Debugger) func(*Collector) { return func(c *Collector) { d.Init() c.debugger = d } }
[ "func", "Debugger", "(", "d", "debug", ".", "Debugger", ")", "func", "(", "*", "Collector", ")", "{", "return", "func", "(", "c", "*", "Collector", ")", "{", "d", ".", "Init", "(", ")", "\n", "c", ".", "debugger", "=", "d", "\n", "}", "\n", "}"...
// Debugger sets the debugger used by the Collector.
[ "Debugger", "sets", "the", "debugger", "used", "by", "the", "Collector", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L359-L364
130,505
gocolly/colly
colly.go
Init
func (c *Collector) Init() { c.UserAgent = "colly - https://github.com/gocolly/colly" c.MaxDepth = 0 c.store = &storage.InMemoryStorage{} c.store.Init() c.MaxBodySize = 10 * 1024 * 1024 c.backend = &httpBackend{} jar, _ := cookiejar.New(nil) c.backend.Init(jar) c.backend.Client.CheckRedirect = c.checkRedirectF...
go
func (c *Collector) Init() { c.UserAgent = "colly - https://github.com/gocolly/colly" c.MaxDepth = 0 c.store = &storage.InMemoryStorage{} c.store.Init() c.MaxBodySize = 10 * 1024 * 1024 c.backend = &httpBackend{} jar, _ := cookiejar.New(nil) c.backend.Init(jar) c.backend.Client.CheckRedirect = c.checkRedirectF...
[ "func", "(", "c", "*", "Collector", ")", "Init", "(", ")", "{", "c", ".", "UserAgent", "=", "\"", "\"", "\n", "c", ".", "MaxDepth", "=", "0", "\n", "c", ".", "store", "=", "&", "storage", ".", "InMemoryStorage", "{", "}", "\n", "c", ".", "store...
// Init initializes the Collector's private variables and sets default // configuration for the Collector
[ "Init", "initializes", "the", "Collector", "s", "private", "variables", "and", "sets", "default", "configuration", "for", "the", "Collector" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L368-L383
130,506
gocolly/colly
colly.go
Visit
func (c *Collector) Visit(URL string) error { if c.CheckHead { if check := c.scrape(URL, "HEAD", 1, nil, nil, nil, true); check != nil { return check } } return c.scrape(URL, "GET", 1, nil, nil, nil, true) }
go
func (c *Collector) Visit(URL string) error { if c.CheckHead { if check := c.scrape(URL, "HEAD", 1, nil, nil, nil, true); check != nil { return check } } return c.scrape(URL, "GET", 1, nil, nil, nil, true) }
[ "func", "(", "c", "*", "Collector", ")", "Visit", "(", "URL", "string", ")", "error", "{", "if", "c", ".", "CheckHead", "{", "if", "check", ":=", "c", ".", "scrape", "(", "URL", ",", "\"", "\"", ",", "1", ",", "nil", ",", "nil", ",", "nil", "...
// Visit starts Collector's collecting job by creating a // request to the URL specified in parameter. // Visit also calls the previously provided callbacks
[ "Visit", "starts", "Collector", "s", "collecting", "job", "by", "creating", "a", "request", "to", "the", "URL", "specified", "in", "parameter", ".", "Visit", "also", "calls", "the", "previously", "provided", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L408-L415
130,507
gocolly/colly
colly.go
Head
func (c *Collector) Head(URL string) error { return c.scrape(URL, "HEAD", 1, nil, nil, nil, false) }
go
func (c *Collector) Head(URL string) error { return c.scrape(URL, "HEAD", 1, nil, nil, nil, false) }
[ "func", "(", "c", "*", "Collector", ")", "Head", "(", "URL", "string", ")", "error", "{", "return", "c", ".", "scrape", "(", "URL", ",", "\"", "\"", ",", "1", ",", "nil", ",", "nil", ",", "nil", ",", "false", ")", "\n", "}" ]
// Head starts a collector job by creating a HEAD request.
[ "Head", "starts", "a", "collector", "job", "by", "creating", "a", "HEAD", "request", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L418-L420
130,508
gocolly/colly
colly.go
Post
func (c *Collector) Post(URL string, requestData map[string]string) error { return c.scrape(URL, "POST", 1, createFormReader(requestData), nil, nil, true) }
go
func (c *Collector) Post(URL string, requestData map[string]string) error { return c.scrape(URL, "POST", 1, createFormReader(requestData), nil, nil, true) }
[ "func", "(", "c", "*", "Collector", ")", "Post", "(", "URL", "string", ",", "requestData", "map", "[", "string", "]", "string", ")", "error", "{", "return", "c", ".", "scrape", "(", "URL", ",", "\"", "\"", ",", "1", ",", "createFormReader", "(", "r...
// Post starts a collector job by creating a POST request. // Post also calls the previously provided callbacks
[ "Post", "starts", "a", "collector", "job", "by", "creating", "a", "POST", "request", ".", "Post", "also", "calls", "the", "previously", "provided", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L424-L426
130,509
gocolly/colly
colly.go
PostRaw
func (c *Collector) PostRaw(URL string, requestData []byte) error { return c.scrape(URL, "POST", 1, bytes.NewReader(requestData), nil, nil, true) }
go
func (c *Collector) PostRaw(URL string, requestData []byte) error { return c.scrape(URL, "POST", 1, bytes.NewReader(requestData), nil, nil, true) }
[ "func", "(", "c", "*", "Collector", ")", "PostRaw", "(", "URL", "string", ",", "requestData", "[", "]", "byte", ")", "error", "{", "return", "c", ".", "scrape", "(", "URL", ",", "\"", "\"", ",", "1", ",", "bytes", ".", "NewReader", "(", "requestDat...
// PostRaw starts a collector job by creating a POST request with raw binary data. // Post also calls the previously provided callbacks
[ "PostRaw", "starts", "a", "collector", "job", "by", "creating", "a", "POST", "request", "with", "raw", "binary", "data", ".", "Post", "also", "calls", "the", "previously", "provided", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L430-L432
130,510
gocolly/colly
colly.go
PostMultipart
func (c *Collector) PostMultipart(URL string, requestData map[string][]byte) error { boundary := randomBoundary() hdr := http.Header{} hdr.Set("Content-Type", "multipart/form-data; boundary="+boundary) hdr.Set("User-Agent", c.UserAgent) return c.scrape(URL, "POST", 1, createMultipartReader(boundary, requestData), ...
go
func (c *Collector) PostMultipart(URL string, requestData map[string][]byte) error { boundary := randomBoundary() hdr := http.Header{} hdr.Set("Content-Type", "multipart/form-data; boundary="+boundary) hdr.Set("User-Agent", c.UserAgent) return c.scrape(URL, "POST", 1, createMultipartReader(boundary, requestData), ...
[ "func", "(", "c", "*", "Collector", ")", "PostMultipart", "(", "URL", "string", ",", "requestData", "map", "[", "string", "]", "[", "]", "byte", ")", "error", "{", "boundary", ":=", "randomBoundary", "(", ")", "\n", "hdr", ":=", "http", ".", "Header", ...
// PostMultipart starts a collector job by creating a Multipart POST request // with raw binary data. PostMultipart also calls the previously provided callbacks
[ "PostMultipart", "starts", "a", "collector", "job", "by", "creating", "a", "Multipart", "POST", "request", "with", "raw", "binary", "data", ".", "PostMultipart", "also", "calls", "the", "previously", "provided", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L436-L442
130,511
gocolly/colly
colly.go
UnmarshalRequest
func (c *Collector) UnmarshalRequest(r []byte) (*Request, error) { req := &serializableRequest{} err := json.Unmarshal(r, req) if err != nil { return nil, err } u, err := url.Parse(req.URL) if err != nil { return nil, err } ctx := NewContext() for k, v := range req.Ctx { ctx.Put(k, v) } return &Requ...
go
func (c *Collector) UnmarshalRequest(r []byte) (*Request, error) { req := &serializableRequest{} err := json.Unmarshal(r, req) if err != nil { return nil, err } u, err := url.Parse(req.URL) if err != nil { return nil, err } ctx := NewContext() for k, v := range req.Ctx { ctx.Put(k, v) } return &Requ...
[ "func", "(", "c", "*", "Collector", ")", "UnmarshalRequest", "(", "r", "[", "]", "byte", ")", "(", "*", "Request", ",", "error", ")", "{", "req", ":=", "&", "serializableRequest", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "r", ","...
// UnmarshalRequest creates a Request from serialized data
[ "UnmarshalRequest", "creates", "a", "Request", "from", "serialized", "data" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L466-L492
130,512
gocolly/colly
colly.go
String
func (c *Collector) String() string { return fmt.Sprintf( "Requests made: %d (%d responses) | Callbacks: OnRequest: %d, OnHTML: %d, OnResponse: %d, OnError: %d", c.requestCount, c.responseCount, len(c.requestCallbacks), len(c.htmlCallbacks), len(c.responseCallbacks), len(c.errorCallbacks), ) }
go
func (c *Collector) String() string { return fmt.Sprintf( "Requests made: %d (%d responses) | Callbacks: OnRequest: %d, OnHTML: %d, OnResponse: %d, OnError: %d", c.requestCount, c.responseCount, len(c.requestCallbacks), len(c.htmlCallbacks), len(c.responseCallbacks), len(c.errorCallbacks), ) }
[ "func", "(", "c", "*", "Collector", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "requestCount", ",", "c", ".", "responseCount", ",", "len", "(", "c", ".", "requestCallbacks", ")", ",", "l...
// String is the text representation of the collector. // It contains useful debug information about the collector's internals
[ "String", "is", "the", "text", "representation", "of", "the", "collector", ".", "It", "contains", "useful", "debug", "information", "about", "the", "collector", "s", "internals" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L735-L745
130,513
gocolly/colly
colly.go
OnRequest
func (c *Collector) OnRequest(f RequestCallback) { c.lock.Lock() if c.requestCallbacks == nil { c.requestCallbacks = make([]RequestCallback, 0, 4) } c.requestCallbacks = append(c.requestCallbacks, f) c.lock.Unlock() }
go
func (c *Collector) OnRequest(f RequestCallback) { c.lock.Lock() if c.requestCallbacks == nil { c.requestCallbacks = make([]RequestCallback, 0, 4) } c.requestCallbacks = append(c.requestCallbacks, f) c.lock.Unlock() }
[ "func", "(", "c", "*", "Collector", ")", "OnRequest", "(", "f", "RequestCallback", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "if", "c", ".", "requestCallbacks", "==", "nil", "{", "c", ".", "requestCallbacks", "=", "make", "(", "[", "...
// OnRequest registers a function. Function will be executed on every // request made by the Collector
[ "OnRequest", "registers", "a", "function", ".", "Function", "will", "be", "executed", "on", "every", "request", "made", "by", "the", "Collector" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L754-L761
130,514
gocolly/colly
colly.go
OnResponse
func (c *Collector) OnResponse(f ResponseCallback) { c.lock.Lock() if c.responseCallbacks == nil { c.responseCallbacks = make([]ResponseCallback, 0, 4) } c.responseCallbacks = append(c.responseCallbacks, f) c.lock.Unlock() }
go
func (c *Collector) OnResponse(f ResponseCallback) { c.lock.Lock() if c.responseCallbacks == nil { c.responseCallbacks = make([]ResponseCallback, 0, 4) } c.responseCallbacks = append(c.responseCallbacks, f) c.lock.Unlock() }
[ "func", "(", "c", "*", "Collector", ")", "OnResponse", "(", "f", "ResponseCallback", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "if", "c", ".", "responseCallbacks", "==", "nil", "{", "c", ".", "responseCallbacks", "=", "make", "(", "[",...
// OnResponse registers a function. Function will be executed on every response
[ "OnResponse", "registers", "a", "function", ".", "Function", "will", "be", "executed", "on", "every", "response" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L764-L771
130,515
gocolly/colly
colly.go
OnHTMLDetach
func (c *Collector) OnHTMLDetach(goquerySelector string) { c.lock.Lock() deleteIdx := -1 for i, cc := range c.htmlCallbacks { if cc.Selector == goquerySelector { deleteIdx = i break } } if deleteIdx != -1 { c.htmlCallbacks = append(c.htmlCallbacks[:deleteIdx], c.htmlCallbacks[deleteIdx+1:]...) } c.lo...
go
func (c *Collector) OnHTMLDetach(goquerySelector string) { c.lock.Lock() deleteIdx := -1 for i, cc := range c.htmlCallbacks { if cc.Selector == goquerySelector { deleteIdx = i break } } if deleteIdx != -1 { c.htmlCallbacks = append(c.htmlCallbacks[:deleteIdx], c.htmlCallbacks[deleteIdx+1:]...) } c.lo...
[ "func", "(", "c", "*", "Collector", ")", "OnHTMLDetach", "(", "goquerySelector", "string", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "deleteIdx", ":=", "-", "1", "\n", "for", "i", ",", "cc", ":=", "range", "c", ".", "htmlCallbacks", ...
// OnHTMLDetach deregister a function. Function will not be execute after detached
[ "OnHTMLDetach", "deregister", "a", "function", ".", "Function", "will", "not", "be", "execute", "after", "detached" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L804-L817
130,516
gocolly/colly
colly.go
OnXMLDetach
func (c *Collector) OnXMLDetach(xpathQuery string) { c.lock.Lock() deleteIdx := -1 for i, cc := range c.xmlCallbacks { if cc.Query == xpathQuery { deleteIdx = i break } } if deleteIdx != -1 { c.xmlCallbacks = append(c.xmlCallbacks[:deleteIdx], c.xmlCallbacks[deleteIdx+1:]...) } c.lock.Unlock() }
go
func (c *Collector) OnXMLDetach(xpathQuery string) { c.lock.Lock() deleteIdx := -1 for i, cc := range c.xmlCallbacks { if cc.Query == xpathQuery { deleteIdx = i break } } if deleteIdx != -1 { c.xmlCallbacks = append(c.xmlCallbacks[:deleteIdx], c.xmlCallbacks[deleteIdx+1:]...) } c.lock.Unlock() }
[ "func", "(", "c", "*", "Collector", ")", "OnXMLDetach", "(", "xpathQuery", "string", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "deleteIdx", ":=", "-", "1", "\n", "for", "i", ",", "cc", ":=", "range", "c", ".", "xmlCallbacks", "{", ...
// OnXMLDetach deregister a function. Function will not be execute after detached
[ "OnXMLDetach", "deregister", "a", "function", ".", "Function", "will", "not", "be", "execute", "after", "detached" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L820-L833
130,517
gocolly/colly
colly.go
OnError
func (c *Collector) OnError(f ErrorCallback) { c.lock.Lock() if c.errorCallbacks == nil { c.errorCallbacks = make([]ErrorCallback, 0, 4) } c.errorCallbacks = append(c.errorCallbacks, f) c.lock.Unlock() }
go
func (c *Collector) OnError(f ErrorCallback) { c.lock.Lock() if c.errorCallbacks == nil { c.errorCallbacks = make([]ErrorCallback, 0, 4) } c.errorCallbacks = append(c.errorCallbacks, f) c.lock.Unlock() }
[ "func", "(", "c", "*", "Collector", ")", "OnError", "(", "f", "ErrorCallback", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "if", "c", ".", "errorCallbacks", "==", "nil", "{", "c", ".", "errorCallbacks", "=", "make", "(", "[", "]", "E...
// OnError registers a function. Function will be executed if an error // occurs during the HTTP request.
[ "OnError", "registers", "a", "function", ".", "Function", "will", "be", "executed", "if", "an", "error", "occurs", "during", "the", "HTTP", "request", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L837-L844
130,518
gocolly/colly
colly.go
OnScraped
func (c *Collector) OnScraped(f ScrapedCallback) { c.lock.Lock() if c.scrapedCallbacks == nil { c.scrapedCallbacks = make([]ScrapedCallback, 0, 4) } c.scrapedCallbacks = append(c.scrapedCallbacks, f) c.lock.Unlock() }
go
func (c *Collector) OnScraped(f ScrapedCallback) { c.lock.Lock() if c.scrapedCallbacks == nil { c.scrapedCallbacks = make([]ScrapedCallback, 0, 4) } c.scrapedCallbacks = append(c.scrapedCallbacks, f) c.lock.Unlock() }
[ "func", "(", "c", "*", "Collector", ")", "OnScraped", "(", "f", "ScrapedCallback", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "if", "c", ".", "scrapedCallbacks", "==", "nil", "{", "c", ".", "scrapedCallbacks", "=", "make", "(", "[", "...
// OnScraped registers a function. Function will be executed after // OnHTML, as a final part of the scraping.
[ "OnScraped", "registers", "a", "function", ".", "Function", "will", "be", "executed", "after", "OnHTML", "as", "a", "final", "part", "of", "the", "scraping", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L848-L855
130,519
gocolly/colly
colly.go
SetCookieJar
func (c *Collector) SetCookieJar(j http.CookieJar) { c.backend.Client.Jar = j }
go
func (c *Collector) SetCookieJar(j http.CookieJar) { c.backend.Client.Jar = j }
[ "func", "(", "c", "*", "Collector", ")", "SetCookieJar", "(", "j", "http", ".", "CookieJar", ")", "{", "c", ".", "backend", ".", "Client", ".", "Jar", "=", "j", "\n", "}" ]
// SetCookieJar overrides the previously set cookie jar
[ "SetCookieJar", "overrides", "the", "previously", "set", "cookie", "jar" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L868-L870
130,520
gocolly/colly
colly.go
SetStorage
func (c *Collector) SetStorage(s storage.Storage) error { if err := s.Init(); err != nil { return err } c.store = s c.backend.Client.Jar = createJar(s) return nil }
go
func (c *Collector) SetStorage(s storage.Storage) error { if err := s.Init(); err != nil { return err } c.store = s c.backend.Client.Jar = createJar(s) return nil }
[ "func", "(", "c", "*", "Collector", ")", "SetStorage", "(", "s", "storage", ".", "Storage", ")", "error", "{", "if", "err", ":=", "s", ".", "Init", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "c", ".", "store", "="...
// SetStorage overrides the default in-memory storage. // Storage stores scraping related data like cookies and visited urls
[ "SetStorage", "overrides", "the", "default", "in", "-", "memory", "storage", ".", "Storage", "stores", "scraping", "related", "data", "like", "cookies", "and", "visited", "urls" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L879-L886
130,521
gocolly/colly
colly.go
SetProxy
func (c *Collector) SetProxy(proxyURL string) error { proxyParsed, err := url.Parse(proxyURL) if err != nil { return err } c.SetProxyFunc(http.ProxyURL(proxyParsed)) return nil }
go
func (c *Collector) SetProxy(proxyURL string) error { proxyParsed, err := url.Parse(proxyURL) if err != nil { return err } c.SetProxyFunc(http.ProxyURL(proxyParsed)) return nil }
[ "func", "(", "c", "*", "Collector", ")", "SetProxy", "(", "proxyURL", "string", ")", "error", "{", "proxyParsed", ",", "err", ":=", "url", ".", "Parse", "(", "proxyURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", ...
// SetProxy sets a proxy for the collector. This method overrides the previously // used http.Transport if the type of the transport is not http.RoundTripper. // The proxy type is determined by the URL scheme. "http" // and "socks5" are supported. If the scheme is empty, // "http" is assumed.
[ "SetProxy", "sets", "a", "proxy", "for", "the", "collector", ".", "This", "method", "overrides", "the", "previously", "used", "http", ".", "Transport", "if", "the", "type", "of", "the", "transport", "is", "not", "http", ".", "RoundTripper", ".", "The", "pr...
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L893-L902
130,522
gocolly/colly
colly.go
Limit
func (c *Collector) Limit(rule *LimitRule) error { return c.backend.Limit(rule) }
go
func (c *Collector) Limit(rule *LimitRule) error { return c.backend.Limit(rule) }
[ "func", "(", "c", "*", "Collector", ")", "Limit", "(", "rule", "*", "LimitRule", ")", "error", "{", "return", "c", ".", "backend", ".", "Limit", "(", "rule", ")", "\n", "}" ]
// Limit adds a new LimitRule to the collector
[ "Limit", "adds", "a", "new", "LimitRule", "to", "the", "collector" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L1085-L1087
130,523
gocolly/colly
colly.go
Limits
func (c *Collector) Limits(rules []*LimitRule) error { return c.backend.Limits(rules) }
go
func (c *Collector) Limits(rules []*LimitRule) error { return c.backend.Limits(rules) }
[ "func", "(", "c", "*", "Collector", ")", "Limits", "(", "rules", "[", "]", "*", "LimitRule", ")", "error", "{", "return", "c", ".", "backend", ".", "Limits", "(", "rules", ")", "\n", "}" ]
// Limits adds new LimitRules to the collector
[ "Limits", "adds", "new", "LimitRules", "to", "the", "collector" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L1090-L1092
130,524
gocolly/colly
colly.go
SetCookies
func (c *Collector) SetCookies(URL string, cookies []*http.Cookie) error { if c.backend.Client.Jar == nil { return ErrNoCookieJar } u, err := url.Parse(URL) if err != nil { return err } c.backend.Client.Jar.SetCookies(u, cookies) return nil }
go
func (c *Collector) SetCookies(URL string, cookies []*http.Cookie) error { if c.backend.Client.Jar == nil { return ErrNoCookieJar } u, err := url.Parse(URL) if err != nil { return err } c.backend.Client.Jar.SetCookies(u, cookies) return nil }
[ "func", "(", "c", "*", "Collector", ")", "SetCookies", "(", "URL", "string", ",", "cookies", "[", "]", "*", "http", ".", "Cookie", ")", "error", "{", "if", "c", ".", "backend", ".", "Client", ".", "Jar", "==", "nil", "{", "return", "ErrNoCookieJar", ...
// SetCookies handles the receipt of the cookies in a reply for the given URL
[ "SetCookies", "handles", "the", "receipt", "of", "the", "cookies", "in", "a", "reply", "for", "the", "given", "URL" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L1095-L1105
130,525
gocolly/colly
colly.go
Cookies
func (c *Collector) Cookies(URL string) []*http.Cookie { if c.backend.Client.Jar == nil { return nil } u, err := url.Parse(URL) if err != nil { return nil } return c.backend.Client.Jar.Cookies(u) }
go
func (c *Collector) Cookies(URL string) []*http.Cookie { if c.backend.Client.Jar == nil { return nil } u, err := url.Parse(URL) if err != nil { return nil } return c.backend.Client.Jar.Cookies(u) }
[ "func", "(", "c", "*", "Collector", ")", "Cookies", "(", "URL", "string", ")", "[", "]", "*", "http", ".", "Cookie", "{", "if", "c", ".", "backend", ".", "Client", ".", "Jar", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "u", ",", "err",...
// Cookies returns the cookies to send in a request for the given URL.
[ "Cookies", "returns", "the", "cookies", "to", "send", "in", "a", "request", "for", "the", "given", "URL", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L1108-L1117
130,526
gocolly/colly
colly.go
Clone
func (c *Collector) Clone() *Collector { return &Collector{ AllowedDomains: c.AllowedDomains, AllowURLRevisit: c.AllowURLRevisit, CacheDir: c.CacheDir, DetectCharset: c.DetectCharset, DisallowedDomains: c.DisallowedDomains, ID: atomic.AddUint32...
go
func (c *Collector) Clone() *Collector { return &Collector{ AllowedDomains: c.AllowedDomains, AllowURLRevisit: c.AllowURLRevisit, CacheDir: c.CacheDir, DetectCharset: c.DetectCharset, DisallowedDomains: c.DisallowedDomains, ID: atomic.AddUint32...
[ "func", "(", "c", "*", "Collector", ")", "Clone", "(", ")", "*", "Collector", "{", "return", "&", "Collector", "{", "AllowedDomains", ":", "c", ".", "AllowedDomains", ",", "AllowURLRevisit", ":", "c", ".", "AllowURLRevisit", ",", "CacheDir", ":", "c", "....
// Clone creates an exact copy of a Collector without callbacks. // HTTP backend, robots.txt cache and cookie jar are shared // between collectors.
[ "Clone", "creates", "an", "exact", "copy", "of", "a", "Collector", "without", "callbacks", ".", "HTTP", "backend", "robots", ".", "txt", "cache", "and", "cookie", "jar", "are", "shared", "between", "collectors", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L1122-L1153
130,527
gocolly/colly
colly.go
SanitizeFileName
func SanitizeFileName(fileName string) string { ext := filepath.Ext(fileName) cleanExt := sanitize.BaseName(ext) if cleanExt == "" { cleanExt = ".unknown" } return strings.Replace(fmt.Sprintf( "%s.%s", sanitize.BaseName(fileName[:len(fileName)-len(ext)]), cleanExt[1:], ), "-", "_", -1) }
go
func SanitizeFileName(fileName string) string { ext := filepath.Ext(fileName) cleanExt := sanitize.BaseName(ext) if cleanExt == "" { cleanExt = ".unknown" } return strings.Replace(fmt.Sprintf( "%s.%s", sanitize.BaseName(fileName[:len(fileName)-len(ext)]), cleanExt[1:], ), "-", "_", -1) }
[ "func", "SanitizeFileName", "(", "fileName", "string", ")", "string", "{", "ext", ":=", "filepath", ".", "Ext", "(", "fileName", ")", "\n", "cleanExt", ":=", "sanitize", ".", "BaseName", "(", "ext", ")", "\n", "if", "cleanExt", "==", "\"", "\"", "{", "...
// SanitizeFileName replaces dangerous characters in a string // so the return value can be used as a safe file name.
[ "SanitizeFileName", "replaces", "dangerous", "characters", "in", "a", "string", "so", "the", "return", "value", "can", "be", "used", "as", "a", "safe", "file", "name", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/colly.go#L1197-L1208
130,528
gocolly/colly
xmlelement.go
NewXMLElementFromHTMLNode
func NewXMLElementFromHTMLNode(resp *Response, s *html.Node) *XMLElement { return &XMLElement{ Name: s.Data, Request: resp.Request, Response: resp, Text: htmlquery.InnerText(s), DOM: s, attributes: s.Attr, isHTML: true, } }
go
func NewXMLElementFromHTMLNode(resp *Response, s *html.Node) *XMLElement { return &XMLElement{ Name: s.Data, Request: resp.Request, Response: resp, Text: htmlquery.InnerText(s), DOM: s, attributes: s.Attr, isHTML: true, } }
[ "func", "NewXMLElementFromHTMLNode", "(", "resp", "*", "Response", ",", "s", "*", "html", ".", "Node", ")", "*", "XMLElement", "{", "return", "&", "XMLElement", "{", "Name", ":", "s", ".", "Data", ",", "Request", ":", "resp", ".", "Request", ",", "Resp...
// NewXMLElementFromHTMLNode creates a XMLElement from a html.Node.
[ "NewXMLElementFromHTMLNode", "creates", "a", "XMLElement", "from", "a", "html", ".", "Node", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/xmlelement.go#L44-L54
130,529
gocolly/colly
xmlelement.go
NewXMLElementFromXMLNode
func NewXMLElementFromXMLNode(resp *Response, s *xmlquery.Node) *XMLElement { return &XMLElement{ Name: s.Data, Request: resp.Request, Response: resp, Text: s.InnerText(), DOM: s, attributes: s.Attr, isHTML: false, } }
go
func NewXMLElementFromXMLNode(resp *Response, s *xmlquery.Node) *XMLElement { return &XMLElement{ Name: s.Data, Request: resp.Request, Response: resp, Text: s.InnerText(), DOM: s, attributes: s.Attr, isHTML: false, } }
[ "func", "NewXMLElementFromXMLNode", "(", "resp", "*", "Response", ",", "s", "*", "xmlquery", ".", "Node", ")", "*", "XMLElement", "{", "return", "&", "XMLElement", "{", "Name", ":", "s", ".", "Data", ",", "Request", ":", "resp", ".", "Request", ",", "R...
// NewXMLElementFromXMLNode creates a XMLElement from a xmlquery.Node.
[ "NewXMLElementFromXMLNode", "creates", "a", "XMLElement", "from", "a", "xmlquery", ".", "Node", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/xmlelement.go#L57-L67
130,530
gocolly/colly
xmlelement.go
ChildTexts
func (h *XMLElement) ChildTexts(xpathQuery string) []string { texts := make([]string, 0) if h.isHTML { for _, child := range htmlquery.Find(h.DOM.(*html.Node), xpathQuery) { texts = append(texts, strings.TrimSpace(htmlquery.InnerText(child))) } } else { xmlquery.FindEach(h.DOM.(*xmlquery.Node), xpathQuery, ...
go
func (h *XMLElement) ChildTexts(xpathQuery string) []string { texts := make([]string, 0) if h.isHTML { for _, child := range htmlquery.Find(h.DOM.(*html.Node), xpathQuery) { texts = append(texts, strings.TrimSpace(htmlquery.InnerText(child))) } } else { xmlquery.FindEach(h.DOM.(*xmlquery.Node), xpathQuery, ...
[ "func", "(", "h", "*", "XMLElement", ")", "ChildTexts", "(", "xpathQuery", "string", ")", "[", "]", "string", "{", "texts", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "if", "h", ".", "isHTML", "{", "for", "_", ",", "child", ":=",...
// ChildTexts returns an array of strings corresponding to child elements that match the xpath query. // Each item in the array is the stripped text content of the corresponding matching child element.
[ "ChildTexts", "returns", "an", "array", "of", "strings", "corresponding", "to", "child", "elements", "that", "match", "the", "xpath", "query", ".", "Each", "item", "in", "the", "array", "is", "the", "stripped", "text", "content", "of", "the", "corresponding", ...
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/xmlelement.go#L158-L170
130,531
gocolly/colly
debug/webdebugger.go
Init
func (w *WebDebugger) Init() error { if w.initialized { return nil } defer func() { w.initialized = true }() if w.Address == "" { w.Address = "127.0.0.1:7676" } w.RequestLog = make([]requestInfo, 0) w.CurrentRequests = make(map[uint32]requestInfo) http.HandleFunc("/", w.indexHandler) http.HandleFunc("/s...
go
func (w *WebDebugger) Init() error { if w.initialized { return nil } defer func() { w.initialized = true }() if w.Address == "" { w.Address = "127.0.0.1:7676" } w.RequestLog = make([]requestInfo, 0) w.CurrentRequests = make(map[uint32]requestInfo) http.HandleFunc("/", w.indexHandler) http.HandleFunc("/s...
[ "func", "(", "w", "*", "WebDebugger", ")", "Init", "(", ")", "error", "{", "if", "w", ".", "initialized", "{", "return", "nil", "\n", "}", "\n", "defer", "func", "(", ")", "{", "w", ".", "initialized", "=", "true", "\n", "}", "(", ")", "\n", "i...
// Init initializes the WebDebugger
[ "Init", "initializes", "the", "WebDebugger" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/debug/webdebugger.go#L43-L60
130,532
gocolly/colly
debug/webdebugger.go
Event
func (w *WebDebugger) Event(e *Event) { switch e.Type { case "request": w.CurrentRequests[e.RequestID] = requestInfo{ URL: e.Values["url"], Started: time.Now(), ID: e.RequestID, CollectorID: e.CollectorID, } case "response", "error": r := w.CurrentRequests[e.RequestID] r.Dura...
go
func (w *WebDebugger) Event(e *Event) { switch e.Type { case "request": w.CurrentRequests[e.RequestID] = requestInfo{ URL: e.Values["url"], Started: time.Now(), ID: e.RequestID, CollectorID: e.CollectorID, } case "response", "error": r := w.CurrentRequests[e.RequestID] r.Dura...
[ "func", "(", "w", "*", "WebDebugger", ")", "Event", "(", "e", "*", "Event", ")", "{", "switch", "e", ".", "Type", "{", "case", "\"", "\"", ":", "w", ".", "CurrentRequests", "[", "e", ".", "RequestID", "]", "=", "requestInfo", "{", "URL", ":", "e"...
// Event updates the debugger's status
[ "Event", "updates", "the", "debugger", "s", "status" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/debug/webdebugger.go#L63-L79
130,533
gocolly/colly
http_backend.go
Init
func (r *LimitRule) Init() error { waitChanSize := 1 if r.Parallelism > 1 { waitChanSize = r.Parallelism } r.waitChan = make(chan bool, waitChanSize) hasPattern := false if r.DomainRegexp != "" { c, err := regexp.Compile(r.DomainRegexp) if err != nil { return err } r.compiledRegexp = c hasPattern =...
go
func (r *LimitRule) Init() error { waitChanSize := 1 if r.Parallelism > 1 { waitChanSize = r.Parallelism } r.waitChan = make(chan bool, waitChanSize) hasPattern := false if r.DomainRegexp != "" { c, err := regexp.Compile(r.DomainRegexp) if err != nil { return err } r.compiledRegexp = c hasPattern =...
[ "func", "(", "r", "*", "LimitRule", ")", "Init", "(", ")", "error", "{", "waitChanSize", ":=", "1", "\n", "if", "r", ".", "Parallelism", ">", "1", "{", "waitChanSize", "=", "r", ".", "Parallelism", "\n", "}", "\n", "r", ".", "waitChan", "=", "make"...
// Init initializes the private members of LimitRule
[ "Init", "initializes", "the", "private", "members", "of", "LimitRule" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/http_backend.go#L66-L93
130,534
gocolly/colly
http_backend.go
Match
func (r *LimitRule) Match(domain string) bool { match := false if r.compiledRegexp != nil && r.compiledRegexp.MatchString(domain) { match = true } if r.compiledGlob != nil && r.compiledGlob.Match(domain) { match = true } return match }
go
func (r *LimitRule) Match(domain string) bool { match := false if r.compiledRegexp != nil && r.compiledRegexp.MatchString(domain) { match = true } if r.compiledGlob != nil && r.compiledGlob.Match(domain) { match = true } return match }
[ "func", "(", "r", "*", "LimitRule", ")", "Match", "(", "domain", "string", ")", "bool", "{", "match", ":=", "false", "\n", "if", "r", ".", "compiledRegexp", "!=", "nil", "&&", "r", ".", "compiledRegexp", ".", "MatchString", "(", "domain", ")", "{", "...
// Match checks that the domain parameter triggers the rule
[ "Match", "checks", "that", "the", "domain", "parameter", "triggers", "the", "rule" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/http_backend.go#L105-L114
130,535
gocolly/colly
htmlelement.go
NewHTMLElementFromSelectionNode
func NewHTMLElementFromSelectionNode(resp *Response, s *goquery.Selection, n *html.Node, idx int) *HTMLElement { return &HTMLElement{ Name: n.Data, Request: resp.Request, Response: resp, Text: goquery.NewDocumentFromNode(n).Text(), DOM: s, Index: idx, attributes: n.Attr, } }
go
func NewHTMLElementFromSelectionNode(resp *Response, s *goquery.Selection, n *html.Node, idx int) *HTMLElement { return &HTMLElement{ Name: n.Data, Request: resp.Request, Response: resp, Text: goquery.NewDocumentFromNode(n).Text(), DOM: s, Index: idx, attributes: n.Attr, } }
[ "func", "NewHTMLElementFromSelectionNode", "(", "resp", "*", "Response", ",", "s", "*", "goquery", ".", "Selection", ",", "n", "*", "html", ".", "Node", ",", "idx", "int", ")", "*", "HTMLElement", "{", "return", "&", "HTMLElement", "{", "Name", ":", "n",...
// NewHTMLElementFromSelectionNode creates a HTMLElement from a goquery.Selection Node.
[ "NewHTMLElementFromSelectionNode", "creates", "a", "HTMLElement", "from", "a", "goquery", ".", "Selection", "Node", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/htmlelement.go#L42-L52
130,536
gocolly/colly
htmlelement.go
ForEach
func (h *HTMLElement) ForEach(goquerySelector string, callback func(int, *HTMLElement)) { i := 0 h.DOM.Find(goquerySelector).Each(func(_ int, s *goquery.Selection) { for _, n := range s.Nodes { callback(i, NewHTMLElementFromSelectionNode(h.Response, s, n, i)) i++ } }) }
go
func (h *HTMLElement) ForEach(goquerySelector string, callback func(int, *HTMLElement)) { i := 0 h.DOM.Find(goquerySelector).Each(func(_ int, s *goquery.Selection) { for _, n := range s.Nodes { callback(i, NewHTMLElementFromSelectionNode(h.Response, s, n, i)) i++ } }) }
[ "func", "(", "h", "*", "HTMLElement", ")", "ForEach", "(", "goquerySelector", "string", ",", "callback", "func", "(", "int", ",", "*", "HTMLElement", ")", ")", "{", "i", ":=", "0", "\n", "h", ".", "DOM", ".", "Find", "(", "goquerySelector", ")", ".",...
// ForEach iterates over the elements matched by the first argument // and calls the callback function on every HTMLElement match.
[ "ForEach", "iterates", "over", "the", "elements", "matched", "by", "the", "first", "argument", "and", "calls", "the", "callback", "function", "on", "every", "HTMLElement", "match", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/htmlelement.go#L94-L102
130,537
gocolly/colly
htmlelement.go
ForEachWithBreak
func (h *HTMLElement) ForEachWithBreak(goquerySelector string, callback func(int, *HTMLElement) bool) { i := 0 h.DOM.Find(goquerySelector).EachWithBreak(func(_ int, s *goquery.Selection) bool { for _, n := range s.Nodes { if callback(i, NewHTMLElementFromSelectionNode(h.Response, s, n, i)) { i++ return t...
go
func (h *HTMLElement) ForEachWithBreak(goquerySelector string, callback func(int, *HTMLElement) bool) { i := 0 h.DOM.Find(goquerySelector).EachWithBreak(func(_ int, s *goquery.Selection) bool { for _, n := range s.Nodes { if callback(i, NewHTMLElementFromSelectionNode(h.Response, s, n, i)) { i++ return t...
[ "func", "(", "h", "*", "HTMLElement", ")", "ForEachWithBreak", "(", "goquerySelector", "string", ",", "callback", "func", "(", "int", ",", "*", "HTMLElement", ")", "bool", ")", "{", "i", ":=", "0", "\n", "h", ".", "DOM", ".", "Find", "(", "goquerySelec...
// ForEachWithBreak iterates over the elements matched by the first argument // and calls the callback function on every HTMLElement match. // It is identical to ForEach except that it is possible to break // out of the loop by returning false in the callback function. It returns the // current Selection object.
[ "ForEachWithBreak", "iterates", "over", "the", "elements", "matched", "by", "the", "first", "argument", "and", "calls", "the", "callback", "function", "on", "every", "HTMLElement", "match", ".", "It", "is", "identical", "to", "ForEach", "except", "that", "it", ...
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/htmlelement.go#L109-L120
130,538
gocolly/colly
context.go
Put
func (c *Context) Put(key string, value interface{}) { c.lock.Lock() c.contextMap[key] = value c.lock.Unlock() }
go
func (c *Context) Put(key string, value interface{}) { c.lock.Lock() c.contextMap[key] = value c.lock.Unlock() }
[ "func", "(", "c", "*", "Context", ")", "Put", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "c", ".", "contextMap", "[", "key", "]", "=", "value", "\n", "c", ".", "lock", "...
// Put stores a value of any type in Context
[ "Put", "stores", "a", "value", "of", "any", "type", "in", "Context" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/context.go#L48-L52
130,539
gocolly/colly
context.go
Get
func (c *Context) Get(key string) string { c.lock.RLock() defer c.lock.RUnlock() if v, ok := c.contextMap[key]; ok { return v.(string) } return "" }
go
func (c *Context) Get(key string) string { c.lock.RLock() defer c.lock.RUnlock() if v, ok := c.contextMap[key]; ok { return v.(string) } return "" }
[ "func", "(", "c", "*", "Context", ")", "Get", "(", "key", "string", ")", "string", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n", "if", "v", ",", "ok", ":=", "c", ".", "contextM...
// Get retrieves a string value from Context. // Get returns an empty string if key not found
[ "Get", "retrieves", "a", "string", "value", "from", "Context", ".", "Get", "returns", "an", "empty", "string", "if", "key", "not", "found" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/context.go#L56-L63
130,540
gocolly/colly
context.go
GetAny
func (c *Context) GetAny(key string) interface{} { c.lock.RLock() defer c.lock.RUnlock() if v, ok := c.contextMap[key]; ok { return v } return nil }
go
func (c *Context) GetAny(key string) interface{} { c.lock.RLock() defer c.lock.RUnlock() if v, ok := c.contextMap[key]; ok { return v } return nil }
[ "func", "(", "c", "*", "Context", ")", "GetAny", "(", "key", "string", ")", "interface", "{", "}", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n", "if", "v", ",", "ok", ":=", "c"...
// GetAny retrieves a value from Context. // GetAny returns nil if key not found
[ "GetAny", "retrieves", "a", "value", "from", "Context", ".", "GetAny", "returns", "nil", "if", "key", "not", "found" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/context.go#L67-L74
130,541
gocolly/colly
context.go
ForEach
func (c *Context) ForEach(fn func(k string, v interface{}) interface{}) []interface{} { c.lock.RLock() defer c.lock.RUnlock() ret := make([]interface{}, 0, len(c.contextMap)) for k, v := range c.contextMap { ret = append(ret, fn(k, v)) } return ret }
go
func (c *Context) ForEach(fn func(k string, v interface{}) interface{}) []interface{} { c.lock.RLock() defer c.lock.RUnlock() ret := make([]interface{}, 0, len(c.contextMap)) for k, v := range c.contextMap { ret = append(ret, fn(k, v)) } return ret }
[ "func", "(", "c", "*", "Context", ")", "ForEach", "(", "fn", "func", "(", "k", "string", ",", "v", "interface", "{", "}", ")", "interface", "{", "}", ")", "[", "]", "interface", "{", "}", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "...
// ForEach iterate context
[ "ForEach", "iterate", "context" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/context.go#L77-L87
130,542
gocolly/colly
debug/logdebugger.go
Init
func (l *LogDebugger) Init() error { l.counter = 0 l.start = time.Now() if l.Output == nil { l.Output = os.Stderr } l.logger = log.New(l.Output, l.Prefix, l.Flag) return nil }
go
func (l *LogDebugger) Init() error { l.counter = 0 l.start = time.Now() if l.Output == nil { l.Output = os.Stderr } l.logger = log.New(l.Output, l.Prefix, l.Flag) return nil }
[ "func", "(", "l", "*", "LogDebugger", ")", "Init", "(", ")", "error", "{", "l", ".", "counter", "=", "0", "\n", "l", ".", "start", "=", "time", ".", "Now", "(", ")", "\n", "if", "l", ".", "Output", "==", "nil", "{", "l", ".", "Output", "=", ...
// Init initializes the LogDebugger
[ "Init", "initializes", "the", "LogDebugger" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/debug/logdebugger.go#L40-L48
130,543
gocolly/colly
debug/logdebugger.go
Event
func (l *LogDebugger) Event(e *Event) { i := atomic.AddInt32(&l.counter, 1) l.logger.Printf("[%06d] %d [%6d - %s] %q (%s)\n", i, e.CollectorID, e.RequestID, e.Type, e.Values, time.Since(l.start)) }
go
func (l *LogDebugger) Event(e *Event) { i := atomic.AddInt32(&l.counter, 1) l.logger.Printf("[%06d] %d [%6d - %s] %q (%s)\n", i, e.CollectorID, e.RequestID, e.Type, e.Values, time.Since(l.start)) }
[ "func", "(", "l", "*", "LogDebugger", ")", "Event", "(", "e", "*", "Event", ")", "{", "i", ":=", "atomic", ".", "AddInt32", "(", "&", "l", ".", "counter", ",", "1", ")", "\n", "l", ".", "logger", ".", "Printf", "(", "\"", "\\n", "\"", ",", "i...
// Event receives Collector events and prints them to STDERR
[ "Event", "receives", "Collector", "events", "and", "prints", "them", "to", "STDERR" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/debug/logdebugger.go#L51-L54
130,544
gocolly/colly
proxy/proxy.go
RoundRobinProxySwitcher
func RoundRobinProxySwitcher(ProxyURLs ...string) (colly.ProxyFunc, error) { if len(ProxyURLs) < 1 { return nil, colly.ErrEmptyProxyURL } urls := make([]*url.URL, len(ProxyURLs)) for i, u := range ProxyURLs { parsedU, err := url.Parse(u) if err != nil { return nil, err } urls[i] = parsedU } return (&...
go
func RoundRobinProxySwitcher(ProxyURLs ...string) (colly.ProxyFunc, error) { if len(ProxyURLs) < 1 { return nil, colly.ErrEmptyProxyURL } urls := make([]*url.URL, len(ProxyURLs)) for i, u := range ProxyURLs { parsedU, err := url.Parse(u) if err != nil { return nil, err } urls[i] = parsedU } return (&...
[ "func", "RoundRobinProxySwitcher", "(", "ProxyURLs", "...", "string", ")", "(", "colly", ".", "ProxyFunc", ",", "error", ")", "{", "if", "len", "(", "ProxyURLs", ")", "<", "1", "{", "return", "nil", ",", "colly", ".", "ErrEmptyProxyURL", "\n", "}", "\n",...
// RoundRobinProxySwitcher creates a proxy switcher function which rotates // ProxyURLs on every request. // The proxy type is determined by the URL scheme. "http", "https" // and "socks5" are supported. If the scheme is empty, // "http" is assumed.
[ "RoundRobinProxySwitcher", "creates", "a", "proxy", "switcher", "function", "which", "rotates", "ProxyURLs", "on", "every", "request", ".", "The", "proxy", "type", "is", "determined", "by", "the", "URL", "scheme", ".", "http", "https", "and", "socks5", "are", ...
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/proxy/proxy.go#L44-L57
130,545
gocolly/colly
storage/storage.go
Init
func (s *InMemoryStorage) Init() error { if s.visitedURLs == nil { s.visitedURLs = make(map[uint64]bool) } if s.lock == nil { s.lock = &sync.RWMutex{} } if s.jar == nil { var err error s.jar, err = cookiejar.New(nil) return err } return nil }
go
func (s *InMemoryStorage) Init() error { if s.visitedURLs == nil { s.visitedURLs = make(map[uint64]bool) } if s.lock == nil { s.lock = &sync.RWMutex{} } if s.jar == nil { var err error s.jar, err = cookiejar.New(nil) return err } return nil }
[ "func", "(", "s", "*", "InMemoryStorage", ")", "Init", "(", ")", "error", "{", "if", "s", ".", "visitedURLs", "==", "nil", "{", "s", ".", "visitedURLs", "=", "make", "(", "map", "[", "uint64", "]", "bool", ")", "\n", "}", "\n", "if", "s", ".", ...
// Init initializes InMemoryStorage
[ "Init", "initializes", "InMemoryStorage" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/storage/storage.go#L54-L67
130,546
gocolly/colly
storage/storage.go
StringifyCookies
func StringifyCookies(cookies []*http.Cookie) string { // Stringify cookies. cs := make([]string, len(cookies)) for i, c := range cookies { cs[i] = c.String() } return strings.Join(cs, "\n") }
go
func StringifyCookies(cookies []*http.Cookie) string { // Stringify cookies. cs := make([]string, len(cookies)) for i, c := range cookies { cs[i] = c.String() } return strings.Join(cs, "\n") }
[ "func", "StringifyCookies", "(", "cookies", "[", "]", "*", "http", ".", "Cookie", ")", "string", "{", "// Stringify cookies.", "cs", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "cookies", ")", ")", "\n", "for", "i", ",", "c", ":=", "range...
// StringifyCookies serializes list of http.Cookies to string
[ "StringifyCookies", "serializes", "list", "of", "http", ".", "Cookies", "to", "string" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/storage/storage.go#L101-L108
130,547
gocolly/colly
storage/storage.go
UnstringifyCookies
func UnstringifyCookies(s string) []*http.Cookie { h := http.Header{} for _, c := range strings.Split(s, "\n") { h.Add("Set-Cookie", c) } r := http.Response{Header: h} return r.Cookies() }
go
func UnstringifyCookies(s string) []*http.Cookie { h := http.Header{} for _, c := range strings.Split(s, "\n") { h.Add("Set-Cookie", c) } r := http.Response{Header: h} return r.Cookies() }
[ "func", "UnstringifyCookies", "(", "s", "string", ")", "[", "]", "*", "http", ".", "Cookie", "{", "h", ":=", "http", ".", "Header", "{", "}", "\n", "for", "_", ",", "c", ":=", "range", "strings", ".", "Split", "(", "s", ",", "\"", "\\n", "\"", ...
// UnstringifyCookies deserializes a cookie string to http.Cookies
[ "UnstringifyCookies", "deserializes", "a", "cookie", "string", "to", "http", ".", "Cookies" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/storage/storage.go#L111-L118
130,548
gocolly/colly
storage/storage.go
ContainsCookie
func ContainsCookie(cookies []*http.Cookie, name string) bool { for _, c := range cookies { if c.Name == name { return true } } return false }
go
func ContainsCookie(cookies []*http.Cookie, name string) bool { for _, c := range cookies { if c.Name == name { return true } } return false }
[ "func", "ContainsCookie", "(", "cookies", "[", "]", "*", "http", ".", "Cookie", ",", "name", "string", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "cookies", "{", "if", "c", ".", "Name", "==", "name", "{", "return", "true", "\n", "}", ...
// ContainsCookie checks if a cookie name is represented in cookies
[ "ContainsCookie", "checks", "if", "a", "cookie", "name", "is", "represented", "in", "cookies" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/storage/storage.go#L121-L128
130,549
gocolly/colly
unmarshal.go
Unmarshal
func (h *HTMLElement) Unmarshal(v interface{}) error { return UnmarshalHTML(v, h.DOM, nil) }
go
func (h *HTMLElement) Unmarshal(v interface{}) error { return UnmarshalHTML(v, h.DOM, nil) }
[ "func", "(", "h", "*", "HTMLElement", ")", "Unmarshal", "(", "v", "interface", "{", "}", ")", "error", "{", "return", "UnmarshalHTML", "(", "v", ",", "h", ".", "DOM", ",", "nil", ")", "\n", "}" ]
// Unmarshal is a shorthand for colly.UnmarshalHTML
[ "Unmarshal", "is", "a", "shorthand", "for", "colly", ".", "UnmarshalHTML" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/unmarshal.go#L26-L28
130,550
gocolly/colly
unmarshal.go
UnmarshalWithMap
func (h *HTMLElement) UnmarshalWithMap(v interface{}, structMap map[string]string) error { return UnmarshalHTML(v, h.DOM, structMap) }
go
func (h *HTMLElement) UnmarshalWithMap(v interface{}, structMap map[string]string) error { return UnmarshalHTML(v, h.DOM, structMap) }
[ "func", "(", "h", "*", "HTMLElement", ")", "UnmarshalWithMap", "(", "v", "interface", "{", "}", ",", "structMap", "map", "[", "string", "]", "string", ")", "error", "{", "return", "UnmarshalHTML", "(", "v", ",", "h", ".", "DOM", ",", "structMap", ")", ...
// UnmarshalWithMap is a shorthand for colly.UnmarshalHTML, extended to allow maps to be passed in.
[ "UnmarshalWithMap", "is", "a", "shorthand", "for", "colly", ".", "UnmarshalHTML", "extended", "to", "allow", "maps", "to", "be", "passed", "in", "." ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/unmarshal.go#L31-L33
130,551
gocolly/colly
request.go
New
func (r *Request) New(method, URL string, body io.Reader) (*Request, error) { u, err := url.Parse(URL) if err != nil { return nil, err } return &Request{ Method: method, URL: u, Body: body, Ctx: r.Ctx, Headers: &http.Header{}, ID: atomic.AddUint32(&r.collector.requestCount...
go
func (r *Request) New(method, URL string, body io.Reader) (*Request, error) { u, err := url.Parse(URL) if err != nil { return nil, err } return &Request{ Method: method, URL: u, Body: body, Ctx: r.Ctx, Headers: &http.Header{}, ID: atomic.AddUint32(&r.collector.requestCount...
[ "func", "(", "r", "*", "Request", ")", "New", "(", "method", ",", "URL", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "Request", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "URL", ")", "\n", "if", "e...
// New creates a new request with the context of the original request
[ "New", "creates", "a", "new", "request", "with", "the", "context", "of", "the", "original", "request" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L65-L79
130,552
gocolly/colly
request.go
AbsoluteURL
func (r *Request) AbsoluteURL(u string) string { if strings.HasPrefix(u, "#") { return "" } var base *url.URL if r.baseURL != nil { base = r.baseURL } else { base = r.URL } absURL, err := base.Parse(u) if err != nil { return "" } absURL.Fragment = "" if absURL.Scheme == "//" { absURL.Scheme = r.URL...
go
func (r *Request) AbsoluteURL(u string) string { if strings.HasPrefix(u, "#") { return "" } var base *url.URL if r.baseURL != nil { base = r.baseURL } else { base = r.URL } absURL, err := base.Parse(u) if err != nil { return "" } absURL.Fragment = "" if absURL.Scheme == "//" { absURL.Scheme = r.URL...
[ "func", "(", "r", "*", "Request", ")", "AbsoluteURL", "(", "u", "string", ")", "string", "{", "if", "strings", ".", "HasPrefix", "(", "u", ",", "\"", "\"", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "var", "base", "*", "url", ".", "URL", ...
// AbsoluteURL returns with the resolved absolute URL of an URL chunk. // AbsoluteURL returns empty string if the URL chunk is a fragment or // could not be parsed
[ "AbsoluteURL", "returns", "with", "the", "resolved", "absolute", "URL", "of", "an", "URL", "chunk", ".", "AbsoluteURL", "returns", "empty", "string", "if", "the", "URL", "chunk", "is", "a", "fragment", "or", "could", "not", "be", "parsed" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L89-L108
130,553
gocolly/colly
request.go
Visit
func (r *Request) Visit(URL string) error { return r.collector.scrape(r.AbsoluteURL(URL), "GET", r.Depth+1, nil, r.Ctx, nil, true) }
go
func (r *Request) Visit(URL string) error { return r.collector.scrape(r.AbsoluteURL(URL), "GET", r.Depth+1, nil, r.Ctx, nil, true) }
[ "func", "(", "r", "*", "Request", ")", "Visit", "(", "URL", "string", ")", "error", "{", "return", "r", ".", "collector", ".", "scrape", "(", "r", ".", "AbsoluteURL", "(", "URL", ")", ",", "\"", "\"", ",", "r", ".", "Depth", "+", "1", ",", "nil...
// Visit continues Collector's collecting job by creating a // request and preserves the Context of the previous request. // Visit also calls the previously provided callbacks
[ "Visit", "continues", "Collector", "s", "collecting", "job", "by", "creating", "a", "request", "and", "preserves", "the", "Context", "of", "the", "previous", "request", ".", "Visit", "also", "calls", "the", "previously", "provided", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L113-L115
130,554
gocolly/colly
request.go
Post
func (r *Request) Post(URL string, requestData map[string]string) error { return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, createFormReader(requestData), r.Ctx, nil, true) }
go
func (r *Request) Post(URL string, requestData map[string]string) error { return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, createFormReader(requestData), r.Ctx, nil, true) }
[ "func", "(", "r", "*", "Request", ")", "Post", "(", "URL", "string", ",", "requestData", "map", "[", "string", "]", "string", ")", "error", "{", "return", "r", ".", "collector", ".", "scrape", "(", "r", ".", "AbsoluteURL", "(", "URL", ")", ",", "\"...
// Post continues a collector job by creating a POST request and preserves the Context // of the previous request. // Post also calls the previously provided callbacks
[ "Post", "continues", "a", "collector", "job", "by", "creating", "a", "POST", "request", "and", "preserves", "the", "Context", "of", "the", "previous", "request", ".", "Post", "also", "calls", "the", "previously", "provided", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L120-L122
130,555
gocolly/colly
request.go
PostRaw
func (r *Request) PostRaw(URL string, requestData []byte) error { return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, bytes.NewReader(requestData), r.Ctx, nil, true) }
go
func (r *Request) PostRaw(URL string, requestData []byte) error { return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, bytes.NewReader(requestData), r.Ctx, nil, true) }
[ "func", "(", "r", "*", "Request", ")", "PostRaw", "(", "URL", "string", ",", "requestData", "[", "]", "byte", ")", "error", "{", "return", "r", ".", "collector", ".", "scrape", "(", "r", ".", "AbsoluteURL", "(", "URL", ")", ",", "\"", "\"", ",", ...
// PostRaw starts a collector job by creating a POST request with raw binary data. // PostRaw preserves the Context of the previous request // and calls the previously provided callbacks
[ "PostRaw", "starts", "a", "collector", "job", "by", "creating", "a", "POST", "request", "with", "raw", "binary", "data", ".", "PostRaw", "preserves", "the", "Context", "of", "the", "previous", "request", "and", "calls", "the", "previously", "provided", "callba...
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L127-L129
130,556
gocolly/colly
request.go
PostMultipart
func (r *Request) PostMultipart(URL string, requestData map[string][]byte) error { boundary := randomBoundary() hdr := http.Header{} hdr.Set("Content-Type", "multipart/form-data; boundary="+boundary) hdr.Set("User-Agent", r.collector.UserAgent) return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, creat...
go
func (r *Request) PostMultipart(URL string, requestData map[string][]byte) error { boundary := randomBoundary() hdr := http.Header{} hdr.Set("Content-Type", "multipart/form-data; boundary="+boundary) hdr.Set("User-Agent", r.collector.UserAgent) return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, creat...
[ "func", "(", "r", "*", "Request", ")", "PostMultipart", "(", "URL", "string", ",", "requestData", "map", "[", "string", "]", "[", "]", "byte", ")", "error", "{", "boundary", ":=", "randomBoundary", "(", ")", "\n", "hdr", ":=", "http", ".", "Header", ...
// PostMultipart starts a collector job by creating a Multipart POST request // with raw binary data. PostMultipart also calls the previously provided. // callbacks
[ "PostMultipart", "starts", "a", "collector", "job", "by", "creating", "a", "Multipart", "POST", "request", "with", "raw", "binary", "data", ".", "PostMultipart", "also", "calls", "the", "previously", "provided", ".", "callbacks" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L134-L140
130,557
gocolly/colly
request.go
Retry
func (r *Request) Retry() error { return r.collector.scrape(r.URL.String(), r.Method, r.Depth, r.Body, r.Ctx, *r.Headers, false) }
go
func (r *Request) Retry() error { return r.collector.scrape(r.URL.String(), r.Method, r.Depth, r.Body, r.Ctx, *r.Headers, false) }
[ "func", "(", "r", "*", "Request", ")", "Retry", "(", ")", "error", "{", "return", "r", ".", "collector", ".", "scrape", "(", "r", ".", "URL", ".", "String", "(", ")", ",", "r", ".", "Method", ",", "r", ".", "Depth", ",", "r", ".", "Body", ","...
// Retry submits HTTP request again with the same parameters
[ "Retry", "submits", "HTTP", "request", "again", "with", "the", "same", "parameters" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L143-L145
130,558
gocolly/colly
request.go
Do
func (r *Request) Do() error { return r.collector.scrape(r.URL.String(), r.Method, r.Depth, r.Body, r.Ctx, *r.Headers, !r.collector.AllowURLRevisit) }
go
func (r *Request) Do() error { return r.collector.scrape(r.URL.String(), r.Method, r.Depth, r.Body, r.Ctx, *r.Headers, !r.collector.AllowURLRevisit) }
[ "func", "(", "r", "*", "Request", ")", "Do", "(", ")", "error", "{", "return", "r", ".", "collector", ".", "scrape", "(", "r", ".", "URL", ".", "String", "(", ")", ",", "r", ".", "Method", ",", "r", ".", "Depth", ",", "r", ".", "Body", ",", ...
// Do submits the request
[ "Do", "submits", "the", "request" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L148-L150
130,559
gocolly/colly
request.go
Marshal
func (r *Request) Marshal() ([]byte, error) { ctx := make(map[string]interface{}) if r.Ctx != nil { r.Ctx.ForEach(func(k string, v interface{}) interface{} { ctx[k] = v return nil }) } var err error var body []byte if r.Body != nil { body, err = ioutil.ReadAll(r.Body) if err != nil { return nil, ...
go
func (r *Request) Marshal() ([]byte, error) { ctx := make(map[string]interface{}) if r.Ctx != nil { r.Ctx.ForEach(func(k string, v interface{}) interface{} { ctx[k] = v return nil }) } var err error var body []byte if r.Body != nil { body, err = ioutil.ReadAll(r.Body) if err != nil { return nil, ...
[ "func", "(", "r", "*", "Request", ")", "Marshal", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ctx", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "r", ".", "Ctx", "!=", "nil", "{", "r", ...
// Marshal serializes the Request
[ "Marshal", "serializes", "the", "Request" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/request.go#L153-L180
130,560
gocolly/colly
extensions/random_user_agent.go
RandomUserAgent
func RandomUserAgent(c *colly.Collector) { c.OnRequest(func(r *colly.Request) { r.Headers.Set("User-Agent", uaGens[rand.Intn(len(uaGens))]()) }) }
go
func RandomUserAgent(c *colly.Collector) { c.OnRequest(func(r *colly.Request) { r.Headers.Set("User-Agent", uaGens[rand.Intn(len(uaGens))]()) }) }
[ "func", "RandomUserAgent", "(", "c", "*", "colly", ".", "Collector", ")", "{", "c", ".", "OnRequest", "(", "func", "(", "r", "*", "colly", ".", "Request", ")", "{", "r", ".", "Headers", ".", "Set", "(", "\"", "\"", ",", "uaGens", "[", "rand", "."...
// RandomUserAgent generates a random browser user agent on every request
[ "RandomUserAgent", "generates", "a", "random", "browser", "user", "agent", "on", "every", "request" ]
b3d99101c625896f85d94cee72ddfa49f0379d25
https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/extensions/random_user_agent.go#L16-L20
130,561
terraform-providers/terraform-provider-azurerm
azurerm/locks.go
azureRMLockByName
func azureRMLockByName(name string, resourceType string) { updatedName := resourceType + "." + name armMutexKV.Lock(updatedName) }
go
func azureRMLockByName(name string, resourceType string) { updatedName := resourceType + "." + name armMutexKV.Lock(updatedName) }
[ "func", "azureRMLockByName", "(", "name", "string", ",", "resourceType", "string", ")", "{", "updatedName", ":=", "resourceType", "+", "\"", "\"", "+", "name", "\n", "armMutexKV", ".", "Lock", "(", "updatedName", ")", "\n", "}" ]
// handle the case of using the same name for different kinds of resources
[ "handle", "the", "case", "of", "using", "the", "same", "name", "for", "different", "kinds", "of", "resources" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/locks.go#L4-L7
130,562
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_dns_mx_record.go
flattenAzureRmDnsMxRecords
func flattenAzureRmDnsMxRecords(records *[]dns.MxRecord) []map[string]interface{} { results := make([]map[string]interface{}, 0, len(*records)) if records != nil { for _, record := range *records { preferenceI32 := *record.Preference preference := strconv.Itoa(int(preferenceI32)) results = append(results,...
go
func flattenAzureRmDnsMxRecords(records *[]dns.MxRecord) []map[string]interface{} { results := make([]map[string]interface{}, 0, len(*records)) if records != nil { for _, record := range *records { preferenceI32 := *record.Preference preference := strconv.Itoa(int(preferenceI32)) results = append(results,...
[ "func", "flattenAzureRmDnsMxRecords", "(", "records", "*", "[", "]", "dns", ".", "MxRecord", ")", "[", "]", "map", "[", "string", "]", "interface", "{", "}", "{", "results", ":=", "make", "(", "[", "]", "map", "[", "string", "]", "interface", "{", "}...
// flatten creates an array of map where preference is a string to suit // the expectations of the ResourceData schema, so that this data can be // managed by Terradata state.
[ "flatten", "creates", "an", "array", "of", "map", "where", "preference", "is", "a", "string", "to", "suit", "the", "expectations", "of", "the", "ResourceData", "schema", "so", "that", "this", "data", "can", "be", "managed", "by", "Terradata", "state", "." ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_dns_mx_record.go#L182-L197
130,563
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_dns_mx_record.go
expandAzureRmDnsMxRecords
func expandAzureRmDnsMxRecords(d *schema.ResourceData) *[]dns.MxRecord { recordStrings := d.Get("record").(*schema.Set).List() records := make([]dns.MxRecord, len(recordStrings)) for i, v := range recordStrings { mxrecord := v.(map[string]interface{}) preference := mxrecord["preference"].(string) i64, _ := st...
go
func expandAzureRmDnsMxRecords(d *schema.ResourceData) *[]dns.MxRecord { recordStrings := d.Get("record").(*schema.Set).List() records := make([]dns.MxRecord, len(recordStrings)) for i, v := range recordStrings { mxrecord := v.(map[string]interface{}) preference := mxrecord["preference"].(string) i64, _ := st...
[ "func", "expandAzureRmDnsMxRecords", "(", "d", "*", "schema", ".", "ResourceData", ")", "*", "[", "]", "dns", ".", "MxRecord", "{", "recordStrings", ":=", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "*", "schema", ".", "Set", ")", ".", "List", ...
// expand creates an array of dns.MxRecord, that is, the array needed // by azure-sdk-for-go to manipulate azure resources, hence Preference // is an int32
[ "expand", "creates", "an", "array", "of", "dns", ".", "MxRecord", "that", "is", "the", "array", "needed", "by", "azure", "-", "sdk", "-", "for", "-", "go", "to", "manipulate", "azure", "resources", "hence", "Preference", "is", "an", "int32" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_dns_mx_record.go#L202-L220
130,564
terraform-providers/terraform-provider-azurerm
azurerm/data_factory.go
azureRmDataFactoryLinkedServiceConnectionStringDiff
func azureRmDataFactoryLinkedServiceConnectionStringDiff(k, old string, new string, d *schema.ResourceData) bool { oldSplit := strings.Split(strings.ToLower(old), ";") newSplit := strings.Split(strings.ToLower(new), ";") sort.Strings(oldSplit) sort.Strings(newSplit) // We need to remove the password from the new...
go
func azureRmDataFactoryLinkedServiceConnectionStringDiff(k, old string, new string, d *schema.ResourceData) bool { oldSplit := strings.Split(strings.ToLower(old), ";") newSplit := strings.Split(strings.ToLower(new), ";") sort.Strings(oldSplit) sort.Strings(newSplit) // We need to remove the password from the new...
[ "func", "azureRmDataFactoryLinkedServiceConnectionStringDiff", "(", "k", ",", "old", "string", ",", "new", "string", ",", "d", "*", "schema", ".", "ResourceData", ")", "bool", "{", "oldSplit", ":=", "strings", ".", "Split", "(", "strings", ".", "ToLower", "(",...
// Because the password isn't returned from the api in the connection string, we'll check all // but the password string and return true if they match.
[ "Because", "the", "password", "isn", "t", "returned", "from", "the", "api", "in", "the", "connection", "string", "we", "ll", "check", "all", "but", "the", "password", "string", "and", "return", "true", "if", "they", "match", "." ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/data_factory.go#L34-L60
130,565
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_storage_container.go
resourceArmStorageContainerRead
func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) error { armClient := meta.(*ArmClient) ctx := armClient.StopContext id, err := parseStorageContainerID(d.Id(), armClient.environment) if err != nil { return err } resourceGroup, err := determineResourceGroupForStorageAccount(id.sto...
go
func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) error { armClient := meta.(*ArmClient) ctx := armClient.StopContext id, err := parseStorageContainerID(d.Id(), armClient.environment) if err != nil { return err } resourceGroup, err := determineResourceGroupForStorageAccount(id.sto...
[ "func", "resourceArmStorageContainerRead", "(", "d", "*", "schema", ".", "ResourceData", ",", "meta", "interface", "{", "}", ")", "error", "{", "armClient", ":=", "meta", ".", "(", "*", "ArmClient", ")", "\n", "ctx", ":=", "armClient", ".", "StopContext", ...
// resourceAzureStorageContainerRead does all the necessary API calls to // read the status of the storage container off Azure.
[ "resourceAzureStorageContainerRead", "does", "all", "the", "necessary", "API", "calls", "to", "read", "the", "status", "of", "the", "storage", "container", "off", "Azure", "." ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_storage_container.go#L148-L232
130,566
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_storage_container.go
resourceArmStorageContainerDelete
func resourceArmStorageContainerDelete(d *schema.ResourceData, meta interface{}) error { armClient := meta.(*ArmClient) ctx := armClient.StopContext id, err := parseStorageContainerID(d.Id(), armClient.environment) if err != nil { return err } resourceGroup, err := determineResourceGroupForStorageAccount(id.s...
go
func resourceArmStorageContainerDelete(d *schema.ResourceData, meta interface{}) error { armClient := meta.(*ArmClient) ctx := armClient.StopContext id, err := parseStorageContainerID(d.Id(), armClient.environment) if err != nil { return err } resourceGroup, err := determineResourceGroupForStorageAccount(id.s...
[ "func", "resourceArmStorageContainerDelete", "(", "d", "*", "schema", ".", "ResourceData", ",", "meta", "interface", "{", "}", ")", "error", "{", "armClient", ":=", "meta", ".", "(", "*", "ArmClient", ")", "\n", "ctx", ":=", "armClient", ".", "StopContext", ...
// resourceAzureStorageContainerDelete does all the necessary API calls to // delete a storage container off Azure.
[ "resourceAzureStorageContainerDelete", "does", "all", "the", "necessary", "API", "calls", "to", "delete", "a", "storage", "container", "off", "Azure", "." ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_storage_container.go#L236-L271
130,567
terraform-providers/terraform-provider-azurerm
azurerm/helpers/suppress/xml.go
expandXmlTokensFromString
func expandXmlTokensFromString(input string) ([]xml.Token, error) { decoder := xml.NewDecoder(strings.NewReader(input)) tokens := make([]xml.Token, 0) for { token, err := decoder.Token() if err != nil { if err == io.EOF { break } return nil, err } if chars, ok := token.(xml.CharData); ok { te...
go
func expandXmlTokensFromString(input string) ([]xml.Token, error) { decoder := xml.NewDecoder(strings.NewReader(input)) tokens := make([]xml.Token, 0) for { token, err := decoder.Token() if err != nil { if err == io.EOF { break } return nil, err } if chars, ok := token.(xml.CharData); ok { te...
[ "func", "expandXmlTokensFromString", "(", "input", "string", ")", "(", "[", "]", "xml", ".", "Token", ",", "error", ")", "{", "decoder", ":=", "xml", ".", "NewDecoder", "(", "strings", ".", "NewReader", "(", "input", ")", ")", "\n", "tokens", ":=", "ma...
// This function will extract all XML tokens from a string, but ignoring all white-space tokens
[ "This", "function", "will", "extract", "all", "XML", "tokens", "from", "a", "string", "but", "ignoring", "all", "white", "-", "space", "tokens" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/suppress/xml.go#L27-L47
130,568
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_batch_pool.go
validateUserIdentity
func validateUserIdentity(userIdentity *batch.UserIdentity) error { if userIdentity == nil { return errors.New("user_identity block needs to be specified") } if userIdentity.AutoUser == nil && userIdentity.UserName == nil { return errors.New("auto_user or user_name needs to be specified in the user_identity blo...
go
func validateUserIdentity(userIdentity *batch.UserIdentity) error { if userIdentity == nil { return errors.New("user_identity block needs to be specified") } if userIdentity.AutoUser == nil && userIdentity.UserName == nil { return errors.New("auto_user or user_name needs to be specified in the user_identity blo...
[ "func", "validateUserIdentity", "(", "userIdentity", "*", "batch", ".", "UserIdentity", ")", "error", "{", "if", "userIdentity", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "userIdentity", ".", "AutoUser...
// validateUserIdentity validates that the user identity for a start task has been well specified // it should have a auto_user block or a user_name defined, but not both at the same time.
[ "validateUserIdentity", "validates", "that", "the", "user", "identity", "for", "a", "start", "task", "has", "been", "well", "specified", "it", "should", "have", "a", "auto_user", "block", "or", "a", "user_name", "defined", "but", "not", "both", "at", "the", ...
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_batch_pool.go#L676-L690
130,569
terraform-providers/terraform-provider-azurerm
azurerm/config.go
clientRequestID
func clientRequestID() string { msClientRequestIDOnce.Do(func() { var err error msClientRequestID, err = uuid.GenerateUUID() if err != nil { log.Printf("[WARN] Fail to generate uuid for msClientRequestID: %+v", err) } }) log.Printf("[DEBUG] AzureRM Client Request Id: %s", msClientRequestID) return msCl...
go
func clientRequestID() string { msClientRequestIDOnce.Do(func() { var err error msClientRequestID, err = uuid.GenerateUUID() if err != nil { log.Printf("[WARN] Fail to generate uuid for msClientRequestID: %+v", err) } }) log.Printf("[DEBUG] AzureRM Client Request Id: %s", msClientRequestID) return msCl...
[ "func", "clientRequestID", "(", ")", "string", "{", "msClientRequestIDOnce", ".", "Do", "(", "func", "(", ")", "{", "var", "err", "error", "\n", "msClientRequestID", ",", "err", "=", "uuid", ".", "GenerateUUID", "(", ")", "\n\n", "if", "err", "!=", "nil"...
// clientRequestID generates a UUID to pass through `x-ms-client-request-id` header.
[ "clientRequestID", "generates", "a", "UUID", "to", "pass", "through", "x", "-", "ms", "-", "client", "-", "request", "-", "id", "header", "." ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/config.go#L388-L400
130,570
terraform-providers/terraform-provider-azurerm
azurerm/loadbalancer.go
loadBalancerSubResourceStateImporter
func loadBalancerSubResourceStateImporter(d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { r, err := regexp.Compile(`.+\/loadBalancers\/.+?\/`) if err != nil { return nil, err } lbID := strings.TrimSuffix(r.FindString(d.Id()), "/") parsed, err := parseAzureResourceID(lbID) if err != nil...
go
func loadBalancerSubResourceStateImporter(d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { r, err := regexp.Compile(`.+\/loadBalancers\/.+?\/`) if err != nil { return nil, err } lbID := strings.TrimSuffix(r.FindString(d.Id()), "/") parsed, err := parseAzureResourceID(lbID) if err != nil...
[ "func", "loadBalancerSubResourceStateImporter", "(", "d", "*", "schema", ".", "ResourceData", ",", "_", "interface", "{", "}", ")", "(", "[", "]", "*", "schema", ".", "ResourceData", ",", "error", ")", "{", "r", ",", "err", ":=", "regexp", ".", "Compile"...
// sets the loadbalancer_id in the ResourceData from the sub resources full id
[ "sets", "the", "loadbalancer_id", "in", "the", "ResourceData", "from", "the", "sub", "resources", "full", "id" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/loadbalancer.go#L151-L169
130,571
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
FlattenBatchPoolAutoScaleSettings
func FlattenBatchPoolAutoScaleSettings(settings *batch.AutoScaleSettings) []interface{} { results := make([]interface{}, 0) if settings == nil { log.Printf("[DEBUG] settings is nil") return results } result := make(map[string]interface{}) if settings.EvaluationInterval != nil { result["evaluation_interval...
go
func FlattenBatchPoolAutoScaleSettings(settings *batch.AutoScaleSettings) []interface{} { results := make([]interface{}, 0) if settings == nil { log.Printf("[DEBUG] settings is nil") return results } result := make(map[string]interface{}) if settings.EvaluationInterval != nil { result["evaluation_interval...
[ "func", "FlattenBatchPoolAutoScaleSettings", "(", "settings", "*", "batch", ".", "AutoScaleSettings", ")", "[", "]", "interface", "{", "}", "{", "results", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ")", "\n\n", "if", "settings", "==", ...
// FlattenBatchPoolAutoScaleSettings flattens the auto scale settings for a Batch pool
[ "FlattenBatchPoolAutoScaleSettings", "flattens", "the", "auto", "scale", "settings", "for", "a", "Batch", "pool" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L13-L32
130,572
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
FlattenBatchPoolFixedScaleSettings
func FlattenBatchPoolFixedScaleSettings(settings *batch.FixedScaleSettings) []interface{} { results := make([]interface{}, 0) if settings == nil { log.Printf("[DEBUG] settings is nil") return results } result := make(map[string]interface{}) if settings.TargetDedicatedNodes != nil { result["target_dedicate...
go
func FlattenBatchPoolFixedScaleSettings(settings *batch.FixedScaleSettings) []interface{} { results := make([]interface{}, 0) if settings == nil { log.Printf("[DEBUG] settings is nil") return results } result := make(map[string]interface{}) if settings.TargetDedicatedNodes != nil { result["target_dedicate...
[ "func", "FlattenBatchPoolFixedScaleSettings", "(", "settings", "*", "batch", ".", "FixedScaleSettings", ")", "[", "]", "interface", "{", "}", "{", "results", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ")", "\n\n", "if", "settings", "==",...
// FlattenBatchPoolFixedScaleSettings flattens the fixed scale settings for a Batch pool
[ "FlattenBatchPoolFixedScaleSettings", "flattens", "the", "fixed", "scale", "settings", "for", "a", "Batch", "pool" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L35-L58
130,573
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
FlattenBatchPoolImageReference
func FlattenBatchPoolImageReference(image *batch.ImageReference) []interface{} { results := make([]interface{}, 0) if image == nil { log.Printf("[DEBUG] image is nil") return results } result := make(map[string]interface{}) if image.Publisher != nil { result["publisher"] = *image.Publisher } if image.Offe...
go
func FlattenBatchPoolImageReference(image *batch.ImageReference) []interface{} { results := make([]interface{}, 0) if image == nil { log.Printf("[DEBUG] image is nil") return results } result := make(map[string]interface{}) if image.Publisher != nil { result["publisher"] = *image.Publisher } if image.Offe...
[ "func", "FlattenBatchPoolImageReference", "(", "image", "*", "batch", ".", "ImageReference", ")", "[", "]", "interface", "{", "}", "{", "results", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ")", "\n", "if", "image", "==", "nil", "{",...
// FlattenBatchPoolImageReference flattens the Batch pool image reference
[ "FlattenBatchPoolImageReference", "flattens", "the", "Batch", "pool", "image", "reference" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L61-L86
130,574
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
FlattenBatchPoolStartTask
func FlattenBatchPoolStartTask(startTask *batch.StartTask) []interface{} { results := make([]interface{}, 0) if startTask == nil { log.Printf("[DEBUG] startTask is nil") return results } result := make(map[string]interface{}) if startTask.CommandLine != nil { result["command_line"] = *startTask.CommandLine...
go
func FlattenBatchPoolStartTask(startTask *batch.StartTask) []interface{} { results := make([]interface{}, 0) if startTask == nil { log.Printf("[DEBUG] startTask is nil") return results } result := make(map[string]interface{}) if startTask.CommandLine != nil { result["command_line"] = *startTask.CommandLine...
[ "func", "FlattenBatchPoolStartTask", "(", "startTask", "*", "batch", ".", "StartTask", ")", "[", "]", "interface", "{", "}", "{", "results", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ")", "\n\n", "if", "startTask", "==", "nil", "{",...
// FlattenBatchPoolStartTask flattens a Batch pool start task
[ "FlattenBatchPoolStartTask", "flattens", "a", "Batch", "pool", "start", "task" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L89-L164
130,575
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
FlattenBatchPoolCertificateReferences
func FlattenBatchPoolCertificateReferences(armCertificates *[]batch.CertificateReference) []interface{} { if armCertificates == nil { return []interface{}{} } output := make([]interface{}, 0) for _, armCertificate := range *armCertificates { certificate := map[string]interface{}{} if armCertificate.ID != nil...
go
func FlattenBatchPoolCertificateReferences(armCertificates *[]batch.CertificateReference) []interface{} { if armCertificates == nil { return []interface{}{} } output := make([]interface{}, 0) for _, armCertificate := range *armCertificates { certificate := map[string]interface{}{} if armCertificate.ID != nil...
[ "func", "FlattenBatchPoolCertificateReferences", "(", "armCertificates", "*", "[", "]", "batch", ".", "CertificateReference", ")", "[", "]", "interface", "{", "}", "{", "if", "armCertificates", "==", "nil", "{", "return", "[", "]", "interface", "{", "}", "{", ...
// FlattenBatchPoolCertificateReferences flattens a Batch pool certificate reference
[ "FlattenBatchPoolCertificateReferences", "flattens", "a", "Batch", "pool", "certificate", "reference" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L167-L192
130,576
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
ExpandBatchPoolImageReference
func ExpandBatchPoolImageReference(list []interface{}) (*batch.ImageReference, error) { if len(list) == 0 { return nil, fmt.Errorf("Error: storage image reference should be defined") } storageImageRef := list[0].(map[string]interface{}) storageImageRefOffer := storageImageRef["offer"].(string) storageImageRefP...
go
func ExpandBatchPoolImageReference(list []interface{}) (*batch.ImageReference, error) { if len(list) == 0 { return nil, fmt.Errorf("Error: storage image reference should be defined") } storageImageRef := list[0].(map[string]interface{}) storageImageRefOffer := storageImageRef["offer"].(string) storageImageRefP...
[ "func", "ExpandBatchPoolImageReference", "(", "list", "[", "]", "interface", "{", "}", ")", "(", "*", "batch", ".", "ImageReference", ",", "error", ")", "{", "if", "len", "(", "list", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "...
// ExpandBatchPoolImageReference expands Batch pool image reference
[ "ExpandBatchPoolImageReference", "expands", "Batch", "pool", "image", "reference" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L195-L215
130,577
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/batch_pool.go
ExpandBatchPoolCertificateReferences
func ExpandBatchPoolCertificateReferences(list []interface{}) (*[]batch.CertificateReference, error) { result := []batch.CertificateReference{} for _, tempItem := range list { item := tempItem.(map[string]interface{}) certificateReference, err := expandBatchPoolCertificateReference(item) if err != nil { ret...
go
func ExpandBatchPoolCertificateReferences(list []interface{}) (*[]batch.CertificateReference, error) { result := []batch.CertificateReference{} for _, tempItem := range list { item := tempItem.(map[string]interface{}) certificateReference, err := expandBatchPoolCertificateReference(item) if err != nil { ret...
[ "func", "ExpandBatchPoolCertificateReferences", "(", "list", "[", "]", "interface", "{", "}", ")", "(", "*", "[", "]", "batch", ".", "CertificateReference", ",", "error", ")", "{", "result", ":=", "[", "]", "batch", ".", "CertificateReference", "{", "}", "...
// ExpandBatchPoolCertificateReferences expands Batch pool certificate references
[ "ExpandBatchPoolCertificateReferences", "expands", "Batch", "pool", "certificate", "references" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/batch_pool.go#L218-L230
130,578
terraform-providers/terraform-provider-azurerm
azurerm/helpers/validate/time.go
RFC3339DateInFutureBy
func RFC3339DateInFutureBy(d time.Duration) schema.SchemaValidateFunc { return func(i interface{}, k string) (warnings []string, errors []error) { v, ok := i.(string) if !ok { errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) return } t, err := date.ParseTime(time.RFC3339, v) ...
go
func RFC3339DateInFutureBy(d time.Duration) schema.SchemaValidateFunc { return func(i interface{}, k string) (warnings []string, errors []error) { v, ok := i.(string) if !ok { errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) return } t, err := date.ParseTime(time.RFC3339, v) ...
[ "func", "RFC3339DateInFutureBy", "(", "d", "time", ".", "Duration", ")", "schema", ".", "SchemaValidateFunc", "{", "return", "func", "(", "i", "interface", "{", "}", ",", "k", "string", ")", "(", "warnings", "[", "]", "string", ",", "errors", "[", "]", ...
// RFC3339 date is duration d or greater into the future
[ "RFC3339", "date", "is", "duration", "d", "or", "greater", "into", "the", "future" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/validate/time.go#L29-L49
130,579
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_key_vault_certificate.go
resourceArmKeyVaultChildResourceImporter
func resourceArmKeyVaultChildResourceImporter(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { client := meta.(*ArmClient).keyVaultClient ctx := meta.(*ArmClient).StopContext id, err := azure.ParseKeyVaultChildID(d.Id()) if err != nil { return []*schema.ResourceData{d}, fmt.Errorf("Err...
go
func resourceArmKeyVaultChildResourceImporter(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { client := meta.(*ArmClient).keyVaultClient ctx := meta.(*ArmClient).StopContext id, err := azure.ParseKeyVaultChildID(d.Id()) if err != nil { return []*schema.ResourceData{d}, fmt.Errorf("Err...
[ "func", "resourceArmKeyVaultChildResourceImporter", "(", "d", "*", "schema", ".", "ResourceData", ",", "meta", "interface", "{", "}", ")", "(", "[", "]", "*", "schema", ".", "ResourceData", ",", "error", ")", "{", "client", ":=", "meta", ".", "(", "*", "...
//todo refactor and find a home for this wayward func
[ "todo", "refactor", "and", "find", "a", "home", "for", "this", "wayward", "func" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_key_vault_certificate.go#L23-L40
130,580
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_virtual_machine_scale_set.go
azureRmVirtualMachineScaleSetCustomizeDiff
func azureRmVirtualMachineScaleSetCustomizeDiff(d *schema.ResourceDiff, _ interface{}) error { mode := d.Get("upgrade_policy_mode").(string) if strings.ToLower(mode) != "rolling" { if policyRaw, ok := d.GetOk("rolling_upgrade_policy.0"); ok { policy := policyRaw.(map[string]interface{}) isDefault := (policy["...
go
func azureRmVirtualMachineScaleSetCustomizeDiff(d *schema.ResourceDiff, _ interface{}) error { mode := d.Get("upgrade_policy_mode").(string) if strings.ToLower(mode) != "rolling" { if policyRaw, ok := d.GetOk("rolling_upgrade_policy.0"); ok { policy := policyRaw.(map[string]interface{}) isDefault := (policy["...
[ "func", "azureRmVirtualMachineScaleSetCustomizeDiff", "(", "d", "*", "schema", ".", "ResourceDiff", ",", "_", "interface", "{", "}", ")", "error", "{", "mode", ":=", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", "\n", "if", "strings", ...
// Make sure rolling_upgrade_policy is default value when upgrade_policy_mode is not Rolling.
[ "Make", "sure", "rolling_upgrade_policy", "is", "default", "value", "when", "upgrade_policy_mode", "is", "not", "Rolling", "." ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_virtual_machine_scale_set.go#L2213-L2228
130,581
terraform-providers/terraform-provider-azurerm
azurerm/helpers/validate/int.go
IntDivisibleBy
func IntDivisibleBy(divisor int) schema.SchemaValidateFunc { // nolint: unparam return func(i interface{}, k string) (warnings []string, errors []error) { v, ok := i.(int) if !ok { errors = append(errors, fmt.Errorf("expected type of %s to be int", k)) return } if math.Mod(float64(v), float64(divisor)) ...
go
func IntDivisibleBy(divisor int) schema.SchemaValidateFunc { // nolint: unparam return func(i interface{}, k string) (warnings []string, errors []error) { v, ok := i.(int) if !ok { errors = append(errors, fmt.Errorf("expected type of %s to be int", k)) return } if math.Mod(float64(v), float64(divisor)) ...
[ "func", "IntDivisibleBy", "(", "divisor", "int", ")", "schema", ".", "SchemaValidateFunc", "{", "// nolint: unparam", "return", "func", "(", "i", "interface", "{", "}", ",", "k", "string", ")", "(", "warnings", "[", "]", "string", ",", "errors", "[", "]", ...
// IntDivisibleBy returns a SchemaValidateFunc which tests if the provided value // is of type int and is divisible by a given number
[ "IntDivisibleBy", "returns", "a", "SchemaValidateFunc", "which", "tests", "if", "the", "provided", "value", "is", "of", "type", "int", "and", "is", "divisible", "by", "a", "given", "number" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/validate/int.go#L58-L73
130,582
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/api_management.go
SchemaApiManagementChildID
func SchemaApiManagementChildID() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: ValidateResourceID, } }
go
func SchemaApiManagementChildID() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: ValidateResourceID, } }
[ "func", "SchemaApiManagementChildID", "(", ")", "*", "schema", ".", "Schema", "{", "return", "&", "schema", ".", "Schema", "{", "Type", ":", "schema", ".", "TypeString", ",", "Required", ":", "true", ",", "ForceNew", ":", "true", ",", "ValidateFunc", ":", ...
// SchemaApiManagementChildID returns the Schema for the identifier // used by resources within nested under the API Management Service resource
[ "SchemaApiManagementChildID", "returns", "the", "Schema", "for", "the", "identifier", "used", "by", "resources", "within", "nested", "under", "the", "API", "Management", "Service", "resource" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/api_management.go#L32-L39
130,583
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/api_management.go
SchemaApiManagementChildName
func SchemaApiManagementChildName() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.ApiManagementChildName, } }
go
func SchemaApiManagementChildName() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validate.ApiManagementChildName, } }
[ "func", "SchemaApiManagementChildName", "(", ")", "*", "schema", ".", "Schema", "{", "return", "&", "schema", ".", "Schema", "{", "Type", ":", "schema", ".", "TypeString", ",", "Required", ":", "true", ",", "ForceNew", ":", "true", ",", "ValidateFunc", ":"...
// SchemaApiManagementChildName returns the Schema for the identifier // used by resources within nested under the API Management Service resource
[ "SchemaApiManagementChildName", "returns", "the", "Schema", "for", "the", "identifier", "used", "by", "resources", "within", "nested", "under", "the", "API", "Management", "Service", "resource" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/api_management.go#L43-L50
130,584
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/api_management.go
SchemaApiManagementChildDataSourceName
func SchemaApiManagementChildDataSourceName() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, Required: true, ValidateFunc: validate.ApiManagementChildName, } }
go
func SchemaApiManagementChildDataSourceName() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, Required: true, ValidateFunc: validate.ApiManagementChildName, } }
[ "func", "SchemaApiManagementChildDataSourceName", "(", ")", "*", "schema", ".", "Schema", "{", "return", "&", "schema", ".", "Schema", "{", "Type", ":", "schema", ".", "TypeString", ",", "Required", ":", "true", ",", "ValidateFunc", ":", "validate", ".", "Ap...
// SchemaApiManagementChildDataSourceName returns the Schema for the identifier // used by resources within nested under the API Management Service resource
[ "SchemaApiManagementChildDataSourceName", "returns", "the", "Schema", "for", "the", "identifier", "used", "by", "resources", "within", "nested", "under", "the", "API", "Management", "Service", "resource" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/api_management.go#L54-L60
130,585
terraform-providers/terraform-provider-azurerm
azurerm/helpers/azure/validate.go
ValidateResourceIDOrEmpty
func ValidateResourceIDOrEmpty(i interface{}, k string) (_ []string, errors []error) { v, ok := i.(string) if !ok { errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) return } if v == "" { return } return ValidateResourceID(i, k) }
go
func ValidateResourceIDOrEmpty(i interface{}, k string) (_ []string, errors []error) { v, ok := i.(string) if !ok { errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) return } if v == "" { return } return ValidateResourceID(i, k) }
[ "func", "ValidateResourceIDOrEmpty", "(", "i", "interface", "{", "}", ",", "k", "string", ")", "(", "_", "[", "]", "string", ",", "errors", "[", "]", "error", ")", "{", "v", ",", "ok", ":=", "i", ".", "(", "string", ")", "\n", "if", "!", "ok", ...
//true for a resource ID or an empty string
[ "true", "for", "a", "resource", "ID", "or", "an", "empty", "string" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/helpers/azure/validate.go#L22-L34
130,586
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_cosmos_db_account.go
expandAzureRmCosmosDBAccountFailoverPolicy
func expandAzureRmCosmosDBAccountFailoverPolicy(databaseName string, d *schema.ResourceData) ([]documentdb.Location, error) { input := d.Get("failover_policy").(*schema.Set).List() locations := make([]documentdb.Location, 0, len(input)) for _, configRaw := range input { data := configRaw.(map[string]interface{})...
go
func expandAzureRmCosmosDBAccountFailoverPolicy(databaseName string, d *schema.ResourceData) ([]documentdb.Location, error) { input := d.Get("failover_policy").(*schema.Set).List() locations := make([]documentdb.Location, 0, len(input)) for _, configRaw := range input { data := configRaw.(map[string]interface{})...
[ "func", "expandAzureRmCosmosDBAccountFailoverPolicy", "(", "databaseName", "string", ",", "d", "*", "schema", ".", "ResourceData", ")", "(", "[", "]", "documentdb", ".", "Location", ",", "error", ")", "{", "input", ":=", "d", ".", "Get", "(", "\"", "\"", "...
//todo remove when deprecated field `failover_policy` is
[ "todo", "remove", "when", "deprecated", "field", "failover_policy", "is" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_cosmos_db_account.go#L849-L895
130,587
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_cosmos_db_account.go
flattenAzureRmCosmosDBAccountFailoverPolicy
func flattenAzureRmCosmosDBAccountFailoverPolicy(list *[]documentdb.FailoverPolicy) *schema.Set { results := schema.Set{ F: resourceAzureRMCosmosDBAccountFailoverPolicyHash, } for _, i := range *list { result := map[string]interface{}{ "id": *i.ID, "location": azureRMNormalizeLocation(*i.LocationNam...
go
func flattenAzureRmCosmosDBAccountFailoverPolicy(list *[]documentdb.FailoverPolicy) *schema.Set { results := schema.Set{ F: resourceAzureRMCosmosDBAccountFailoverPolicyHash, } for _, i := range *list { result := map[string]interface{}{ "id": *i.ID, "location": azureRMNormalizeLocation(*i.LocationNam...
[ "func", "flattenAzureRmCosmosDBAccountFailoverPolicy", "(", "list", "*", "[", "]", "documentdb", ".", "FailoverPolicy", ")", "*", "schema", ".", "Set", "{", "results", ":=", "schema", ".", "Set", "{", "F", ":", "resourceAzureRMCosmosDBAccountFailoverPolicyHash", ","...
//todo remove when failover_policy field is removed
[ "todo", "remove", "when", "failover_policy", "field", "is", "removed" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_cosmos_db_account.go#L936-L952
130,588
terraform-providers/terraform-provider-azurerm
azurerm/resource_arm_cosmos_db_account.go
resourceAzureRMCosmosDBAccountFailoverPolicyHash
func resourceAzureRMCosmosDBAccountFailoverPolicyHash(v interface{}) int { var buf bytes.Buffer if m, ok := v.(map[string]interface{}); ok { location := azureRMNormalizeLocation(m["location"].(string)) priority := int32(m["priority"].(int)) buf.WriteString(fmt.Sprintf("%s-%d", location, priority)) } return...
go
func resourceAzureRMCosmosDBAccountFailoverPolicyHash(v interface{}) int { var buf bytes.Buffer if m, ok := v.(map[string]interface{}); ok { location := azureRMNormalizeLocation(m["location"].(string)) priority := int32(m["priority"].(int)) buf.WriteString(fmt.Sprintf("%s-%d", location, priority)) } return...
[ "func", "resourceAzureRMCosmosDBAccountFailoverPolicyHash", "(", "v", "interface", "{", "}", ")", "int", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "if", "m", ",", "ok", ":=", "v", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ...
//todo remove once deprecated field `failover_policy` is removed
[ "todo", "remove", "once", "deprecated", "field", "failover_policy", "is", "removed" ]
c89b300fc1d77c63d2c53be6ae5d7e3719d9384d
https://github.com/terraform-providers/terraform-provider-azurerm/blob/c89b300fc1d77c63d2c53be6ae5d7e3719d9384d/azurerm/resource_arm_cosmos_db_account.go#L1022-L1033
130,589
coredns/coredns
plugin/hosts/hosts.go
aaaa
func aaaa(zone string, ttl uint32, ips []net.IP) []dns.RR { answers := []dns.RR{} for _, ip := range ips { r := new(dns.AAAA) r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: ttl} r.AAAA = ip answers = append(answers, r) } return answers }
go
func aaaa(zone string, ttl uint32, ips []net.IP) []dns.RR { answers := []dns.RR{} for _, ip := range ips { r := new(dns.AAAA) r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: ttl} r.AAAA = ip answers = append(answers, r) } return answers }
[ "func", "aaaa", "(", "zone", "string", ",", "ttl", "uint32", ",", "ips", "[", "]", "net", ".", "IP", ")", "[", "]", "dns", ".", "RR", "{", "answers", ":=", "[", "]", "dns", ".", "RR", "{", "}", "\n", "for", "_", ",", "ip", ":=", "range", "i...
// aaaa takes a slice of net.IPs and returns a slice of AAAA RRs.
[ "aaaa", "takes", "a", "slice", "of", "net", ".", "IPs", "and", "returns", "a", "slice", "of", "AAAA", "RRs", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/hosts/hosts.go#L112-L122
130,590
coredns/coredns
plugin/hosts/hosts.go
ptr
func (h *Hosts) ptr(zone string, ttl uint32, names []string) []dns.RR { answers := []dns.RR{} for _, n := range names { r := new(dns.PTR) r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: ttl} r.Ptr = dns.Fqdn(n) answers = append(answers, r) } return answers }
go
func (h *Hosts) ptr(zone string, ttl uint32, names []string) []dns.RR { answers := []dns.RR{} for _, n := range names { r := new(dns.PTR) r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: ttl} r.Ptr = dns.Fqdn(n) answers = append(answers, r) } return answers }
[ "func", "(", "h", "*", "Hosts", ")", "ptr", "(", "zone", "string", ",", "ttl", "uint32", ",", "names", "[", "]", "string", ")", "[", "]", "dns", ".", "RR", "{", "answers", ":=", "[", "]", "dns", ".", "RR", "{", "}", "\n", "for", "_", ",", "...
// ptr takes a slice of host names and filters out the ones that aren't in Origins, if specified, and returns a slice of PTR RRs.
[ "ptr", "takes", "a", "slice", "of", "host", "names", "and", "filters", "out", "the", "ones", "that", "aren", "t", "in", "Origins", "if", "specified", "and", "returns", "a", "slice", "of", "PTR", "RRs", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/hosts/hosts.go#L125-L135
130,591
coredns/coredns
plugin/kubernetes/controller.go
newdnsController
func newdnsController(kubeClient kubernetes.Interface, opts dnsControlOpts) *dnsControl { dns := dnsControl{ client: kubeClient, selector: opts.selector, namespaceSelector: opts.namespaceSelector, stopCh: make(chan struct{}), zones: opts.zones, endpointNameMode: ...
go
func newdnsController(kubeClient kubernetes.Interface, opts dnsControlOpts) *dnsControl { dns := dnsControl{ client: kubeClient, selector: opts.selector, namespaceSelector: opts.namespaceSelector, stopCh: make(chan struct{}), zones: opts.zones, endpointNameMode: ...
[ "func", "newdnsController", "(", "kubeClient", "kubernetes", ".", "Interface", ",", "opts", "dnsControlOpts", ")", "*", "dnsControl", "{", "dns", ":=", "dnsControl", "{", "client", ":", "kubeClient", ",", "selector", ":", "opts", ".", "selector", ",", "namespa...
// newDNSController creates a controller for CoreDNS.
[ "newDNSController", "creates", "a", "controller", "for", "CoreDNS", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L97-L156
130,592
coredns/coredns
plugin/kubernetes/controller.go
Run
func (dns *dnsControl) Run() { go dns.svcController.Run(dns.stopCh) if dns.epController != nil { go dns.epController.Run(dns.stopCh) } if dns.podController != nil { go dns.podController.Run(dns.stopCh) } go dns.nsController.Run(dns.stopCh) <-dns.stopCh }
go
func (dns *dnsControl) Run() { go dns.svcController.Run(dns.stopCh) if dns.epController != nil { go dns.epController.Run(dns.stopCh) } if dns.podController != nil { go dns.podController.Run(dns.stopCh) } go dns.nsController.Run(dns.stopCh) <-dns.stopCh }
[ "func", "(", "dns", "*", "dnsControl", ")", "Run", "(", ")", "{", "go", "dns", ".", "svcController", ".", "Run", "(", "dns", ".", "stopCh", ")", "\n", "if", "dns", ".", "epController", "!=", "nil", "{", "go", "dns", ".", "epController", ".", "Run",...
// Run starts the controller.
[ "Run", "starts", "the", "controller", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L259-L269
130,593
coredns/coredns
plugin/kubernetes/controller.go
HasSynced
func (dns *dnsControl) HasSynced() bool { a := dns.svcController.HasSynced() b := true if dns.epController != nil { b = dns.epController.HasSynced() } c := true if dns.podController != nil { c = dns.podController.HasSynced() } d := dns.nsController.HasSynced() return a && b && c && d }
go
func (dns *dnsControl) HasSynced() bool { a := dns.svcController.HasSynced() b := true if dns.epController != nil { b = dns.epController.HasSynced() } c := true if dns.podController != nil { c = dns.podController.HasSynced() } d := dns.nsController.HasSynced() return a && b && c && d }
[ "func", "(", "dns", "*", "dnsControl", ")", "HasSynced", "(", ")", "bool", "{", "a", ":=", "dns", ".", "svcController", ".", "HasSynced", "(", ")", "\n", "b", ":=", "true", "\n", "if", "dns", ".", "epController", "!=", "nil", "{", "b", "=", "dns", ...
// HasSynced calls on all controllers.
[ "HasSynced", "calls", "on", "all", "controllers", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L272-L284
130,594
coredns/coredns
plugin/kubernetes/controller.go
GetNodeByName
func (dns *dnsControl) GetNodeByName(name string) (*api.Node, error) { v1node, err := dns.client.CoreV1().Nodes().Get(name, meta.GetOptions{}) return v1node, err }
go
func (dns *dnsControl) GetNodeByName(name string) (*api.Node, error) { v1node, err := dns.client.CoreV1().Nodes().Get(name, meta.GetOptions{}) return v1node, err }
[ "func", "(", "dns", "*", "dnsControl", ")", "GetNodeByName", "(", "name", "string", ")", "(", "*", "api", ".", "Node", ",", "error", ")", "{", "v1node", ",", "err", ":=", "dns", ".", "client", ".", "CoreV1", "(", ")", ".", "Nodes", "(", ")", ".",...
// GetNodeByName return the node by name. If nothing is found an error is // returned. This query causes a roundtrip to the k8s API server, so use // sparingly. Currently this is only used for Federation.
[ "GetNodeByName", "return", "the", "node", "by", "name", ".", "If", "nothing", "is", "found", "an", "error", "is", "returned", ".", "This", "query", "causes", "a", "roundtrip", "to", "the", "k8s", "API", "server", "so", "use", "sparingly", ".", "Currently",...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L389-L392
130,595
coredns/coredns
plugin/kubernetes/controller.go
GetNamespaceByName
func (dns *dnsControl) GetNamespaceByName(name string) (*api.Namespace, error) { os := dns.nsLister.List() for _, o := range os { ns, ok := o.(*api.Namespace) if !ok { continue } if name == ns.ObjectMeta.Name { return ns, nil } } return nil, fmt.Errorf("namespace not found") }
go
func (dns *dnsControl) GetNamespaceByName(name string) (*api.Namespace, error) { os := dns.nsLister.List() for _, o := range os { ns, ok := o.(*api.Namespace) if !ok { continue } if name == ns.ObjectMeta.Name { return ns, nil } } return nil, fmt.Errorf("namespace not found") }
[ "func", "(", "dns", "*", "dnsControl", ")", "GetNamespaceByName", "(", "name", "string", ")", "(", "*", "api", ".", "Namespace", ",", "error", ")", "{", "os", ":=", "dns", ".", "nsLister", ".", "List", "(", ")", "\n", "for", "_", ",", "o", ":=", ...
// GetNamespaceByName returns the namespace by name. If nothing is found an error is returned.
[ "GetNamespaceByName", "returns", "the", "namespace", "by", "name", ".", "If", "nothing", "is", "found", "an", "error", "is", "returned", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L395-L407
130,596
coredns/coredns
plugin/kubernetes/controller.go
detectChanges
func (dns *dnsControl) detectChanges(oldObj, newObj interface{}) { // If both objects have the same resource version, they are identical. if newObj != nil && oldObj != nil && (oldObj.(meta.Object).GetResourceVersion() == newObj.(meta.Object).GetResourceVersion()) { return } obj := newObj if obj == nil { obj = ...
go
func (dns *dnsControl) detectChanges(oldObj, newObj interface{}) { // If both objects have the same resource version, they are identical. if newObj != nil && oldObj != nil && (oldObj.(meta.Object).GetResourceVersion() == newObj.(meta.Object).GetResourceVersion()) { return } obj := newObj if obj == nil { obj = ...
[ "func", "(", "dns", "*", "dnsControl", ")", "detectChanges", "(", "oldObj", ",", "newObj", "interface", "{", "}", ")", "{", "// If both objects have the same resource version, they are identical.", "if", "newObj", "!=", "nil", "&&", "oldObj", "!=", "nil", "&&", "(...
// detectChanges detects changes in objects, and updates the modified timestamp
[ "detectChanges", "detects", "changes", "in", "objects", "and", "updates", "the", "modified", "timestamp" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L414-L442
130,597
coredns/coredns
plugin/kubernetes/controller.go
endpointsEquivalent
func endpointsEquivalent(a, b *object.Endpoints) bool { if len(a.Subsets) != len(b.Subsets) { return false } // we should be able to rely on // these being sorted and able to be compared // they are supposed to be in a canonical format for i, sa := range a.Subsets { sb := b.Subsets[i] if !subsetsEquivalen...
go
func endpointsEquivalent(a, b *object.Endpoints) bool { if len(a.Subsets) != len(b.Subsets) { return false } // we should be able to rely on // these being sorted and able to be compared // they are supposed to be in a canonical format for i, sa := range a.Subsets { sb := b.Subsets[i] if !subsetsEquivalen...
[ "func", "endpointsEquivalent", "(", "a", ",", "b", "*", "object", ".", "Endpoints", ")", "bool", "{", "if", "len", "(", "a", ".", "Subsets", ")", "!=", "len", "(", "b", ".", "Subsets", ")", "{", "return", "false", "\n", "}", "\n\n", "// we should be ...
// endpointsEquivalent checks if the update to an endpoint is something // that matters to us or if they are effectively equivalent.
[ "endpointsEquivalent", "checks", "if", "the", "update", "to", "an", "endpoint", "is", "something", "that", "matters", "to", "us", "or", "if", "they", "are", "effectively", "equivalent", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L485-L501
130,598
coredns/coredns
plugin/kubernetes/controller.go
updateModifed
func (dns *dnsControl) updateModifed() { unix := time.Now().Unix() atomic.StoreInt64(&dns.modified, unix) }
go
func (dns *dnsControl) updateModifed() { unix := time.Now().Unix() atomic.StoreInt64(&dns.modified, unix) }
[ "func", "(", "dns", "*", "dnsControl", ")", "updateModifed", "(", ")", "{", "unix", ":=", "time", ".", "Now", "(", ")", ".", "Unix", "(", ")", "\n", "atomic", ".", "StoreInt64", "(", "&", "dns", ".", "modified", ",", "unix", ")", "\n", "}" ]
// updateModified set dns.modified to the current time.
[ "updateModified", "set", "dns", ".", "modified", "to", "the", "current", "time", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/controller.go#L509-L512
130,599
coredns/coredns
plugin/file/reload.go
Reload
func (z *Zone) Reload() error { if z.ReloadInterval == 0 { return nil } tick := time.NewTicker(TickTime) go func() { for { select { case <-tick.C: if z.LastReloaded.Add(z.ReloadInterval).After(time.Now()) { //reload interval not reached yet continue } //saving timestamp of last at...
go
func (z *Zone) Reload() error { if z.ReloadInterval == 0 { return nil } tick := time.NewTicker(TickTime) go func() { for { select { case <-tick.C: if z.LastReloaded.Add(z.ReloadInterval).After(time.Now()) { //reload interval not reached yet continue } //saving timestamp of last at...
[ "func", "(", "z", "*", "Zone", ")", "Reload", "(", ")", "error", "{", "if", "z", ".", "ReloadInterval", "==", "0", "{", "return", "nil", "\n", "}", "\n", "tick", ":=", "time", ".", "NewTicker", "(", "TickTime", ")", "\n\n", "go", "func", "(", ")"...
// Reload reloads a zone when it is changed on disk. If z.NoReload is true, no reloading will be done.
[ "Reload", "reloads", "a", "zone", "when", "it", "is", "changed", "on", "disk", ".", "If", "z", ".", "NoReload", "is", "true", "no", "reloading", "will", "be", "done", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/reload.go#L12-L63