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
27,700
golang/gddo
gddo-server/template.go
commentTextFn
func commentTextFn(v string) string { const indent = " " var buf bytes.Buffer godoc.ToText(&buf, v, indent, "\t", 80-2*len(indent)) p := buf.Bytes() return string(p) }
go
func commentTextFn(v string) string { const indent = " " var buf bytes.Buffer godoc.ToText(&buf, v, indent, "\t", 80-2*len(indent)) p := buf.Bytes() return string(p) }
[ "func", "commentTextFn", "(", "v", "string", ")", "string", "{", "const", "indent", "=", "\"", "\"", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "godoc", ".", "ToText", "(", "&", "buf", ",", "v", ",", "indent", ",", "\"", "\\t", "\"", ",", ...
// commentTextFn formats a source code comment as text.
[ "commentTextFn", "formats", "a", "source", "code", "comment", "as", "text", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/template.go#L409-L415
27,701
golang/gddo
httputil/transport.go
RoundTrip
func (t *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error) { var reqCopy *http.Request if t.UserAgent != "" { reqCopy = copyRequest(req) reqCopy.Header.Set("User-Agent", t.UserAgent) } if req.URL.Host == "api.github.com" && req.URL.Scheme == "https" { switch { case t.GithubClientID != "" &...
go
func (t *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error) { var reqCopy *http.Request if t.UserAgent != "" { reqCopy = copyRequest(req) reqCopy.Header.Set("User-Agent", t.UserAgent) } if req.URL.Host == "api.github.com" && req.URL.Scheme == "https" { switch { case t.GithubClientID != "" &...
[ "func", "(", "t", "*", "AuthTransport", ")", "RoundTrip", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "var", "reqCopy", "*", "http", ".", "Request", "\n", "if", "t", ".", "UserAgent", "!=...
// RoundTrip implements the http.RoundTripper interface.
[ "RoundTrip", "implements", "the", "http", ".", "RoundTripper", "interface", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/httputil/transport.go#L30-L58
27,702
golang/gddo
log/log.go
FromContext
func FromContext(ctx context.Context) log15.Logger { if logger, ok := ctx.Value(loggerKey).(log15.Logger); ok { return logger } return log15.Root() }
go
func FromContext(ctx context.Context) log15.Logger { if logger, ok := ctx.Value(loggerKey).(log15.Logger); ok { return logger } return log15.Root() }
[ "func", "FromContext", "(", "ctx", "context", ".", "Context", ")", "log15", ".", "Logger", "{", "if", "logger", ",", "ok", ":=", "ctx", ".", "Value", "(", "loggerKey", ")", ".", "(", "log15", ".", "Logger", ")", ";", "ok", "{", "return", "logger", ...
// FromContext always returns a logger. If there is no logger in the context, it // returns the root logger. It is not recommended for use and may be removed in // the future.
[ "FromContext", "always", "returns", "a", "logger", ".", "If", "there", "is", "no", "logger", "in", "the", "context", "it", "returns", "the", "root", "logger", ".", "It", "is", "not", "recommended", "for", "use", "and", "may", "be", "removed", "in", "the"...
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/log/log.go#L21-L27
27,703
golang/gddo
log/log.go
NewContext
func NewContext(ctx context.Context, l log15.Logger) context.Context { return context.WithValue(ctx, loggerKey, l) }
go
func NewContext(ctx context.Context, l log15.Logger) context.Context { return context.WithValue(ctx, loggerKey, l) }
[ "func", "NewContext", "(", "ctx", "context", ".", "Context", ",", "l", "log15", ".", "Logger", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "loggerKey", ",", "l", ")", "\n", "}" ]
// NewContext creates a new context containing the given logger. It is not // recommended for use and may be removed in the future.
[ "NewContext", "creates", "a", "new", "context", "containing", "the", "given", "logger", ".", "It", "is", "not", "recommended", "for", "use", "and", "may", "be", "removed", "in", "the", "future", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/log/log.go#L31-L33
27,704
golang/gddo
gosrc/client.go
get
func (c *httpClient) get(ctx context.Context, url string) (*http.Response, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } // Take the trace ID to group all outbound requests together. req = req.WithContext(ctx) for k, vs := range c.header { req.Header[k] = vs } resp...
go
func (c *httpClient) get(ctx context.Context, url string) (*http.Response, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } // Take the trace ID to group all outbound requests together. req = req.WithContext(ctx) for k, vs := range c.header { req.Header[k] = vs } resp...
[ "func", "(", "c", "*", "httpClient", ")", "get", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ","...
// get issues a GET to the specified URL.
[ "get", "issues", "a", "GET", "to", "the", "specified", "URL", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gosrc/client.go#L35-L51
27,705
golang/gddo
gosrc/client.go
getNoFollow
func (c *httpClient) getNoFollow(url string) (*http.Response, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } for k, vs := range c.header { req.Header[k] = vs } t := c.client.Transport if t == nil { t = http.DefaultTransport } resp, err := t.RoundTrip(req) if err ...
go
func (c *httpClient) getNoFollow(url string) (*http.Response, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } for k, vs := range c.header { req.Header[k] = vs } t := c.client.Transport if t == nil { t = http.DefaultTransport } resp, err := t.RoundTrip(req) if err ...
[ "func", "(", "c", "*", "httpClient", ")", "getNoFollow", "(", "url", "string", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "url", ",", "nil", ")", "\n",...
// getNoFollow issues a GET to the specified URL without following redirects.
[ "getNoFollow", "issues", "a", "GET", "to", "the", "specified", "URL", "without", "following", "redirects", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gosrc/client.go#L54-L71
27,706
golang/gddo
database/indexae.go
putIndex
func putIndex(c context.Context, pdoc *doc.Package, id string, score float64, importCount int) error { if id == "" { return errors.New("indexae: no id assigned") } idx, err := search.Open("packages") if err != nil { return err } var pkg Package if err := idx.Get(c, id, &pkg); err != nil { if err != search...
go
func putIndex(c context.Context, pdoc *doc.Package, id string, score float64, importCount int) error { if id == "" { return errors.New("indexae: no id assigned") } idx, err := search.Open("packages") if err != nil { return err } var pkg Package if err := idx.Get(c, id, &pkg); err != nil { if err != search...
[ "func", "putIndex", "(", "c", "context", ".", "Context", ",", "pdoc", "*", "doc", ".", "Package", ",", "id", "string", ",", "score", "float64", ",", "importCount", "int", ")", "error", "{", "if", "id", "==", "\"", "\"", "{", "return", "errors", ".", ...
// putIndex creates or updates a package entry in the search index. id identifies the document in the index. // If pdoc is non-nil, putIndex will update the package's name, path and synopsis supplied by pdoc. // pdoc must be non-nil for a package's first call to putIndex. // putIndex updates the Score to score, if non-...
[ "putIndex", "creates", "or", "updates", "a", "package", "entry", "in", "the", "search", "index", ".", "id", "identifies", "the", "document", "in", "the", "index", ".", "If", "pdoc", "is", "non", "-", "nil", "putIndex", "will", "update", "the", "package", ...
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/database/indexae.go#L91-L128
27,707
golang/gddo
database/indexae.go
searchAE
func searchAE(c context.Context, q string) ([]Package, error) { index, err := search.Open("packages") if err != nil { return nil, err } var pkgs []Package opt := &search.SearchOptions{ Limit: 100, } for it := index.Search(c, parseQuery2(q), opt); ; { var p Package _, err := it.Next(&p) if err == search...
go
func searchAE(c context.Context, q string) ([]Package, error) { index, err := search.Open("packages") if err != nil { return nil, err } var pkgs []Package opt := &search.SearchOptions{ Limit: 100, } for it := index.Search(c, parseQuery2(q), opt); ; { var p Package _, err := it.Next(&p) if err == search...
[ "func", "searchAE", "(", "c", "context", ".", "Context", ",", "q", "string", ")", "(", "[", "]", "Package", ",", "error", ")", "{", "index", ",", "err", ":=", "search", ".", "Open", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// searchAE searches the packages index for a given query. A path-like query string // will be passed in unchanged, whereas single words will be stemmed.
[ "searchAE", "searches", "the", "packages", "index", "for", "a", "given", "query", ".", "A", "path", "-", "like", "query", "string", "will", "be", "passed", "in", "unchanged", "whereas", "single", "words", "will", "be", "stemmed", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/database/indexae.go#L132-L153
27,708
golang/gddo
gddo-server/crawl.go
isActivePkg
func (s *server) isActivePkg(pkg string, status gosrc.DirectoryStatus) bool { switch status { case gosrc.Active: return true case gosrc.NoRecentCommits: // It should be inactive only if it has no imports as well. n, err := s.db.ImporterCount(pkg) if err != nil { log.Printf("ERROR db.ImporterCount(%q): %v"...
go
func (s *server) isActivePkg(pkg string, status gosrc.DirectoryStatus) bool { switch status { case gosrc.Active: return true case gosrc.NoRecentCommits: // It should be inactive only if it has no imports as well. n, err := s.db.ImporterCount(pkg) if err != nil { log.Printf("ERROR db.ImporterCount(%q): %v"...
[ "func", "(", "s", "*", "server", ")", "isActivePkg", "(", "pkg", "string", ",", "status", "gosrc", ".", "DirectoryStatus", ")", "bool", "{", "switch", "status", "{", "case", "gosrc", ".", "Active", ":", "return", "true", "\n", "case", "gosrc", ".", "No...
// isActivePkg reports whether a package is considered active, // either because its directory is active or because it is imported by another package.
[ "isActivePkg", "reports", "whether", "a", "package", "is", "considered", "active", "either", "because", "its", "directory", "is", "active", "or", "because", "it", "is", "imported", "by", "another", "package", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/crawl.go#L158-L171
27,709
golang/gddo
internal/health/health.go
Add
func (h *Handler) Add(c Checker) { h.checkers = append(h.checkers, c) }
go
func (h *Handler) Add(c Checker) { h.checkers = append(h.checkers, c) }
[ "func", "(", "h", "*", "Handler", ")", "Add", "(", "c", "Checker", ")", "{", "h", ".", "checkers", "=", "append", "(", "h", ".", "checkers", ",", "c", ")", "\n", "}" ]
// Add adds a new check to the handler.
[ "Add", "adds", "a", "new", "check", "to", "the", "handler", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/internal/health/health.go#L22-L24
27,710
golang/gddo
internal/health/health.go
ServeHTTP
func (h *Handler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { for _, c := range h.checkers { if err := c.CheckHealth(); err != nil { writeUnhealthy(w) return } } writeHealthy(w) }
go
func (h *Handler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { for _, c := range h.checkers { if err := c.CheckHealth(); err != nil { writeUnhealthy(w) return } } writeHealthy(w) }
[ "func", "(", "h", "*", "Handler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "_", "*", "http", ".", "Request", ")", "{", "for", "_", ",", "c", ":=", "range", "h", ".", "checkers", "{", "if", "err", ":=", "c", ".", "CheckHealt...
// ServeHTTP returns 200 if it is healthy, 500 otherwise.
[ "ServeHTTP", "returns", "200", "if", "it", "is", "healthy", "500", "otherwise", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/internal/health/health.go#L27-L35
27,711
golang/gddo
gddo-server/logging.go
LogEvent
func (g *GCELogger) LogEvent(w http.ResponseWriter, r *http.Request, content interface{}) { const sessionCookieName = "GODOC_ORG_SESSION_ID" cookie, err := r.Cookie(sessionCookieName) if err != nil { // Generates a random session id and sends it in response. rs, err := randomString() if err != nil { log.Pri...
go
func (g *GCELogger) LogEvent(w http.ResponseWriter, r *http.Request, content interface{}) { const sessionCookieName = "GODOC_ORG_SESSION_ID" cookie, err := r.Cookie(sessionCookieName) if err != nil { // Generates a random session id and sends it in response. rs, err := randomString() if err != nil { log.Pri...
[ "func", "(", "g", "*", "GCELogger", ")", "LogEvent", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "content", "interface", "{", "}", ")", "{", "const", "sessionCookieName", "=", "\"", "\"", "\n", "cookie", ",", ...
// LogEvent creates an entry in Cloud Logging to record user's behavior. We should only // use this to log events we are interested in. General request logs are handled by GAE // automatically in request_log and stderr.
[ "LogEvent", "creates", "an", "entry", "in", "Cloud", "Logging", "to", "record", "user", "s", "behavior", ".", "We", "should", "only", "use", "this", "to", "log", "events", "we", "are", "interested", "in", ".", "General", "request", "logs", "are", "handled"...
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/logging.go#L33-L71
27,712
golang/gddo
gosrc/util.go
isDocFile
func isDocFile(n string) bool { if strings.HasSuffix(n, ".go") && n[0] != '_' && n[0] != '.' { return true } return readmePat.MatchString(n) }
go
func isDocFile(n string) bool { if strings.HasSuffix(n, ".go") && n[0] != '_' && n[0] != '.' { return true } return readmePat.MatchString(n) }
[ "func", "isDocFile", "(", "n", "string", ")", "bool", "{", "if", "strings", ".", "HasSuffix", "(", "n", ",", "\"", "\"", ")", "&&", "n", "[", "0", "]", "!=", "'_'", "&&", "n", "[", "0", "]", "!=", "'.'", "{", "return", "true", "\n", "}", "\n"...
// isDocFile returns true if a file with name n should be included in the // documentation.
[ "isDocFile", "returns", "true", "if", "a", "file", "with", "name", "n", "should", "be", "included", "in", "the", "documentation", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gosrc/util.go#L55-L60
27,713
golang/gddo
gddo-server/main.go
getDoc
func (s *server) getDoc(ctx context.Context, path string, requestType int) (*doc.Package, []database.Package, error) { if path == "-" { // A hack in the database package uses the path "-" to represent the // next document to crawl. Block "-" here so that requests to /- always // return not found. return nil, n...
go
func (s *server) getDoc(ctx context.Context, path string, requestType int) (*doc.Package, []database.Package, error) { if path == "-" { // A hack in the database package uses the path "-" to represent the // next document to crawl. Block "-" here so that requests to /- always // return not found. return nil, n...
[ "func", "(", "s", "*", "server", ")", "getDoc", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "requestType", "int", ")", "(", "*", "doc", ".", "Package", ",", "[", "]", "database", ".", "Package", ",", "error", ")", "{", "if", ...
// getDoc gets the package documentation from the database or from the version // control system as needed.
[ "getDoc", "gets", "the", "package", "documentation", "from", "the", "database", "or", "from", "the", "version", "control", "system", "as", "needed", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/main.go#L78-L140
27,714
golang/gddo
gddo-server/main.go
httpEtag
func (s *server) httpEtag(pdoc *doc.Package, pkgs []database.Package, importerCount int, flashMessages []flashMessage) string { b := make([]byte, 0, 128) b = strconv.AppendInt(b, pdoc.Updated.Unix(), 16) b = append(b, 0) b = append(b, pdoc.Etag...) if importerCount >= 8 { importerCount = 8 } b = append(b, 0) ...
go
func (s *server) httpEtag(pdoc *doc.Package, pkgs []database.Package, importerCount int, flashMessages []flashMessage) string { b := make([]byte, 0, 128) b = strconv.AppendInt(b, pdoc.Updated.Unix(), 16) b = append(b, 0) b = append(b, pdoc.Etag...) if importerCount >= 8 { importerCount = 8 } b = append(b, 0) ...
[ "func", "(", "s", "*", "server", ")", "httpEtag", "(", "pdoc", "*", "doc", ".", "Package", ",", "pkgs", "[", "]", "database", ".", "Package", ",", "importerCount", "int", ",", "flashMessages", "[", "]", "flashMessage", ")", "string", "{", "b", ":=", ...
// httpEtag returns the package entity tag used in HTTP transactions.
[ "httpEtag", "returns", "the", "package", "entity", "tag", "used", "in", "HTTP", "transactions", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/main.go#L179-L210
27,715
golang/gddo
gddo-server/config.go
setDefaults
func setDefaults(v *viper.Viper) { // ConfigGAERemoteAPI is based on project. project := v.GetString(ConfigProject) if project != "" { defaultEndpoint := fmt.Sprintf("serviceproxy-dot-%s.appspot.com", project) v.SetDefault(ConfigGAERemoteAPI, defaultEndpoint) } }
go
func setDefaults(v *viper.Viper) { // ConfigGAERemoteAPI is based on project. project := v.GetString(ConfigProject) if project != "" { defaultEndpoint := fmt.Sprintf("serviceproxy-dot-%s.appspot.com", project) v.SetDefault(ConfigGAERemoteAPI, defaultEndpoint) } }
[ "func", "setDefaults", "(", "v", "*", "viper", ".", "Viper", ")", "{", "// ConfigGAERemoteAPI is based on project.", "project", ":=", "v", ".", "GetString", "(", "ConfigProject", ")", "\n", "if", "project", "!=", "\"", "\"", "{", "defaultEndpoint", ":=", "fmt"...
// setDefaults sets defaults for configuration options that depend on other // configuration options. This allows for smart defaults but allows for // overrides.
[ "setDefaults", "sets", "defaults", "for", "configuration", "options", "that", "depend", "on", "other", "configuration", "options", ".", "This", "allows", "for", "smart", "defaults", "but", "allows", "for", "overrides", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/config.go#L141-L148
27,716
golang/gddo
gddo-server/config.go
readViperConfig
func readViperConfig(ctx context.Context, v *viper.Viper) error { v.AddConfigPath(".") v.AddConfigPath("/etc") v.SetConfigName("gddo") if v.GetString("config") != "" { v.SetConfigFile(v.GetString("config")) } if err := v.ReadInConfig(); err != nil { // If a config exists but could not be parsed, we should ba...
go
func readViperConfig(ctx context.Context, v *viper.Viper) error { v.AddConfigPath(".") v.AddConfigPath("/etc") v.SetConfigName("gddo") if v.GetString("config") != "" { v.SetConfigFile(v.GetString("config")) } if err := v.ReadInConfig(); err != nil { // If a config exists but could not be parsed, we should ba...
[ "func", "readViperConfig", "(", "ctx", "context", ".", "Context", ",", "v", "*", "viper", ".", "Viper", ")", "error", "{", "v", ".", "AddConfigPath", "(", "\"", "\"", ")", "\n", "v", ".", "AddConfigPath", "(", "\"", "\"", ")", "\n", "v", ".", "SetC...
// readViperConfig finds and then parses a config file. It will return // an error if the config file was specified or could not parse. // Otherwise it will only warn that it failed to load the config.
[ "readViperConfig", "finds", "and", "then", "parses", "a", "config", "file", ".", "It", "will", "return", "an", "error", "if", "the", "config", "file", "was", "specified", "or", "could", "not", "parse", ".", "Otherwise", "it", "will", "only", "warn", "that"...
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/config.go#L183-L207
27,717
golang/gddo
httputil/buster.go
Get
func (cb *CacheBusters) Get(path string) string { cb.mu.Lock() if cb.tokens == nil { cb.tokens = make(map[string]string) } token, ok := cb.tokens[path] cb.mu.Unlock() if ok { return token } w := busterWriter{ Writer: ioutil.Discard, headerMap: make(http.Header), } r := &http.Request{URL: &url.URL{...
go
func (cb *CacheBusters) Get(path string) string { cb.mu.Lock() if cb.tokens == nil { cb.tokens = make(map[string]string) } token, ok := cb.tokens[path] cb.mu.Unlock() if ok { return token } w := busterWriter{ Writer: ioutil.Discard, headerMap: make(http.Header), } r := &http.Request{URL: &url.URL{...
[ "func", "(", "cb", "*", "CacheBusters", ")", "Get", "(", "path", "string", ")", "string", "{", "cb", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "cb", ".", "tokens", "==", "nil", "{", "cb", ".", "tokens", "=", "make", "(", "map", "[", "string...
// Get returns the cache busting token for path. If the token is not already // cached, Get issues a HEAD request on handler and uses the response ETag and // Last-Modified headers to compute a token.
[ "Get", "returns", "the", "cache", "busting", "token", "for", "path", ".", "If", "the", "token", "is", "not", "already", "cached", "Get", "issues", "a", "HEAD", "request", "on", "handler", "and", "uses", "the", "response", "ETag", "and", "Last", "-", "Mod...
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/httputil/buster.go#L54-L86
27,718
golang/gddo
httputil/buster.go
AppendQueryParam
func (cb *CacheBusters) AppendQueryParam(path string, name string) string { token := cb.Get(path) if token == "" { return path } return path + "?" + name + "=" + token }
go
func (cb *CacheBusters) AppendQueryParam(path string, name string) string { token := cb.Get(path) if token == "" { return path } return path + "?" + name + "=" + token }
[ "func", "(", "cb", "*", "CacheBusters", ")", "AppendQueryParam", "(", "path", "string", ",", "name", "string", ")", "string", "{", "token", ":=", "cb", ".", "Get", "(", "path", ")", "\n", "if", "token", "==", "\"", "\"", "{", "return", "path", "\n", ...
// AppendQueryParam appends the token as a query parameter to path.
[ "AppendQueryParam", "appends", "the", "token", "as", "a", "query", "parameter", "to", "path", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/httputil/buster.go#L89-L95
27,719
golang/gddo
gddo-server/browse.go
isBrowseURL
func isBrowseURL(s string) (importPath string, ok bool) { for _, c := range browsePatterns { if m := c.pat.FindStringSubmatch(s); m != nil { return c.fn(m), true } } return "", false }
go
func isBrowseURL(s string) (importPath string, ok bool) { for _, c := range browsePatterns { if m := c.pat.FindStringSubmatch(s); m != nil { return c.fn(m), true } } return "", false }
[ "func", "isBrowseURL", "(", "s", "string", ")", "(", "importPath", "string", ",", "ok", "bool", ")", "{", "for", "_", ",", "c", ":=", "range", "browsePatterns", "{", "if", "m", ":=", "c", ".", "pat", ".", "FindStringSubmatch", "(", "s", ")", ";", "...
// isBrowserURL returns importPath and true if URL looks like a URL for a VCS // source browser.
[ "isBrowserURL", "returns", "importPath", "and", "true", "if", "URL", "looks", "like", "a", "URL", "for", "a", "VCS", "source", "browser", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gddo-server/browse.go#L90-L97
27,720
golang/gddo
gosrc/path.go
IsValidRemotePath
func IsValidRemotePath(importPath string) bool { parts := strings.Split(importPath, "/") if !validTLDs[path.Ext(parts[0])] { return false } if !validHost.MatchString(parts[0]) { return false } for _, part := range parts[1:] { if !isValidPathElement(part) { return false } } return true }
go
func IsValidRemotePath(importPath string) bool { parts := strings.Split(importPath, "/") if !validTLDs[path.Ext(parts[0])] { return false } if !validHost.MatchString(parts[0]) { return false } for _, part := range parts[1:] { if !isValidPathElement(part) { return false } } return true }
[ "func", "IsValidRemotePath", "(", "importPath", "string", ")", "bool", "{", "parts", ":=", "strings", ".", "Split", "(", "importPath", ",", "\"", "\"", ")", "\n\n", "if", "!", "validTLDs", "[", "path", ".", "Ext", "(", "parts", "[", "0", "]", ")", "]...
// IsValidRemotePath returns true if importPath is structurally valid for "go get".
[ "IsValidRemotePath", "returns", "true", "if", "importPath", "is", "structurally", "valid", "for", "go", "get", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gosrc/path.go#L25-L44
27,721
golang/gddo
gosrc/path.go
IsValidPath
func IsValidPath(importPath string) bool { return pathFlags[importPath]&packagePath != 0 || pathFlags["vendor/"+importPath]&packagePath != 0 || IsValidRemotePath(importPath) }
go
func IsValidPath(importPath string) bool { return pathFlags[importPath]&packagePath != 0 || pathFlags["vendor/"+importPath]&packagePath != 0 || IsValidRemotePath(importPath) }
[ "func", "IsValidPath", "(", "importPath", "string", ")", "bool", "{", "return", "pathFlags", "[", "importPath", "]", "&", "packagePath", "!=", "0", "||", "pathFlags", "[", "\"", "\"", "+", "importPath", "]", "&", "packagePath", "!=", "0", "||", "IsValidRem...
// IsValidPath returns true if importPath is structurally valid.
[ "IsValidPath", "returns", "true", "if", "importPath", "is", "structurally", "valid", "." ]
af0f2af80721261f4d211b2c9563f7b46b2aab06
https://github.com/golang/gddo/blob/af0f2af80721261f4d211b2c9563f7b46b2aab06/gosrc/path.go#L52-L56
27,722
dchest/captcha
image.go
NewImage
func NewImage(id string, digits []byte, width, height int) *Image { m := new(Image) // Initialize PRNG. m.rng.Seed(deriveSeed(imageSeedPurpose, id, digits)) m.Paletted = image.NewPaletted(image.Rect(0, 0, width, height), m.getRandomPalette()) m.calculateSizes(width, height, len(digits)) // Randomly position cap...
go
func NewImage(id string, digits []byte, width, height int) *Image { m := new(Image) // Initialize PRNG. m.rng.Seed(deriveSeed(imageSeedPurpose, id, digits)) m.Paletted = image.NewPaletted(image.Rect(0, 0, width, height), m.getRandomPalette()) m.calculateSizes(width, height, len(digits)) // Randomly position cap...
[ "func", "NewImage", "(", "id", "string", ",", "digits", "[", "]", "byte", ",", "width", ",", "height", "int", ")", "*", "Image", "{", "m", ":=", "new", "(", "Image", ")", "\n\n", "// Initialize PRNG.", "m", ".", "rng", ".", "Seed", "(", "deriveSeed",...
// NewImage returns a new captcha image of the given width and height with the // given digits, where each digit must be in range 0-9.
[ "NewImage", "returns", "a", "new", "captcha", "image", "of", "the", "given", "width", "and", "height", "with", "the", "given", "digits", "where", "each", "digit", "must", "be", "in", "range", "0", "-", "9", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/image.go#L36-L67
27,723
dchest/captcha
image.go
encodedPNG
func (m *Image) encodedPNG() []byte { var buf bytes.Buffer if err := png.Encode(&buf, m.Paletted); err != nil { panic(err.Error()) } return buf.Bytes() }
go
func (m *Image) encodedPNG() []byte { var buf bytes.Buffer if err := png.Encode(&buf, m.Paletted); err != nil { panic(err.Error()) } return buf.Bytes() }
[ "func", "(", "m", "*", "Image", ")", "encodedPNG", "(", ")", "[", "]", "byte", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "if", "err", ":=", "png", ".", "Encode", "(", "&", "buf", ",", "m", ".", "Paletted", ")", ";", "err", "!=", "nil", ...
// encodedPNG encodes an image to PNG and returns // the result as a byte slice.
[ "encodedPNG", "encodes", "an", "image", "to", "PNG", "and", "returns", "the", "result", "as", "a", "byte", "slice", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/image.go#L90-L96
27,724
dchest/captcha
image.go
WriteTo
func (m *Image) WriteTo(w io.Writer) (int64, error) { n, err := w.Write(m.encodedPNG()) return int64(n), err }
go
func (m *Image) WriteTo(w io.Writer) (int64, error) { n, err := w.Write(m.encodedPNG()) return int64(n), err }
[ "func", "(", "m", "*", "Image", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "n", ",", "err", ":=", "w", ".", "Write", "(", "m", ".", "encodedPNG", "(", ")", ")", "\n", "return", "int64", "(", "n",...
// WriteTo writes captcha image in PNG format into the given writer.
[ "WriteTo", "writes", "captcha", "image", "in", "PNG", "format", "into", "the", "given", "writer", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/image.go#L99-L102
27,725
dchest/captcha
random.go
randomBytesMod
func randomBytesMod(length int, mod byte) (b []byte) { if length == 0 { return nil } if mod == 0 { panic("captcha: bad mod argument for randomBytesMod") } maxrb := 255 - byte(256%int(mod)) b = make([]byte, length) i := 0 for { r := randomBytes(length + (length / 4)) for _, c := range r { if c > maxrb...
go
func randomBytesMod(length int, mod byte) (b []byte) { if length == 0 { return nil } if mod == 0 { panic("captcha: bad mod argument for randomBytesMod") } maxrb := 255 - byte(256%int(mod)) b = make([]byte, length) i := 0 for { r := randomBytes(length + (length / 4)) for _, c := range r { if c > maxrb...
[ "func", "randomBytesMod", "(", "length", "int", ",", "mod", "byte", ")", "(", "b", "[", "]", "byte", ")", "{", "if", "length", "==", "0", "{", "return", "nil", "\n", "}", "\n", "if", "mod", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", ...
// randomBytesMod returns a byte slice of the given length, where each byte is // a random number modulo mod.
[ "randomBytesMod", "returns", "a", "byte", "slice", "of", "the", "given", "length", "where", "each", "byte", "is", "a", "random", "number", "modulo", "mod", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/random.go#L74-L99
27,726
dchest/captcha
random.go
randomId
func randomId() string { b := randomBytesMod(idLen, byte(len(idChars))) for i, c := range b { b[i] = idChars[c] } return string(b) }
go
func randomId() string { b := randomBytesMod(idLen, byte(len(idChars))) for i, c := range b { b[i] = idChars[c] } return string(b) }
[ "func", "randomId", "(", ")", "string", "{", "b", ":=", "randomBytesMod", "(", "idLen", ",", "byte", "(", "len", "(", "idChars", ")", ")", ")", "\n", "for", "i", ",", "c", ":=", "range", "b", "{", "b", "[", "i", "]", "=", "idChars", "[", "c", ...
// randomId returns a new random id string.
[ "randomId", "returns", "a", "new", "random", "id", "string", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/random.go#L102-L108
27,727
dchest/captcha
siprng.go
Seed
func (p *siprng) Seed(k [16]byte) { p.k0 = binary.LittleEndian.Uint64(k[0:8]) p.k1 = binary.LittleEndian.Uint64(k[8:16]) p.ctr = 1 }
go
func (p *siprng) Seed(k [16]byte) { p.k0 = binary.LittleEndian.Uint64(k[0:8]) p.k1 = binary.LittleEndian.Uint64(k[8:16]) p.ctr = 1 }
[ "func", "(", "p", "*", "siprng", ")", "Seed", "(", "k", "[", "16", "]", "byte", ")", "{", "p", ".", "k0", "=", "binary", ".", "LittleEndian", ".", "Uint64", "(", "k", "[", "0", ":", "8", "]", ")", "\n", "p", ".", "k1", "=", "binary", ".", ...
// Seed sets a new secret seed for PRNG.
[ "Seed", "sets", "a", "new", "secret", "seed", "for", "PRNG", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/siprng.go#L193-L197
27,728
dchest/captcha
siprng.go
Uint64
func (p *siprng) Uint64() uint64 { v := siphash(p.k0, p.k1, p.ctr) p.ctr++ return v }
go
func (p *siprng) Uint64() uint64 { v := siphash(p.k0, p.k1, p.ctr) p.ctr++ return v }
[ "func", "(", "p", "*", "siprng", ")", "Uint64", "(", ")", "uint64", "{", "v", ":=", "siphash", "(", "p", ".", "k0", ",", "p", ".", "k1", ",", "p", ".", "ctr", ")", "\n", "p", ".", "ctr", "++", "\n", "return", "v", "\n", "}" ]
// Uint64 returns a new pseudorandom uint64.
[ "Uint64", "returns", "a", "new", "pseudorandom", "uint64", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/siprng.go#L200-L204
27,729
dchest/captcha
captcha.go
NewLen
func NewLen(length int) (id string) { id = randomId() globalStore.Set(id, RandomDigits(length)) return }
go
func NewLen(length int) (id string) { id = randomId() globalStore.Set(id, RandomDigits(length)) return }
[ "func", "NewLen", "(", "length", "int", ")", "(", "id", "string", ")", "{", "id", "=", "randomId", "(", ")", "\n", "globalStore", ".", "Set", "(", "id", ",", "RandomDigits", "(", "length", ")", ")", "\n", "return", "\n", "}" ]
// NewLen is just like New, but accepts length of a captcha solution as the // argument.
[ "NewLen", "is", "just", "like", "New", "but", "accepts", "length", "of", "a", "captcha", "solution", "as", "the", "argument", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/captcha.go#L85-L89
27,730
dchest/captcha
captcha.go
WriteImage
func WriteImage(w io.Writer, id string, width, height int) error { d := globalStore.Get(id, false) if d == nil { return ErrNotFound } _, err := NewImage(id, d, width, height).WriteTo(w) return err }
go
func WriteImage(w io.Writer, id string, width, height int) error { d := globalStore.Get(id, false) if d == nil { return ErrNotFound } _, err := NewImage(id, d, width, height).WriteTo(w) return err }
[ "func", "WriteImage", "(", "w", "io", ".", "Writer", ",", "id", "string", ",", "width", ",", "height", "int", ")", "error", "{", "d", ":=", "globalStore", ".", "Get", "(", "id", ",", "false", ")", "\n", "if", "d", "==", "nil", "{", "return", "Err...
// WriteImage writes PNG-encoded image representation of the captcha with the // given id. The image will have the given width and height.
[ "WriteImage", "writes", "PNG", "-", "encoded", "image", "representation", "of", "the", "captcha", "with", "the", "given", "id", ".", "The", "image", "will", "have", "the", "given", "width", "and", "height", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/captcha.go#L108-L115
27,731
dchest/captcha
captcha.go
Verify
func Verify(id string, digits []byte) bool { if digits == nil || len(digits) == 0 { return false } reald := globalStore.Get(id, true) if reald == nil { return false } return bytes.Equal(digits, reald) }
go
func Verify(id string, digits []byte) bool { if digits == nil || len(digits) == 0 { return false } reald := globalStore.Get(id, true) if reald == nil { return false } return bytes.Equal(digits, reald) }
[ "func", "Verify", "(", "id", "string", ",", "digits", "[", "]", "byte", ")", "bool", "{", "if", "digits", "==", "nil", "||", "len", "(", "digits", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "reald", ":=", "globalStore", ".", "Get", ...
// Verify returns true if the given digits are the ones that were used to // create the given captcha id. // // The function deletes the captcha with the given id from the internal // storage, so that the same captcha can't be verified anymore.
[ "Verify", "returns", "true", "if", "the", "given", "digits", "are", "the", "ones", "that", "were", "used", "to", "create", "the", "given", "captcha", "id", ".", "The", "function", "deletes", "the", "captcha", "with", "the", "given", "id", "from", "the", ...
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/captcha.go#L134-L143
27,732
dchest/captcha
captcha.go
VerifyString
func VerifyString(id string, digits string) bool { if digits == "" { return false } ns := make([]byte, len(digits)) for i := range ns { d := digits[i] switch { case '0' <= d && d <= '9': ns[i] = d - '0' case d == ' ' || d == ',': // ignore default: return false } } return Verify(id, ns) }
go
func VerifyString(id string, digits string) bool { if digits == "" { return false } ns := make([]byte, len(digits)) for i := range ns { d := digits[i] switch { case '0' <= d && d <= '9': ns[i] = d - '0' case d == ' ' || d == ',': // ignore default: return false } } return Verify(id, ns) }
[ "func", "VerifyString", "(", "id", "string", ",", "digits", "string", ")", "bool", "{", "if", "digits", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "ns", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "digits", ")", ")", "\n...
// VerifyString is like Verify, but accepts a string of digits. It removes // spaces and commas from the string, but any other characters, apart from // digits and listed above, will cause the function to return false.
[ "VerifyString", "is", "like", "Verify", "but", "accepts", "a", "string", "of", "digits", ".", "It", "removes", "spaces", "and", "commas", "from", "the", "string", "but", "any", "other", "characters", "apart", "from", "digits", "and", "listed", "above", "will...
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/captcha.go#L148-L165
27,733
dchest/captcha
audio.go
WriteTo
func (a *Audio) WriteTo(w io.Writer) (n int64, err error) { // Calculate padded length of PCM chunk data. bodyLen := uint32(a.body.Len()) paddedBodyLen := bodyLen if bodyLen%2 != 0 { paddedBodyLen++ } totalLen := uint32(len(waveHeader)) - 4 + paddedBodyLen // Header. header := make([]byte, len(waveHeader)+4) ...
go
func (a *Audio) WriteTo(w io.Writer) (n int64, err error) { // Calculate padded length of PCM chunk data. bodyLen := uint32(a.body.Len()) paddedBodyLen := bodyLen if bodyLen%2 != 0 { paddedBodyLen++ } totalLen := uint32(len(waveHeader)) - 4 + paddedBodyLen // Header. header := make([]byte, len(waveHeader)+4) ...
[ "func", "(", "a", "*", "Audio", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "// Calculate padded length of PCM chunk data.", "bodyLen", ":=", "uint32", "(", "a", ".", "body", ".", "Len", "(", ")...
// WriteTo writes captcha audio in WAVE format into the given io.Writer, and // returns the number of bytes written and an error if any.
[ "WriteTo", "writes", "captcha", "audio", "in", "WAVE", "format", "into", "the", "given", "io", ".", "Writer", "and", "returns", "the", "number", "of", "bytes", "written", "and", "an", "error", "if", "any", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/audio.go#L85-L119
27,734
dchest/captcha
audio.go
mixSound
func mixSound(dst, src []byte) { for i, v := range src { av := int(v) bv := int(dst[i]) if av < 128 && bv < 128 { dst[i] = byte(av * bv / 128) } else { dst[i] = byte(2*(av+bv) - av*bv/128 - 256) } } }
go
func mixSound(dst, src []byte) { for i, v := range src { av := int(v) bv := int(dst[i]) if av < 128 && bv < 128 { dst[i] = byte(av * bv / 128) } else { dst[i] = byte(2*(av+bv) - av*bv/128 - 256) } } }
[ "func", "mixSound", "(", "dst", ",", "src", "[", "]", "byte", ")", "{", "for", "i", ",", "v", ":=", "range", "src", "{", "av", ":=", "int", "(", "v", ")", "\n", "bv", ":=", "int", "(", "dst", "[", "i", "]", ")", "\n", "if", "av", "<", "12...
// mixSound mixes src into dst. Dst must have length equal to or greater than // src length.
[ "mixSound", "mixes", "src", "into", "dst", ".", "Dst", "must", "have", "length", "equal", "to", "or", "greater", "than", "src", "length", "." ]
6a29415a8364ec2971fdc62d9e415ed53fc20410
https://github.com/dchest/captcha/blob/6a29415a8364ec2971fdc62d9e415ed53fc20410/audio.go#L172-L182
27,735
google/go-genproto
regen.go
goPkg
func goPkg(fname string) (string, error) { content, err := ioutil.ReadFile(fname) if err != nil { return "", err } var pkgName string if match := goPkgOptRe.FindSubmatch(content); len(match) > 0 { pn, err := strconv.Unquote(string(match[1])) if err != nil { return "", err } pkgName = pn } if p := s...
go
func goPkg(fname string) (string, error) { content, err := ioutil.ReadFile(fname) if err != nil { return "", err } var pkgName string if match := goPkgOptRe.FindSubmatch(content); len(match) > 0 { pn, err := strconv.Unquote(string(match[1])) if err != nil { return "", err } pkgName = pn } if p := s...
[ "func", "goPkg", "(", "fname", "string", ")", "(", "string", ",", "error", ")", "{", "content", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "fname", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\...
// goPkg reports the import path declared in the given file's // `go_package` option. If the option is missing, goPkg returns empty string.
[ "goPkg", "reports", "the", "import", "path", "declared", "in", "the", "given", "file", "s", "go_package", "option", ".", "If", "the", "option", "is", "missing", "goPkg", "returns", "empty", "string", "." ]
54afdca5d873f7b529e2ce3def1a99df16feda90
https://github.com/google/go-genproto/blob/54afdca5d873f7b529e2ce3def1a99df16feda90/regen.go#L107-L125
27,736
google/go-genproto
regen.go
protoc
func protoc(goOut string, includes, fnames []string) ([]byte, error) { args := []string{"--go_out=plugins=grpc:" + goOut} for _, inc := range includes { args = append(args, "-I", inc) } args = append(args, fnames...) return exec.Command("protoc", args...).CombinedOutput() }
go
func protoc(goOut string, includes, fnames []string) ([]byte, error) { args := []string{"--go_out=plugins=grpc:" + goOut} for _, inc := range includes { args = append(args, "-I", inc) } args = append(args, fnames...) return exec.Command("protoc", args...).CombinedOutput() }
[ "func", "protoc", "(", "goOut", "string", ",", "includes", ",", "fnames", "[", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", "+", "goOut", "}", "\n", "for", "_", ",", "inc"...
// protoc executes the "protoc" command on files named in fnames, // passing go_out and include flags specified in goOut and includes respectively. // protoc returns combined output from stdout and stderr.
[ "protoc", "executes", "the", "protoc", "command", "on", "files", "named", "in", "fnames", "passing", "go_out", "and", "include", "flags", "specified", "in", "goOut", "and", "includes", "respectively", ".", "protoc", "returns", "combined", "output", "from", "stdo...
54afdca5d873f7b529e2ce3def1a99df16feda90
https://github.com/google/go-genproto/blob/54afdca5d873f7b529e2ce3def1a99df16feda90/regen.go#L130-L137
27,737
gopherjs/vecty
example/todomvc/store/storeutil/storeutil.go
Add
func (r *ListenerRegistry) Add(key interface{}, listener func()) { if key == nil { key = new(int) } if _, ok := r.listeners[key]; ok { panic("duplicate listener key") } r.listeners[key] = listener }
go
func (r *ListenerRegistry) Add(key interface{}, listener func()) { if key == nil { key = new(int) } if _, ok := r.listeners[key]; ok { panic("duplicate listener key") } r.listeners[key] = listener }
[ "func", "(", "r", "*", "ListenerRegistry", ")", "Add", "(", "key", "interface", "{", "}", ",", "listener", "func", "(", ")", ")", "{", "if", "key", "==", "nil", "{", "key", "=", "new", "(", "int", ")", "\n", "}", "\n", "if", "_", ",", "ok", "...
// Add adds listener with key to the registry. // key may be nil, then an arbitrary unused key is assigned. // It panics if a listener with same key is already present.
[ "Add", "adds", "listener", "with", "key", "to", "the", "registry", ".", "key", "may", "be", "nil", "then", "an", "arbitrary", "unused", "key", "is", "assigned", ".", "It", "panics", "if", "a", "listener", "with", "same", "key", "is", "already", "present"...
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/example/todomvc/store/storeutil/storeutil.go#L20-L28
27,738
gopherjs/vecty
dom.go
Node
func (h *HTML) Node() *js.Object { if h.node == nil { panic("vecty: cannot call (*HTML).Node() before DOM node creation / component mount") } return h.node.(wrappedObject).j }
go
func (h *HTML) Node() *js.Object { if h.node == nil { panic("vecty: cannot call (*HTML).Node() before DOM node creation / component mount") } return h.node.(wrappedObject).j }
[ "func", "(", "h", "*", "HTML", ")", "Node", "(", ")", "*", "js", ".", "Object", "{", "if", "h", ".", "node", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "h", ".", "node", ".", "(", "wrappedObject", ")", ".", ...
// Node returns the underlying JavaScript Element or TextNode. // // It panics if it is called before the DOM node has been attached, i.e. before // the associated component's Mounter interface would be invoked.
[ "Node", "returns", "the", "underlying", "JavaScript", "Element", "or", "TextNode", ".", "It", "panics", "if", "it", "is", "called", "before", "the", "DOM", "node", "has", "been", "attached", "i", ".", "e", ".", "before", "the", "associated", "component", "...
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L156-L161
27,739
gopherjs/vecty
dom.go
createNode
func (h *HTML) createNode() { switch { case h.tag != "" && h.text != "": panic("vecty: internal error (only one of HTML.tag or HTML.text may be set)") case h.tag == "" && h.innerHTML != "": panic("vecty: only HTML may have UnsafeHTML attribute") case h.tag != "" && h.namespace == "": h.node = global.Get("docu...
go
func (h *HTML) createNode() { switch { case h.tag != "" && h.text != "": panic("vecty: internal error (only one of HTML.tag or HTML.text may be set)") case h.tag == "" && h.innerHTML != "": panic("vecty: only HTML may have UnsafeHTML attribute") case h.tag != "" && h.namespace == "": h.node = global.Get("docu...
[ "func", "(", "h", "*", "HTML", ")", "createNode", "(", ")", "{", "switch", "{", "case", "h", ".", "tag", "!=", "\"", "\"", "&&", "h", ".", "text", "!=", "\"", "\"", ":", "panic", "(", "\"", "\"", ")", "\n", "case", "h", ".", "tag", "==", "\...
// createNode creates a HTML node of the appropriate type and namespace.
[ "createNode", "creates", "a", "HTML", "node", "of", "the", "appropriate", "type", "and", "namespace", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L175-L188
27,740
gopherjs/vecty
dom.go
reconcileText
func (h *HTML) reconcileText(prev *HTML) { h.node = prev.node // Text modifications. if h.text != prev.text { h.node.Set("nodeValue", h.text) } }
go
func (h *HTML) reconcileText(prev *HTML) { h.node = prev.node // Text modifications. if h.text != prev.text { h.node.Set("nodeValue", h.text) } }
[ "func", "(", "h", "*", "HTML", ")", "reconcileText", "(", "prev", "*", "HTML", ")", "{", "h", ".", "node", "=", "prev", ".", "node", "\n\n", "// Text modifications.", "if", "h", ".", "text", "!=", "prev", ".", "text", "{", "h", ".", "node", ".", ...
// reconcileText replaces the content of a text node.
[ "reconcileText", "replaces", "the", "content", "of", "a", "text", "node", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L191-L198
27,741
gopherjs/vecty
dom.go
removeChildren
func (h *HTML) removeChildren(prevChildren []ComponentOrHTML) { for _, prevChild := range prevChildren { if prevChildList, ok := prevChild.(KeyedList); ok { // Previous child was a list, so remove all DOM nodes in it. prevChildList.remove(h) continue } prevChildRender := extractHTML(prevChild) if prev...
go
func (h *HTML) removeChildren(prevChildren []ComponentOrHTML) { for _, prevChild := range prevChildren { if prevChildList, ok := prevChild.(KeyedList); ok { // Previous child was a list, so remove all DOM nodes in it. prevChildList.remove(h) continue } prevChildRender := extractHTML(prevChild) if prev...
[ "func", "(", "h", "*", "HTML", ")", "removeChildren", "(", "prevChildren", "[", "]", "ComponentOrHTML", ")", "{", "for", "_", ",", "prevChild", ":=", "range", "prevChildren", "{", "if", "prevChildList", ",", "ok", ":=", "prevChild", ".", "(", "KeyedList", ...
// removeChildren removes child elements from the previous render pass that no // longer exist on the current HTML children.
[ "removeChildren", "removes", "child", "elements", "from", "the", "previous", "render", "pass", "that", "no", "longer", "exist", "on", "the", "current", "HTML", "children", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L605-L618
27,742
gopherjs/vecty
dom.go
firstChild
func (h *HTML) firstChild() jsObject { if h == nil || h.node == nil { return nil } return h.node.Get("firstChild") }
go
func (h *HTML) firstChild() jsObject { if h == nil || h.node == nil { return nil } return h.node.Get("firstChild") }
[ "func", "(", "h", "*", "HTML", ")", "firstChild", "(", ")", "jsObject", "{", "if", "h", "==", "nil", "||", "h", ".", "node", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "h", ".", "node", ".", "Get", "(", "\"", "\"", ")", "\n...
// firstChild returns the first child DOM node of this element.
[ "firstChild", "returns", "the", "first", "child", "DOM", "node", "of", "this", "element", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L621-L626
27,743
gopherjs/vecty
dom.go
nextSibling
func (h *HTML) nextSibling() jsObject { if h == nil || h.node == nil { return nil } return h.node.Get("nextSibling") }
go
func (h *HTML) nextSibling() jsObject { if h == nil || h.node == nil { return nil } return h.node.Get("nextSibling") }
[ "func", "(", "h", "*", "HTML", ")", "nextSibling", "(", ")", "jsObject", "{", "if", "h", "==", "nil", "||", "h", ".", "node", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "h", ".", "node", ".", "Get", "(", "\"", "\"", ")", "\...
// nextSibling returns the next sibling DOM node for this element.
[ "nextSibling", "returns", "the", "next", "sibling", "DOM", "node", "for", "this", "element", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L629-L634
27,744
gopherjs/vecty
dom.go
removeChild
func (h *HTML) removeChild(child *HTML) { // If we're removing the current insert target, use the next // sibling, if any. if h.insertBeforeNode != nil && h.insertBeforeNode == child.node { h.insertBeforeNode = h.insertBeforeNode.Get("nextSibling") } unmount(child) if child.node == nil { return } // Use the...
go
func (h *HTML) removeChild(child *HTML) { // If we're removing the current insert target, use the next // sibling, if any. if h.insertBeforeNode != nil && h.insertBeforeNode == child.node { h.insertBeforeNode = h.insertBeforeNode.Get("nextSibling") } unmount(child) if child.node == nil { return } // Use the...
[ "func", "(", "h", "*", "HTML", ")", "removeChild", "(", "child", "*", "HTML", ")", "{", "// If we're removing the current insert target, use the next", "// sibling, if any.", "if", "h", ".", "insertBeforeNode", "!=", "nil", "&&", "h", ".", "insertBeforeNode", "==", ...
// removeChild removes the provided child element from this element, and // triggers unmount handlers.
[ "removeChild", "removes", "the", "provided", "child", "element", "from", "this", "element", "and", "triggers", "unmount", "handlers", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L638-L651
27,745
gopherjs/vecty
dom.go
appendChild
func (h *HTML) appendChild(child *HTML) { h.node.Call("appendChild", child.node) }
go
func (h *HTML) appendChild(child *HTML) { h.node.Call("appendChild", child.node) }
[ "func", "(", "h", "*", "HTML", ")", "appendChild", "(", "child", "*", "HTML", ")", "{", "h", ".", "node", ".", "Call", "(", "\"", "\"", ",", "child", ".", "node", ")", "\n", "}" ]
// appendChild appends a new child to this element.
[ "appendChild", "appends", "a", "new", "child", "to", "this", "element", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L654-L656
27,746
gopherjs/vecty
dom.go
insertBefore
func (h *HTML) insertBefore(node jsObject, child *HTML) { if node == nil { h.appendChild(child) return } h.node.Call("insertBefore", child.node, node) }
go
func (h *HTML) insertBefore(node jsObject, child *HTML) { if node == nil { h.appendChild(child) return } h.node.Call("insertBefore", child.node, node) }
[ "func", "(", "h", "*", "HTML", ")", "insertBefore", "(", "node", "jsObject", ",", "child", "*", "HTML", ")", "{", "if", "node", "==", "nil", "{", "h", ".", "appendChild", "(", "child", ")", "\n", "return", "\n", "}", "\n", "h", ".", "node", ".", ...
// insertBefore inserts the provided child before the provided DOM node. If the // DOM node is nil, the child will be appended instead.
[ "insertBefore", "inserts", "the", "provided", "child", "before", "the", "provided", "DOM", "node", ".", "If", "the", "DOM", "node", "is", "nil", "the", "child", "will", "be", "appended", "instead", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L660-L666
27,747
gopherjs/vecty
dom.go
WithKey
func (l List) WithKey(key interface{}) KeyedList { return KeyedList{key: key, html: &HTML{children: l}} }
go
func (l List) WithKey(key interface{}) KeyedList { return KeyedList{key: key, html: &HTML{children: l}} }
[ "func", "(", "l", "List", ")", "WithKey", "(", "key", "interface", "{", "}", ")", "KeyedList", "{", "return", "KeyedList", "{", "key", ":", "key", ",", "html", ":", "&", "HTML", "{", "children", ":", "l", "}", "}", "\n", "}" ]
// WithKey wraps the List in a Keyer using the given key. List members are // inaccessible within the returned value.
[ "WithKey", "wraps", "the", "List", "in", "a", "Keyer", "using", "the", "given", "key", ".", "List", "members", "are", "inaccessible", "within", "the", "returned", "value", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L679-L681
27,748
gopherjs/vecty
dom.go
reconcile
func (l KeyedList) reconcile(parent *HTML, prevChild ComponentOrHTML) (pendingMounts []Mounter) { // Effectively become the parent (copy its scope) so that we can reconcile // our children against the prev child. l.html.node = parent.node l.html.insertBeforeNode = parent.insertBeforeNode l.html.lastRenderedChild =...
go
func (l KeyedList) reconcile(parent *HTML, prevChild ComponentOrHTML) (pendingMounts []Mounter) { // Effectively become the parent (copy its scope) so that we can reconcile // our children against the prev child. l.html.node = parent.node l.html.insertBeforeNode = parent.insertBeforeNode l.html.lastRenderedChild =...
[ "func", "(", "l", "KeyedList", ")", "reconcile", "(", "parent", "*", "HTML", ",", "prevChild", "ComponentOrHTML", ")", "(", "pendingMounts", "[", "]", "Mounter", ")", "{", "// Effectively become the parent (copy its scope) so that we can reconcile", "// our children again...
// reconcile reconciles the keyedList against the DOM node in a separate // context, unless keyed. Uses the currently known insertion point from the // parent to insert children at the correct position.
[ "reconcile", "reconciles", "the", "keyedList", "against", "the", "DOM", "node", "in", "a", "separate", "context", "unless", "keyed", ".", "Uses", "the", "currently", "known", "insertion", "point", "from", "the", "parent", "to", "insert", "children", "at", "the...
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L708-L746
27,749
gopherjs/vecty
dom.go
remove
func (l KeyedList) remove(parent *HTML) { // Become the parent so that we can remove all of our children and get an // updated insertBeforeNode value. l.html.node = parent.node l.html.insertBeforeNode = parent.insertBeforeNode l.html.removeChildren(l.html.children) // Now that the children are removed, and our i...
go
func (l KeyedList) remove(parent *HTML) { // Become the parent so that we can remove all of our children and get an // updated insertBeforeNode value. l.html.node = parent.node l.html.insertBeforeNode = parent.insertBeforeNode l.html.removeChildren(l.html.children) // Now that the children are removed, and our i...
[ "func", "(", "l", "KeyedList", ")", "remove", "(", "parent", "*", "HTML", ")", "{", "// Become the parent so that we can remove all of our children and get an", "// updated insertBeforeNode value.", "l", ".", "html", ".", "node", "=", "parent", ".", "node", "\n", "l",...
// remove keyedList elements from the parent.
[ "remove", "keyedList", "elements", "from", "the", "parent", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L749-L762
27,750
gopherjs/vecty
dom.go
add
func (b *batchRenderer) add(c Component) { if i, ok := b.idx[c]; ok { // Shift idx for delete. for j, c := range b.batch[i+1:] { b.idx[c] = i + j } // Delete previously queued render. copy(b.batch[i:], b.batch[i+1:]) b.batch[len(b.batch)-1] = nil b.batch = b.batch[:len(b.batch)-1] } // Append and in...
go
func (b *batchRenderer) add(c Component) { if i, ok := b.idx[c]; ok { // Shift idx for delete. for j, c := range b.batch[i+1:] { b.idx[c] = i + j } // Delete previously queued render. copy(b.batch[i:], b.batch[i+1:]) b.batch[len(b.batch)-1] = nil b.batch = b.batch[:len(b.batch)-1] } // Append and in...
[ "func", "(", "b", "*", "batchRenderer", ")", "add", "(", "c", "Component", ")", "{", "if", "i", ",", "ok", ":=", "b", ".", "idx", "[", "c", "]", ";", "ok", "{", "// Shift idx for delete.", "for", "j", ",", "c", ":=", "range", "b", ".", "batch", ...
// add a Component to the pending batch.
[ "add", "a", "Component", "to", "the", "pending", "batch", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L825-L845
27,751
gopherjs/vecty
dom.go
sameType
func sameType(first, second ComponentOrHTML) bool { return reflect.TypeOf(first) == reflect.TypeOf(second) }
go
func sameType(first, second ComponentOrHTML) bool { return reflect.TypeOf(first) == reflect.TypeOf(second) }
[ "func", "sameType", "(", "first", ",", "second", "ComponentOrHTML", ")", "bool", "{", "return", "reflect", ".", "TypeOf", "(", "first", ")", "==", "reflect", ".", "TypeOf", "(", "second", ")", "\n", "}" ]
// sameType returns whether first and second ComponentOrHTML are of the same // underlying type.
[ "sameType", "returns", "whether", "first", "and", "second", "ComponentOrHTML", "are", "of", "the", "same", "underlying", "type", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L915-L917
27,752
gopherjs/vecty
dom.go
copyComponent
func copyComponent(c Component) Component { if c == nil { panic("vecty: internal error (cannot copy nil Component)") } // If the Component implements the Copier interface, then use that to // perform the copy. if copier, ok := c.(Copier); ok { cpy := copier.Copy() if cpy == c { panic("vecty: Component.Co...
go
func copyComponent(c Component) Component { if c == nil { panic("vecty: internal error (cannot copy nil Component)") } // If the Component implements the Copier interface, then use that to // perform the copy. if copier, ok := c.(Copier); ok { cpy := copier.Copy() if cpy == c { panic("vecty: Component.Co...
[ "func", "copyComponent", "(", "c", "Component", ")", "Component", "{", "if", "c", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// If the Component implements the Copier interface, then use that to", "// perform the copy.", "if", "copier", ","...
// copyComponent makes a copy of the given component.
[ "copyComponent", "makes", "a", "copy", "of", "the", "given", "component", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L920-L944
27,753
gopherjs/vecty
dom.go
mountUnmount
func mountUnmount(next, prev ComponentOrHTML) Mounter { if next == prev { return nil } if !sameType(next, prev) { if prev != nil { unmount(prev) } if m, ok := next.(Mounter); ok { return m } return nil } if prevHTML := extractHTML(prev); prevHTML != nil { if nextHTML := extractHTML(next); nextH...
go
func mountUnmount(next, prev ComponentOrHTML) Mounter { if next == prev { return nil } if !sameType(next, prev) { if prev != nil { unmount(prev) } if m, ok := next.(Mounter); ok { return m } return nil } if prevHTML := extractHTML(prev); prevHTML != nil { if nextHTML := extractHTML(next); nextH...
[ "func", "mountUnmount", "(", "next", ",", "prev", "ComponentOrHTML", ")", "Mounter", "{", "if", "next", "==", "prev", "{", "return", "nil", "\n", "}", "\n", "if", "!", "sameType", "(", "next", ",", "prev", ")", "{", "if", "prev", "!=", "nil", "{", ...
// mountUnmount determines whether a mount or unmount event should occur, // actions unmounts recursively if appropriate, and returns either a Mounter, // or nil.
[ "mountUnmount", "determines", "whether", "a", "mount", "or", "unmount", "event", "should", "occur", "actions", "unmounts", "recursively", "if", "appropriate", "and", "returns", "either", "a", "Mounter", "or", "nil", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L1076-L1103
27,754
gopherjs/vecty
dom.go
mount
func mount(pendingMounts ...Mounter) { for _, mounter := range pendingMounts { if mounter == nil { continue } if c, ok := mounter.(Component); ok { if c.Context().mounted { continue } c.Context().mounted = true c.Context().unmounted = false } mounter.Mount() } }
go
func mount(pendingMounts ...Mounter) { for _, mounter := range pendingMounts { if mounter == nil { continue } if c, ok := mounter.(Component); ok { if c.Context().mounted { continue } c.Context().mounted = true c.Context().unmounted = false } mounter.Mount() } }
[ "func", "mount", "(", "pendingMounts", "...", "Mounter", ")", "{", "for", "_", ",", "mounter", ":=", "range", "pendingMounts", "{", "if", "mounter", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "c", ",", "ok", ":=", "mounter", ".", "(", "Comp...
// mount all pending Mounters
[ "mount", "all", "pending", "Mounters" ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L1106-L1120
27,755
gopherjs/vecty
dom.go
unmount
func unmount(e ComponentOrHTML) { if c, ok := e.(Component); ok { if c.Context().unmounted { return } c.Context().unmounted = true c.Context().mounted = false if prevRenderComponent, ok := c.Context().prevRender.(Component); ok { unmount(prevRenderComponent) } } if l, ok := e.(KeyedList); ok { f...
go
func unmount(e ComponentOrHTML) { if c, ok := e.(Component); ok { if c.Context().unmounted { return } c.Context().unmounted = true c.Context().mounted = false if prevRenderComponent, ok := c.Context().prevRender.(Component); ok { unmount(prevRenderComponent) } } if l, ok := e.(KeyedList); ok { f...
[ "func", "unmount", "(", "e", "ComponentOrHTML", ")", "{", "if", "c", ",", "ok", ":=", "e", ".", "(", "Component", ")", ";", "ok", "{", "if", "c", ".", "Context", "(", ")", ".", "unmounted", "{", "return", "\n", "}", "\n", "c", ".", "Context", "...
// unmount recursively unmounts the provided ComponentOrHTML, and any children // that satisfy the Unmounter interface.
[ "unmount", "recursively", "unmounts", "the", "provided", "ComponentOrHTML", "and", "any", "children", "that", "satisfy", "the", "Unmounter", "interface", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L1124-L1152
27,756
gopherjs/vecty
dom.go
RenderBody
func RenderBody(body Component) { // block batch until we're done batch.scheduled = true defer func() { requestAnimationFrame(batch.render) }() nextRender, skip, pendingMounts := renderComponent(body, nil) if skip { panic("vecty: RenderBody Component.SkipRender illegally returned true") } if nextRender.tag ...
go
func RenderBody(body Component) { // block batch until we're done batch.scheduled = true defer func() { requestAnimationFrame(batch.render) }() nextRender, skip, pendingMounts := renderComponent(body, nil) if skip { panic("vecty: RenderBody Component.SkipRender illegally returned true") } if nextRender.tag ...
[ "func", "RenderBody", "(", "body", "Component", ")", "{", "// block batch until we're done", "batch", ".", "scheduled", "=", "true", "\n", "defer", "func", "(", ")", "{", "requestAnimationFrame", "(", "batch", ".", "render", ")", "\n", "}", "(", ")", "\n", ...
// RenderBody renders the given component as the document body. The given // Component's Render method must return a "body" element.
[ "RenderBody", "renders", "the", "given", "component", "as", "the", "document", "body", ".", "The", "given", "Component", "s", "Render", "method", "must", "return", "a", "body", "element", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L1161-L1190
27,757
gopherjs/vecty
dom.go
AddStylesheet
func AddStylesheet(url string) { link := global.Get("document").Call("createElement", "link") link.Set("rel", "stylesheet") link.Set("href", url) global.Get("document").Get("head").Call("appendChild", link) }
go
func AddStylesheet(url string) { link := global.Get("document").Call("createElement", "link") link.Set("rel", "stylesheet") link.Set("href", url) global.Get("document").Get("head").Call("appendChild", link) }
[ "func", "AddStylesheet", "(", "url", "string", ")", "{", "link", ":=", "global", ".", "Get", "(", "\"", "\"", ")", ".", "Call", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "link", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "lin...
// AddStylesheet adds an external stylesheet to the document.
[ "AddStylesheet", "adds", "an", "external", "stylesheet", "to", "the", "document", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/dom.go#L1198-L1203
27,758
gopherjs/vecty
markup.go
Data
func Data(key, value string) Applyer { return markupFunc(func(h *HTML) { if h.dataset == nil { h.dataset = make(map[string]string) } h.dataset[key] = value }) }
go
func Data(key, value string) Applyer { return markupFunc(func(h *HTML) { if h.dataset == nil { h.dataset = make(map[string]string) } h.dataset[key] = value }) }
[ "func", "Data", "(", "key", ",", "value", "string", ")", "Applyer", "{", "return", "markupFunc", "(", "func", "(", "h", "*", "HTML", ")", "{", "if", "h", ".", "dataset", "==", "nil", "{", "h", ".", "dataset", "=", "make", "(", "map", "[", "string...
// Data returns an Applyer which applies the given data attribute.
[ "Data", "returns", "an", "Applyer", "which", "applies", "the", "given", "data", "attribute", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/markup.go#L140-L147
27,759
gopherjs/vecty
markup.go
Class
func Class(class ...string) Applyer { mustValidateClassNames(class) return markupFunc(func(h *HTML) { if h.classes == nil { h.classes = make(map[string]struct{}) } for _, name := range class { h.classes[name] = struct{}{} } }) }
go
func Class(class ...string) Applyer { mustValidateClassNames(class) return markupFunc(func(h *HTML) { if h.classes == nil { h.classes = make(map[string]struct{}) } for _, name := range class { h.classes[name] = struct{}{} } }) }
[ "func", "Class", "(", "class", "...", "string", ")", "Applyer", "{", "mustValidateClassNames", "(", "class", ")", "\n", "return", "markupFunc", "(", "func", "(", "h", "*", "HTML", ")", "{", "if", "h", ".", "classes", "==", "nil", "{", "h", ".", "clas...
// Class returns an Applyer which applies the provided classes. Subsequent // calls to this function will append additional classes. To toggle classes, // use ClassMap instead. Each class name must be passed as a separate argument.
[ "Class", "returns", "an", "Applyer", "which", "applies", "the", "provided", "classes", ".", "Subsequent", "calls", "to", "this", "function", "will", "append", "additional", "classes", ".", "To", "toggle", "classes", "use", "ClassMap", "instead", ".", "Each", "...
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/markup.go#L152-L162
27,760
gopherjs/vecty
markup.go
mustValidateClassNames
func mustValidateClassNames(class []string) { for _, name := range class { if containsSpace(name) { panic(`vecty: invalid argument to vecty.Class "` + name + `" (string may not contain spaces)`) } } }
go
func mustValidateClassNames(class []string) { for _, name := range class { if containsSpace(name) { panic(`vecty: invalid argument to vecty.Class "` + name + `" (string may not contain spaces)`) } } }
[ "func", "mustValidateClassNames", "(", "class", "[", "]", "string", ")", "{", "for", "_", ",", "name", ":=", "range", "class", "{", "if", "containsSpace", "(", "name", ")", "{", "panic", "(", "`vecty: invalid argument to vecty.Class \"`", "+", "name", "+", "...
// mustValidateClassNames ensures no class names have spaces // and panics with clear instructions on how to fix this user error.
[ "mustValidateClassNames", "ensures", "no", "class", "names", "have", "spaces", "and", "panics", "with", "clear", "instructions", "on", "how", "to", "fix", "this", "user", "error", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/markup.go#L166-L172
27,761
gopherjs/vecty
markup.go
containsSpace
func containsSpace(s string) bool { for _, c := range s { if c == ' ' { return true } } return false }
go
func containsSpace(s string) bool { for _, c := range s { if c == ' ' { return true } } return false }
[ "func", "containsSpace", "(", "s", "string", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "s", "{", "if", "c", "==", "' '", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// containsSpace reports whether s contains a space character.
[ "containsSpace", "reports", "whether", "s", "contains", "a", "space", "character", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/markup.go#L175-L182
27,762
gopherjs/vecty
markup.go
If
func If(cond bool, children ...ComponentOrHTML) MarkupOrChild { if cond { return List(children) } return nil }
go
func If(cond bool, children ...ComponentOrHTML) MarkupOrChild { if cond { return List(children) } return nil }
[ "func", "If", "(", "cond", "bool", ",", "children", "...", "ComponentOrHTML", ")", "MarkupOrChild", "{", "if", "cond", "{", "return", "List", "(", "children", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// If returns nil if cond is false, otherwise it returns the given children.
[ "If", "returns", "nil", "if", "cond", "is", "false", "otherwise", "it", "returns", "the", "given", "children", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/markup.go#L234-L239
27,763
gopherjs/vecty
markup.go
MarkupIf
func MarkupIf(cond bool, markup ...Applyer) Applyer { if cond { return Markup(markup...) } return nil }
go
func MarkupIf(cond bool, markup ...Applyer) Applyer { if cond { return Markup(markup...) } return nil }
[ "func", "MarkupIf", "(", "cond", "bool", ",", "markup", "...", "Applyer", ")", "Applyer", "{", "if", "cond", "{", "return", "Markup", "(", "markup", "...", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// MarkupIf returns nil if cond is false, otherwise it returns the given markup.
[ "MarkupIf", "returns", "nil", "if", "cond", "is", "false", "otherwise", "it", "returns", "the", "given", "markup", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/markup.go#L242-L247
27,764
gopherjs/vecty
example/todomvc/dispatcher/dispatcher.go
Register
func Register(callback func(action interface{})) ID { idCounter++ id := idCounter callbacks[id] = callback return id }
go
func Register(callback func(action interface{})) ID { idCounter++ id := idCounter callbacks[id] = callback return id }
[ "func", "Register", "(", "callback", "func", "(", "action", "interface", "{", "}", ")", ")", "ID", "{", "idCounter", "++", "\n", "id", ":=", "idCounter", "\n", "callbacks", "[", "id", "]", "=", "callback", "\n", "return", "id", "\n", "}" ]
// Register registers the callback to handle dispatched actions, the returned // ID may be used to unregister the callback later.
[ "Register", "registers", "the", "callback", "to", "handle", "dispatched", "actions", "the", "returned", "ID", "may", "be", "used", "to", "unregister", "the", "callback", "later", "." ]
d00da0c86b426642cf5acc29133d33491a711209
https://github.com/gopherjs/vecty/blob/d00da0c86b426642cf5acc29133d33491a711209/example/todomvc/dispatcher/dispatcher.go#L18-L23
27,765
dghubble/go-twitter
twitter/twitter.go
Bool
func Bool(v bool) *bool { ptr := new(bool) *ptr = v return ptr }
go
func Bool(v bool) *bool { ptr := new(bool) *ptr = v return ptr }
[ "func", "Bool", "(", "v", "bool", ")", "*", "bool", "{", "ptr", ":=", "new", "(", "bool", ")", "\n", "*", "ptr", "=", "v", "\n", "return", "ptr", "\n", "}" ]
// Bool returns a new pointer to the given bool value.
[ "Bool", "returns", "a", "new", "pointer", "to", "the", "given", "bool", "value", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/twitter.go#L54-L58
27,766
dghubble/go-twitter
twitter/twitter.go
Float
func Float(v float64) *float64 { ptr := new(float64) *ptr = v return ptr }
go
func Float(v float64) *float64 { ptr := new(float64) *ptr = v return ptr }
[ "func", "Float", "(", "v", "float64", ")", "*", "float64", "{", "ptr", ":=", "new", "(", "float64", ")", "\n", "*", "ptr", "=", "v", "\n", "return", "ptr", "\n", "}" ]
// Float returns a new pointer to the given float64 value.
[ "Float", "returns", "a", "new", "pointer", "to", "the", "given", "float64", "value", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/twitter.go#L61-L65
27,767
dghubble/go-twitter
twitter/demux.go
NewSwitchDemux
func NewSwitchDemux() SwitchDemux { return SwitchDemux{ All: func(message interface{}) {}, Tweet: func(tweet *Tweet) {}, DM: func(dm *DirectMessage) {}, StatusDeletion: func(deletion *StatusDeletion) {}, LocationDeletion: func(LocationDeletion *LocationDeletion) {}, ...
go
func NewSwitchDemux() SwitchDemux { return SwitchDemux{ All: func(message interface{}) {}, Tweet: func(tweet *Tweet) {}, DM: func(dm *DirectMessage) {}, StatusDeletion: func(deletion *StatusDeletion) {}, LocationDeletion: func(LocationDeletion *LocationDeletion) {}, ...
[ "func", "NewSwitchDemux", "(", ")", "SwitchDemux", "{", "return", "SwitchDemux", "{", "All", ":", "func", "(", "message", "interface", "{", "}", ")", "{", "}", ",", "Tweet", ":", "func", "(", "tweet", "*", "Tweet", ")", "{", "}", ",", "DM", ":", "f...
// NewSwitchDemux returns a new SwitchMux which has NoOp handler functions.
[ "NewSwitchDemux", "returns", "a", "new", "SwitchMux", "which", "has", "NoOp", "handler", "functions", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/demux.go#L30-L46
27,768
dghubble/go-twitter
twitter/demux.go
Handle
func (d SwitchDemux) Handle(message interface{}) { d.All(message) switch msg := message.(type) { case *Tweet: d.Tweet(msg) case *DirectMessage: d.DM(msg) case *StatusDeletion: d.StatusDeletion(msg) case *LocationDeletion: d.LocationDeletion(msg) case *StreamLimit: d.StreamLimit(msg) case *StatusWithhe...
go
func (d SwitchDemux) Handle(message interface{}) { d.All(message) switch msg := message.(type) { case *Tweet: d.Tweet(msg) case *DirectMessage: d.DM(msg) case *StatusDeletion: d.StatusDeletion(msg) case *LocationDeletion: d.LocationDeletion(msg) case *StreamLimit: d.StreamLimit(msg) case *StatusWithhe...
[ "func", "(", "d", "SwitchDemux", ")", "Handle", "(", "message", "interface", "{", "}", ")", "{", "d", ".", "All", "(", "message", ")", "\n", "switch", "msg", ":=", "message", ".", "(", "type", ")", "{", "case", "*", "Tweet", ":", "d", ".", "Tweet...
// Handle determines the type of a message and calls the corresponding receiver // function with the typed message. All messages are passed to the All func. // Messages with unmatched types are passed to the Other func.
[ "Handle", "determines", "the", "type", "of", "a", "message", "and", "calls", "the", "corresponding", "receiver", "function", "with", "the", "typed", "message", ".", "All", "messages", "are", "passed", "to", "the", "All", "func", ".", "Messages", "with", "unm...
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/demux.go#L51-L79
27,769
dghubble/go-twitter
twitter/streams.go
newStreamService
func newStreamService(client *http.Client, sling *sling.Sling) *StreamService { sling.Set("User-Agent", userAgent) return &StreamService{ client: client, public: sling.New().Base(publicStream).Path("statuses/"), user: sling.New().Base(userStream), site: sling.New().Base(siteStream), } }
go
func newStreamService(client *http.Client, sling *sling.Sling) *StreamService { sling.Set("User-Agent", userAgent) return &StreamService{ client: client, public: sling.New().Base(publicStream).Path("statuses/"), user: sling.New().Base(userStream), site: sling.New().Base(siteStream), } }
[ "func", "newStreamService", "(", "client", "*", "http", ".", "Client", ",", "sling", "*", "sling", ".", "Sling", ")", "*", "StreamService", "{", "sling", ".", "Set", "(", "\"", "\"", ",", "userAgent", ")", "\n", "return", "&", "StreamService", "{", "cl...
// newStreamService returns a new StreamService.
[ "newStreamService", "returns", "a", "new", "StreamService", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/streams.go#L30-L38
27,770
dghubble/go-twitter
twitter/streams.go
Stop
func (s *Stream) Stop() { close(s.done) // Scanner does not have a Stop() or take a done channel, so for low volume // streams Scan() blocks until the next keep-alive. Close the resp.Body to // escape and stop the stream in a timely fashion. if s.body != nil { s.body.Close() } // block until the retry goroutin...
go
func (s *Stream) Stop() { close(s.done) // Scanner does not have a Stop() or take a done channel, so for low volume // streams Scan() blocks until the next keep-alive. Close the resp.Body to // escape and stop the stream in a timely fashion. if s.body != nil { s.body.Close() } // block until the retry goroutin...
[ "func", "(", "s", "*", "Stream", ")", "Stop", "(", ")", "{", "close", "(", "s", ".", "done", ")", "\n", "// Scanner does not have a Stop() or take a done channel, so for low volume", "// streams Scan() blocks until the next keep-alive. Close the resp.Body to", "// escape and st...
// Stop signals retry and receiver to stop, closes the Messages channel, and // blocks until done.
[ "Stop", "signals", "retry", "and", "receiver", "to", "stop", "closes", "the", "Messages", "channel", "and", "blocks", "until", "done", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/streams.go#L169-L179
27,771
dghubble/go-twitter
twitter/streams.go
receive
func (s *Stream) receive(body io.Reader) { reader := newStreamResponseBodyReader(body) for !stopped(s.done) { data, err := reader.readNext() if err != nil { return } if len(data) == 0 { // empty keep-alive continue } select { // send messages, data, or errors case s.Messages <- getMessage(dat...
go
func (s *Stream) receive(body io.Reader) { reader := newStreamResponseBodyReader(body) for !stopped(s.done) { data, err := reader.readNext() if err != nil { return } if len(data) == 0 { // empty keep-alive continue } select { // send messages, data, or errors case s.Messages <- getMessage(dat...
[ "func", "(", "s", "*", "Stream", ")", "receive", "(", "body", "io", ".", "Reader", ")", "{", "reader", ":=", "newStreamResponseBodyReader", "(", "body", ")", "\n", "for", "!", "stopped", "(", "s", ".", "done", ")", "{", "data", ",", "err", ":=", "r...
// receive scans a stream response body, JSON decodes tokens to messages, and // sends messages to the Messages channel. Receiving continues until an EOF, // scan error, or the done channel is closed.
[ "receive", "scans", "a", "stream", "response", "body", "JSON", "decodes", "tokens", "to", "messages", "and", "sends", "messages", "to", "the", "Messages", "channel", ".", "Receiving", "continues", "until", "an", "EOF", "scan", "error", "or", "the", "done", "...
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/streams.go#L230-L250
27,772
dghubble/go-twitter
twitter/streams.go
decodeMessage
func decodeMessage(token []byte, data map[string]interface{}) interface{} { if hasPath(data, "retweet_count") { tweet := new(Tweet) json.Unmarshal(token, tweet) return tweet } else if hasPath(data, "direct_message") { notice := new(directMessageNotice) json.Unmarshal(token, notice) return notice.DirectMes...
go
func decodeMessage(token []byte, data map[string]interface{}) interface{} { if hasPath(data, "retweet_count") { tweet := new(Tweet) json.Unmarshal(token, tweet) return tweet } else if hasPath(data, "direct_message") { notice := new(directMessageNotice) json.Unmarshal(token, notice) return notice.DirectMes...
[ "func", "decodeMessage", "(", "token", "[", "]", "byte", ",", "data", "map", "[", "string", "]", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "hasPath", "(", "data", ",", "\"", "\"", ")", "{", "tweet", ":=", "new", "(", "Tweet", ...
// decodeMessage determines the message type from known data keys, allocates // at most one message struct, and JSON decodes the token into the message. // Returns the message struct or the data map if the message type could not be // determined.
[ "decodeMessage", "determines", "the", "message", "type", "from", "known", "data", "keys", "allocates", "at", "most", "one", "message", "struct", "and", "JSON", "decodes", "the", "token", "into", "the", "message", ".", "Returns", "the", "message", "struct", "or...
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/streams.go#L269-L317
27,773
dghubble/go-twitter
twitter/streams.go
hasPath
func hasPath(data map[string]interface{}, key string) bool { _, ok := data[key] return ok }
go
func hasPath(data map[string]interface{}, key string) bool { _, ok := data[key] return ok }
[ "func", "hasPath", "(", "data", "map", "[", "string", "]", "interface", "{", "}", ",", "key", "string", ")", "bool", "{", "_", ",", "ok", ":=", "data", "[", "key", "]", "\n", "return", "ok", "\n", "}" ]
// hasPath returns true if the map contains the given key, false otherwise.
[ "hasPath", "returns", "true", "if", "the", "map", "contains", "the", "given", "key", "false", "otherwise", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/streams.go#L320-L323
27,774
dghubble/go-twitter
twitter/statuses.go
CreatedAtTime
func (t Tweet) CreatedAtTime() (time.Time, error) { return time.Parse(time.RubyDate, t.CreatedAt) }
go
func (t Tweet) CreatedAtTime() (time.Time, error) { return time.Parse(time.RubyDate, t.CreatedAt) }
[ "func", "(", "t", "Tweet", ")", "CreatedAtTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RubyDate", ",", "t", ".", "CreatedAt", ")", "\n", "}" ]
// CreatedAtTime returns the time a tweet was created.
[ "CreatedAtTime", "returns", "the", "time", "a", "tweet", "was", "created", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/statuses.go#L54-L56
27,775
dghubble/go-twitter
twitter/direct_messages.go
newDirectMessageService
func newDirectMessageService(sling *sling.Sling) *DirectMessageService { return &DirectMessageService{ baseSling: sling.New(), sling: sling.Path("direct_messages/"), } }
go
func newDirectMessageService(sling *sling.Sling) *DirectMessageService { return &DirectMessageService{ baseSling: sling.New(), sling: sling.Path("direct_messages/"), } }
[ "func", "newDirectMessageService", "(", "sling", "*", "sling", ".", "Sling", ")", "*", "DirectMessageService", "{", "return", "&", "DirectMessageService", "{", "baseSling", ":", "sling", ".", "New", "(", ")", ",", "sling", ":", "sling", ".", "Path", "(", "...
// newDirectMessageService returns a new DirectMessageService.
[ "newDirectMessageService", "returns", "a", "new", "DirectMessageService", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/direct_messages.go#L83-L88
27,776
dghubble/go-twitter
twitter/stream_utils.go
newStreamResponseBodyReader
func newStreamResponseBodyReader(body io.Reader) *streamResponseBodyReader { return &streamResponseBodyReader{reader: bufio.NewReader(body)} }
go
func newStreamResponseBodyReader(body io.Reader) *streamResponseBodyReader { return &streamResponseBodyReader{reader: bufio.NewReader(body)} }
[ "func", "newStreamResponseBodyReader", "(", "body", "io", ".", "Reader", ")", "*", "streamResponseBodyReader", "{", "return", "&", "streamResponseBodyReader", "{", "reader", ":", "bufio", ".", "NewReader", "(", "body", ")", "}", "\n", "}" ]
// newStreamResponseBodyReader returns an instance of streamResponseBodyReader // for the given Twitter stream response body.
[ "newStreamResponseBodyReader", "returns", "an", "instance", "of", "streamResponseBodyReader", "for", "the", "given", "Twitter", "stream", "response", "body", "." ]
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/stream_utils.go#L43-L45
27,777
dghubble/go-twitter
twitter/stream_utils.go
readNext
func (r *streamResponseBodyReader) readNext() ([]byte, error) { // Discard all the bytes from buf and continue to use the allocated memory // space for reading the next message. r.buf.Truncate(0) for { // Twitter stream messages are separated with "\r\n", and a valid // message may sometimes contain '\n' in the...
go
func (r *streamResponseBodyReader) readNext() ([]byte, error) { // Discard all the bytes from buf and continue to use the allocated memory // space for reading the next message. r.buf.Truncate(0) for { // Twitter stream messages are separated with "\r\n", and a valid // message may sometimes contain '\n' in the...
[ "func", "(", "r", "*", "streamResponseBodyReader", ")", "readNext", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Discard all the bytes from buf and continue to use the allocated memory", "// space for reading the next message.", "r", ".", "buf", ".", "Tr...
// readNext reads Twitter stream response body and returns the next stream // content if exists. Returns io.EOF error if we reached the end of the stream // and there's no more message to read.
[ "readNext", "reads", "Twitter", "stream", "response", "body", "and", "returns", "the", "next", "stream", "content", "if", "exists", ".", "Returns", "io", ".", "EOF", "error", "if", "we", "reached", "the", "end", "of", "the", "stream", "and", "there", "s", ...
0022a70e9bee80163be82fdd74ac1d92bdebaf57
https://github.com/dghubble/go-twitter/blob/0022a70e9bee80163be82fdd74ac1d92bdebaf57/twitter/stream_utils.go#L50-L95
27,778
logrusorgru/aurora
wrap.go
Reset
func Reset(arg interface{}) Value { if val, ok := arg.(Value); ok { return val.Reset() } return value{value: arg} }
go
func Reset(arg interface{}) Value { if val, ok := arg.(Value); ok { return val.Reset() } return value{value: arg} }
[ "func", "Reset", "(", "arg", "interface", "{", "}", ")", "Value", "{", "if", "val", ",", "ok", ":=", "arg", ".", "(", "Value", ")", ";", "ok", "{", "return", "val", ".", "Reset", "(", ")", "\n", "}", "\n", "return", "value", "{", "value", ":", ...
// Reset wraps given argument returning Value // without formats and colors.
[ "Reset", "wraps", "given", "argument", "returning", "Value", "without", "formats", "and", "colors", "." ]
cea283e61946ad8227cc02a24201407a2c9e5182
https://github.com/logrusorgru/aurora/blob/cea283e61946ad8227cc02a24201407a2c9e5182/wrap.go#L51-L56
27,779
logrusorgru/aurora
color.go
Nos
func (c Color) Nos(zero bool) string { return string(c.appendNos(make([]byte, 0, 59), zero)) }
go
func (c Color) Nos(zero bool) string { return string(c.appendNos(make([]byte, 0, 59), zero)) }
[ "func", "(", "c", "Color", ")", "Nos", "(", "zero", "bool", ")", "string", "{", "return", "string", "(", "c", ".", "appendNos", "(", "make", "(", "[", "]", "byte", ",", "0", ",", "59", ")", ",", "zero", ")", ")", "\n", "}" ]
// Nos returns string like 1;7;31;45. It // may be an empty string for empty color. // If the zero is true, then the string // is prepended with 0;
[ "Nos", "returns", "string", "like", "1", ";", "7", ";", "31", ";", "45", ".", "It", "may", "be", "an", "empty", "string", "for", "empty", "color", ".", "If", "the", "zero", "is", "true", "then", "the", "string", "is", "prepended", "with", "0", ";" ...
cea283e61946ad8227cc02a24201407a2c9e5182
https://github.com/logrusorgru/aurora/blob/cea283e61946ad8227cc02a24201407a2c9e5182/color.go#L186-L188
27,780
logrusorgru/aurora
color.go
appendSemi
func appendSemi(bs []byte, semi bool, vals ...byte) []byte { if semi { bs = append(bs, ';') } return append(bs, vals...) }
go
func appendSemi(bs []byte, semi bool, vals ...byte) []byte { if semi { bs = append(bs, ';') } return append(bs, vals...) }
[ "func", "appendSemi", "(", "bs", "[", "]", "byte", ",", "semi", "bool", ",", "vals", "...", "byte", ")", "[", "]", "byte", "{", "if", "semi", "{", "bs", "=", "append", "(", "bs", ",", "';'", ")", "\n", "}", "\n", "return", "append", "(", "bs", ...
// if the semi is true, then prepend with semicolon
[ "if", "the", "semi", "is", "true", "then", "prepend", "with", "semicolon" ]
cea283e61946ad8227cc02a24201407a2c9e5182
https://github.com/logrusorgru/aurora/blob/cea283e61946ad8227cc02a24201407a2c9e5182/color.go#L198-L203
27,781
logrusorgru/aurora
color.go
appendNos
func (c Color) appendNos(bs []byte, zero bool) []byte { if zero { bs = append(bs, '0') // reset previous } // formats // if c&maskFm != 0 { // 1-2 // don't combine bold and faint using only on of them, preferring bold if c&BoldFm != 0 { bs = appendSemi(bs, zero, '1') } else if c&FaintFm != 0 { ...
go
func (c Color) appendNos(bs []byte, zero bool) []byte { if zero { bs = append(bs, '0') // reset previous } // formats // if c&maskFm != 0 { // 1-2 // don't combine bold and faint using only on of them, preferring bold if c&BoldFm != 0 { bs = appendSemi(bs, zero, '1') } else if c&FaintFm != 0 { ...
[ "func", "(", "c", "Color", ")", "appendNos", "(", "bs", "[", "]", "byte", ",", "zero", "bool", ")", "[", "]", "byte", "{", "if", "zero", "{", "bs", "=", "append", "(", "bs", ",", "'0'", ")", "// reset previous", "\n", "}", "\n\n", "// formats", "...
// append 1;3;38;5;216 like string that represents ANSI // color of the Color; the zero argument requires // appending of '0' before to reset previous format // and colors
[ "append", "1", ";", "3", ";", "38", ";", "5", ";", "216", "like", "string", "that", "represents", "ANSI", "color", "of", "the", "Color", ";", "the", "zero", "argument", "requires", "appending", "of", "0", "before", "to", "reset", "previous", "format", ...
cea283e61946ad8227cc02a24201407a2c9e5182
https://github.com/logrusorgru/aurora/blob/cea283e61946ad8227cc02a24201407a2c9e5182/color.go#L309-L388
27,782
gosuri/uilive
writer.go
New
func New() *Writer { termWidth, _ = getTermSize() if termWidth != 0 { overFlowHandled = true } return &Writer{ Out: Out, RefreshInterval: RefreshInterval, mtx: &sync.Mutex{}, } }
go
func New() *Writer { termWidth, _ = getTermSize() if termWidth != 0 { overFlowHandled = true } return &Writer{ Out: Out, RefreshInterval: RefreshInterval, mtx: &sync.Mutex{}, } }
[ "func", "New", "(", ")", "*", "Writer", "{", "termWidth", ",", "_", "=", "getTermSize", "(", ")", "\n", "if", "termWidth", "!=", "0", "{", "overFlowHandled", "=", "true", "\n", "}", "\n\n", "return", "&", "Writer", "{", "Out", ":", "Out", ",", "Ref...
// New returns a new Writer with defaults
[ "New", "returns", "a", "new", "Writer", "with", "defaults" ]
810653011da975cf3ac54bf7aea22d5c9e49e317
https://github.com/gosuri/uilive/blob/810653011da975cf3ac54bf7aea22d5c9e49e317/writer.go#L59-L71
27,783
gosuri/uilive
writer.go
Flush
func (w *Writer) Flush() error { w.mtx.Lock() defer w.mtx.Unlock() // do nothing if buffer is empty if len(w.buf.Bytes()) == 0 { return nil } w.clearLines() lines := 0 var currentLine bytes.Buffer for _, b := range w.buf.Bytes() { if b == '\n' { lines++ currentLine.Reset() } else { currentLine...
go
func (w *Writer) Flush() error { w.mtx.Lock() defer w.mtx.Unlock() // do nothing if buffer is empty if len(w.buf.Bytes()) == 0 { return nil } w.clearLines() lines := 0 var currentLine bytes.Buffer for _, b := range w.buf.Bytes() { if b == '\n' { lines++ currentLine.Reset() } else { currentLine...
[ "func", "(", "w", "*", "Writer", ")", "Flush", "(", ")", "error", "{", "w", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "// do nothing if buffer is empty", "if", "len", "(", "w", ".", "buf", ...
// Flush writes to the out and resets the buffer. It should be called after the last call to Write to ensure that any data buffered in the Writer is written to output. // Any incomplete escape sequence at the end is considered complete for formatting purposes. // An error is returned if the contents of the buffer canno...
[ "Flush", "writes", "to", "the", "out", "and", "resets", "the", "buffer", ".", "It", "should", "be", "called", "after", "the", "last", "call", "to", "Write", "to", "ensure", "that", "any", "data", "buffered", "in", "the", "Writer", "is", "written", "to", ...
810653011da975cf3ac54bf7aea22d5c9e49e317
https://github.com/gosuri/uilive/blob/810653011da975cf3ac54bf7aea22d5c9e49e317/writer.go#L76-L104
27,784
gosuri/uilive
writer.go
Start
func (w *Writer) Start() { if w.ticker == nil { w.ticker = time.NewTicker(w.RefreshInterval) w.tdone = make(chan bool, 1) } go w.Listen() }
go
func (w *Writer) Start() { if w.ticker == nil { w.ticker = time.NewTicker(w.RefreshInterval) w.tdone = make(chan bool, 1) } go w.Listen() }
[ "func", "(", "w", "*", "Writer", ")", "Start", "(", ")", "{", "if", "w", ".", "ticker", "==", "nil", "{", "w", ".", "ticker", "=", "time", ".", "NewTicker", "(", "w", ".", "RefreshInterval", ")", "\n", "w", ".", "tdone", "=", "make", "(", "chan...
// Start starts the listener in a non-blocking manner
[ "Start", "starts", "the", "listener", "in", "a", "non", "-", "blocking", "manner" ]
810653011da975cf3ac54bf7aea22d5c9e49e317
https://github.com/gosuri/uilive/blob/810653011da975cf3ac54bf7aea22d5c9e49e317/writer.go#L107-L114
27,785
gosuri/uilive
writer.go
Listen
func (w *Writer) Listen() { for { select { case <-w.ticker.C: if w.ticker != nil { w.Flush() } case <-w.tdone: w.mtx.Lock() w.ticker.Stop() w.ticker = nil w.mtx.Unlock() return } } }
go
func (w *Writer) Listen() { for { select { case <-w.ticker.C: if w.ticker != nil { w.Flush() } case <-w.tdone: w.mtx.Lock() w.ticker.Stop() w.ticker = nil w.mtx.Unlock() return } } }
[ "func", "(", "w", "*", "Writer", ")", "Listen", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "w", ".", "ticker", ".", "C", ":", "if", "w", ".", "ticker", "!=", "nil", "{", "w", ".", "Flush", "(", ")", "\n", "}", "\n", "case", "<-...
// Listen listens for updates to the writer's buffer and flushes to the out provided. It blocks the runtime.
[ "Listen", "listens", "for", "updates", "to", "the", "writer", "s", "buffer", "and", "flushes", "to", "the", "out", "provided", ".", "It", "blocks", "the", "runtime", "." ]
810653011da975cf3ac54bf7aea22d5c9e49e317
https://github.com/gosuri/uilive/blob/810653011da975cf3ac54bf7aea22d5c9e49e317/writer.go#L123-L138
27,786
gosuri/uilive
writer.go
Write
func (w *Writer) Write(buf []byte) (n int, err error) { w.mtx.Lock() defer w.mtx.Unlock() return w.buf.Write(buf) }
go
func (w *Writer) Write(buf []byte) (n int, err error) { w.mtx.Lock() defer w.mtx.Unlock() return w.buf.Write(buf) }
[ "func", "(", "w", "*", "Writer", ")", "Write", "(", "buf", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "w", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return...
// Write save the contents of buf to the writer b. The only errors returned are ones encountered while writing to the underlying buffer.
[ "Write", "save", "the", "contents", "of", "buf", "to", "the", "writer", "b", ".", "The", "only", "errors", "returned", "are", "ones", "encountered", "while", "writing", "to", "the", "underlying", "buffer", "." ]
810653011da975cf3ac54bf7aea22d5c9e49e317
https://github.com/gosuri/uilive/blob/810653011da975cf3ac54bf7aea22d5c9e49e317/writer.go#L141-L145
27,787
ory/dockertest
docker/pkg/jsonmessage/jsonmessage.go
Display
func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error { if jm.Error != nil { if jm.Error.Code == 401 { return fmt.Errorf("authentication is required") } return jm.Error } var endl string if termInfo != nil && jm.Stream == "" && jm.Progress != nil { clearLine(out, termInfo) endl = "\r" ...
go
func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error { if jm.Error != nil { if jm.Error.Code == 401 { return fmt.Errorf("authentication is required") } return jm.Error } var endl string if termInfo != nil && jm.Stream == "" && jm.Progress != nil { clearLine(out, termInfo) endl = "\r" ...
[ "func", "(", "jm", "*", "JSONMessage", ")", "Display", "(", "out", "io", ".", "Writer", ",", "termInfo", "termInfo", ")", "error", "{", "if", "jm", ".", "Error", "!=", "nil", "{", "if", "jm", ".", "Error", ".", "Code", "==", "401", "{", "return", ...
// Display displays the JSONMessage to `out`. `termInfo` is non-nil if `out` // is a terminal. If this is the case, it will erase the entire current line // when displaying the progressbar.
[ "Display", "displays", "the", "JSONMessage", "to", "out", ".", "termInfo", "is", "non", "-", "nil", "if", "out", "is", "a", "terminal", ".", "If", "this", "is", "the", "case", "it", "will", "erase", "the", "entire", "current", "line", "when", "displaying...
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/pkg/jsonmessage/jsonmessage.go#L207-L243
27,788
ory/dockertest
docker/client_unix.go
initializeNativeClient
func (c *Client) initializeNativeClient(trFunc func() *http.Transport) { if c.endpointURL.Scheme != unixProtocol { return } sockPath := c.endpointURL.Path tr := trFunc() tr.Dial = func(network, addr string) (net.Conn, error) { return c.Dialer.Dial(unixProtocol, sockPath) } tr.DialContext = func(ctx context...
go
func (c *Client) initializeNativeClient(trFunc func() *http.Transport) { if c.endpointURL.Scheme != unixProtocol { return } sockPath := c.endpointURL.Path tr := trFunc() tr.Dial = func(network, addr string) (net.Conn, error) { return c.Dialer.Dial(unixProtocol, sockPath) } tr.DialContext = func(ctx context...
[ "func", "(", "c", "*", "Client", ")", "initializeNativeClient", "(", "trFunc", "func", "(", ")", "*", "http", ".", "Transport", ")", "{", "if", "c", ".", "endpointURL", ".", "Scheme", "!=", "unixProtocol", "{", "return", "\n", "}", "\n", "sockPath", ":...
// initializeNativeClient initializes the native Unix domain socket client on // Unix-style operating systems
[ "initializeNativeClient", "initializes", "the", "native", "Unix", "domain", "socket", "client", "on", "Unix", "-", "style", "operating", "systems" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/client_unix.go#L17-L32
27,789
ory/dockertest
docker/distribution.go
InspectDistribution
func (c *Client) InspectDistribution(name string) (*registry.DistributionInspect, error) { path := "/distribution/" + name + "/json" resp, err := c.do("GET", path, doOptions{}) if err != nil { return nil, err } defer resp.Body.Close() var distributionInspect registry.DistributionInspect if err := json.NewDecod...
go
func (c *Client) InspectDistribution(name string) (*registry.DistributionInspect, error) { path := "/distribution/" + name + "/json" resp, err := c.do("GET", path, doOptions{}) if err != nil { return nil, err } defer resp.Body.Close() var distributionInspect registry.DistributionInspect if err := json.NewDecod...
[ "func", "(", "c", "*", "Client", ")", "InspectDistribution", "(", "name", "string", ")", "(", "*", "registry", ".", "DistributionInspect", ",", "error", ")", "{", "path", ":=", "\"", "\"", "+", "name", "+", "\"", "\"", "\n", "resp", ",", "err", ":=",...
// InspectDistribution returns image digest and platform information by contacting the registry
[ "InspectDistribution", "returns", "image", "digest", "and", "platform", "information", "by", "contacting", "the", "registry" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/distribution.go#L14-L26
27,790
ory/dockertest
docker/pkg/system/lcow.go
IsOSSupported
func IsOSSupported(os string) bool { if runtime.GOOS == os { return true } if LCOWSupported() && os == "linux" { return true } return false }
go
func IsOSSupported(os string) bool { if runtime.GOOS == os { return true } if LCOWSupported() && os == "linux" { return true } return false }
[ "func", "IsOSSupported", "(", "os", "string", ")", "bool", "{", "if", "runtime", ".", "GOOS", "==", "os", "{", "return", "true", "\n", "}", "\n", "if", "LCOWSupported", "(", ")", "&&", "os", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n",...
// IsOSSupported determines if an operating system is supported by the host
[ "IsOSSupported", "determines", "if", "an", "operating", "system", "is", "supported", "by", "the", "host" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/pkg/system/lcow.go#L61-L69
27,791
ory/dockertest
docker/event.go
AddEventListener
func (c *Client) AddEventListener(listener chan<- *APIEvents) error { var err error if !c.eventMonitor.isEnabled() { err = c.eventMonitor.enableEventMonitoring(c) if err != nil { return err } } return c.eventMonitor.addListener(listener) }
go
func (c *Client) AddEventListener(listener chan<- *APIEvents) error { var err error if !c.eventMonitor.isEnabled() { err = c.eventMonitor.enableEventMonitoring(c) if err != nil { return err } } return c.eventMonitor.addListener(listener) }
[ "func", "(", "c", "*", "Client", ")", "AddEventListener", "(", "listener", "chan", "<-", "*", "APIEvents", ")", "error", "{", "var", "err", "error", "\n", "if", "!", "c", ".", "eventMonitor", ".", "isEnabled", "(", ")", "{", "err", "=", "c", ".", "...
// AddEventListener adds a new listener to container events in the Docker API. // // The parameter is a channel through which events will be sent.
[ "AddEventListener", "adds", "a", "new", "listener", "to", "container", "events", "in", "the", "Docker", "API", ".", "The", "parameter", "is", "a", "channel", "through", "which", "events", "will", "be", "sent", "." ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/event.go#L95-L104
27,792
ory/dockertest
docker/event.go
RemoveEventListener
func (c *Client) RemoveEventListener(listener chan *APIEvents) error { err := c.eventMonitor.removeListener(listener) if err != nil { return err } if c.eventMonitor.listernersCount() == 0 { c.eventMonitor.disableEventMonitoring() } return nil }
go
func (c *Client) RemoveEventListener(listener chan *APIEvents) error { err := c.eventMonitor.removeListener(listener) if err != nil { return err } if c.eventMonitor.listernersCount() == 0 { c.eventMonitor.disableEventMonitoring() } return nil }
[ "func", "(", "c", "*", "Client", ")", "RemoveEventListener", "(", "listener", "chan", "*", "APIEvents", ")", "error", "{", "err", ":=", "c", ".", "eventMonitor", ".", "removeListener", "(", "listener", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// RemoveEventListener removes a listener from the monitor.
[ "RemoveEventListener", "removes", "a", "listener", "from", "the", "monitor", "." ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/event.go#L107-L116
27,793
ory/dockertest
docker/event.go
transformEvent
func transformEvent(event *APIEvents) { // if event version is <= 1.21 there will be no Action and no Type if event.Action == "" && event.Type == "" { event.Action = event.Status event.Actor.ID = event.ID event.Actor.Attributes = map[string]string{} switch event.Status { case "delete", "import", "pull", "pu...
go
func transformEvent(event *APIEvents) { // if event version is <= 1.21 there will be no Action and no Type if event.Action == "" && event.Type == "" { event.Action = event.Status event.Actor.ID = event.ID event.Actor.Attributes = map[string]string{} switch event.Status { case "delete", "import", "pull", "pu...
[ "func", "transformEvent", "(", "event", "*", "APIEvents", ")", "{", "// if event version is <= 1.21 there will be no Action and no Type", "if", "event", ".", "Action", "==", "\"", "\"", "&&", "event", ".", "Type", "==", "\"", "\"", "{", "event", ".", "Action", "...
// transformEvent takes an event and determines what version it is from // then populates both versions of the event
[ "transformEvent", "takes", "an", "event", "and", "determines", "what", "version", "it", "is", "from", "then", "populates", "both", "versions", "of", "the", "event" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/event.go#L376-L410
27,794
ory/dockertest
docker/container.go
Proto
func (p Port) Proto() string { parts := strings.Split(string(p), "/") if len(parts) == 1 { return "tcp" } return parts[1] }
go
func (p Port) Proto() string { parts := strings.Split(string(p), "/") if len(parts) == 1 { return "tcp" } return parts[1] }
[ "func", "(", "p", "Port", ")", "Proto", "(", ")", "string", "{", "parts", ":=", "strings", ".", "Split", "(", "string", "(", "p", ")", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "==", "1", "{", "return", "\"", "\"", "\n", "}"...
// Proto returns the name of the protocol.
[ "Proto", "returns", "the", "name", "of", "the", "protocol", "." ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/container.go#L109-L115
27,795
ory/dockertest
docker/container.go
String
func (s *State) String() string { if s.Running { if s.Paused { return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) } if s.Restarting { return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) } return fmt...
go
func (s *State) String() string { if s.Running { if s.Paused { return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) } if s.Restarting { return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) } return fmt...
[ "func", "(", "s", "*", "State", ")", "String", "(", ")", "string", "{", "if", "s", ".", "Running", "{", "if", "s", ".", "Paused", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "units", ".", "HumanDuration", "(", "time", ".", "Now", ...
// String returns a human-readable description of the state
[ "String", "returns", "a", "human", "-", "readable", "description", "of", "the", "state" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/container.go#L150-L179
27,796
ory/dockertest
docker/container.go
StateString
func (s *State) StateString() string { if s.Running { if s.Paused { return "paused" } if s.Restarting { return "restarting" } return "running" } if s.Dead { return "dead" } if s.StartedAt.IsZero() { return "created" } return "exited" }
go
func (s *State) StateString() string { if s.Running { if s.Paused { return "paused" } if s.Restarting { return "restarting" } return "running" } if s.Dead { return "dead" } if s.StartedAt.IsZero() { return "created" } return "exited" }
[ "func", "(", "s", "*", "State", ")", "StateString", "(", ")", "string", "{", "if", "s", ".", "Running", "{", "if", "s", ".", "Paused", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "s", ".", "Restarting", "{", "return", "\"", "\"", "\n", "}...
// StateString returns a single string to describe state
[ "StateString", "returns", "a", "single", "string", "to", "describe", "state" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/container.go#L182-L202
27,797
ory/dockertest
docker/container.go
PortMappingAPI
func (settings *NetworkSettings) PortMappingAPI() []APIPort { var mapping []APIPort for port, bindings := range settings.Ports { p, _ := parsePort(port.Port()) if len(bindings) == 0 { mapping = append(mapping, APIPort{ PrivatePort: int64(p), Type: port.Proto(), }) continue } for _, bin...
go
func (settings *NetworkSettings) PortMappingAPI() []APIPort { var mapping []APIPort for port, bindings := range settings.Ports { p, _ := parsePort(port.Port()) if len(bindings) == 0 { mapping = append(mapping, APIPort{ PrivatePort: int64(p), Type: port.Proto(), }) continue } for _, bin...
[ "func", "(", "settings", "*", "NetworkSettings", ")", "PortMappingAPI", "(", ")", "[", "]", "APIPort", "{", "var", "mapping", "[", "]", "APIPort", "\n", "for", "port", ",", "bindings", ":=", "range", "settings", ".", "Ports", "{", "p", ",", "_", ":=", ...
// PortMappingAPI translates the port mappings as contained in NetworkSettings // into the format in which they would appear when returned by the API
[ "PortMappingAPI", "translates", "the", "port", "mappings", "as", "contained", "in", "NetworkSettings", "into", "the", "format", "in", "which", "they", "would", "appear", "when", "returned", "by", "the", "API" ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/container.go#L253-L276
27,798
ory/dockertest
docker/client.go
NewClient
func NewClient(endpoint string) (*Client, error) { client, err := NewVersionedClient(endpoint, "") if err != nil { return nil, err } client.SkipServerVersionCheck = true return client, nil }
go
func NewClient(endpoint string) (*Client, error) { client, err := NewVersionedClient(endpoint, "") if err != nil { return nil, err } client.SkipServerVersionCheck = true return client, nil }
[ "func", "NewClient", "(", "endpoint", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "client", ",", "err", ":=", "NewVersionedClient", "(", "endpoint", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err"...
// NewClient returns a Client instance ready for communication with the given // server endpoint. It will use the latest remote API version available in the // server.
[ "NewClient", "returns", "a", "Client", "instance", "ready", "for", "communication", "with", "the", "given", "server", "endpoint", ".", "It", "will", "use", "the", "latest", "remote", "API", "version", "available", "in", "the", "server", "." ]
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/client.go#L165-L172
27,799
ory/dockertest
docker/client.go
NewTLSClient
func NewTLSClient(endpoint string, cert, key, ca string) (*Client, error) { client, err := NewVersionedTLSClient(endpoint, cert, key, ca, "") if err != nil { return nil, err } client.SkipServerVersionCheck = true return client, nil }
go
func NewTLSClient(endpoint string, cert, key, ca string) (*Client, error) { client, err := NewVersionedTLSClient(endpoint, cert, key, ca, "") if err != nil { return nil, err } client.SkipServerVersionCheck = true return client, nil }
[ "func", "NewTLSClient", "(", "endpoint", "string", ",", "cert", ",", "key", ",", "ca", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "client", ",", "err", ":=", "NewVersionedTLSClient", "(", "endpoint", ",", "cert", ",", "key", ",", "ca", ...
// NewTLSClient returns a Client instance ready for TLS communications with the givens // server endpoint, key and certificates . It will use the latest remote API version // available in the server.
[ "NewTLSClient", "returns", "a", "Client", "instance", "ready", "for", "TLS", "communications", "with", "the", "givens", "server", "endpoint", "key", "and", "certificates", ".", "It", "will", "use", "the", "latest", "remote", "API", "version", "available", "in", ...
56b367fe94ad17019ab80b91fe686218e65ce9fa
https://github.com/ory/dockertest/blob/56b367fe94ad17019ab80b91fe686218e65ce9fa/docker/client.go#L177-L184