_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20100 | TeamAppCollaboratorList | train | func (s *Service) TeamAppCollaboratorList(ctx context.Context, teamAppIdentity string, lr *ListRange) (TeamAppCollaboratorListResult, error) {
var teamAppCollaborator TeamAppCollaboratorListResult
return teamAppCollaborator, s.Get(ctx, &teamAppCollaborator, fmt.Sprintf("/teams/apps/%v/collaborators", teamAppIdentity)... | go | {
"resource": ""
} |
q20101 | TeamAppPermissionList | train | func (s *Service) TeamAppPermissionList(ctx context.Context, lr *ListRange) (TeamAppPermissionListResult, error) {
var teamAppPermission TeamAppPermissionListResult
return teamAppPermission, s.Get(ctx, &teamAppPermission, fmt.Sprintf("/teams/permissions"), nil, lr)
} | go | {
"resource": ""
} |
q20102 | TeamFeatureInfo | train | func (s *Service) TeamFeatureInfo(ctx context.Context, teamIdentity string, teamFeatureIdentity string) (*TeamFeature, error) {
var teamFeature TeamFeature
return &teamFeature, s.Get(ctx, &teamFeature, fmt.Sprintf("/teams/%v/features/%v", teamIdentity, teamFeatureIdentity), nil, nil)
} | go | {
"resource": ""
} |
q20103 | TeamFeatureList | train | func (s *Service) TeamFeatureList(ctx context.Context, teamIdentity string, lr *ListRange) (TeamFeatureListResult, error) {
var teamFeature TeamFeatureListResult
return teamFeature, s.Get(ctx, &teamFeature, fmt.Sprintf("/teams/%v/features", teamIdentity), nil, lr)
} | go | {
"resource": ""
} |
q20104 | TeamInvitationCreate | train | func (s *Service) TeamInvitationCreate(ctx context.Context, teamIdentity string, o TeamInvitationCreateOpts) (*TeamInvitation, error) {
var teamInvitation TeamInvitation
return &teamInvitation, s.Put(ctx, &teamInvitation, fmt.Sprintf("/teams/%v/invitations", teamIdentity), o)
} | go | {
"resource": ""
} |
q20105 | TeamInvitationRevoke | train | func (s *Service) TeamInvitationRevoke(ctx context.Context, teamIdentity string, teamInvitationIdentity string) (*TeamInvitation, error) {
var teamInvitation TeamInvitation
return &teamInvitation, s.Delete(ctx, &teamInvitation, fmt.Sprintf("/teams/%v/invitations/%v", teamIdentity, teamInvitationIdentity))
} | go | {
"resource": ""
} |
q20106 | TeamInvitationAccept | train | func (s *Service) TeamInvitationAccept(ctx context.Context, teamInvitationToken string) (*TeamInvitationAcceptResult, error) {
var teamInvitation TeamInvitationAcceptResult
return &teamInvitation, s.Post(ctx, &teamInvitation, fmt.Sprintf("/teams/invitations/%v/accept", teamInvitationToken), nil)
} | go | {
"resource": ""
} |
q20107 | TeamMemberCreateOrUpdate | train | func (s *Service) TeamMemberCreateOrUpdate(ctx context.Context, teamIdentity string, o TeamMemberCreateOrUpdateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Put(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | go | {
"resource": ""
} |
q20108 | TeamMemberCreate | train | func (s *Service) TeamMemberCreate(ctx context.Context, teamIdentity string, o TeamMemberCreateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Post(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | go | {
"resource": ""
} |
q20109 | TeamMemberUpdate | train | func (s *Service) TeamMemberUpdate(ctx context.Context, teamIdentity string, o TeamMemberUpdateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Patch(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | go | {
"resource": ""
} |
q20110 | TeamMemberDelete | train | func (s *Service) TeamMemberDelete(ctx context.Context, teamIdentity string, teamMemberIdentity string) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Delete(ctx, &teamMember, fmt.Sprintf("/teams/%v/members/%v", teamIdentity, teamMemberIdentity))
} | go | {
"resource": ""
} |
q20111 | TeamMemberList | train | func (s *Service) TeamMemberList(ctx context.Context, teamIdentity string, lr *ListRange) (TeamMemberListResult, error) {
var teamMember TeamMemberListResult
return teamMember, s.Get(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), nil, lr)
} | go | {
"resource": ""
} |
q20112 | TeamMemberListByMember | train | func (s *Service) TeamMemberListByMember(ctx context.Context, teamIdentity string, teamMemberIdentity string, lr *ListRange) (TeamMemberListByMemberResult, error) {
var teamMember TeamMemberListByMemberResult
return teamMember, s.Get(ctx, &teamMember, fmt.Sprintf("/teams/%v/members/%v/apps", teamIdentity, teamMemberI... | go | {
"resource": ""
} |
q20113 | TeamPreferencesList | train | func (s *Service) TeamPreferencesList(ctx context.Context, teamPreferencesIdentity string) (*TeamPreferences, error) {
var teamPreferences TeamPreferences
return &teamPreferences, s.Get(ctx, &teamPreferences, fmt.Sprintf("/teams/%v/preferences", teamPreferencesIdentity), nil, nil)
} | go | {
"resource": ""
} |
q20114 | TeamPreferencesUpdate | train | func (s *Service) TeamPreferencesUpdate(ctx context.Context, teamPreferencesIdentity string, o TeamPreferencesUpdateOpts) (*TeamPreferences, error) {
var teamPreferences TeamPreferences
return &teamPreferences, s.Patch(ctx, &teamPreferences, fmt.Sprintf("/teams/%v/preferences", teamPreferencesIdentity), o)
} | go | {
"resource": ""
} |
q20115 | UserPreferencesList | train | func (s *Service) UserPreferencesList(ctx context.Context, userPreferencesIdentity string) (*UserPreferences, error) {
var userPreferences UserPreferences
return &userPreferences, s.Get(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), nil, nil)
} | go | {
"resource": ""
} |
q20116 | UserPreferencesUpdate | train | func (s *Service) UserPreferencesUpdate(ctx context.Context, userPreferencesIdentity string, o UserPreferencesUpdateOpts) (*UserPreferences, error) {
var userPreferences UserPreferences
return &userPreferences, s.Patch(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), o)
} | go | {
"resource": ""
} |
q20117 | VPNConnectionCreate | train | func (s *Service) VPNConnectionCreate(ctx context.Context, spaceIdentity string, o VPNConnectionCreateOpts) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Post(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections", spaceIdentity), o)
} | go | {
"resource": ""
} |
q20118 | VPNConnectionDestroy | train | func (s *Service) VPNConnectionDestroy(ctx context.Context, spaceIdentity string, vpnConnectionIdentity string) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Delete(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections/%v", spaceIdentity, vpnConnectionIdentity))
} | go | {
"resource": ""
} |
q20119 | VPNConnectionList | train | func (s *Service) VPNConnectionList(ctx context.Context, spaceIdentity string, lr *ListRange) (VPNConnectionListResult, error) {
var vpnConnection VPNConnectionListResult
return vpnConnection, s.Get(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections", spaceIdentity), nil, lr)
} | go | {
"resource": ""
} |
q20120 | VPNConnectionInfo | train | func (s *Service) VPNConnectionInfo(ctx context.Context, spaceIdentity string, vpnConnectionIdentity string) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Get(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections/%v", spaceIdentity, vpnConnectionIdentity), nil, nil)
} | go | {
"resource": ""
} |
q20121 | WhitelistedAddOnServiceListByOrganization | train | func (s *Service) WhitelistedAddOnServiceListByOrganization(ctx context.Context, organizationIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByOrganizationResult, error) {
var whitelistedAddOnService WhitelistedAddOnServiceListByOrganizationResult
return whitelistedAddOnService, s.Get(ctx, &whitelistedAdd... | go | {
"resource": ""
} |
q20122 | WhitelistedAddOnServiceListByTeam | train | func (s *Service) WhitelistedAddOnServiceListByTeam(ctx context.Context, teamIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByTeamResult, error) {
var whitelistedAddOnService WhitelistedAddOnServiceListByTeamResult
return whitelistedAddOnService, s.Get(ctx, &whitelistedAddOnService, fmt.Sprintf("/teams/%... | go | {
"resource": ""
} |
q20123 | CancelRequest | train | func (t *Transport) CancelRequest(req *http.Request) {
type canceler interface {
CancelRequest(*http.Request)
}
tr, ok := t.Transport.(canceler)
if !ok {
log.Printf("heroku: Client Transport of type %T doesn't support CancelRequest; Timeout not supported\n", t.Transport)
return
}
tr.CancelRequest(req)
} | go | {
"resource": ""
} |
q20124 | NewContextManager | train | func NewContextManager() *ContextManager {
mgr := &ContextManager{values: make(map[uint]Values)}
mgrRegistryMtx.Lock()
defer mgrRegistryMtx.Unlock()
mgrRegistry[mgr] = true
return mgr
} | go | {
"resource": ""
} |
q20125 | Unregister | train | func (m *ContextManager) Unregister() {
mgrRegistryMtx.Lock()
defer mgrRegistryMtx.Unlock()
delete(mgrRegistry, m)
} | go | {
"resource": ""
} |
q20126 | GetValue | train | func (m *ContextManager) GetValue(key interface{}) (
value interface{}, ok bool) {
gid, ok := GetGoroutineId()
if !ok {
return nil, false
}
m.mtx.Lock()
state, found := m.values[gid]
m.mtx.Unlock()
if !found {
return nil, false
}
value, ok = state[key]
return value, ok
} | go | {
"resource": ""
} |
q20127 | Go | train | func Go(cb func()) {
mgrRegistryMtx.RLock()
defer mgrRegistryMtx.RUnlock()
for mgr := range mgrRegistry {
values := mgr.getValues()
if len(values) > 0 {
cb = func(mgr *ContextManager, cb func()) func() {
return func() { mgr.SetValues(values, cb) }
}(mgr, cb)
}
}
go cb()
} | go | {
"resource": ""
} |
q20128 | GenSym | train | func GenSym() ContextKey {
keyMtx.Lock()
defer keyMtx.Unlock()
keyCounter += 1
return ContextKey{id: keyCounter}
} | go | {
"resource": ""
} |
q20129 | EnsureGoroutineId | train | func EnsureGoroutineId(cb func(gid uint)) {
if gid, ok := readStackTag(); ok {
cb(gid)
return
}
gid := stackTagPool.Acquire()
defer stackTagPool.Release(gid)
addStackTag(gid, func() { cb(gid) })
} | go | {
"resource": ""
} |
q20130 | handler | train | func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error {
// little bit of gRPC internals never hurt anyone
fullMethodName, ok := grpc.MethodFromServerStream(serverStream)
if !ok {
return grpc.Errorf(codes.Internal, "lowLevelServerStream not exists in context")
}
// We require that the d... | go | {
"resource": ""
} |
q20131 | AddRef | train | func (f *Footer) AddRef() {
f.m.Lock()
f.refs++
f.m.Unlock()
} | go | {
"resource": ""
} |
q20132 | DecRef | train | func (f *Footer) DecRef() {
f.m.Lock()
f.refs--
if f.refs <= 0 {
f.SegmentLocs.DecRef()
f.SegmentLocs = nil
f.ss = nil
}
f.m.Unlock()
} | go | {
"resource": ""
} |
q20133 | Length | train | func (f *Footer) Length() uint64 {
jBuf, err := json.Marshal(f)
if err != nil {
return 0
}
footerLen := footerBegLen + len(jBuf) + footerEndLen
return uint64(footerLen)
} | go | {
"resource": ""
} |
q20134 | Stats | train | func (m *collection) Stats() (*CollectionStats, error) {
rv := &CollectionStats{}
m.stats.AtomicCopyTo(rv)
m.m.Lock()
m.statsSegmentsLOCKED(rv)
m.m.Unlock()
return rv, nil
} | go | {
"resource": ""
} |
q20135 | statsSegmentsLOCKED | train | func (m *collection) statsSegmentsLOCKED(rv *CollectionStats) {
var sssDirtyTop *SegmentStackStats
var sssDirtyMid *SegmentStackStats
var sssDirtyBase *SegmentStackStats
var sssClean *SegmentStackStats
if m.stackDirtyTop != nil {
sssDirtyTop = m.stackDirtyTop.Stats()
}
if m.stackDirtyMid != nil {
sssDirtyM... | go | {
"resource": ""
} |
q20136 | buildNewFooter | train | func (s *Store) buildNewFooter(storeFooter *Footer, ss *segmentStack) *Footer {
footer := &Footer{refs: 1, incarNum: ss.incarNum}
numSegmentLocs := len(ss.a)
var segmentLocs []SegmentLoc
if storeFooter != nil {
numSegmentLocs += len(storeFooter.SegmentLocs)
segmentLocs = make([]SegmentLoc, 0, numSegmentLocs)
... | go | {
"resource": ""
} |
q20137 | persistSegments | train | func (s *Store) persistSegments(ss *segmentStack, footer *Footer,
file File, fref *FileRef) error {
// First persist the child segments recursively.
for cName, childSegStack := range ss.childSegStacks {
err := s.persistSegments(childSegStack, footer.ChildFooters[cName],
file, fref)
if err != nil {
return e... | go | {
"resource": ""
} |
q20138 | removeFileOnClose | train | func (s *Store) removeFileOnClose(fref *FileRef) (os.FileInfo, error) {
finfo, err := fref.file.Stat()
if err != nil {
return nil, err
}
if len(finfo.Name()) > 0 {
fref.OnAfterClose(func() {
fileName := finfo.Name()
go func() {
s.m.Lock()
delete(s.fileRefMap, fileName)
s.m.Unlock()
err :=... | go | {
"resource": ""
} |
q20139 | pageOffset | train | func pageOffset(pos, pageSize int64) int64 {
rem := pos % pageSize
if rem != 0 {
return pos - rem
}
return pos
} | go | {
"resource": ""
} |
q20140 | Stats | train | func (s *Store) Stats() (map[string]interface{}, error) {
finfos, err := ioutil.ReadDir(s.dir)
if err != nil {
return nil, err
}
var numBytesUsedDisk uint64
for _, finfo := range finfos {
if !finfo.IsDir() {
numBytesUsedDisk += uint64(finfo.Size())
}
}
s.m.Lock()
totPersists := s.totPersists
totComp... | go | {
"resource": ""
} |
q20141 | Histograms | train | func (s *Store) Histograms() ghistogram.Histograms {
histogramsSnapshot := make(ghistogram.Histograms)
histogramsSnapshot.AddAll(s.histograms)
return histogramsSnapshot
} | go | {
"resource": ""
} |
q20142 | Close | train | func (m *collection) Close() error {
m.fireEvent(EventKindCloseStart, 0)
startTime := time.Now()
defer func() {
m.fireEvent(EventKindClose, time.Now().Sub(startTime))
}()
atomic.AddUint64(&m.stats.TotCloseBeg, 1)
m.m.Lock()
m.invalidateLatestSnapshotLOCKED()
close(m.stopCh)
m.stackDirtyTopCond.Broadcast... | go | {
"resource": ""
} |
q20143 | Snapshot | train | func (m *collection) Snapshot() (rv Snapshot, err error) {
m.m.Lock()
rv = reuseSnapshot(m.latestSnapshot)
if rv == nil { // No cached snapshot.
rv, err = m.newSnapshotLOCKED()
if err == nil {
// collection holds 1 ref count for its cached snapshot copy.
m.latestSnapshot = reuseSnapshot(rv)
}
}
m.m.Unl... | go | {
"resource": ""
} |
q20144 | newSnapshotLOCKED | train | func (m *collection) newSnapshotLOCKED() (Snapshot, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotSnapshotBeg, 1)
rv, _, _, _, _ := m.snapshot(0, nil, true) // collection lock already held.
atomic.AddUint64(&m.stats.TotSnapshotEnd, 1)
return rv, nil
} | go | {
"resource": ""
} |
q20145 | Get | train | func (m *collection) Get(key []byte, readOptions ReadOptions) ([]byte, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotGet, 1)
val, err := m.get(key, readOptions)
if err != nil {
atomic.AddUint64(&m.stats.TotGetErr, 1)
}
return val, err
} | go | {
"resource": ""
} |
q20146 | NewBatch | train | func (m *collection) NewBatch(totalOps, totalKeyValBytes int) (
Batch, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotNewBatch, 1)
atomic.AddUint64(&m.stats.TotNewBatchTotalOps, uint64(totalOps))
atomic.AddUint64(&m.stats.TotNewBatchTotalKeyValBytes, uint64(totalKeyValBytes))
... | go | {
"resource": ""
} |
q20147 | appendChildLLSnapshot | train | func (m *collection) appendChildLLSnapshot(dst *segmentStack,
src Snapshot) *segmentStack {
if m.incarNum != 0 {
dst.lowerLevelSnapshot = NewSnapshotWrapper(src, nil)
}
for cName, childCollection := range m.childCollections {
dstChildStack := childCollection.getOrInitChildStack(dst, cName)
var childSnap Sna... | go | {
"resource": ""
} |
q20148 | appendChildStacks | train | func (m *collection) appendChildStacks(dst, src *segmentStack) *segmentStack {
if src == nil {
return dst
}
dst.a = append(dst.a, src.a...)
for cName, srcChildStack := range src.childSegStacks {
childCollection, exists := m.childCollections[cName]
if !exists || // This child collection was dropped recently,... | go | {
"resource": ""
} |
q20149 | nextDelta | train | func (c *segmentCursor) nextDelta(delta int) error {
c.curr += delta
if c.curr >= c.end {
return ErrIteratorDone
}
return nil
} | go | {
"resource": ""
} |
q20150 | currentKey | train | func (c *segmentCursor) currentKey() (idx int, key []byte) {
if c.curr >= c.start && c.curr < c.end {
idx = c.curr
_, key, _ = c.s.getOperationKeyVal(c.curr)
}
return
} | go | {
"resource": ""
} |
q20151 | searchIndex | train | func (a *segment) searchIndex(key []byte) (int, int) {
if a.index != nil {
// Check the in-memory index for a more accurate window.
return a.index.lookup(key)
}
return 0, a.Len()
} | go | {
"resource": ""
} |
q20152 | FullMerge | train | func (mo *MergeOperatorStringAppend) FullMerge(key, existingValue []byte,
operands [][]byte) ([]byte, bool) {
mo.m.Lock()
mo.numFull++
mo.m.Unlock()
s := string(existingValue)
for _, operand := range operands {
s = s + mo.Sep + string(operand)
}
return []byte(s), true
} | go | {
"resource": ""
} |
q20153 | PartialMerge | train | func (mo *MergeOperatorStringAppend) PartialMerge(key,
leftOperand, rightOperand []byte) ([]byte, bool) {
mo.m.Lock()
mo.numPartial++
mo.m.Unlock()
return []byte(string(leftOperand) + mo.Sep + string(rightOperand)), true
} | go | {
"resource": ""
} |
q20154 | OnAfterClose | train | func (r *FileRef) OnAfterClose(cb func()) {
r.m.Lock()
r.afterCloseCallbacks = append(r.afterCloseCallbacks, cb)
r.m.Unlock()
} | go | {
"resource": ""
} |
q20155 | AddRef | train | func (r *FileRef) AddRef() File {
if r == nil {
return nil
}
r.m.Lock()
r.refs++
file := r.file
r.m.Unlock()
return file
} | go | {
"resource": ""
} |
q20156 | DecRef | train | func (r *FileRef) DecRef() (err error) {
if r == nil {
return nil
}
r.m.Lock()
r.refs--
if r.refs <= 0 {
for _, cb := range r.beforeCloseCallbacks {
cb()
}
r.beforeCloseCallbacks = nil
err = r.file.Close()
for _, cb := range r.afterCloseCallbacks {
cb()
}
r.afterCloseCallbacks = nil
r.... | go | {
"resource": ""
} |
q20157 | FetchRefCount | train | func (r *FileRef) FetchRefCount() int {
if r == nil {
return 0
}
r.m.Lock()
ref := r.refs
r.m.Unlock()
return ref
} | go | {
"resource": ""
} |
q20158 | ToOsFile | train | func ToOsFile(f File) *os.File {
if osFile, ok := f.(*os.File); ok {
return osFile
}
if osFile2, ok := f.(OsFile); ok {
return osFile2.OsFile()
}
return nil
} | go | {
"resource": ""
} |
q20159 | add | train | func (s *segmentKeysIndex) add(keyIdx int, key []byte) bool {
if s.numKeys >= s.numIndexableKeys {
// All keys that can be indexed already have been,
// return false indicating that there's no room for
// anymore.
return false
}
if len(key) > (len(s.data) - s.numKeyBytes) {
// No room for any more keys.
... | go | {
"resource": ""
} |
q20160 | lookup | train | func (s *segmentKeysIndex) lookup(key []byte) (leftPos int, rightPos int) {
i, j := 0, s.numKeys
if i == j || s.numKeys < 2 {
// The index either wasn't used or isn't of any use.
rightPos = s.srcKeyCount
return
}
// If key smaller than the first key, return early.
keyStart := s.offsets[0]
keyEnd := s.offs... | go | {
"resource": ""
} |
q20161 | AddTo | train | func (sss *SegmentStackStats) AddTo(dest *SegmentStackStats) {
if sss == nil {
return
}
dest.CurOps += sss.CurOps
dest.CurBytes += sss.CurBytes
dest.CurSegments += sss.CurSegments
} | go | {
"resource": ""
} |
q20162 | Stats | train | func (ss *segmentStack) Stats() *SegmentStackStats {
rv := &SegmentStackStats{CurSegments: uint64(len(ss.a))}
for _, seg := range ss.a {
rv.CurOps += uint64(seg.Len())
nk, nv := seg.NumKeyValBytes()
rv.CurBytes += nk + nv
}
return rv
} | go | {
"resource": ""
} |
q20163 | ensureFullySorted | train | func (ss *segmentStack) ensureFullySorted() {
ss.ensureSorted(0, len(ss.a)-1)
for _, childSnapshot := range ss.childSegStacks {
childSnapshot.ensureFullySorted()
}
} | go | {
"resource": ""
} |
q20164 | Get | train | func (w *SnapshotWrapper) Get(key []byte, readOptions ReadOptions) (
[]byte, error) {
return w.ss.Get(key, readOptions)
} | go | {
"resource": ""
} |
q20165 | StartIterator | train | func (w *SnapshotWrapper) StartIterator(
startKeyInclusive, endKeyExclusive []byte,
iteratorOptions IteratorOptions,
) (Iterator, error) {
return w.ss.StartIterator(startKeyInclusive, endKeyExclusive,
iteratorOptions)
} | go | {
"resource": ""
} |
q20166 | AddRef | train | func (slocs SegmentLocs) AddRef() {
for _, sloc := range slocs {
if sloc.mref != nil {
sloc.mref.AddRef()
}
}
} | go | {
"resource": ""
} |
q20167 | DecRef | train | func (slocs SegmentLocs) DecRef() {
for _, sloc := range slocs {
if sloc.mref != nil {
sloc.mref.DecRef()
}
}
} | go | {
"resource": ""
} |
q20168 | AddRef | train | func (s *Store) AddRef() {
s.m.Lock()
s.refs++
s.m.Unlock()
} | go | {
"resource": ""
} |
q20169 | Close | train | func (s *Store) Close() error {
s.m.Lock()
defer s.m.Unlock()
s.refs--
if s.refs > 0 || s.footer == nil {
return nil
}
footer := s.footer
s.footer = nil
return footer.Close()
} | go | {
"resource": ""
} |
q20170 | CloseEx | train | func (s *Store) CloseEx(options StoreCloseExOptions) error {
if options.Abort {
close(s.abortCh)
}
return s.Close()
} | go | {
"resource": ""
} |
q20171 | delta | train | func delta(cb func(c *smatContext)) func(ctx smat.Context) (next smat.State, err error) {
return func(ctx smat.Context) (next smat.State, err error) {
c := ctx.(*smatContext)
cb(c)
if c.curBatch < 0 {
c.curBatch = 1000
}
if c.curSnapshot < 0 {
c.curSnapshot = 1000
}
if c.curIterator < 0 {
c.curI... | go | {
"resource": ""
} |
q20172 | HandleRequest | train | func (r *Router) HandleRequest(ctx *fasthttp.RequestCtx) {
c := r.pool.Get().(*Context)
c.init(ctx)
c.handlers, c.pnames = r.find(string(ctx.Method()), string(ctx.Path()), c.pvalues)
if err := c.Next(); err != nil {
r.handleError(c, err)
}
r.pool.Put(c)
} | go | {
"resource": ""
} |
q20173 | handleError | train | func (r *Router) handleError(c *Context, err error) {
if httpError, ok := err.(HTTPError); ok {
c.Error(httpError.Error(), httpError.StatusCode())
} else {
c.Error(err.Error(), http.StatusInternalServerError)
}
} | go | {
"resource": ""
} |
q20174 | Patch | train | func (r *RouteGroup) Patch(path string, handlers ...Handler) *Route {
return newRoute(path, r).Patch(handlers...)
} | go | {
"resource": ""
} |
q20175 | URL | train | func (c *Context) URL(route string, pairs ...interface{}) string {
if r := c.router.routes[route]; r != nil {
return r.URL(pairs...)
}
return ""
} | go | {
"resource": ""
} |
q20176 | Serialize | train | func Serialize(data interface{}) (bytes []byte, err error) {
switch data.(type) {
case []byte:
return data.([]byte), nil
case string:
return []byte(data.(string)), nil
default:
if data != nil {
return []byte(fmt.Sprint(data)), nil
}
}
return nil, nil
} | go | {
"resource": ""
} |
q20177 | add | train | func (r *Route) add(method string, handlers []Handler) *Route {
hh := combineHandlers(r.group.handlers, handlers)
r.group.router.add(method, r.path, hh)
return r
} | go | {
"resource": ""
} |
q20178 | buildURLTemplate | train | func buildURLTemplate(path string) string {
template, start, end := "", -1, -1
for i := 0; i < len(path); i++ {
if path[i] == '<' && start < 0 {
start = i
} else if path[i] == '>' && start >= 0 {
name := path[start+1 : i]
for j := start + 1; j < i; j++ {
if path[j] == ':' {
name = path[start+1 :... | go | {
"resource": ""
} |
q20179 | ioctl | train | func ioctl(fd, name, data uintptr) error {
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(name), uintptr(data))
if e != 0 {
return e
}
return nil
} | go | {
"resource": ""
} |
q20180 | Notify | train | func Notify(title, message, appIcon string) (err error) {
defer func() {
e := recover()
if e == nil {
return
}
if e, ok := e.(*js.Error); ok {
err = e
} else {
panic(e)
}
}()
n := js.Global().Get("Notification")
opts := js.Global().Get("Object").Invoke()
opts.Set("body", message)
opts.Set... | go | {
"resource": ""
} |
q20181 | Alert | train | func Alert(title, message, appIcon string) error {
if err := Notify(title, message, appIcon); err != nil {
return err
}
return Beep(DefaultFreq, DefaultDuration)
} | go | {
"resource": ""
} |
q20182 | Notify | train | func Notify(title, message, appIcon string) error {
appIcon = pathAbs(appIcon)
cmd := func() error {
send, err := exec.LookPath("sw-notify-send")
if err != nil {
send, err = exec.LookPath("notify-send")
if err != nil {
return err
}
}
c := exec.Command(send, title, message, "-i", appIcon)
retu... | go | {
"resource": ""
} |
q20183 | Notify | train | func Notify(title, message, appIcon string) error {
if isWindows10 {
return toastNotify(title, message, appIcon)
}
err := baloonNotify(title, message, appIcon, false)
if err != nil {
e := msgNotify(title, message)
if e != nil {
return errors.New("beeep: " + err.Error() + "; " + e.Error())
}
}
return ... | go | {
"resource": ""
} |
q20184 | LooksLikeIPv6 | train | func LooksLikeIPv6(ip string) bool {
if !strings.Contains(ip, ":") {
return false
}
return ipv6Pattern.MatchString(ip)
} | go | {
"resource": ""
} |
q20185 | NewHostname | train | func NewHostname(domain, ip string, enabled bool) (*Hostname, error) {
if !LooksLikeIPv4(ip) && !LooksLikeIPv6(ip) {
return nil, fmt.Errorf("Unable to parse IP address %q", ip)
}
IP := net.ParseIP(ip)
return &Hostname{domain, IP, enabled, LooksLikeIPv6(ip)}, nil
} | go | {
"resource": ""
} |
q20186 | MustHostname | train | func MustHostname(domain, ip string, enabled bool) *Hostname {
hostname, err := NewHostname(domain, ip, enabled)
if err != nil {
panic(err)
}
return hostname
} | go | {
"resource": ""
} |
q20187 | Equal | train | func (h *Hostname) Equal(n *Hostname) bool {
return h.Domain == n.Domain && h.IP.Equal(n.IP)
} | go | {
"resource": ""
} |
q20188 | EqualIP | train | func (h *Hostname) EqualIP(ip net.IP) bool {
return h.IP.Equal(ip)
} | go | {
"resource": ""
} |
q20189 | AnyBool | train | func AnyBool(c *cli.Context, key string) bool {
return c.Bool(key) || c.GlobalBool(key)
} | go | {
"resource": ""
} |
q20190 | MaybeErrorln | train | func MaybeErrorln(c *cli.Context, message string) {
if !AnyBool(c, "s") {
os.Stderr.WriteString(fmt.Sprintf("%s\n", message))
}
} | go | {
"resource": ""
} |
q20191 | MaybeError | train | func MaybeError(c *cli.Context, message string) {
MaybeErrorln(c, message)
os.Exit(1)
} | go | {
"resource": ""
} |
q20192 | MaybePrintln | train | func MaybePrintln(c *cli.Context, message string) {
if !AnyBool(c, "q") && !AnyBool(c, "s") {
fmt.Println(message)
}
} | go | {
"resource": ""
} |
q20193 | MaybeLoadHostFile | train | func MaybeLoadHostFile(c *cli.Context) *Hostfile {
hostsfile, errs := LoadHostfile()
if len(errs) > 0 && !AnyBool(c, "f") {
for _, err := range errs {
MaybeErrorln(c, err.Error())
}
MaybeError(c, "Errors while parsing hostsfile. Try hostess fix")
}
return hostsfile
} | go | {
"resource": ""
} |
q20194 | AlwaysLoadHostFile | train | func AlwaysLoadHostFile(c *cli.Context) *Hostfile {
hostsfile, errs := LoadHostfile()
if len(errs) > 0 {
for _, err := range errs {
MaybeErrorln(c, err.Error())
}
}
return hostsfile
} | go | {
"resource": ""
} |
q20195 | MaybeSaveHostFile | train | func MaybeSaveHostFile(c *cli.Context, hostfile *Hostfile) {
// If -n is passed, no-op and output the resultant hosts file to stdout.
// Otherwise it's for real and we're going to write it.
if AnyBool(c, "n") {
fmt.Printf("%s", hostfile.Format())
} else {
err := hostfile.Save()
if err != nil {
MaybeError(c... | go | {
"resource": ""
} |
q20196 | StrPadRight | train | func StrPadRight(s string, l int) string {
r := l - len(s)
if r < 0 {
r = 0
}
return s + strings.Repeat(" ", r)
} | go | {
"resource": ""
} |
q20197 | Has | train | func Has(c *cli.Context) {
if len(c.Args()) != 1 {
MaybeError(c, "expected <hostname>")
}
domain := c.Args()[0]
hostsfile := MaybeLoadHostFile(c)
found := hostsfile.Hosts.ContainsDomain(domain)
if found {
MaybePrintln(c, fmt.Sprintf("Found %s in %s", domain, GetHostsPath()))
} else {
MaybeError(c, fmt.Spr... | go | {
"resource": ""
} |
q20198 | Ls | train | func Ls(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
maxdomain := 0
maxip := 0
for _, hostname := range hostsfile.Hosts {
dlen := len(hostname.Domain)
if dlen > maxdomain {
maxdomain = dlen
}
ilen := len(hostname.IP)
if ilen > maxip {
maxip = ilen
}
}
for _, hostname := range hostsfile.... | go | {
"resource": ""
} |
q20199 | Fix | train | func Fix(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
if bytes.Equal(hostsfile.GetData(), hostsfile.Format()) {
MaybePrintln(c, fmt.Sprintf("%s is already formatted and contains no dupes or conflicts; nothing to do", GetHostsPath()))
os.Exit(0)
}
MaybeSaveHostFile(c, hostsfile)
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.