id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c180600
{ field := typ.Field(i) if field.Name == "Error" || field.Name == "String" { continue } if field.PkgPath != "" { // ignore unexported fields continue } fmt.Printf(" %s = %v\n", field.Name, val.Field(i).Interface()) } fmt.Print("\n") } return nil }
c180601
results to JSON: %s", err.Error()) } if _, err = io.Copy(os.Stdout, bytes.NewReader(data)); err != nil { return fmt.Errorf("Failed to write json output: %s", err.Error()) } fmt.Print("\n") return nil }
c180602
Xor64Source s.Seed(seed) return &s }
c180603
7 x ^= x << 17 return x }
c180604
*s = Xor64Source(x) return x }
c180605
= seed0 } *s = Xor64Source(seed) }
c180606
add it to the frame set for _, match := range matches { if err = frameSet.handleMatch(match); err != nil { return nil, err } } return frameSet, nil }
c180607
== 0 { return fmt.Errorf("Failed to parse part of range %v. "+ "Encountered invalid 0 value", match[3]) } if start, err = parseInt(match[0]); err != nil { return err } if end, err = parseInt(match[1]); err != nil { return err } if mod = match[2]; !isModifier(mod) { return fmt.Errorf("%q is not one of the valid modifier 'xy:'", mod) } switch mod { case `x`: s.rangePtr.AppendUnique(start, end, chunk) case `y`: // TODO: Add proper support for adding inverse of range. // This approach will add excessive amounts of singe // range elements. They could be compressed into chunks skip := start aRange := ranges.NewInclusiveRange(start, end, 1) var val int for it := aRange.IterValues(); !it.IsDone(); { val = it.Next() if val == skip { skip += chunk continue } s.rangePtr.AppendUnique(val, val, 1) } case `:`: for ; chunk > 0; chunk-- { s.rangePtr.AppendUnique(start, end, chunk) } } default: return fmt.Errorf("Unexpected match []string size: %v", match) } return nil }
c180608
return s.rangePtr.Index(frame) }
c180609
return s.rangePtr.Value(index) }
c180610
return s.rangePtr.Contains(frame) }
c180611
return PadFrameRange(s.frange, pad) }
c180612
:= s.rangePtr.Normalized() return &FrameSet{ptr.String(), ptr} }
c180613
different step size if i == 1 && count > 3 { // Check if the next two pairwise frames have the same step. // If so, then it is better than our current grouping. if (frames[2] - frames[1]) == (frames[3] - frames[2]) { // Just consume the first frame, and allow the next // loop to scan the new stepping buf.WriteString(zfillInt(frames[0], zfill)) frames = frames[1:] continue } } // Otherwise write out this step range start = zfillInt(frames[0], zfill) end = zfillInt(frames[i], zfill) buf.WriteString(fmt.Sprintf("%s-%s", start, end)) if step > 1 { buf.WriteString(fmt.Sprintf("x%d", step)) } frames = frames[i+1:] } return buf.String() }
c180614
matches := make([][]string, size, size) for i, part := range parts { matched = false // Build up frames for all comma-sep components for _, rx = range rangePatterns { if match = rx.FindStringSubmatch(part); match == nil { continue } matched = true matches[i] = match[1:] } // If any component of the comma-sep frame range fails to // parse, we bail out if !matched { err := fmt.Errorf("Failed to parse frame range: %s on part %q", frange, part) return nil, err } } return matches, nil }
c180615
+= step } } else { for i := start; i >= end; { nums = append(nums, i) i -= step } } return nums }
c180616
make(chan string), inSeqs: make(chan *fileseq.FileSequence), outSeqs: make(chan fileseq.FileSequences), fileOpts: fileopts, } return s }
c180617
nil continue } path, err := seq.Format("{{dir}}{{base}}{{pad}}{{ext}}") if err != nil { fmt.Fprintf(errOut, "%s %q: Not a valid path\n", ErrorPattern, path) continue } seq, err := fileseq.FindSequenceOnDisk(path) if err != nil { if !os.IsNotExist(err) { fmt.Fprintf(errOut, "%s %q: %s\n", ErrorPattern, path, err) } continue } if seq != nil { outSeqs <- fileseq.FileSequences{seq} } } } }
c180618
if w.inSeqs != nil { return false } return true }
c180619
if w.inSeqs != nil { close(w.inSeqs) } }
c180620
w.inSeqs <- s } for _, r := range dirs { w.inDirs <- r } }
c180621
tranversing into hidden dirs if len(info.Name()) > 1 && strings.HasPrefix(info.Name(), ".") { return walk.SkipDir } } // Add the path to the input channel for sequence scanning w.inDirs <- path } return nil } dirs, seqs := preparePaths(paths) for _, s := range seqs { w.inSeqs <- s } for _, r := range dirs { r := r if err := walk.Walk(r, walkFn); err != nil { if err != walk.SkipDir { fmt.Fprintf(errOut, "%s %q: %s\n", ErrorPath, r, err) } } } }
c180622
if _, seen := previous[p]; seen { continue } previous[p] = struct{}{} if fi, err = os.Stat(p); err != nil { // If the path doesn't exist, test it for // a valid fileseq pattern if seq, err := fileseq.NewFileSequence(p); err == nil { seqs = append(seqs, seq) continue } fmt.Fprintf(errOut, "%s %q: %s\n", ErrorPath, p, err) continue } if !fi.IsDir() { continue } dirs = append(dirs, p) } return dirs, seqs }
c180623
matched[3]) default: // No match. Try the next pattern continue } // If we got here, we matched a case and can stop // checking the rest of the patterns didMatch = true break } // If we didn't match one of our expected patterns // then just take the original part and add it unmodified if !didMatch { parts = append(parts, part) } } return strings.Join(parts, ",") }
c180624
return fmt.Sprintf("-%s%s", fill, src[1:]) } return fmt.Sprintf("%s%s", fill, src) }
c180625
return fmt.Sprintf(fmt.Sprintf("%%0%dd", z), src) }
c180626
= -1 } } r := &InclusiveRange{ start: start, end: end, step: step, } return r }
c180627
stepping, if its not 1 step := r.Step() if step > 1 || step < -1 { buf.WriteString(`x`) buf.WriteString(strconv.Itoa(r.Step())) } } return buf.String() }
c180628
= r.start return r.cachedEnd } else if (r.end > r.start) && r.step > (r.end-r.start) { r.cachedEnd = r.start return r.cachedEnd } // Calculate the end, taking into account the stepping r.cachedEnd = r.closestInRange(r.end, r.start, r.end, r.step) return r.cachedEnd }
c180629
r.cachedLen = int(math.Ceil(diff / math.Abs(float64(r.step)))) r.isLenCached = true return r.cachedLen }
c180630
end := r.End() if start < end { return start } return end }
c180631
end := r.End() if start > end { return start } return end }
c180632
// then it is in the range. closest := r.closestInRange(value, r.start, r.End(), r.step) return closest == value }
c180633
} } // No calculation needed if there is no stepping if step == 1 || step == -1 { return value } // Modified the value so that it is a properly stepped // increment within the range return (((value - start) / step) * step) + start }
c180634
f.step) if closest != value { return -1 } idx := (value - f.start) / f.step if idx < 0 { idx *= -1 } return idx }
c180635
range l.blocks { if i > 0 { buf.WriteString(`,`) } buf.WriteString(b.String()) } return buf.String() }
c180636
totalLen += b.Len() } return totalLen }
c180637
_, b := range l.blocks { return b.Start() } return 0 }
c180638
return l.blocks[len(l.blocks)-1].End() }
c180639
if next < val { val = next } } return val }
c180640
if next > val { val = next } } return val }
c180641
return 0 } return len(l.blocks) }
c180642
l.numRanges() { return nil } return l.blocks[idx] }
c180643
end, step) l.blocks = append(l.blocks, block) }
c180644
// Is a unique value in the range last = subEnd if pending == 0 { subStart = last } pending++ continue } if pending == 0 { // Nothing to add yet continue } // Current value is already in range. // Add previous values l.Append(subStart, last, subStep) subStart = subEnd + step pending = 0 } // Flush the remaining values if pending > 0 { l.Append(subStart, last, subStep) } }
c180645
b := range l.blocks { if b.Contains(value) { return true } } return false }
c180646
= b.Index(value); idx >= 0 { return idx + n } // Update the offset for the values we have seen n += b.Len() } // The previous loop ended in error return -1 }
c180647
} return s.frameSet.FrameRange() }
c180648
} return s.frameSet.FrameRangePadded(s.zfill) }
c180649
:= s.frameSet.Frame(idx) if err != nil { return "" } path, err := s.Frame(frame) if err != nil { return "" } return path }
c180650
dir = dir + string(filepath.Separator) } s.dir = dir }
c180651
{ s.padChar = padChars s.zfill = s.padMapper.PaddingCharsSize(padChars) }
c180652
s.SetPadding(s.padMapper.PaddingChars(s.ZFill())) }
c180653
ext = "." + ext } s.ext = ext }
c180654
return err } s.frameSet = frameSet return nil }
c180655
== nil { return 1 } return s.frameSet.Len() }
c180656
buf := bytes.NewBufferString(s.dir) buf.WriteString(s.basename) buf.WriteString(fs) buf.WriteString(s.padChar) buf.WriteString(s.ext) return buf.String() }
c180657
:= NewFileSequence(s.String()) return seq }
c180658
url, tls: tls, header: header, } }
c180659
if err = d.DecodeElement(h.Content, &se); err != nil { return err } case xml.EndElement: break Loop } } return nil }
c180660
WS-I compliant") } else if se.Name.Space == envelopeNameSpace && se.Name.Local == "Fault" { b.Fault = &Fault{} b.Content = nil err = d.DecodeElement(b.Fault, &se) if err != nil { return err } consumed = true } else { if err = d.DecodeElement(b.Content, &se); err != nil { return err } consumed = true } case xml.EndElement: break Loop } } return nil }
c180661
soapFault, err := ioutil.ReadAll(res.Body) if err != nil { return errors.Wrap(err, "failed to read SOAP fault response body") } msg := fmt.Sprintf("HTTP Status Code: %d, SOAP Fault: \n%s", res.StatusCode, string(soapFault)) return errors.New(msg) } rawbody, err := ioutil.ReadAll(res.Body) if err != nil { return errors.Wrap(err, "failed to read SOAP body") } if len(rawbody) == 0 { return nil } respEnvelope := Envelope{} respEnvelope.Body = Body{Content: response} if header != nil { respEnvelope.Header = &Header{Content: header} } if err = xml.Unmarshal(rawbody, &respEnvelope); err != nil { return errors.Wrap(err, "failed to unmarshal response SOAP Envelope") } return nil }
c180662
if err != nil { return nil, err } return json.RawMessage(data), nil }
c180663
Fn: load, Next: prev, } spec.PathLoader = loaders.Fn }
c180664
nil, err } // convert to json return Analyzed(data, "") }
c180665
!= nil { return nil, err } return &Document{ raw: orig, origSpec: &origSpec, spec: &flatSpec, }, nil }
c180666
{ return nil, lastErr } b, err := defaultLoader.Fn(path) if err != nil { return nil, err } document, err := Analyzed(b, "") if document != nil { document.specFilePath = path } return document, err }
c180667
nil { return nil, err } origsqspec, err := cloneSpec(swspec) if err != nil { return nil, err } d := &Document{ Analyzer: analysis.New(swspec), schema: spec.MustLoadSwagger20Schema(), spec: swspec, raw: raw, origSpec: origsqspec, } return d, nil }
c180668
} dd := &Document{ Analyzer: analysis.New(swspec), spec: swspec, specFilePath: d.specFilePath, schema: spec.MustLoadSwagger20Schema(), raw: d.raw, origSpec: d.origSpec, } return dd, nil }
c180669
len(d.origSpec.Definitions)) for k, v := range d.origSpec.Definitions { defs[k] = v } d.spec.Definitions = defs return d }
c180670
:= Analyzed(d.Raw(), d.Version()) return dd }
c180671
g.db, err = C.GeoIP_open(cbase, C.int(flag)) if g.db != nil && err != nil { break } } if err != nil { return nil, fmt.Errorf("Error opening GeoIP database (%s): %s", files, err) } if g.db == nil { return nil, fmt.Errorf("Didn't open GeoIP database (%s)", files) } C.GeoIP_set_charset(g.db, C.GEOIP_CHARSET_UTF8) return g, nil }
c180672
_ := gi.GetName(ip) return name }
c180673
countryCode := C.GoString(&region.country_code[0]) regionCode := C.GoString(&region.region[0]) defer C.free(unsafe.Pointer(region)) return countryCode, regionCode }
c180674
"" } // it's a static string constant, don't free this regionName := C.GoString(region) return regionName }
c180675
if ccountry != nil { cc = C.GoString(ccountry) netmask = int(C.GeoIP_last_netmask(gi.db)) return } return }
c180676
var err error h.fd, err = os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { return nil, err } f, err := h.fd.Stat() if err != nil { return nil, err } h.curBytes = int(f.Size()) return h, nil }
c180677
return h.fd.Close() } return nil }
c180678
return "info" case LevelWarn: return "warn" case LevelError: return "error" case LevelFatal: return "fatal" } // return default info return "info" }
c180679
handler l.flag = flag l.bufs = sync.Pool{ New: func() interface{} { return make([]byte, 0, 1024) }, } return l }
c180680
l.hLock.Unlock() l.handler.Close() }
c180681
level = LevelError case "fatal": level = LevelFatal default: level = LevelInfo } l.SetLevel(level) }
c180682
file = file[i+1:] break } } } buf = append(buf, file...) buf = append(buf, ':') buf = strconv.AppendInt(buf, int64(line), 10) buf = append(buf, ' ') } buf = append(buf, msg...) if len(msg) == 0 || msg[len(msg)-1] != '\n' { buf = append(buf, '\n') } l.hLock.Lock() l.handler.Write(buf) l.hLock.Unlock() }
c180683
- 1; i > 0; i-- { if file[i] == '/' { file = file[i+1:] break } } } jsonlog.File = file jsonlog.Line = string(strconv.AppendInt(buf, int64(line), 10)) } jsonlog.Body = body msg, _ := json.Marshal(jsonlog) msg = append(msg, '\n') l.hLock.Lock() l.handler.Write(msg) l.hLock.Unlock() }
c180684
{ l.Output(2, LevelTrace, fmt.Sprint(args...)) }
c180685
{ l.Output(2, LevelTrace, fmt.Sprintln(args...)) }
c180686
{ l.Output(2, LevelDebug, fmt.Sprint(args...)) }
c180687
{ l.Output(2, LevelDebug, fmt.Sprintln(args...)) }
c180688
{ l.Output(2, LevelError, fmt.Sprint(args...)) }
c180689
{ l.Output(2, LevelError, fmt.Sprintln(args...)) }
c180690
{ l.Output(2, LevelInfo, fmt.Sprint(args...)) }
c180691
{ l.Output(2, LevelInfo, fmt.Sprintln(args...)) }
c180692
{ l.Output(2, LevelWarn, fmt.Sprint(args...)) }
c180693
{ l.Output(2, LevelWarn, fmt.Sprintln(args...)) }
c180694
:= new(StreamHandler) h.w = w return h, nil }
c180695
str + times(pad, length-len(str)) }
c180696
api.Metadata = GenMetadata return &API{API: api} }
c180697
} } } for n, r := range ssc.GenMetadata { result[n] = r for _, a := range r.Actions { for _, p := range a.PathPatterns { // remove "/api/catalog" prefix p.Regexp = removePrefixes(p.Regexp, 2) } } } for n, r := range ssm.GenMetadata { result[n] = r for _, a := range r.Actions { for _, p := range a.PathPatterns { // remove "/api/manager" prefix p.Regexp = removePrefixes(p.Regexp, 2) } } } return }
c180698
p.recordTypes(f.Type) } } } else if a, ok := root.(*gen.ArrayDataType); ok { p.recordTypes(a.ElemType.Type) } }
c180699
= append(params, param) sort.Sort(gen.ByName(params)) return params }