id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c12000 | }
srcFile, err := os.Open(source)
if err != nil {
return err
}
defer srcFile.Close()
dstFile, err := os.Create(dest)
if err != nil {
return err
}
defer dstFile.Close()
if _, err = io.Copy(dstFile, srcFile); err != nil {
return err
}
return os.Chmod(dest, srcStat.Mode())
} | |
c12001 | return v.(int64), true
case reflect.Float32:
return int64(v.(float32)), true
case reflect.Float64:
return int64(v.(float64)), true
}
return 0, false
} | |
c12002 | return uint64(v.(uint8)), true
case reflect.Uint16:
return uint64(v.(uint16)), true
case reflect.Uint32:
return uint64(v.(uint32)), true
case reflect.Uint64:
return v.(uint64), true
}
return 0, false
} | |
c12003 | return float32(v.(int16)), true
case reflect.Uint16:
return float32(v.(uint16)), true
case reflect.Int32:
return float32(v.(int32)), true
case reflect.Uint32:
return float32(v.(uint32)), true
case reflect.Int64:
return float32(v.(int64)), true
case reflect.Uint64:
return float32(v.(uint64)), true
case ... | |
c12004 |
srcValue := reflect.ValueOf(src)
UnsafeCopyValue(dstValue, srcValue)
} | |
c12005 | := reflect.Indirect(reflect.ValueOf(ptrToStruct))
member := structVal.FieldByName(name)
SetValue(member, data)
} | |
c12006 |
member := structVal.Field(idx)
SetValue(member, data)
} | |
c12007 | return size, io.EOF
}
*b.buffer = (*b.buffer)[:start+size]
copy((*b.buffer)[start:], data)
return size, nil
} | |
c12008 | Transition {
return Transition{
nextState: nextState,
flags: flags,
callback: callback,
}
} | |
c12009 |
lookup: []string{},
tokens: []*tcontainer.TrieNode{},
stack: []ParserStateID{},
}
} | |
c12010 |
}
}
id := ParserStateID(len(parser.lookup))
parser.lookup = append(parser.lookup, stateName)
parser.tokens = append(parser.tokens, nil)
return id
} | |
c12011 | < ParserStateID(len(parser.lookup)) {
return parser.lookup[id]
}
return ""
} | |
c12012 |
parser.Add(dir.State, dir.Token, dir.NextState, dir.Flags, dir.Callback)
}
} | |
c12013 | callback ParsedFunc) {
nextStateID := parser.GetStateID(nextStateName)
parser.AddTransition(stateName, NewTransition(nextStateID, flags, callback), token)
} | |
c12014 | parser.AddTransition(stateName, NewTransition(ParserStateStop, flags, callback), token)
} | |
c12015 | {
parser.tokens[stateID] = tcontainer.NewTrie([]byte(token), newTrans)
} else {
parser.tokens[stateID] = state.Add([]byte(token), newTrans)
}
} | |
c12016 | continueIdx
}
nextStateID := t.nextState
// Pop before push to allow both at the same time
if t.flags&ParserFlagPop != 0 {
stackLen := len(parser.stack)
if stackLen > 0 {
nextStateID = parser.stack[stackLen-1]
parser.stack = parser.stack[:stackLen-1]
}
}
if t.flags&ParserFlagPush != 0 {... | |
c12017 | uri.Address, portString, err = SplitAddress(addressString, defaultProtocol)
portNum, _ := strconv.ParseInt(portString, 10, 16)
uri.Port = uint16(portNum)
return uri, err
} | |
c12018 | switch errno {
default:
case syscall.ECONNRESET:
return true // ### return, close connection ###
}
}
}
return false
} | |
c12019 | "\x1b[" + strconv.Itoa(c.X) + ";" + strconv.Itoa(c.Y) + "H"
} | |
c12020 | atomic.AddInt32(&wg.counter, int32(delta))
} | |
c12021 | !atomic.CompareAndSwapInt32(&wg.counter, 0, 1) {
spin.Yield()
}
} | |
c12022 | wg.Active() {
spin.Yield()
}
} | |
c12023 | if time.Since(start) > timeout {
return false // ### return, timed out ###
}
spin.Yield()
}
return true
} | |
c12024 |
copy(messageCopy, message)
log.messages = append(log.messages, messageCopy)
}
return len(message), nil
} | |
c12025 |
for _, message := range log.messages {
writer.Write(message)
}
log.messages = [][]byte{}
} | |
c12026 | return b.largeSlab.getSlice(size)
case size <= huge:
return b.hugeSlab.getSlice(size)
default:
return make([]byte, size)
}
} | |
c12027 | true
}()
select {
case <-timeout.C:
return false
case <-callOk:
return true
}
} | |
c12028 | return RootUid, nil
default:
userInfo, err := user.Lookup(name)
if err != nil {
return 0, err
}
return strconv.Atoi(userInfo.Uid)
}
} | |
c12029 | return RootGid, nil
default:
groupInfo, err := user.LookupGroup(name)
if err != nil {
return 0, err
}
return strconv.Atoi(groupInfo.Gid)
}
} | |
c12030 | sync.NewCond(new(sync.Mutex)),
burned: new(int32),
}
} | |
c12031 | fuse.signal.L.Unlock()
if fuse.IsBurned() {
fuse.signal.Wait()
}
} | |
c12032 | > max {
max = b
}
if c > max {
max = c
}
return max
} | |
c12033 | if b > max {
max = b
}
if c > max {
max = c
}
return max
} | |
c12034 |
if b > max {
max = b
}
if c > max {
max = c
}
return max
} | |
c12035 | < min {
min = b
}
if c < min {
min = c
}
return min
} | |
c12036 | if b < min {
min = b
}
if c < min {
min = c
}
return min
} | |
c12037 |
if b < min {
min = b
}
if c < min {
min = c
}
return min
} | |
c12038 | isString := keyMeta.Interface().(string)
if !isString {
continue
}
if formatKey != nil {
strKey = formatKey(strKey)
}
val := valueMeta.MapIndex(keyMeta).Interface()
converted[strKey] = TryConvertToMarshalMap(val, formatKey)
}
return converted // ### return, converted MarshalMap ###
}
} | |
c12039 | := cloneMap(reflect.ValueOf(mmap))
return clone.Interface().(MarshalMap)
} | |
c12040 | return false, fmt.Errorf(`"%s" is expected to be a boolean`, key)
}
return boolValue, nil
} | |
c12041 | intVal, nil
}
return 0, fmt.Errorf(`"%s" is expected to be an unsigned number type`, key)
} | |
c12042 | not set`, key)
}
if intVal, isNumber := treflect.Int64(val); isNumber {
return intVal, nil
}
return 0, fmt.Errorf(`"%s" is expected to be a signed number type`, key)
} | |
c12043 | not set`, key)
}
if floatVal, isNumber := treflect.Float64(val); isNumber {
return floatVal, nil
}
return 0, fmt.Errorf(`"%s" is expected to be a signed number type`, key)
} | |
c12044 | case string:
return time.ParseDuration(val.(string))
}
return time.Duration(0), fmt.Errorf(`"%s" is expected to be a duration or string`, key)
} | |
c12045 | not set`, key)
}
strValue, isString := val.(string)
if !isString {
return "", fmt.Errorf(`"%s" is expected to be a string`, key)
}
return strValue, nil
} | |
c12046 | return mmap.StringArray(key)
} | |
c12047 | return mmap.Int64Array(key)
} | |
c12048 | (map[string][]string, error) {
return mmap.StringArrayMap(key)
} | |
c12049 | v != nil {
p.SetMapIndex(k, reflect.Value{})
}
})
} | |
c12050 | v interface{}) {
p.SetMapIndex(k, reflect.ValueOf(val))
})
} | |
c12051 | := clone(value)
return copy.Interface()
} | |
c12052 |
return BoolVar(flagVar, short, long, false, usage)
} | |
c12053 | flag.BoolVar(flagVar, long, value, usage)
addKeyDescription(short, long, value, usage)
return flagVar
} | |
c12054 | short, value, usage)
flag.IntVar(flagVar, long, value, usage)
addKeyDescription(short, long, value, usage)
return flagVar
} | |
c12055 | flag.Int64Var(flagVar, long, value, usage)
addKeyDescription(short, long, value, usage)
return flagVar
} | |
c12056 | flag.Float64Var(flagVar, long, value, usage)
addKeyDescription(short, long, value, usage)
return flagVar
} | |
c12057 | flag.StringVar(flagVar, long, value, usage)
addKeyDescription(short, long, value, usage)
return flagVar
} | |
c12058 | *bool {
var flagVar bool
return SwitchVar(&flagVar, short, long, usage)
} | |
c12059 | *bool {
flagVar := value
return BoolVar(&flagVar, short, long, value, usage)
} | |
c12060 | *int {
flagVar := value
return IntVar(&flagVar, short, long, value, usage)
} | |
c12061 | *int64 {
flagVar := value
return Int64Var(&flagVar, short, long, value, usage)
} | |
c12062 | *float64 {
flagVar := value
return Float64Var(&flagVar, short, long, value, usage)
} | |
c12063 | *string {
flagVar := value
return StringVar(&flagVar, short, long, value, usage)
} | |
c12064 | range descriptions {
fmt.Printf(valueFmt, desc.flagKey, desc.value, desc.usage)
}
} | |
c12065 | = 0
buffer.incomplete = true
} | |
c12066 | buffer.data[:buffer.end]
buffer.Reset(0)
return remains
} | |
c12067 | buffer.flags&BufferedReaderFlagEverything != 0 {
msgStartIdx = 0
}
return buffer.data[msgStartIdx:nextMsgIdx], nextMsgIdx
} | |
c12068 | data, nextMsgIdx := buffer.extractMessage(messageLen, 0)
if data != nil && buffer.flags&BufferedReaderFlagEverything == 0 {
nextMsgIdx += len(buffer.delimiter)
}
return data, nextMsgIdx
} | |
c12069 | err := binary.Read(reader, buffer.encoding, &messageLen)
if err != nil {
return nil, -1 // ### return, malformed ###
}
return buffer.extractMessage(int(messageLen), buffer.paramMLE+2)
} | |
c12070 | We're done if we have data before the match (incomplete message)
if startOffset > 0 || delimiterIdx[0] > 0 {
return buffer.extractMessage(delimiterIdx[0]+startOffset, 0) // ### done, start of line ###
}
// Found delimiter at start of data, look for the start of a second message.
// We don't need to add sta... | |
c12071 |
if err != nil {
return err // ### return, error ###
}
if !more {
return nil // ### return, done ###
}
}
} | |
c12072 | Warning: log.New(logLogger{Warning}, scopeMarker, 0),
Note: log.New(logLogger{Note}, scopeMarker, 0),
Debug: log.New(logLogger{Debug}, scopeMarker, 0),
}
} | |
c12073 | 0)
fallthrough
case VerbosityWarning:
Warning = log.New(&logEnabled, tfmt.Colorize(tfmt.Yellow, tfmt.NoBackground, "Warning: "), 0)
fallthrough
case VerbosityError:
Error = log.New(&logEnabled, tfmt.Colorize(tfmt.Red, tfmt.NoBackground, "ERROR: "), log.Lshortfile)
}
} | |
c12074 | logEnabled.writer = new(logCache)
}
} | |
c12075 | != nil {
return nil, err
}
socket.SetReadDeadline(time.Now().Add(5 * time.Second))
reader := bufio.NewReader(socket)
return http.ReadResponse(reader, req)
} | |
c12076 |
storeGuard: new(sync.RWMutex),
rateGuard: new(sync.RWMutex),
}
} | |
c12077 | int64) {
atomic.StoreInt64(met.get(name), value)
} | |
c12078 | atomic.AddInt64(met.get(name), 1)
} | |
c12079 | atomic.AddInt64(met.get(name), -1)
} | |
c12080 | atomic.AddInt64(met.get(name), value)
} | |
c12081 |
}
if rate := met.tryGetRate(name); rate != nil {
return *rate, nil
}
// Neither rate nor metric found
return 0, fmt.Errorf("Metric %s not found", name)
} | |
c12082 |
for key, rate := range met.rates {
snapshot[key] = rate.value
}
met.rateGuard.RUnlock()
return json.Marshal(snapshot)
} | |
c12083 | }
met.storeGuard.Unlock()
met.rateGuard.Lock()
for _, rate := range met.rates {
rate.lastSample = 0
rate.value = 0
rate.index = 0
rate.samples.Set(0)
}
met.rateGuard.Unlock()
} | |
c12084 | := met.rates[key]; exists {
rate.lastSample = 0
rate.value = 0
rate.index = 0
rate.samples.Set(0)
}
}
met.rateGuard.Unlock()
return state
} | |
c12085 |
met.SetB(MetricMemoryGCEnabled, stats.EnableGC)
met.Set(MetricMemoryNumObjects, int64(stats.HeapObjects))
} | |
c12086 | data,
children: []*TrieNode{},
longestPath: len(data),
PathLen: len(data),
Payload: payload,
}
} | |
c12087 |
callback(node)
for _, child := range node.children {
child.ForEach(callback)
}
} | |
c12088 | return nil // ### return, invalid match ###
}
data = data[suffixLen:]
numChildren := len(node.children)
for i := 0; i < numChildren; i++ {
matchedNode := node.children[i].Match(data)
if matchedNode != nil {
return matchedNode // ### return, match found ###
}
}
return nil // ### return, no valid path #... | |
c12089 | stack.errors = append(stack.errors, err)
return true
}
return false
} | |
c12090 | append(stack.errors, fmt.Errorf(message, args...))
} | |
c12091 | != nil {
stack.errors = append(stack.errors, fmt.Errorf(message+" %s", err.Error()))
return true
}
return false
} | |
c12092 | nil
}
err := stack.errors[len(stack.errors)-1]
stack.errors = stack.errors[:len(stack.errors)-1]
return err
} | |
c12093 |
return stack.formatter(stack.errors)
} | |
c12094 | i+1, errors[i].Error())
}
errString = fmt.Sprintf("%s%d: %s", errString, lastIdx+1, errors[lastIdx].Error())
return errString
} | |
c12095 | updates: time.NewTicker(time.Second),
}
} | |
c12096 |
metrics: m,
running: false,
updates: time.NewTicker(time.Second),
}
} | |
c12097 | err := server.listen.Close(); err != nil {
log.Print("Metrics: ", err)
}
}
} | |
c12098 |
read: newQueueAccess(),
write: newQueueAccess(),
locked: new(int32),
capacity: uint64(capacity),
spin: spinner,
}
} | |
c12099 | q.capacity
spin := q.spin
// Wait for pending reads on slot
for ticket-atomic.LoadUint64(q.read.processing) >= q.capacity {
spin.Yield()
}
q.items[slot] = item
// Wait for previous writers to finish writing
for ticket != atomic.LoadUint64(q.write.processing) {
spin.Yield()
}
atomic.AddUint64(q.write.pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.