_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q172500
GroupBy
validation
func (idx *Index) GroupBy(rowsQueries ...*PQLRowsQuery) *PQLBaseQuery { if len(rowsQueries) < 1 { return NewPQLBaseQuery("", idx, errors.New("there should be at least one rows query")) } text := fmt.Sprintf("GroupBy(%s)", strings.Join(serializeGroupBy(rowsQueries...), ",")) return NewPQLBaseQuery(text, idx, nil) ...
go
{ "resource": "" }
q172501
GroupByLimit
validation
func (idx *Index) GroupByLimit(limit int64, rowsQueries ...*PQLRowsQuery) *PQLBaseQuery { if len(rowsQueries) < 1 { return NewPQLBaseQuery("", idx, errors.New("there should be at least one rows query")) } if limit < 0 { return NewPQLBaseQuery("", idx, errors.New("limit must be non-negative")) } text := fmt.Spr...
go
{ "resource": "" }
q172502
GroupByFilter
validation
func (idx *Index) GroupByFilter(filterQuery *PQLRowQuery, rowsQueries ...*PQLRowsQuery) *PQLBaseQuery { if len(rowsQueries) < 1 { return NewPQLBaseQuery("", idx, errors.New("there should be at least one rows query")) } filterText := filterQuery.serialize().String() text := fmt.Sprintf("GroupBy(%s,filter=%s)", str...
go
{ "resource": "" }
q172503
OptFieldTypeSet
validation
func OptFieldTypeSet(cacheType CacheType, cacheSize int) FieldOption { return func(options *FieldOptions) { options.fieldType = FieldTypeSet options.cacheType = cacheType options.cacheSize = cacheSize } }
go
{ "resource": "" }
q172504
OptFieldTypeInt
validation
func OptFieldTypeInt(min int64, max int64) FieldOption { return func(options *FieldOptions) { options.fieldType = FieldTypeInt options.min = min options.max = max } }
go
{ "resource": "" }
q172505
OptFieldTypeTime
validation
func OptFieldTypeTime(quantum TimeQuantum, opts ...bool) FieldOption { return func(options *FieldOptions) { options.fieldType = FieldTypeTime options.timeQuantum = quantum if len(opts) > 0 && opts[0] { options.noStandardView = true } } }
go
{ "resource": "" }
q172506
OptFieldTypeMutex
validation
func OptFieldTypeMutex(cacheType CacheType, cacheSize int) FieldOption { return func(options *FieldOptions) { options.fieldType = FieldTypeMutex options.cacheType = cacheType options.cacheSize = cacheSize } }
go
{ "resource": "" }
q172507
Row
validation
func (f *Field) Row(rowIDOrKey interface{}) *PQLRowQuery { rowStr, err := formatIDKeyBool(rowIDOrKey) if err != nil { return NewPQLRowQuery("", f.index, err) } text := fmt.Sprintf("Row(%s=%s)", f.name, rowStr) q := NewPQLRowQuery(text, f.index, nil) return q }
go
{ "resource": "" }
q172508
Set
validation
func (f *Field) Set(rowIDOrKey, colIDOrKey interface{}) *PQLBaseQuery { rowStr, colStr, err := formatRowColIDKey(rowIDOrKey, colIDOrKey) if err != nil { return NewPQLBaseQuery("", f.index, err) } text := fmt.Sprintf("Set(%s,%s=%s)", colStr, f.name, rowStr) q := NewPQLBaseQuery(text, f.index, nil) q.hasKeys = f....
go
{ "resource": "" }
q172509
SetTimestamp
validation
func (f *Field) SetTimestamp(rowIDOrKey, colIDOrKey interface{}, timestamp time.Time) *PQLBaseQuery { rowStr, colStr, err := formatRowColIDKey(rowIDOrKey, colIDOrKey) if err != nil { return NewPQLBaseQuery("", f.index, err) } text := fmt.Sprintf("Set(%s,%s=%s,%s)", colStr, f.name, rowStr, timestamp.Format(timeFor...
go
{ "resource": "" }
q172510
ClearRow
validation
func (f *Field) ClearRow(rowIDOrKey interface{}) *PQLBaseQuery { rowStr, err := formatIDKeyBool(rowIDOrKey) if err != nil { return NewPQLBaseQuery("", f.index, err) } text := fmt.Sprintf("ClearRow(%s=%s)", f.name, rowStr) q := NewPQLBaseQuery(text, f.index, nil) return q }
go
{ "resource": "" }
q172511
RowTopN
validation
func (f *Field) RowTopN(n uint64, row *PQLRowQuery) *PQLRowQuery { q := NewPQLRowQuery(fmt.Sprintf("TopN(%s,%s,n=%d)", f.name, row.serialize(), n), f.index, nil) return q }
go
{ "resource": "" }
q172512
FilterAttrTopN
validation
func (f *Field) FilterAttrTopN(n uint64, row *PQLRowQuery, attrName string, attrValues ...interface{}) *PQLRowQuery { return f.filterAttrTopN(n, row, attrName, attrValues...) }
go
{ "resource": "" }
q172513
Store
validation
func (f *Field) Store(row *PQLRowQuery, rowIDOrKey interface{}) *PQLBaseQuery { rowStr, err := formatIDKeyBool(rowIDOrKey) if err != nil { return NewPQLBaseQuery("", f.index, err) } return NewPQLBaseQuery(fmt.Sprintf("Store(%s,%s=%s)", row.serialize().String(), f.name, rowStr), f.index, nil) }
go
{ "resource": "" }
q172514
NotNull
validation
func (f *Field) NotNull() *PQLRowQuery { text := fmt.Sprintf("Range(%s != null)", f.name) q := NewPQLRowQuery(text, f.index, nil) q.hasKeys = f.options.keys || f.index.options.keys return q }
go
{ "resource": "" }
q172515
Between
validation
func (f *Field) Between(a int, b int) *PQLRowQuery { text := fmt.Sprintf("Range(%s >< [%d,%d])", f.name, a, b) q := NewPQLRowQuery(text, f.index, nil) q.hasKeys = f.options.keys || f.index.options.keys return q }
go
{ "resource": "" }
q172516
SetIntValue
validation
func (f *Field) SetIntValue(colIDOrKey interface{}, value int) *PQLBaseQuery { colStr, err := formatIDKey(colIDOrKey) if err != nil { return NewPQLBaseQuery("", f.index, err) } q := fmt.Sprintf("Set(%s, %s=%d)", colStr, f.name, value) return NewPQLBaseQuery(q, f.index, nil) }
go
{ "resource": "" }
q172517
NewPQLRowsQuery
validation
func NewPQLRowsQuery(pql string, index *Index, err error) *PQLRowsQuery { return &PQLRowsQuery{ index: index, pql: pql, err: err, } }
go
{ "resource": "" }
q172518
Rows
validation
func (f *Field) Rows() *PQLRowsQuery { text := fmt.Sprintf("Rows(field='%s')", f.name) return NewPQLRowsQuery(text, f.index, nil) }
go
{ "resource": "" }
q172519
RowsLimit
validation
func (f *Field) RowsLimit(limit int64) *PQLRowsQuery { if limit < 0 { return NewPQLRowsQuery("", f.index, errors.New("rows limit must be non-negative")) } text := fmt.Sprintf("Rows(field='%s',limit=%d)", f.name, limit) return NewPQLRowsQuery(text, f.index, nil) }
go
{ "resource": "" }
q172520
Result
validation
func (qr *QueryResponse) Result() QueryResult { if len(qr.ResultList) == 0 { return nil } return qr.ResultList[0] }
go
{ "resource": "" }
q172521
MarshalJSON
validation
func (b RowResult) MarshalJSON() ([]byte, error) { columns := b.Columns if columns == nil { columns = []uint64{} } keys := b.Keys if keys == nil { keys = []string{} } return json.Marshal(struct { Attributes map[string]interface{} `json:"attrs"` Columns []uint64 `json:"columns"` Keys ...
go
{ "resource": "" }
q172522
NewURIFromHostPort
validation
func NewURIFromHostPort(host string, port uint16) (*URI, error) { uri := DefaultURI() err := uri.SetHost(host) if err != nil { return nil, err } uri.SetPort(port) return uri, nil }
go
{ "resource": "" }
q172523
NewURIFromAddress
validation
func NewURIFromAddress(address string) (*URI, error) { uri, err := parseAddress(address) if err != nil { return &URI{error: err}, err } return uri, err }
go
{ "resource": "" }
q172524
SetScheme
validation
func (u *URI) SetScheme(scheme string) error { m := schemeRegexp.FindStringSubmatch(scheme) if m == nil { return errors.New("invalid scheme") } u.scheme = scheme return nil }
go
{ "resource": "" }
q172525
SetHost
validation
func (u *URI) SetHost(host string) error { m := hostRegexp.FindStringSubmatch(host) if m == nil { return errors.New("invalid host") } u.host = host return nil }
go
{ "resource": "" }
q172526
Normalize
validation
func (u *URI) Normalize() string { scheme := u.scheme index := strings.Index(scheme, "+") if index >= 0 { scheme = scheme[:index] } return fmt.Sprintf("%s://%s:%d", scheme, u.host, u.port) }
go
{ "resource": "" }
q172527
Equals
validation
func (u URI) Equals(other *URI) bool { if other == nil { return false } return u.scheme == other.scheme && u.host == other.host && u.port == other.port }
go
{ "resource": "" }
q172528
ValidLabel
validation
func ValidLabel(label string) bool { return len(label) <= maxLabel && labelRegex.Match([]byte(label)) }
go
{ "resource": "" }
q172529
ValidKey
validation
func ValidKey(key string) bool { return len(key) <= maxKey && keyRegex.Match([]byte(key)) }
go
{ "resource": "" }
q172530
NewClient
validation
func NewClient(addrURIOrCluster interface{}, options ...ClientOption) (*Client, error) { var cluster *Cluster clientOptions := &ClientOptions{} err := clientOptions.addOptions(options...) if err != nil { return nil, err } switch u := addrURIOrCluster.(type) { case string: uri, err := NewURIFromAddress(u) ...
go
{ "resource": "" }
q172531
Query
validation
func (c *Client) Query(query PQLQuery, options ...interface{}) (*QueryResponse, error) { span := c.tracer.StartSpan("Client.Query") defer span.Finish() if err := query.Error(); err != nil { return nil, err } queryOptions := &QueryOptions{} err := queryOptions.addOptions(options...) if err != nil { return ni...
go
{ "resource": "" }
q172532
CreateIndex
validation
func (c *Client) CreateIndex(index *Index) error { span := c.tracer.StartSpan("Client.CreateIndex") defer span.Finish() data := []byte(index.options.String()) path := fmt.Sprintf("/index/%s", index.name) response, _, err := c.httpRequest("POST", path, data, nil, false) if err != nil { if response != nil && res...
go
{ "resource": "" }
q172533
CreateField
validation
func (c *Client) CreateField(field *Field) error { span := c.tracer.StartSpan("Client.CreateField") defer span.Finish() data := []byte(field.options.String()) path := fmt.Sprintf("/index/%s/field/%s", field.index.name, field.name) response, _, err := c.httpRequest("POST", path, data, nil, false) if err != nil { ...
go
{ "resource": "" }
q172534
EnsureIndex
validation
func (c *Client) EnsureIndex(index *Index) error { err := c.CreateIndex(index) if err == ErrIndexExists { return nil } return err }
go
{ "resource": "" }
q172535
EnsureField
validation
func (c *Client) EnsureField(field *Field) error { err := c.CreateField(field) if err == ErrFieldExists { return nil } return err }
go
{ "resource": "" }
q172536
DeleteIndex
validation
func (c *Client) DeleteIndex(index *Index) error { span := c.tracer.StartSpan("Client.DeleteIndex") defer span.Finish() path := fmt.Sprintf("/index/%s", index.name) _, _, err := c.httpRequest("DELETE", path, nil, nil, false) return err }
go
{ "resource": "" }
q172537
DeleteField
validation
func (c *Client) DeleteField(field *Field) error { span := c.tracer.StartSpan("Client.DeleteField") defer span.Finish() path := fmt.Sprintf("/index/%s/field/%s", field.index.name, field.name) _, _, err := c.httpRequest("DELETE", path, nil, nil, false) return err }
go
{ "resource": "" }
q172538
SyncSchema
validation
func (c *Client) SyncSchema(schema *Schema) error { span := c.tracer.StartSpan("Client.SyncSchema") defer span.Finish() serverSchema, err := c.Schema() if err != nil { return err } return c.syncSchema(schema, serverSchema) }
go
{ "resource": "" }
q172539
Schema
validation
func (c *Client) Schema() (*Schema, error) { span := c.tracer.StartSpan("Client.Schema") defer span.Finish() var indexes []SchemaIndex indexes, err := c.readSchema() if err != nil { return nil, err } schema := NewSchema() for _, indexInfo := range indexes { index := schema.indexWithOptions(indexInfo.Name, ...
go
{ "resource": "" }
q172540
ImportField
validation
func (c *Client) ImportField(field *Field, iterator RecordIterator, options ...ImportOption) error { span := c.tracer.StartSpan("Client.ImportField") defer span.Finish() importOptions := ImportOptions{} for _, option := range options { if err := option(&importOptions); err != nil { return err } } importOp...
go
{ "resource": "" }
q172541
ExportField
validation
func (c *Client) ExportField(field *Field) (io.Reader, error) { span := c.tracer.StartSpan("Client.ExportField") defer span.Finish() var shardsMax map[string]uint64 var err error status, err := c.Status() if err != nil { return nil, err } shardsMax, err = c.shardsMax() if err != nil { return nil, err } ...
go
{ "resource": "" }
q172542
Status
validation
func (c *Client) Status() (Status, error) { span := c.tracer.StartSpan("Client.Status") defer span.Finish() _, data, err := c.httpRequest("GET", "/status", nil, nil, false) if err != nil { return Status{}, errors.Wrap(err, "requesting /status") } status := Status{} err = json.Unmarshal(data, &status) if err ...
go
{ "resource": "" }
q172543
httpRequest
validation
func (c *Client) httpRequest(method string, path string, data []byte, headers map[string]string, useCoordinator bool) (*http.Response, []byte, error) { if data == nil { data = []byte{} } // try at most maxHosts non-failed hosts; protect against broken cluster.removeHost var response *http.Response var err error...
go
{ "resource": "" }
q172544
doRequest
validation
func (c *Client) doRequest(host *URI, method, path string, headers map[string]string, reader io.Reader) (*http.Response, error) { req, err := makeRequest(host, method, path, headers, reader) if err != nil { return nil, errors.Wrap(err, "building request") } return c.client.Do(req) }
go
{ "resource": "" }
q172545
statusToNodeShardsForIndex
validation
func (c *Client) statusToNodeShardsForIndex(status Status, indexName string) (map[uint64]*URI, error) { result := make(map[uint64]*URI) if maxShard, ok := status.indexMaxShard[indexName]; ok { for shard := 0; shard <= int(maxShard); shard++ { fragmentNodes, err := c.fetchFragmentNodes(indexName, uint64(shard)) ...
go
{ "resource": "" }
q172546
ExperimentalReplayImport
validation
func (c *Client) ExperimentalReplayImport(r io.Reader, concurrency int) error { span := c.tracer.StartSpan("Client.ExperimentalReplayImport") defer span.Finish() // make work channel work := make(chan *importLog, concurrency*2) // spawn <concurrency> workers to read from channel eg := &errgroup.Group{} for i :...
go
{ "resource": "" }
q172547
viewByTimeUnit
validation
func viewByTimeUnit(t time.Time, unit rune) string { switch unit { case 'Y': return t.Format("2006") case 'M': return t.Format("200601") case 'D': return t.Format("20060102") case 'H': return t.Format("2006010215") default: return "" } }
go
{ "resource": "" }
q172548
OptClientSocketTimeout
validation
func OptClientSocketTimeout(timeout time.Duration) ClientOption { return func(options *ClientOptions) error { options.SocketTimeout = timeout return nil } }
go
{ "resource": "" }
q172549
OptClientConnectTimeout
validation
func OptClientConnectTimeout(timeout time.Duration) ClientOption { return func(options *ClientOptions) error { options.ConnectTimeout = timeout return nil } }
go
{ "resource": "" }
q172550
OptClientPoolSizePerRoute
validation
func OptClientPoolSizePerRoute(size int) ClientOption { return func(options *ClientOptions) error { options.PoolSizePerRoute = size return nil } }
go
{ "resource": "" }
q172551
OptClientTotalPoolSize
validation
func OptClientTotalPoolSize(size int) ClientOption { return func(options *ClientOptions) error { options.TotalPoolSize = size return nil } }
go
{ "resource": "" }
q172552
OptClientTLSConfig
validation
func OptClientTLSConfig(config *tls.Config) ClientOption { return func(options *ClientOptions) error { options.TLSConfig = config return nil } }
go
{ "resource": "" }
q172553
OptClientManualServerAddress
validation
func OptClientManualServerAddress(enabled bool) ClientOption { return func(options *ClientOptions) error { options.manualServerAddress = enabled return nil } }
go
{ "resource": "" }
q172554
ExperimentalOptClientLogImports
validation
func ExperimentalOptClientLogImports(loc io.Writer) ClientOption { return func(options *ClientOptions) error { options.importLogWriter = loc return nil } }
go
{ "resource": "" }
q172555
OptQueryColumnAttrs
validation
func OptQueryColumnAttrs(enable bool) QueryOption { return func(options *QueryOptions) error { options.ColumnAttrs = enable return nil } }
go
{ "resource": "" }
q172556
OptQueryShards
validation
func OptQueryShards(shards ...uint64) QueryOption { return func(options *QueryOptions) error { options.Shards = append(options.Shards, shards...) return nil } }
go
{ "resource": "" }
q172557
OptQueryExcludeAttrs
validation
func OptQueryExcludeAttrs(enable bool) QueryOption { return func(options *QueryOptions) error { options.ExcludeRowAttrs = enable return nil } }
go
{ "resource": "" }
q172558
OptQueryExcludeColumns
validation
func OptQueryExcludeColumns(enable bool) QueryOption { return func(options *QueryOptions) error { options.ExcludeColumns = enable return nil } }
go
{ "resource": "" }
q172559
OptImportThreadCount
validation
func OptImportThreadCount(count int) ImportOption { return func(options *ImportOptions) error { options.threadCount = count return nil } }
go
{ "resource": "" }
q172560
OptImportBatchSize
validation
func OptImportBatchSize(batchSize int) ImportOption { return func(options *ImportOptions) error { options.batchSize = batchSize return nil } }
go
{ "resource": "" }
q172561
OptImportStatusChannel
validation
func OptImportStatusChannel(statusChan chan<- ImportStatusUpdate) ImportOption { return func(options *ImportOptions) error { options.statusChan = statusChan return nil } }
go
{ "resource": "" }
q172562
OptImportClear
validation
func OptImportClear(clear bool) ImportOption { return func(options *ImportOptions) error { options.clear = clear return nil } }
go
{ "resource": "" }
q172563
OptImportRoaring
validation
func OptImportRoaring(enable bool) ImportOption { return func(options *ImportOptions) error { options.wantRoaring = &enable return nil } }
go
{ "resource": "" }
q172564
OptImportSort
validation
func OptImportSort(sorting bool) ImportOption { return func(options *ImportOptions) error { // skipSort is expressed negatively because we want to // keep sorting enabled by default, so the zero value should // be that default behavior. The client option expresses it // positively because that's easier for API...
go
{ "resource": "" }
q172565
Read
validation
func (r *exportReader) Read(p []byte) (n int, err error) { if r.currentShard >= r.shardCount { err = io.EOF return } if r.body == nil { uri, _ := r.shardURIs[r.currentShard] headers := map[string]string{ "Accept": "text/csv", } path := fmt.Sprintf("/export?index=%s&field=%s&shard=%d", r.field.index...
go
{ "resource": "" }
q172566
ColumnUnmarshallerWithTimestamp
validation
func ColumnUnmarshallerWithTimestamp(format Format, timestampFormat string) RecordUnmarshaller { return func(text string) (pilosa.Record, error) { var err error column := pilosa.Column{} parts := strings.Split(text, ",") if len(parts) < 2 { return nil, errors.New("Invalid CSV line") } hasRowKey := form...
go
{ "resource": "" }
q172567
NewIterator
validation
func NewIterator(reader io.Reader, unmarshaller RecordUnmarshaller) *Iterator { return &Iterator{ reader: reader, line: 0, scanner: bufio.NewScanner(reader), unmarshaller: unmarshaller, } }
go
{ "resource": "" }
q172568
NewColumnIterator
validation
func NewColumnIterator(format Format, reader io.Reader) *Iterator { return NewIterator(reader, ColumnUnmarshaller(format)) }
go
{ "resource": "" }
q172569
NewColumnIteratorWithTimestampFormat
validation
func NewColumnIteratorWithTimestampFormat(format Format, reader io.Reader, timestampFormat string) *Iterator { return NewIterator(reader, ColumnUnmarshallerWithTimestamp(format, timestampFormat)) }
go
{ "resource": "" }
q172570
NewValueIterator
validation
func NewValueIterator(format Format, reader io.Reader) *Iterator { return NewIterator(reader, FieldValueUnmarshaller(format)) }
go
{ "resource": "" }
q172571
NextRecord
validation
func (c *Iterator) NextRecord() (pilosa.Record, error) { if ok := c.scanner.Scan(); ok { c.line++ text := strings.TrimSpace(c.scanner.Text()) if text != "" { rc, err := c.unmarshaller(text) if err != nil { return nil, fmt.Errorf("%s at line: %d", err.Error(), c.line) } return rc, nil } } err ...
go
{ "resource": "" }
q172572
FieldValueUnmarshaller
validation
func FieldValueUnmarshaller(format Format) RecordUnmarshaller { return func(text string) (pilosa.Record, error) { parts := strings.Split(text, ",") if len(parts) < 2 { return nil, errors.New("Invalid CSV") } value, err := strconv.ParseInt(parts[1], 10, 64) if err != nil { return nil, errors.New("Invali...
go
{ "resource": "" }
q172573
MergeConfig
validation
func MergeConfig(a, b *Config) *Config { // Return quickly if either side was nil if a == nil { return b } if b == nil { return a } var result Config = *a if b.Delim != "" { result.Delim = b.Delim } if b.Glue != "" { result.Glue = b.Glue } if b.Prefix != "" { result.Prefix = b.Prefix } if b.Emp...
go
{ "resource": "" }
q172574
stringFormat
validation
func stringFormat(c *Config, widths []int, columns int) string { // Create the buffer with an estimate of the length buf := bytes.NewBuffer(make([]byte, 0, (6+len(c.Glue))*columns)) // Start with the prefix, if any was given. The buffer will not return an // error so it does not need to be handled buf.WriteString...
go
{ "resource": "" }
q172575
elementsFromLine
validation
func elementsFromLine(config *Config, line string) []interface{} { separated := strings.Split(line, config.Delim) elements := make([]interface{}, len(separated)) for i, field := range separated { value := field if !config.NoTrim { value = strings.TrimSpace(field) } // Apply the empty value, if configured...
go
{ "resource": "" }
q172576
widthsFromLines
validation
func widthsFromLines(config *Config, lines []string) []int { widths := make([]int, 0, 8) for _, line := range lines { elems := elementsFromLine(config, line) for i := 0; i < len(elems); i++ { l := runeLen(elems[i].(string)) if len(widths) <= i { widths = append(widths, l) } else if widths[i] < l { ...
go
{ "resource": "" }
q172577
Format
validation
func Format(lines []string, config *Config) string { conf := MergeConfig(DefaultConfig(), config) widths := widthsFromLines(conf, lines) // Estimate the buffer size glueSize := len(conf.Glue) var size int for _, w := range widths { size += w + glueSize } size *= len(lines) // Create the buffer buf := byte...
go
{ "resource": "" }
q172578
Build
validation
func (m *GorillaHost) Build(u *url.URL, values url.Values) error { host, err := m.RevertValid(values) if err == nil { if u.Scheme == "" { u.Scheme = "http" } u.Host = host } return err }
go
{ "resource": "" }
q172579
Build
validation
func (m *GorillaPathPrefix) Build(u *url.URL, values url.Values) error { path, err := m.RevertValid(values) if err == nil { u.Path = path } return err }
go
{ "resource": "" }
q172580
braceIndices
validation
func braceIndices(s string) ([]int, error) { var level, idx int idxs := make([]int, 0) for i := 0; i < len(s); i++ { switch s[i] { case '{': if level++; level == 1 { idx = i } case '}': if level--; level == 0 { idxs = append(idxs, idx, i+1) } else if level < 0 { return nil, fmt.Errorf("...
go
{ "resource": "" }
q172581
Extract
validation
func (m *RegexpHost) Extract(result *Result, r *http.Request) { result.Values = mergeValues(result.Values, m.Values(getHost(r))) }
go
{ "resource": "" }
q172582
mergeValues
validation
func mergeValues(u1, u2 url.Values) url.Values { if u1 == nil { return u2 } if u2 == nil { return u1 } for k, v := range u2 { u1[k] = append(u1[k], v...) } return u1 }
go
{ "resource": "" }
q172583
redirectPath
validation
func redirectPath(path string, r *http.Request) http.Handler { t1 := strings.HasSuffix(path, "/") t2 := strings.HasSuffix(r.URL.Path, "/") if t1 != t2 { u, _ := url.Parse(r.URL.String()) if t1 { u.Path += "/" } else { u.Path = u.Path[:len(u.Path)-1] } return http.RedirectHandler(u.String(), 301) } ...
go
{ "resource": "" }
q172584
CompileRegexp
validation
func CompileRegexp(pattern string) (*Regexp, error) { compiled, err := regexp.Compile(pattern) if err != nil { return nil, err } re, err := syntax.Parse(pattern, syntax.Perl) if err != nil { return nil, err } tpl := &template{buffer: new(bytes.Buffer)} tpl.write(re) return &Regexp{ compiled: compiled, ...
go
{ "resource": "" }
q172585
MatchString
validation
func (r *Regexp) MatchString(s string) bool { return r.compiled.MatchString(s) }
go
{ "resource": "" }
q172586
Values
validation
func (r *Regexp) Values(s string) url.Values { match := r.compiled.FindStringSubmatch(s) if match != nil { values := url.Values{} for k, v := range r.groups { values.Add(v, match[r.indices[k]]) } return values } return nil }
go
{ "resource": "" }
q172587
Revert
validation
func (r *Regexp) Revert(values url.Values) (string, error) { vars := make([]interface{}, len(r.groups)) for k, v := range r.groups { if len(values[v]) == 0 { return "", fmt.Errorf( "Missing key %q to revert the regexp "+ "(expected a total of %d variables)", v, len(r.groups)) } vars[k] = values[v][0...
go
{ "resource": "" }
q172588
RevertValid
validation
func (r *Regexp) RevertValid(values url.Values) (string, error) { reverse, err := r.Revert(values) if err != nil { return "", err } if !r.compiled.MatchString(reverse) { return "", fmt.Errorf("Resulting string doesn't match the regexp: %q", reverse) } return reverse, nil }
go
{ "resource": "" }
q172589
write
validation
func (t *template) write(re *syntax.Regexp) { switch re.Op { case syntax.OpLiteral: if t.level == 0 { for _, r := range re.Rune { t.buffer.WriteRune(r) if r == '%' { t.buffer.WriteRune('%') } } } case syntax.OpCapture: t.level++ t.index++ if t.level == 1 { t.groups = append(t.grou...
go
{ "resource": "" }
q172590
NewMultiple
validation
func NewMultiple(buf []byte, options Options, h hash.Hash, compareOnMatch bool) *Cmp { c := &Cmp{ Opt: options, hashType: h, hashMatchCompare: compareOnMatch, hashTable: map[string]hashSum{}, buf: buf, } if c.buf == nil || len(c.buf) == 0 { c.buf = make([]byte, de...
go
{ "resource": "" }
q172591
New
validation
func New(buf []byte, options Options) *Cmp { return NewMultiple(buf, options, nil, true) }
go
{ "resource": "" }
q172592
CompareFile
validation
func (c *Cmp) CompareFile(path1, path2 string) (bool, error) { if c.Opt.MaxSize < 0 { return false, fmt.Errorf("negative MaxSize") } r1, openErr1 := os.Open(path1) if openErr1 != nil { return false, openErr1 } defer r1.Close() info1, statErr1 := r1.Stat() if statErr1 != nil { return false, statErr1 } ...
go
{ "resource": "" }
q172593
readPartial
validation
func readPartial(c *Cmp, r io.Reader, buf []byte, n1, n2 int) (int, error) { for n1 < n2 { n, err := c.read(r, buf[n1:n2]) n1 += n if err != nil { return n1, err } } return n1, nil }
go
{ "resource": "" }
q172594
postEOFCheck
validation
func postEOFCheck(c *Cmp, r io.Reader, buf []byte) bool { tmpLR, isLR := r.(*io.LimitedReader) if isLR { // If the limit wasn't reached, then we don't need to check for // more data after the EOF if tmpLR.N > 0 { return true } // Use the internal Reader for checking for more data r = tmpLR.R } else {...
go
{ "resource": "" }
q172595
Stats
validation
func (h *HAProxyClient) Stats() (stats []*Stat, err error) { res, err := h.RunCommand("show stat") if err != nil { return nil, err } reader := csv.NewReader(res) reader.TrailingComma = true err = gocsv.UnmarshalCSV(reader, &stats) if err != nil { return nil, fmt.Errorf("error reading csv: %s", err) } // ...
go
{ "resource": "" }
q172596
Info
validation
func (h *HAProxyClient) Info() (*Info, error) { res, err := h.RunCommand("show info") if err != nil { return nil, err } info := &Info{} err = kvcodec.Unmarshal(res, info) if err != nil { return nil, fmt.Errorf("error decoding response: %s", err) } return info, nil }
go
{ "resource": "" }
q172597
RunCommand
validation
func (h *HAProxyClient) RunCommand(cmd string) (*bytes.Buffer, error) { err := h.dial() if err != nil { return nil, err } defer h.conn.Close() result := bytes.NewBuffer(nil) _, err = h.conn.Write([]byte(cmd + "\n")) if err != nil { return nil, err } _, err = io.Copy(result, h.conn) if err != nil { re...
go
{ "resource": "" }
q172598
IsExist
validation
func IsExist(err error) bool { if err == ErrUserExist || err == ErrGroupExist { return true } return false }
go
{ "resource": "" }
q172599
exist
validation
func exist(file string) (bool, error) { _, err := os.Stat(file) if err != nil { if err == os.ErrNotExist { return false, nil } return false, err } return true, nil }
go
{ "resource": "" }