id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c16200 |
_, err := mg.db.Exec(mg.dialect.dropTableSql(tn))
if err != nil && !mg.dialect.catchMigrationError(err) {
panic(err)
}
} | |
c16201 | executed on database which name has 'test' suffix")
}
mg.dropTableIfExists(strutPtr)
} | |
c16202 | + "_" + name
if !mg.dialect.indexExists(mg, tn, name) {
sql := mg.dialect.createIndexSql(name, tn, unique, columns...)
if mg.Log {
fmt.Println(sql)
}
_, err := mg.db.Exec(sql)
return err
}
return nil
} | |
c16203 | err := sql.Open(driver, driverSource)
if err != nil {
return nil, err
}
return &Migration{db, dbName, dial, false}, nil
} | |
c16204 |
return err
}
defer mg.Close()
return task(mg)
} | |
c16205 | database, err = sql.Open(driverName, driverSource)
if err != nil {
panic(err)
}
RegisterWithDb(driverName, database, dialect)
}
} | |
c16206 | < 0 {
connectionLimit = nil
}
blockingOnLimit = blocking
} | |
c16207 | q.tx = tx
q.txStmtMap = make(map[string]*sql.Stmt)
return err
} | |
c16208 | range q.txStmtMap {
v.Close()
}
q.txStmtMap = nil
return q.firstTxError
} | |
c16209 | v.Close()
}
q.txStmtMap = nil
return q.updateTxError(err)
} | |
c16210 | *Qbs {
q.criteria.condition = condition
return q
} | |
c16211 | *Qbs {
q.criteria.omitFields = fieldName
return q
} | |
c16212 | q.criteria.condition = idCondition
} else {
q.criteria.condition = idCondition.AndCondition(q.criteria.condition)
}
}
query, args := q.Dialect.querySql(q.criteria)
return q.doQueryRow(structPtr, query, args...)
} | |
c16213 | !q.criteria.omitJoin, q.criteria.omitFields)
query, args := q.Dialect.querySql(q.criteria)
return q.doQueryRows(ptrOfSliceOfStructPtr, query, args...)
} | |
c16214 | }
result, err := stmt.Exec(args...)
if err != nil {
return nil, q.updateTxError(err)
}
return result, nil
} | |
c16215 | nil {
q.updateTxError(err)
return nil
}
return stmt.QueryRow(args...)
} | |
c16216 |
if err != nil {
q.updateTxError(err)
return
}
return stmt.Query(args...)
} | |
c16217 | return
}
stmt, err = db.Prepare(query + ";")
if err != nil {
q.updateTxError(err)
return
}
mu.Lock()
stmtMap[query] = stmt
mu.Unlock()
}
return
} | |
c16218 |
structValue := reflect.Indirect(reflect.ValueOf(structPtr))
if _, ok := model.pk.value.(int64); ok && id != 0 {
idField := structValue.FieldByName(model.pk.camelName)
idField.SetInt(id)
}
if updateModelField != nil {
updateField := structValue.FieldByName(updateModelField.camelName)
updateField.Set... | |
c16219 | }
}
model := structPtrToModel(structPtr, true, q.criteria.omitFields)
q.criteria.model = model
q.criteria.mergePkCondition(q.Dialect)
if q.criteria.condition == nil {
panic("Can not update without condition")
}
return q.Dialect.update(q)
} | |
c16220 |
q.criteria.model = model
q.criteria.mergePkCondition(q.Dialect)
if q.criteria.condition == nil {
panic("Can not delete without condition")
}
return q.Dialect.delete(q)
} | |
c16221 | query := fmt.Sprintf("SELECT %v FROM %v WHERE %v = ?", quotedColumn, quotedTable, quotedColumn)
row := q.QueryRow(query, value)
var result interface{}
err := row.Scan(&result)
q.updateTxError(err)
return err == nil
} | |
c16222 | != nil {
return q.Rollback()
}
return nil
} | |
c16223 |
} else {
row = q.QueryRow(query)
}
var count int64
err := row.Scan(&count)
if err == sql.ErrNoRows {
return 0
} else if err != nil {
q.updateTxError(err)
}
return count
} | |
c16224 | len(mapSlice) == 1 {
return mapSlice[0], err
}
return nil, sql.ErrNoRows
} | |
c16225 | return q.doQueryMap(query, false, args...)
} | |
c16226 | } else { //query rows
rowStructPointer = reflect.New(structType)
}
dests := make([]interface{}, len(columns))
for i := 0; i < len(dests); i++ {
fieldName := fieldNames[i]
if fieldName == "-" {
var placeholder interface{}
dests[i] = &placeholder
} else {
field := rowStructPointer.Elem().F... | |
c16227 | q.prepare(query)
if err != nil {
return q.updateTxError(err)
}
rows, err := stmt.Query(args...)
if err != nil {
return q.updateTxError(err)
}
rowValue := reflect.ValueOf(structPtr)
defer rows.Close()
for rows.Next() {
err = q.scanRows(rowValue, rows)
if err != nil {
return err
}
if err = do(); e... | |
c16228 | len(strs))
for i := 0; i < len(strs); i++ {
ret[i] = strs[i]
}
return ret
} | |
c16229 | make(chan *consumer)
es.consumers = list.New()
es.timeout = settings.Timeout
es.idleTimeout = settings.IdleTimeout
es.closeOnTimeout = settings.CloseOnTimeout
es.gzip = settings.Gzip
go controlProcess(es)
return es
} | |
c16230 | var buf bytes.Buffer
err = tpl.Execute(&buf, o)
if err != nil {
return err
}
bo, err := format.Source(buf.Bytes())
if err != nil {
return err
}
return ioutil.WriteFile("example/all/main.go", bo, 0600)
} | |
c16231 | text, IsTerminal: isTerminal}
for _, option := range options {
option(&wow)
}
return &wow
} | |
c16232 |
w.done = done
w.running = true
go w.run(ctx)
}
} | |
c16233 | w.done()
}
w.running = false
} | |
c16234 |
w.s = s
w.Start()
return w
} | |
c16235 | = txt
w.mu.Unlock()
return w
} | |
c16236 | "\n"
if w.IsTerminal {
fmt.Fprint(w.out, txt)
}
} | |
c16237 | }
txt := erase + a + text + "\n"
if w.IsTerminal {
fmt.Fprint(w.out, txt)
}
} | |
c16238 |
err := json.Unmarshal(res.RawMpIms, &mpim)
if err != nil {
return nil, err
}
return mpim, nil
} | |
c16239 |
if cb(mpim) {
return mpim, nil
}
}
return nil, errors.New("No such mpim.")
} | |
c16240 | &groups)
if err != nil {
return nil, err
}
return groups, nil
} | |
c16241 | {
if cb(group) {
return group, nil
}
}
return nil, errors.New("No such group.")
} | |
c16242 | *Group) bool {
return group.Name == name
})
} | |
c16243 |
if cb(member) {
return member, nil
}
}
return nil, errors.New("No such user.")
} | |
c16244 | *User) bool {
return user.Name == name
})
} | |
c16245 | json.Unmarshal(res.RawChannels, &chs)
if err != nil {
return nil, err
}
return chs, nil
} | |
c16246 | {
if cb(channel) {
return channel, nil
}
}
return nil, errors.New("No such channel.")
} | |
c16247 | *Channel) bool {
return channel.Name == name
})
} | |
c16248 |
err := json.Unmarshal(res.RawIms, &im)
if err != nil {
return nil, err
}
return im, nil
} | |
c16249 |
if cb(im) {
return im, nil
}
}
return nil, errors.New("No such im.")
} | |
c16250 | return sl.FindIm(func(im *Im) bool {
return im.User == id
})
} | |
c16251 | // there cannot be a carry here.
z.norm()
return z
} | |
c16252 | is the same as adding b.
z[n] = x[n]
if z[0] <= ^big.Word(0)-b {
z[0] += b
} else {
addVW(z, z, b)
}
z.norm()
return z
} | |
c16253 | p.a[i] = make(nat, m)
copy(p.a[i], x)
break
}
p.a[i] = x[:m]
x = x[m:]
}
return p
} | |
c16254 | c := addVV(np[:l], np[:l], p.a[i])
if np[l] < ^big.Word(0) {
np[l] += c
} else {
addVW(np[l:], np[l:], c)
}
np = np[m:]
}
n = trim(n)
return n
} | |
c16255 | pv, qv := p.Transform(n), q.Transform(n)
rv := pv.Mul(&qv)
r := rv.InvTransform()
r.m = p.m
return r
} | |
c16256 | range q {
q[i] = fermat(qbits[i*(n+1) : (i+1)*(n+1)])
}
fourier(q, v.values, true, n, k)
// Divide by K, and untwist q to recover p.
u := make(fermat, n+1)
a := make([]nat, 1<<k)
for i := range q {
u.Shift(q[i], -int(k)-i*θshift)
copy(q[i], u)
a[i] = nat(q[i])
}
return poly{k: k, m: 0, a: a}
} | |
c16257 | idxShift] * x^(K-1)
// The P(x) = Q1(x²) + x*Q2(x²)
// where Q1's coefficients are src with indices shifted by 1
// where Q2's coefficients are src[1<<idxShift:] with indices shifted by 1
// Split destination vectors in halves.
dst1 := dst[:1<<(size-1)]
dst2 := dst[1<<(size-1):]
// Transform Q1 and Q2 i... | |
c16258 |
buf := make(fermat, 8*n)
for i := range r.values {
r.values[i] = bits[i*(n+1) : (i+1)*(n+1)]
z := buf.Mul(p.values[i], q.values[i])
copy(r.values[i], z)
}
return
} | |
c16259 |
name = allowName(name, slot)
return l.redis.Del(name).Err()
} | |
c16260 | period.Nanoseconds()
name = allowRateName(name, period, slot)
return l.redis.Del(name).Err()
} | |
c16261 | {
allow = l.Fallback.Allow()
}
name = allowName(name, slot)
count, err := l.incr(name, period, n)
if err == nil {
allow = count <= maxn
}
return count, delay, allow
} | |
c16262 | slot := now.UnixNano() / period.Nanoseconds()
name = allowRateName(name, period, slot)
count, err := l.incr(name, period, 1)
if err == nil {
allow = count <= limit
} else if l.Fallback != nil {
allow = l.Fallback.Allow()
}
if !allow {
delay = time.Duration(slot+1)*period - time.Duration(now.UnixNano())
... | |
c16263 |
// write the old path of the binary to the backup dir
err = ioutil.WriteFile(pathpath, []byte(loc), 0644)
if err != nil {
return "", fmt.Errorf("could not stash path: %s", err)
}
f := util.Move
if keep {
f = util.CopyTo
}
stump.VLog(" - moving %s to %s", loc, npath)
err = f(loc, npath)
if err != nil {... | |
c16264 | minor) ||
(verMajor == major && verMinor == minor && verMicro >= micro)
} | |
c16265 | 0 {
return 0, fmt.Errorf("API level operations are not supported")
}
return uint(api), nil
} | |
c16266 | operations are not supported")
}
return fmt.Errorf("could not set API level: %v", retCode)
}
return nil
} | |
c16267 |
retCode := C.seccomp_attr_get(f.filterCtx, attr.toNative(), &attribute)
if retCode != 0 {
return 0x0, syscall.Errno(-1 * retCode)
}
return attribute, nil
} | |
c16268 |
retCode := C.seccomp_attr_set(f.filterCtx, attr.toNative(), value)
if retCode != 0 {
return syscall.Errno(-1 * retCode)
}
return nil
} | |
c16269 | else {
retCode = C.seccomp_rule_add_array(f.filterCtx, action.toNative(), C.int(call), length, cond)
}
if syscall.Errno(-1*retCode) == syscall.EFAULT {
return fmt.Errorf("unrecognized syscall %#x", int32(call))
} else if syscall.Errno(-1*retCode) == syscall.EPERM {
return fmt.Errorf("requested action matches... | |
c16270 | return VersionError{
message: "conditional filtering is not supported",
minimum: "2.2.1",
}
}
argsArr := C.make_arg_cmp_array(C.uint(len(conds)))
if argsArr == nil {
return fmt.Errorf("error allocating memory for conditions")
}
defer C.free(argsArr)
for i, cond := range conds {
C.add_str... | |
c16271 | C.C_ARCH_BAD {
return fmt.Errorf("architecture %v is not supported on this version of the library", in)
}
return nil
} | |
c16272 |
case CompareGreater:
return C.C_CMP_GT
case CompareMaskedEqual:
return C.C_CMP_MASKED_EQ
default:
return 0x0
}
} | |
c16273 | return C.C_ACT_ERRNO | (C.uint32_t(a) >> 16)
case ActTrace:
return C.C_ACT_TRACE | (C.uint32_t(a) >> 16)
case ActLog:
return C.C_ACT_LOG
case ActAllow:
return C.C_ACT_ALLOW
default:
return 0x0
}
} | |
c16274 | case filterAttrTsync:
return uint32(C.C_ATTRIBUTE_TSYNC)
case filterAttrLog:
return uint32(C.C_ATTRIBUTE_LOG)
default:
return 0x0
}
} | |
c16275 |
return ArchMIPSEL64, nil
case "mipsel64n32":
return ArchMIPSEL64N32, nil
case "ppc":
return ArchPPC, nil
case "ppc64":
return ArchPPC64, nil
case "ppc64le":
return ArchPPC64LE, nil
case "s390":
return ArchS390, nil
case "s390x":
return ArchS390X, nil
default:
return ArchInvalid, fmt.Errorf("cann... | |
c16276 | case ArchPPC64LE:
return "ppc64le"
case ArchS390:
return "s390"
case ArchS390X:
return "s390x"
case ArchNative:
return "native"
case ArchInvalid:
return "Invalid architecture"
default:
return fmt.Sprintf("Unknown architecture %#x", uint(a))
}
} | |
c16277 | return "Greater than"
case CompareMaskedEqual:
return "Masked equality"
case CompareInvalid:
return "Invalid comparison operator"
default:
return fmt.Sprintf("Unrecognized comparison operator %#x", uint(a))
}
} | |
c16278 | %d",
(a >> 16))
case ActLog:
return "Action: Log system call"
case ActAllow:
return "Action: Allow system call"
default:
return fmt.Sprintf("Unrecognized Action %#x", uint(a))
}
} | |
c16279 | {
return (aTmp | (ScmpAction(code)&0xFFFF)<<16)
}
return a
} | |
c16280 |
if cString == nil {
return "", fmt.Errorf("could not resolve syscall name for %#x", int32(s))
}
defer C.free(unsafe.Pointer(cString))
finalStr := C.GoString(cString)
return finalStr, nil
} | |
c16281 | if result == scmpError {
return 0, fmt.Errorf("could not resolve name to syscall: %q", name)
}
return ScmpSyscall(result), nil
} | |
c16282 | err
}
cString := C.CString(name)
defer C.free(unsafe.Pointer(cString))
result := C.seccomp_syscall_resolve_name_arch(arch.toNative(), cString)
if result == scmpError {
return 0, fmt.Errorf("could not resolve name to syscall: %q on %v", name, arch)
}
return ScmpSyscall(result), nil
} | |
c16283 | != nil {
return ArchInvalid, err
}
arch := C.seccomp_arch_native()
return archFromNative(arch)
} | |
c16284 | does not support TSYNC, allow us to continue without error
if err := filter.setFilterAttr(filterAttrTsync, 0x1); err != nil && err != syscall.ENOTSUP {
filter.Release()
return nil, fmt.Errorf("could not create filter - error setting tsync bit: %v", err)
}
return filter, nil
} | |
c16285 | }
retCode := C.seccomp_reset(f.filterCtx, defaultAction.toNative())
if retCode != 0 {
return syscall.Errno(-1 * retCode)
}
return nil
} | |
c16286 | and the
// architecture is present already.
retCode := C.seccomp_arch_add(f.filterCtx, arch.toNative())
if retCode != 0 && syscall.Errno(-1*retCode) != syscall.EEXIST {
return syscall.Errno(-1 * retCode)
}
return nil
} | |
c16287 | C.seccomp_load(f.filterCtx); retCode != 0 {
return syscall.Errno(-1 * retCode)
}
return nil
} | |
c16288 | f.getFilterAttr(filterAttrActDefault)
if err != nil {
return 0x0, err
}
return actionFromNative(action)
} | |
c16289 | f.getFilterAttr(filterAttrActBadArch)
if err != nil {
return 0x0, err
}
return actionFromNative(action)
} | |
c16290 | bit is only supported in libseccomp 2.4.0 and newer with API level 3 or higher")
}
return false, err
}
if log == 0 {
return false, nil
}
return true, nil
} | |
c16291 | }
return f.setFilterAttr(filterAttrActBadArch, action.toNative())
} | |
c16292 | toSet = 0x1
}
return f.setFilterAttr(filterAttrNNP, toSet)
} | |
c16293 | {
api, apiErr := getApi()
if (apiErr != nil && api == 0) || (apiErr == nil && api < 3) {
return fmt.Errorf("setting the log bit is only supported in libseccomp 2.4.0 and newer with API level 3 or higher")
}
}
return err
} | |
c16294 | return f.addRuleGeneric(call, action, false, nil)
} | |
c16295 | {
return f.addRuleGeneric(call, action, false, conds)
} | |
c16296 | {
log.Printf("Post error: %s\n", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println("Read error: could not read body: %s", err)
return
}
err = json.Unmarshal(body, &r)
if err != nil {
log.Println("Read error: got invalid JSON: %s", err)
return
}... | |
c16297 | error) {
resp, err := check(remoteip, response)
result = resp.Success
return
} | |
c16298 | w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
if !ok || !(credentials.Password == password && user == credentials.User) {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("invalid credentials"))
return
}
next.ServeHTTP(w, r)
}
} | |
c16299 |
return
}
proxyReq, err := buildProxyRequest(originalReq, functionAddr, pathVars["params"])
if err != nil {
writeError(w, http.StatusInternalServerError, "Failed to resolve service: %s.", functionName)
return
}
defer proxyReq.Body.Close()
start := time.Now()
response, err := proxyClient.Do(proxyReq.WithC... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.