id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c174400 |
options = append(options, opt.name)
}
break
}
}
return options
} | |
c174401 | range sect.options {
options[opt.name] = opt.value
}
break
}
}
return options
} | |
c174402 | c.sections {
if sect.name == section {
return sect.comments
}
}
return nil
} | |
c174403 | return
}
}
c.sections = append(c.sections, section{
name: sect,
comments: []string{comment},
})
} | |
c174404 | if m := iniSectionRe.FindStringSubmatch(line); len(m) > 0 {
curSection = m[1]
} else if m := iniOptionRe.FindStringSubmatch(line); len(m) > 0 {
key := m[1]
val := m[2]
if !strings.Contains(val, "\"") {
// If val does not contain any quote characers, we can make it
// a quoted string and safely let strconv.Unquote sort out any
// escapes
val = "\"" + val + "\""
}
if val[0] == '"' {
val, _ = strconv.Unquote(val)
}
cfg.Set(curSection, key, val)
}
}
}
return cfg
} | |
c174405 | := opt.value
if len(val) == 0 {
continue
}
// Quote the string if it begins or ends with space
needsQuoting := val[0] == ' ' || val[len(val)-1] == ' '
if !needsQuoting {
// Quote the string if it contains any unprintable characters
for _, r := range val {
if !strconv.IsPrint(r) {
needsQuoting = true
break
}
}
}
if needsQuoting {
val = strconv.Quote(val)
}
fmt.Fprintf(out, "%s=%s\n", opt.name, val)
}
fmt.Fprintln(out)
}
return nil
} | |
c174406 | opt.name == key {
return opt.value
}
}
return ""
}
}
return ""
} | |
c174407 |
c.sections[i].options[j].value = value
return
}
}
c.sections[i].options = append(sect.options, option{key, value})
return
}
}
c.sections = append(c.sections, section{
name: sectionName,
options: []option{{key, value}},
})
} | |
c174408 | c.sections[sn].options = append(sect.options[:i], sect.options[i+1:]...)
return
}
}
return
}
}
} | |
c174409 | sliceSize := len(realVal)
targetSlice := reflect.MakeSlice(targetType, 0, sliceSize)
elemType := targetType.Elem()
for i := 0; i < sliceSize; i++ {
targetSlice = reflect.Append(targetSlice, Convert(value.Index(i), elemType))
}
return targetSlice
}
panic(fmt.Errorf("convert from type %v to %v failed: %v", valType, targetType, value))
} | |
c174410 | time.Now().Add(i.lifetime)
} | |
c174411 |
LogBackend: l,
r: r,
}
} | |
c174412 | if len(vleft) == 1 {
val = reflect.Indirect(reflect.ValueOf(vleft[0]))
if val.IsValid() && val.Kind() == reflect.Interface {
val = val.Elem()
}
}
return &op{
field: field,
vright: val,
op: o,
}
} | |
c174413 | {
return &apply{
condition: condition,
rule: rule,
}
} | |
c174414 | condition: condition,
rule: rule,
el: el,
}
} | |
c174415 | HttpHeader_WwwAuthenticate().
SetValue(BASIC_REALM).
SetWriter(w.Header())
http.Error(w, http.StatusText(http.StatusUnauthorized),
http.StatusUnauthorized)
}
return http.HandlerFunc(f)
} | |
c174416 | exec.LookPath(s.binCmd)
return err == nil
} | |
c174417 | := exe.Run(); err != nil {
return stdout.String(), ExternalCmdError{
err, stderr.String(), stdout.String()}
}
return stdout.String(), nil
} | |
c174418 | *HttpHeader {
s.Value = h.Get(s.Name)
return s
} | |
c174419 | s.Name = name
return s
} | |
c174420 | s.Value = value
return s
} | |
c174421 | *HttpHeader {
h.Set(s.Name, s.Value)
return s
} | |
c174422 | key is ok. Or, if the primary key is
// marked as ok to encrypt to, then we can obviously use it.
i := e.primaryIdentity()
if !i.SelfSignature.FlagsValid || i.SelfSignature.FlagEncryptCommunications &&
e.PrimaryKey.PubKeyAlgo.CanEncrypt() &&
!i.SelfSignature.KeyExpired(now) {
return Key{e, e.PrimaryKey, e.PrivateKey, i.SelfSignature}, true
}
// This Entity appears to be signing only.
return Key{}, false
} | |
c174423 | {
result := &ContentNegotiator{}
result.DefaultEncoder = defaultEncoder
result.ResponseWriter = responseWriter
return result
} | |
c174424 | {
result := NewContentNegotiator(defaultEncoder, responseWriter)
result.AddEncoder(MimeJSON, JsonEncoder{prettyPrint})
result.AddEncoder(MimeXML, XmlEncoder{prettyPrint})
return result
} | |
c174425 |
var e = cn.getEncoder(req)
cn.ResponseWriter.Header().Set("Content-Type", e.ContentType())
return e.Encode(data)
} | |
c174426 | = make(map[string]Encoder)
}
cn.encoderMap[mimeType] = enc
} | |
c174427 | := req.Header.Get("Accept")
for k, v := range cn.encoderMap {
if strings.Contains(accept, k) {
result = v
break
}
}
return result
} | |
c174428 | PubKeyAlgoDSA:
return true
}
return false
} | |
c174429 |
} else {
sort.Sort(sort.Reverse(ByWinnings{s}))
}
} | |
c174430 | return true
}
case <-after:
return false
}
}
return false
} | |
c174431 | fmt.Sprintf("%s:%d", s.IpAddress, s.Port)
} | |
c174432 | nil {
return err
}
s.Port, s.Protocol = uint16(iPort), split[1]
return nil
} | |
c174433 | range b {
b[i] = s.readByte()
}
return len(b), nil
} | |
c174434 |
time.Sleep(DEFAULT_SLEEP_TIME + rndDuration)
diff := time.Now().Sub(before)
n := byte(diff.Nanoseconds())
s.val[s.index] = n
s.index ^= 1
return n
} | |
c174435 | %+v", err))
JsonWrite(w, jerr.Status, jerr)
}
}()
next.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
} | |
c174436 | },
RandFactory: rand.Int,
// Settings.
RandReader: rand.Reader,
Timeout: 1 * time.Second,
}
} | |
c174437 |
// Dependencies.
backoffFactory: config.BackoffFactory,
randFactory: config.RandFactory,
// Settings.
randReader: config.RandReader,
timeout: config.Timeout,
}
return newService, nil
} | |
c174438 | "--nojournal")
return s.Image.Run(cfg)
} | |
c174439 | in.
if err := viper.ReadInConfig(); err == nil {
fmt.Println("Using config file:", viper.ConfigFileUsed())
}
fs, err := fstack.OpenStack(stackFile)
if err != nil {
panic(err)
}
stack = fs
} | |
c174440 | if v.Port > 0 || len(v.Protocol) > 0 {
return true
}
}
return false
} | |
c174441 | inspecting container: %v", err))
}
if len(list) == 0 {
return nil, UnexpectedOutputError(
"Empty output when inspecting container")
}
return list, nil
} | |
c174442 | !inspect[0].State.Running {
return true
}
return false
})
if !stopped {
err = fmt.Errorf("Timeout waiting '%s' container to stop", s.id)
}
return err
} | |
c174443 |
IpAddress: ip,
})
} else {
for k, _ := range i.NetworkSettings.Ports {
node := NetworkNode{}
node.IpAddress = ip
node.SetFromDocker(k)
nodes = append(nodes, node)
}
}
}
return nodes, nil
} | |
c174444 | return exec.Command(s.docker.binCmd, "rm", s.id).Run()
} | |
c174445 | nodes[0].Protocol, nodes[0].FormatDialAddress(), timeout)
if !ok {
err = fmt.Errorf("%s unreachable for %v",
nodes[0].FormatDialAddress(), timeout)
}
return err
} | |
c174446 | (h *Handler) {
return &Handler{
Counter: counter,
Level: level,
}
} | |
c174447 | h.Counter.criticalCounter.Inc()
case logging.ERROR:
h.Counter.errorCounter.Inc()
case logging.WARNING:
h.Counter.warningCounter.Inc()
case logging.NOTICE:
h.Counter.noticeCounter.Inc()
case logging.INFO:
h.Counter.infoCounter.Inc()
case logging.DEBUG:
h.Counter.debugCounter.Inc()
}
return nil
} | |
c174448 | alertCounter: vector.WithLabelValues("alert"),
criticalCounter: vector.WithLabelValues("critical"),
errorCounter: vector.WithLabelValues("error"),
warningCounter: vector.WithLabelValues("warning"),
noticeCounter: vector.WithLabelValues("notice"),
infoCounter: vector.WithLabelValues("info"),
debugCounter: vector.WithLabelValues("debug"),
}
} | |
c174449 | {
return []prometheus.Collector{c.vector}
} | |
c174450 |
}
}
// If the file is not an archive store it and finish processing.
if source.Archive == nil {
log.Printf("Created asset: %s ...", source.Path)
files[source.Path] = &mfs.File{file.data, file.modTime}
continue
}
// Extract files from the archive and store them.
archFiles, err := processArchive(source.Archive, file.data)
if err != nil {
return nil, &ArchiveError{source.Location, err}
}
for _, file := range archFiles {
log.Printf("Created asset: %s ...", file.path)
files[file.path] = &mfs.File{file.data, file.modTime}
}
}
fs, err := mfs.New(files)
if err != nil {
return nil, err
}
return httpfs.New(fs), nil
} | |
c174451 |
opts.VariableComment = fmt.Sprintf("%s implements a http.FileSystem.", varName)
}
err = vfsgen.Generate(fs, vfsgen.Options{
Filename: filePath,
PackageName: pkgName,
BuildTags: opts.BuildTags,
VariableName: varName,
VariableComment: opts.VariableComment,
})
if err != nil {
return err
}
return nil
} | |
c174452 | {
return block, err
}
return block, binary.Read(reader, binary.LittleEndian, &block)
} | |
c174453 | return err
}
return binary.Write(writer, binary.LittleEndian, *fb)
} | |
c174454 | = binary.Write(file, binary.LittleEndian, block)
if err != nil {
file.Seek(currentOffset, os.SEEK_SET)
return -1, err
}
// Write header
_, err = file.Write(header)
if err != nil {
file.Seek(currentOffset, os.SEEK_SET)
return -1, err
}
// Write data
_, err = file.Write(data)
if err != nil {
file.Seek(currentOffset, os.SEEK_SET)
return -1, err
}
s.depth++
s.currentBlockPos = currentOffset
s.currentBlock = block
return s.depth, nil
} | |
c174455 | nil {
return nil, nil, err
}
// Read data
_, err = file.ReadAt(data, int64(s.currentBlock.DataPoint))
if err != nil {
return nil, nil, err
}
// Read new block if current block is not head
var newBlock fileBlock
if s.currentBlockPos != 0 {
newBlock, err = readBlockAt(file, int64(s.currentBlock.PrevBlock))
if err != nil {
return nil, nil, err
}
}
// Remove tail
err = file.Truncate(int64(s.currentBlockPos))
if err != nil {
return nil, nil, err
}
s.depth--
s.currentBlockPos = int64(s.currentBlock.PrevBlock)
s.currentBlock = newBlock
return header, data, nil
} | |
c174456 |
if err != nil {
return nil, nil, err
}
// Read data
_, err = file.ReadAt(data, int64(s.currentBlock.DataPoint))
if err != nil {
return nil, nil, err
}
return header, data, nil
} | |
c174457 | = make([]byte, s.currentBlock.HeaderSize)
// Read header
_, err = file.ReadAt(header, int64(s.currentBlock.HeaderPoint))
if err != nil {
return nil, err
}
return header, nil
} | |
c174458 | if currentBlock.PrevBlock > currentBlockOffset {
log.Printf("Danger back-ref link: prev block %v has greater index then current %v", currentBlock.PrevBlock, currentBlockOffset)
}
depth--
if currentBlock.PrevBlock == currentBlockOffset {
// First block has prev block = 0
break
}
currentBlockOffset = currentBlock.PrevBlock
currentBlock, err = readBlockAt(file, int64(currentBlock.PrevBlock))
if err != nil {
return err
}
}
if depth != 0 {
log.Println("Broker back path detected at", depth, "depth index")
}
return nil
} | |
c174459 | {
log.Println("Can't read block at", newPos)
return err
}
// Check back-ref
if block.PrevBlock != currentBlockOffset {
log.Println("Bad back reference", block.PrevBlock, "!=", currentBlockOffset, "!upd!")
block.PrevBlock = currentBlockOffset
block.writeTo(file, newPos)
}
// Update current state
currentBlockOffset = uint64(newPos)
currentBlock = block
body := io.NewSectionReader(file, int64(currentBlock.DataPoint), int64(currentBlock.DataSize))
header := io.NewSectionReader(file, int64(currentBlock.HeaderPoint), int64(currentBlock.HeaderSize))
// invoke block processor
if handler != nil && !handler(depth, header, body) {
return nil
}
depth++
}
s.depth = depth
s.currentBlock = currentBlock
s.currentBlockPos = int64(currentBlockOffset)
return nil
} | |
c174460 | := s.file.Close()
s.file = nil
return err
}
return nil
} | |
c174461 | err != nil {
return nil, err
}
return NewStack(file)
} | |
c174462 | nil {
stack.Close()
return nil, err
}
return stack, nil
} | |
c174463 |
cache: data.NewCache(d),
salter: crypt.NewSalter(
crypt.NewRandomSourceListSecure(), []byte(salt)),
}
} | |
c174464 | "The requested token '%s' is invalid or is expired", token))
} | |
c174465 | return nil, s.getInvalidTokenError(token)
}
return v, err
} | |
c174466 | panic("Something is seriously wrong, a duplicated token was generated")
}
return strSum
} | |
c174467 | s.getInvalidTokenError(token)
}
return nil
} | |
c174468 |
return s.getInvalidTokenError(token)
}
return nil
} | |
c174469 | serverPort: serverPort,
writeTimeout: 30 * time.Second,
readTimeout: 100 * time.Millisecond,
channels: map[string]struct{}{},
mutex: &sync.Mutex{},
}
} | |
c174470 | c.serverHost,
c.serverPort))
if err != nil {
return fmt.Errorf("error dialing: %s", err)
}
c.conn = conn
c.rw = bufio.NewReadWriter(bufio.NewReader(c.conn), bufio.NewWriter(c.conn))
return nil
} | |
c174471 | sz != len(buf) {
return fmt.Errorf("short write")
}
if err := c.rw.Flush(); err != nil {
return fmt.Errorf("flush error: %s", err)
}
log.Printf("client %s: sent: %s", c.nick, strings.TrimRight(buf, "\r\n"))
return nil
} | |
c174472 | %s", c.nick, strings.TrimRight(line, "\r\n"))
m, err := irc.ParseMessage(line)
if err != nil && err != irc.ErrTruncated {
return irc.Message{}, fmt.Errorf("unable to parse message: %s: %s", line,
err)
}
return m, nil
} | |
c174473 | reader and writer won't be sending on the error channel any
// more.
close(c.errChan)
_ = c.conn.Close()
for range c.recvChan {
}
for range c.errChan {
}
} | |
c174474 | channels = append(channels, k)
}
c.mutex.Unlock()
return channels
} | |
c174475 |
w.WriteHeader(status)
if content != nil {
json.NewEncoder(w).Encode(content)
}
} | |
c174476 |
return false
}
if err := body.Close(); err != nil {
jerr := NewJsonErrorFromError(http.StatusInternalServerError, err)
JsonWrite(w, jerr.Status, jerr)
return false
}
if err := json.Unmarshal(content, obj); err != nil {
jerr := NewJsonErrorFromError(StatusUnprocessableEntity, err)
JsonWrite(w, jerr.Status, jerr)
return false
}
return true
} | |
c174477 | if err != nil {
return err
}
return pk.VerifySignature(h, sig)
} | |
c174478 | storage.Store(p)
if err != nil {
return nil,
errors.New(err.Error() + " - Could not write user to storage")
}
return &p.User, nil
} | |
c174479 | }
if next := c.route.next; next != nil {
c.route = next
next.ServeHTTPContext(w, r, c)
} else {
c.holdUp = true
}
} | |
c174480 | := &Context{route: route}
route.ServeHTTPContext(w, r, c)
} | |
c174481 |
r.f = h
return
}
route := r.getLeaf()
route.next = &Route{f: h}
} | |
c174482 |
batch := batchRoute(f)
if err := entry.SetMethodHandler(method, batch); err != nil {
panic(err)
}
} | |
c174483 |
batch := batchRoute(f)
if err := entry.SetHandler(batch); err != nil {
panic(err)
}
} | |
c174484 | f...)
r.HandleMethod(pat, "HEAD", f...)
} | |
c174485 | r.HandleMethod(pat, "POST", f...)
} | |
c174486 | r.HandleMethod(pat, "PUT", f...)
} | |
c174487 | r.HandleMethod(pat, "PATCH", f...)
} | |
c174488 | r.HandleMethod(pat, "DELETE", f...)
} | |
c174489 | r.HandleMethod(pat, "OPTIONS", f...)
} | |
c174490 | += v.Weight
}
return &Salter{
salt: hash.Sum(nil),
rndSources: sources,
sumWeight: sum,
}
} | |
c174491 | := float32(size) * (float32(v.Weight) / float32(self.sumWeight))
mac.Write(getRandomBytes(v.Reader, int(itemSize)))
}
macSum := mac.Sum(nil)
self.salt = macSum
return macSum
} | |
c174492 | {
return base64.URLEncoding.EncodeToString(self.BToken(size))
} | |
c174493 | nil {
panic("Could not access secure random generator")
}
return b
} | |
c174494 | = uuid.V4()
c.Author = author
c.Created = time.Now()
if err := storage.Store(c); err != nil {
return nil, errors.New(err.Error() + " - Could not write NewsItem to storage")
}
eventqueue.Publish(utils.CKPTEvent{
Type: utils.NEWS_EVENT,
Subject: "Nytt bidrag lagt ut",
Message: "Det er lagt ut et nytt bidrag på ckpt.no!"})
return c, nil
} | |
c174495 | unicode.IsSpace)))
return len(p), nil
} | |
c174496 | unicode.IsSpace)))
return len(p), nil
} | |
c174497 |
lw.Warning(string(bytes.TrimRightFunc(p, unicode.IsSpace)))
return len(p), nil
} | |
c174498 | unicode.IsSpace)))
return len(p), nil
} | |
c174499 | }
lock.RLock()
logger, ok := loggers[name]
lock.RUnlock()
if !ok {
return nil, fmt.Errorf("unknown logger %s", name)
}
return logger, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.