id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c174300 | *IrcText {
i.bgColor = c
return i
} | |
c174301 | return build(HandlerFunc(i.(func(context.Context, http.ResponseWriter, *http.Request) error))), nil
}
return nil, errors.New("Invalid type")
} | |
c174302 |
res = ctx.Err
}
}
log.Printf("%vmw: logger: %v: %v, in: \"%v\", out: \"%#v\"", prefix, ctx.ID, ctx.Method, v, res)
return err
}
} | |
c174303 | parseMimeInfo(e.Mime())
m[e] = info
}
return &Encoder{
defaultEncoding: defaultEncoding,
encodings: m,
}
} | |
c174304 |
if info != nil {
for encoding, i := range e.encodings {
if i.equals(info) {
return encoding
}
}
}
return e.defaultEncoding
} | |
c174305 |
if i.equals(info) {
return encoding
}
}
}
return e.Parser(r).(Responder)
} | |
c174306 | {
return &errStatus{
error: errors.New(err),
status: status,
}
} | |
c174307 | error {
return &errStatus{
error: err,
status: status,
}
} | |
c174308 | instead read in fileEndOffset - currentOffset bytes
if offset+int64(len(p)) > f.dataOffset+int64(f.DataBlockSize) {
remainingBytes := (f.dataOffset + int64(f.DataBlockSize)) - offset
return file.Read(p[:remainingBytes])
}
return file.Read(p)
} | |
c174309 | terminator for each key/val
baseSize += len(key) + len(val) + 2
}
// There's a null terminator at the end of the block
return baseSize + 1
} | |
c174310 | log level: %s", log.LogLevel))
}
logger := lager.NewLogger(log.Name)
logger.RegisterSink(lager.NewWriterSink(log.Writer, minLagerLogLevel))
log.Logger = logger
return log
} | |
c174311 | := ctx.Value("scaffold_url_parts").([]string); ok {
return ctx, parts
}
parts := pathSplit(r.URL.Path)
ctx = context.WithValue(ctx, "scaffold_url_parts", parts)
return URLParts(ctx, r)
} | |
c174312 | len(parts) > i && i >= 0 {
return ctx, parts[i], true
}
return ctx, "", false
} | |
c174313 | context.Context {
n := paramName(name)
return context.WithValue(ctx, n, Param(value))
} | |
c174314 | := paramName(name)
if p, ok := ctx.Value(n).(Param); ok {
return p
}
return ""
} | |
c174315 | := strconv.ParseInt(string(p), 10, 32)
return int32(i), err
} | |
c174316 | strconv.IntSize)
return uint(i), err
} | |
c174317 | strconv.ParseUint(string(p), 10, 32)
return uint32(i), err
} | |
c174318 | strconv.ParseFloat(string(p), 32)
return float32(f), err
} | |
c174319 | nil {
defer rfile.Close()
_, err = io.Copy(rfile, lfile)
}
return
} | |
c174320 | == nil {
err = SafeRemoveSSH(sftpclient, s.remotePath)
}
return
} | |
c174321 | err == nil {
rfile, err = SafeCreateSSH(sftpclient, s.remotePath)
}
return
} | |
c174322 | Session: cmap.New(),
resRoutes: cmap.New(),
deadline: time.Second * time.Duration(300),
disconnHandler: func(c *Conn) {},
}
c.connected.Store(false)
return c, nil
} | |
c174323 |
if ws == nil {
return nil
}
return ws.RemoteAddr()
} | |
c174324 | id, Method: method, Params: params}
if err = c.send(req); err != nil {
return "", err
}
c.resRoutes.Set(req.ID, resHandler)
return id, nil
} | |
c174325 | string, err error) {
return c.SendRequest(method, params, resHandler)
} | |
c174326 |
if ws != nil {
ws.Close()
}
return nil
} | |
c174327 |
return c.send(response{ID: id, Result: result, Error: err})
} | |
c174328 |
return websocket.JSON.Send(c.ws.Load().(*websocket.Conn), msg)
} | |
c174329 | return websocket.JSON.Receive(c.ws.Load().(*websocket.Conn), &msg)
} | |
c174330 | err != nil {
return fmt.Errorf("conn: error while setting websocket connection deadline: %v", err)
}
return nil
} | |
c174331 | c.RemoteAddr(), m)
break
}
// if the message is a response
if resHandler, ok := c.resRoutes.GetOk(m.ID); ok {
resCounter.Add(1)
c.wg.Add(1)
go func() {
defer resCounter.Add(-1)
defer recoverAndLog(c, &c.wg)
err := resHandler.(func(ctx *ResCtx) error)(newResCtx(c, m.ID, m.Result, m.Error))
c.resRoutes.Delete(m.ID)
if err != nil {
log.Printf("conn: error while handling response: %v", err)
c.Close()
}
}()
} else {
log.Printf("conn: error while handling response: got response to a request with unknown ID: %v", m.ID)
break
}
}
} | |
c174332 |
entry.pbo = &pbo
pbo.Entries = append(pbo.Entries, entry)
}
// Loop through all of our entries and set their data offset
baseOffset := pbo.dataOffset
for i := range pbo.Entries {
entry := &pbo.Entries[i]
// If the block is compressed, use the compressed size. If it's not, use the actual size
entry.dataOffset = baseOffset
baseOffset += int64(entry.DataBlockSize)
}
return &pbo, nil
} | |
c174333 | {
return &MockReadWriteCloser{
ReadErr: readErr,
WriteErr: writeErr,
CloseErr: closeErr,
}
} | |
c174334 | nil {
r.BytesRead = p
n = len(p)
}
return
} | |
c174335 | nil {
r.BytesWritten = p
n = len(p)
}
return
} | |
c174336 | if !ssh.exists(filePath) {
lo.G.Debug("Removing %s", filePath)
err = client.Remove(filePath)
}
return
} | |
c174337 |
}
fpath := path.Join(name...)
basepath := filepath.Dir(fpath)
if err = ssh.remoteSafeMkdirAll(basepath); err == nil {
file, err = client.Create(fpath)
}
return
} | |
c174338 | e := ensurePath(path.Join(name...))
if e != nil {
return nil, e
}
return os.Create(p)
} | |
c174339 | pass, nil
})
if err != nil || !jt.Valid {
ctx.Conn.Close()
return fmt.Errorf("mw: jwt: invalid JWT authentication attempt: %v: %v: %v", err, ctx.Conn.RemoteAddr(), t.Token)
}
userID := jt.Claims["userid"].(string)
ctx.Conn.Session.Set("userid", userID)
log.Printf("mw: jwt: client authenticated, user: %v, conn: %v, ip: %v", userID, ctx.Conn.ID, ctx.Conn.RemoteAddr())
return ctx.Next()
}
} | |
c174340 | New(d)
platform.Routes(router)
return router.dispatcher
} | |
c174341 | := r.pattern(pattern)
return r.clone(c)
} | |
c174342 | := r.pattern(pattern)
group(r.clone(c))
} | |
c174343 | := r.pattern(pattern)
platform.Routes(r.clone(c))
} | |
c174344 | r.clone(c)
clone.handle(handlers)
return clone
} | |
c174345 |
clone := r.clone(c)
clone.handle(handlers)
return clone
} | |
c174346 | r.buildMiddlewares(middleware)...)
} | |
c174347 | := r.buildHandler(i)
r.dispatcher.NotFoundHandler(r.route, handler)
} | |
c174348 | r.builders = append(r.builders, &builder)
} | |
c174349 | int, err error) {
e(ctx, w, r, status, err)
} | |
c174350 |
key = fmt.Sprintf("error_handler_%d", AllStatusCodes)
if h, ok := ctx.Value(key).(ErrorHandler); ok {
return h
}
return DefaultErrorHandler
} | |
c174351 | key := fmt.Sprintf("error_handler_%d", status)
ctx = context.WithValue(ctx, key, handler)
next.CtxServeHTTP(ctx, w, r)
})
})
} | |
c174352 | err error)) scaffold.Middleware {
return SetErrorHandler(status, ErrorHandlerFunc(handler))
} | |
c174353 | into response directly
if err := ctx.Params(&ctx.Res); err != nil {
return err
}
return ctx.Next()
} | |
c174354 | the buffer
c.StringLength = binary.BigEndian.Uint16(b[6:8])
if len(b[8:]) < int(c.StringLength) {
return io.ErrUnexpectedEOF
}
// StringLength must not be greater than 1024, per AoEr11, Section 3.2.
if c.StringLength > 1024 {
return ErrorBadArgumentParameter
}
// Copy config string for use
d := make([]byte, c.StringLength)
copy(d, b[8:])
c.String = d
return nil
} | |
c174355 | implementation
return nil, ErrNotImplemented
}
// Retrieve device identity information
id, err := ident.Identify()
if err != nil {
return nil, err
}
return &ATAArg{
CmdStatus: ATACmdStatusReadyStatus,
Data: id[:],
}, nil
} | |
c174356 |
// stream
//
// TODO(mdlayher): use r.Data instead of allocating?
b := make([]byte, int(r.SectorCount)*sectorSize)
n, err := rs.Read(b)
if err != nil {
return nil, err
}
// Verify sector count
if sectors := n / sectorSize; sectors != int(r.SectorCount) {
return nil, errATAAbort
}
return &ATAArg{
CmdStatus: ATACmdStatusReadyStatus,
Data: b,
}, nil
} | |
c174357 | is
// requested
rws, ok := rs.(io.ReadWriteSeeker)
if !ok {
// A write was requested, but the io.ReadSeeker is not an io.Writer
return nil, errATAAbort
}
// TODO(mdlayher): implement asynchronous writes
// Convert LBA to byte offset and seek to correct location
offset := calculateLBA(r.LBA, r.FlagLBA48Extended) * sectorSize
if _, err := rs.Seek(offset, os.SEEK_SET); err != nil {
return nil, err
}
// Write data to stream
n, err := rws.Write(r.Data)
if err != nil {
return nil, err
}
// Verify full sectors written to disk using sector count
if sectors := n / sectorSize; sectors != int(r.SectorCount) {
return nil, errATAAbort
}
return &ATAArg{
CmdStatus: ATACmdStatusReadyStatus,
}, nil
} | |
c174358 | 0,
0,
}
lba := binary.LittleEndian.Uint64(b)
// Mask off high bits to limit size to either 48 bit or 28 bit,
// depending on is48Bit's value.
if is48Bit {
// 48-bit
lba &= 0x0000ffffffffffff
} else {
// 28-bit
lba &= 0x0fffffff
}
return int64(lba)
} | |
c174359 | Copy each hardware address into byte slice, after verifying exactly
// 6 bytes in length
n := 2
for _, m := range r.MACs {
if len(m) != 6 {
return nil, ErrorBadArgumentParameter
}
copy(b[n:n+6], m)
n += 6
}
return b, nil
} | |
c174360 | number of bytes for hardware addresses with
// this count
if len(b[2:]) != (6 * int(r.NMACs)) {
return io.ErrUnexpectedEOF
}
// Copy each hardware address into slice
r.MACs = make([]net.HardwareAddr, r.NMACs)
for i := 0; i < int(r.NMACs); i++ {
m := make(net.HardwareAddr, 6)
copy(m, b[2+(i*6):2+(i*6)+6])
r.MACs[i] = m
}
return nil
} | |
c174361 | uint8
if a.FlagLBA48Extended {
flags |= (1 << 6)
}
if a.FlagATADeviceHeadRegister {
flags |= (1 << 4)
}
if a.FlagAsynchronous {
flags |= (1 << 1)
}
if a.FlagWrite {
flags |= 1
}
b[0] = flags
// Set other ATA data
b[1] = a.ErrFeature
b[2] = a.SectorCount
b[3] = uint8(a.CmdStatus)
b[4] = a.LBA[0]
b[5] = a.LBA[1]
b[6] = a.LBA[2]
b[7] = a.LBA[3]
b[8] = a.LBA[4]
b[9] = a.LBA[5]
// 2 bytes reserved space
// Copy raw data after argument header
copy(b[12:], a.Data)
return b, nil
} | |
c174362 | Fixture{db: db, Tables: tables}
return fixture
} | |
c174363 |
var tables Tables
err := yaml.Unmarshal(yamlIn, &tables)
return New(db, tables), err
} | |
c174364 |
var tables Tables
err := json.Unmarshal(jsonIn, &tables)
return New(db, tables), err
} | |
c174365 | byte reserved
// Add command copy hardware address into Directive
b[1] = uint8(d.Command)
copy(b[2:], d.MAC)
return b, nil
} | |
c174366 | // 1 byte reserved
b[1] = uint8(m.Command)
b[2] = uint8(m.Error)
b[3] = m.DirCount
// Marshal each directive into binary and copy into byte slice
// after argument
n := 4
for _, d := range m.Directives {
db, err := d.MarshalBinary()
if err != nil {
return nil, err
}
copy(b[n:n+directiveLen], db)
n += directiveLen
}
return b, nil
} | |
c174367 | &SendToLogger{
Logger: golog.New(os.Stderr, "", golog.LstdFlags),
}
}
return &SendToLogger{
Logger: logger,
}
} | |
c174368 |
}
f, ok := vals[i+1].(Formatter)
if !ok {
Fail(e.New("not a Formatter"))
return nil
}
bak.F(f)
mp = append(mp, bak)
}
return &MultiLog{
mp: mp,
}
} | |
c174369 | := <-mp.chouter:
logger.Tag(tags...).Println(string(buf))
case ch := <-mp.chclose:
ch <- struct{}{}
return
}
}
}()
return &outer{
ch: mp.chouter,
buf: make([]byte, 0),
}
} | |
c174370 | {
s.Options = append(s.Options, "-p",
fmt.Sprintf("%d:%d", hostPort, containerPort))
} | |
c174371 | append(s.Options, "--name", name)
} | |
c174372 | = append(s.Args, args...)
} | |
c174373 |
"Accept", "Authorization",
},
ExposedHeaders: make([]string, 0),
}
} | |
c174374 | = true
}
}
for k, v := range hList {
list = append(list, Route{
Name: "",
Method: DEFAULT_CORS_PREFLIGHT_METHOD,
Path: k,
MustAuth: v.UseCredentials,
ActionFunc: v.ServeHTTP,
})
}
return list
} | |
c174375 | HttpHeader_AccessControlAllowHeaders().
SetValue(strings.Join(s.Headers, ", ")).
SetWriter(w.Header())
}
HttpHeader_AccessControlAllowMethods().
SetValue(strings.Join(s.Methods, ", ")).
SetWriter(w.Header())
HttpHeader_AccessControlAllowOrigin().
SetValue(origin.Value).
SetWriter(w.Header())
HttpHeader_AccessControlAllowCredentials().
SetValue(strconv.FormatBool(s.UseCredentials)).
SetWriter(w.Header())
// Optional
HttpHeader_AccessControlMaxAge().
SetValue(strconv.Itoa(int(DEFAULT_CORS_MAX_AGE))).
SetWriter(w.Header())
status = http.StatusOK
} else {
status = http.StatusNotFound
}
} | |
c174376 | HttpHeader_AccessControlAllowHeaders().
SetValue(strings.Join(s.Headers, ", ")).
SetWriter(w.Header())
} else {
HttpHeader_AccessControlAllowHeaders().
SetWriter(w.Header())
}
}
next.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
} | |
c174377 |
RandomSource{
Reader: NewRandom(),
Weight: DEFAULT_RAIQUB_RAND_SIZE,
},
}
} | |
c174378 | switch record.Level {
case EMERGENCY:
return handler.writter.Emerg(msg)
case ALERT:
return handler.writter.Alert(msg)
case CRITICAL:
return handler.writter.Crit(msg)
case ERROR:
return handler.writter.Err(msg)
case WARNING:
return handler.writter.Warning(msg)
case NOTICE:
return handler.writter.Notice(msg)
case INFO:
return handler.writter.Info(msg)
default:
return handler.writter.Debug(msg)
}
} | |
c174379 | handler.writter == nil {
return nil
}
return handler.writter.Close()
} | |
c174380 | }
// day
if s[8] == '0' {
if s[9] == '0' {
return false
}
} else if s[8] == '3' {
if s[9] > '1' {
return false
}
} else if s[8] != '1' && s[8] != '2' {
return false
}
return true
}
count += 1
}
return true
} | |
c174381 | offset = i
matchStr = str[:i]
return
}
return
}
offset = length
matchStr = str
return
} | |
c174382 | match to suffix pattern
if i != 0 && m.suffix == str[i:i+len(m.suffix)] {
offset = i + len(m.suffix)
matchStr = str[:i]
return
}
if !m.matcher.MatchRune(r) {
return
}
}
return
} | |
c174383 | return m.matcher.MatchRune(r)
} | |
c174384 |
offset = -1
return
}
return m.length, s[:m.length]
} | |
c174385 | db, err = b.OpenFunc(b.DataPath())
}
if err != nil {
return DB{}, errorsp.WithStacks(err)
}
b.db, b.count = db, 0
}
b.count++
return b.db, nil
} | |
c174386 |
b.count--
if b.count == 0 {
b.db.Close()
b.db = DB{}
}
} | |
c174387 | g.l.Infof(format, args...)
} | |
c174388 | g.l.Warningf(format, args...)
} | |
c174389 | g.l.Errorf(format, args...)
} | |
c174390 | g.l.Criticalf(format, args...)
} | |
c174391 | case 11:
for _, i := range f.theString {
count++
buffer.WriteString(string(i))
switch count {
case 1:
buffer.WriteString(" (")
case 4:
buffer.WriteString(") ")
case 7:
buffer.WriteString(fmt.Sprintf("%s", delimiter))
}
}
default:
return "", errors.New("non US number given")
}
return buffer.String(), nil
} | |
c174392 | f.theString), nil
}
if len(subdomain) > 0 {
return fmt.Sprintf("http://%s.%s", subdomain, f.theString), nil
}
return fmt.Sprintf("http://%s", f.theString), nil
} | |
c174393 | _, i := range f.theString {
count++
buffer.WriteString(string(i))
if count == 3 || count == 5 {
buffer.WriteString(delimiter)
}
}
return buffer.String(), nil
} | |
c174394 | if _, ok := morse[key]; ok {
buffer.WriteString(morse[key])
} else if key == " " {
buffer.WriteString(" ")
}
}
return buffer.String(), nil
} | |
c174395 | defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
return "", err
}
return string(contents), nil
} | |
c174396 | strings.ToLower(string(i))
if _, ok := irsa[key]; ok {
buffer.WriteString(irsa[key] + " ")
}
}
return buffer.String(), nil
} | |
c174397 |
Formatter: &StandardFormatter{TimeFormat: StandardTimeFormat},
Writer: os.Stderr,
},
}, 0)
} | |
c174398 | getDefaultLogger().log(level, format, a...)
} | |
c174399 | = append(sections, sect.name)
}
return sections
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.