image
image
text
string
language
string
kind
string
style
string
font
string
font_size
int64
line_numbers
bool
repo
string
file
string
cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) }
Go
fragment
pastie
Liberation Mono
16
false
gravitational/teleport
lib/services/clustername.go
cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) }
Go
fragment
gruvbox-light
Liberation Mono
14
true
gravitational/teleport
lib/services/clustername.go
if ss == str { return true } }
Go
fragment
friendly
DejaVu Sans Mono
15
true
google/codesearch
index/regexp.go
if ss == str { return true } }
Go
fragment
gruvbox-light
Ubuntu Mono
20
true
google/codesearch
index/regexp.go
return 0, nil } // Decode the peers var peerSet []string dec := json.NewDecoder(bytes.NewReader(buf)) if err := dec.Decode(&peerSet); err != nil { return 0, err } return len(peerSet), nil
Go
fragment
material
DejaVu Sans Mono
16
false
rqlite/rqlite
store/peers.go
return 0, nil } // Decode the peers var peerSet []string dec := json.NewDecoder(bytes.NewReader(buf)) if err := dec.Decode(&peerSet); err != nil { return 0, err } return len(peerSet), nil
Go
fragment
monokai
Liberation Mono
20
true
rqlite/rqlite
store/peers.go
func PopulatedChunk(numSamples int, minTime int64) chunks.Meta { samples := make([]Sample, numSamples) for i := 0; i < numSamples; i++ { samples[i] = sample{minTime + int64(i*1000), 1.0} } return ChunkFromSamples(samples) }
Go
block
dracula
DejaVu Sans Mono
14
true
prometheus/tsdb
tsdbutil/chunks.go
func PopulatedChunk(numSamples int, minTime int64) chunks.Meta { samples := make([]Sample, numSamples) for i := 0; i < numSamples; i++ { samples[i] = sample{minTime + int64(i*1000), 1.0} } return ChunkFromSamples(samples) }
Go
block
zenburn
Liberation Mono
14
true
prometheus/tsdb
tsdbutil/chunks.go
func Redirect(w http.ResponseWriter, r *http.Request, newPath string, statusCode int) { if q := r.URL.RawQuery; q != "" { newPath += "?" + q
Go
fragment
dracula
DejaVu Sans Mono
15
true
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/staticfiles/fileserver.go
func Redirect(w http.ResponseWriter, r *http.Request, newPath string, statusCode int) { if q := r.URL.RawQuery; q != "" { newPath += "?" + q
Go
fragment
material
Liberation Mono
15
false
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/staticfiles/fileserver.go
func defaultFont(size int, scaling float64) font.Face { defaultFontInit.Do(func() { fontData, _ := assets.Asset("DroidSansMono.ttf") ttfontDefault, _ = freetype.ParseFont(fontData) }) sz := int(float64(size) * scaling) return truetype.NewFace(ttfontDefault, &truetype.Options{Size: float64(sz), Hinting: font.H...
Go
block
solarized-light
Liberation Mono
18
true
aarzilli/nucular
style/style.go
func defaultFont(size int, scaling float64) font.Face { defaultFontInit.Do(func() { fontData, _ := assets.Asset("DroidSansMono.ttf") ttfontDefault, _ = freetype.ParseFont(fontData) }) sz := int(float64(size) * scaling) return truetype.NewFace(ttfontDefault, &truetype.Options{Size: float64(sz), Hinting: font.H...
Go
block
solarized-light
Liberation Mono
14
false
aarzilli/nucular
style/style.go
func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (t *Torrent, new bool, err error) { t, new = cl.AddTorrentInfoHashWithStorage(spec.InfoHash, spec.Storage) if spec.DisplayName != "" { t.SetDisplayName(spec.DisplayName) } if spec.InfoBytes != nil { err = t.SetInfoBytes(spec.InfoBytes) if err != nil { ret...
Go
block
friendly
Ubuntu Mono
18
false
anacrolix/torrent
client.go
func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (t *Torrent, new bool, err error) { t, new = cl.AddTorrentInfoHashWithStorage(spec.InfoHash, spec.Storage) if spec.DisplayName != "" { t.SetDisplayName(spec.DisplayName) } if spec.InfoBytes != nil { err = t.SetInfoBytes(spec.InfoBytes) if err != nil { ret...
Go
block
pastie
DejaVu Sans Mono
14
true
anacrolix/torrent
client.go
func (d *Drawer) Dirty() { d.lazyInit() for _, t := range d.targets { t.clean = false } }
Go
block
solarized-light
DejaVu Sans Mono
15
true
faiface/pixel
drawer.go
func (d *Drawer) Dirty() { d.lazyInit() for _, t := range d.targets { t.clean = false } }
Go
block
friendly
Liberation Mono
18
false
faiface/pixel
drawer.go
h := mux.handler() // Register each header byte. for _, hdr := range hdrs { // Create a new listener and assign it. mux.handlers[hdr] = h } return h
Go
fragment
default
Liberation Mono
20
false
flynn/flynn
pkg/mux/mux.go
h := mux.handler() // Register each header byte. for _, hdr := range hdrs { // Create a new listener and assign it. mux.handlers[hdr] = h } return h
Go
fragment
nord
Ubuntu Mono
20
true
flynn/flynn
pkg/mux/mux.go
func (c *Client) SetWriteTimeout(d time.Duration) error { if c == nil { return fmt.Errorf("Client is nil") } return c.writer.SetWriteTimeout(d) }
Go
block
pastie
Ubuntu Mono
14
false
DataDog/datadog-go
statsd/statsd.go
func (c *Client) SetWriteTimeout(d time.Duration) error { if c == nil { return fmt.Errorf("Client is nil") } return c.writer.SetWriteTimeout(d) }
Go
block
gruvbox-light
Ubuntu Mono
16
true
DataDog/datadog-go
statsd/statsd.go
func (ro *rescanOptions) spendsWatchedInput(tx *btcutil.Tx) bool { for _, in := range tx.MsgTx().TxIn { for _, input := range ro.watchInputs { switch { // If we're watching for a zero outpoint, then we should // match on the output script being spent instead. case input.OutPoint == zeroOutPoint: pkSc...
Go
block
material
Ubuntu Mono
14
false
lightninglabs/neutrino
rescan.go
func (ro *rescanOptions) spendsWatchedInput(tx *btcutil.Tx) bool { for _, in := range tx.MsgTx().TxIn { for _, input := range ro.watchInputs { switch { // If we're watching for a zero outpoint, then we should // match on the output script being spent instead. case input.OutPoint == zeroOutPoint: pkSc...
Go
block
nord
Ubuntu Mono
16
true
lightninglabs/neutrino
rescan.go
func CheckBlobDescriptorCache(t *testing.T, provider cache.BlobDescriptorCacheProvider) { ctx := context.Background() checkBlobDescriptorCacheEmptyRepository(ctx, t, provider) checkBlobDescriptorCacheSetAndRead(ctx, t, provider) checkBlobDescriptorCacheClear(ctx, t, provider) }
Go
block
zenburn
Ubuntu Mono
14
false
docker/distribution
registry/storage/cache/cachecheck/suite.go
func CheckBlobDescriptorCache(t *testing.T, provider cache.BlobDescriptorCacheProvider) { ctx := context.Background() checkBlobDescriptorCacheEmptyRepository(ctx, t, provider) checkBlobDescriptorCacheSetAndRead(ctx, t, provider) checkBlobDescriptorCacheClear(ctx, t, provider) }
Go
block
github-dark
Liberation Mono
14
false
docker/distribution
registry/storage/cache/cachecheck/suite.go
func (s *Action) generatePasswordXKCD(ctx context.Context, c *cli.Context, length string) (string, error) { xkcdSeparator := " " if c.IsSet("xkcdsep") { xkcdSeparator = c.String("xkcdsep") } var pwlen int if length == "" { candidateLength := defaultXKCDLength question := "How many words should be combined t...
Go
block
pastie
DejaVu Sans Mono
15
false
gopasspw/gopass
pkg/action/generate.go
func (s *Action) generatePasswordXKCD(ctx context.Context, c *cli.Context, length string) (string, error) { xkcdSeparator := " " if c.IsSet("xkcdsep") { xkcdSeparator = c.String("xkcdsep") } var pwlen int if length == "" { candidateLength := defaultXKCDLength question := "How many words should be combined t...
Go
block
solarized-dark
Ubuntu Mono
20
false
gopasspw/gopass
pkg/action/generate.go
func createPaths(mode byte, paths *MvcPath) { if (mode & OModel) == OModel { os.Mkdir(paths.ModelPath, 0777) } if (mode & OController) == OController { os.Mkdir(paths.ControllerPath, 0777) } if (mode & ORouter) == ORouter { os.Mkdir(paths.RouterPath, 0777) } }
Go
block
monokai
Liberation Mono
15
true
beego/bee
generate/g_appcode.go
func createPaths(mode byte, paths *MvcPath) { if (mode & OModel) == OModel { os.Mkdir(paths.ModelPath, 0777) } if (mode & OController) == OController { os.Mkdir(paths.ControllerPath, 0777) } if (mode & ORouter) == ORouter { os.Mkdir(paths.RouterPath, 0777) } }
Go
block
gruvbox-dark
Liberation Mono
16
true
beego/bee
generate/g_appcode.go
func IsISO3166Alpha3(str string) bool { for _, entry := range ISO3166List { if str == entry.Alpha3Code { return true } } return false }
Go
block
friendly
Ubuntu Mono
18
true
asaskevich/govalidator
validator.go
func IsISO3166Alpha3(str string) bool { for _, entry := range ISO3166List { if str == entry.Alpha3Code { return true } } return false }
Go
block
solarized-dark
Ubuntu Mono
20
false
asaskevich/govalidator
validator.go
func (t *MockTransactor) CreateTransaction(request fab.TransactionRequest) (*fab.Transaction, error) { response := &fab.Transaction{ Proposal: &fab.TransactionProposal{ Proposal: &pb.Proposal{}, }, Transaction: &pb.Transaction{}, } return response, nil }
Go
block
friendly
Liberation Mono
20
false
hyperledger/fabric-sdk-go
pkg/fab/mocks/mocktransactor.go
func (t *MockTransactor) CreateTransaction(request fab.TransactionRequest) (*fab.Transaction, error) { response := &fab.Transaction{ Proposal: &fab.TransactionProposal{ Proposal: &pb.Proposal{}, }, Transaction: &pb.Transaction{}, } return response, nil }
Go
block
nord
Liberation Mono
15
false
hyperledger/fabric-sdk-go
pkg/fab/mocks/mocktransactor.go
if conn != nil { if err := conn.Close(); err != nil { return fmt.Errorf("Close connection error: %s", err) } } return nil }
Go
fragment
pastie
Liberation Mono
16
true
RichardKnop/machinery
v1/common/amqp.go
if conn != nil { if err := conn.Close(); err != nil { return fmt.Errorf("Close connection error: %s", err) } } return nil }
Go
fragment
xcode
Ubuntu Mono
20
false
RichardKnop/machinery
v1/common/amqp.go
func (s *Sprite) DrawColorMask(t Target, matrix Matrix, mask color.Color) { dirty := false if matrix != s.matrix { s.matrix = matrix dirty = true } if mask == nil { mask = Alpha(1) } rgba := ToRGBA(mask) if rgba != s.mask { s.mask = rgba dirty = true } if dirty { s.calcData() } s.d.Draw(t) }
Go
block
nord
DejaVu Sans Mono
18
true
faiface/pixel
sprite.go
func (s *Sprite) DrawColorMask(t Target, matrix Matrix, mask color.Color) { dirty := false if matrix != s.matrix { s.matrix = matrix dirty = true } if mask == nil { mask = Alpha(1) } rgba := ToRGBA(mask) if rgba != s.mask { s.mask = rgba dirty = true } if dirty { s.calcData() } s.d.Draw(t) }
Go
block
native
DejaVu Sans Mono
20
false
faiface/pixel
sprite.go
func (l *Ledis) DumpFile(path string) error { f, err := os.Create(path) if err != nil { return err } defer f.Close() return l.Dump(f) }
Go
block
solarized-light
Liberation Mono
16
false
siddontang/ledisdb
ledis/dump.go
func (l *Ledis) DumpFile(path string) error { f, err := os.Create(path) if err != nil { return err } defer f.Close() return l.Dump(f) }
Go
block
pastie
Ubuntu Mono
14
true
siddontang/ledisdb
ledis/dump.go
func (s *Action) CompleteGenerate(ctx context.Context, c *cli.Context) { args := c.Args() if len(args) < 1 { return } needle := args[0] _, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil if err != nil { out.Error(ctx, "Store not initialized: %s", err) return } list, err ...
Go
block
nord
Liberation Mono
14
false
gopasspw/gopass
pkg/action/generate.go
func (s *Action) CompleteGenerate(ctx context.Context, c *cli.Context) { args := c.Args() if len(args) < 1 { return } needle := args[0] _, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil if err != nil { out.Error(ctx, "Store not initialized: %s", err) return } list, err ...
Go
block
gruvbox-dark
Ubuntu Mono
14
true
gopasspw/gopass
pkg/action/generate.go
func UnmarshalTunnelConnection(data []byte, opts ...MarshalOption) (TunnelConnection, error) { if len(data) == 0 { return nil, trace.BadParameter("missing tunnel connection data") } cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } var h ResourceHeader err = utils.FastUnmarshal(d...
Go
block
material
Liberation Mono
15
true
gravitational/teleport
lib/services/tunnelconn.go
func UnmarshalTunnelConnection(data []byte, opts ...MarshalOption) (TunnelConnection, error) { if len(data) == 0 { return nil, trace.BadParameter("missing tunnel connection data") } cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } var h ResourceHeader err = utils.FastUnmarshal(d...
Go
block
native
Liberation Mono
16
false
gravitational/teleport
lib/services/tunnelconn.go
func MustParseStrict(ulid string) ULID { id, err := ParseStrict(ulid) if err != nil { panic(err) } return id }
Go
block
one-dark
DejaVu Sans Mono
15
true
oklog/ulid
ulid.go
func MustParseStrict(ulid string) ULID { id, err := ParseStrict(ulid) if err != nil { panic(err) } return id }
Go
block
default
DejaVu Sans Mono
18
false
oklog/ulid
ulid.go
func (v Variable) String() string { switch v.Kind { case String: return v.Str case Indexed: if len(v.List) > 0 { return v.List[0] } case Associative: // nothing to do } return "" }
Go
block
monokai
Ubuntu Mono
14
false
mvdan/sh
expand/environ.go
func (v Variable) String() string { switch v.Kind { case String: return v.Str case Indexed: if len(v.List) > 0 { return v.List[0] } case Associative: // nothing to do } return "" }
Go
block
material
Ubuntu Mono
18
false
mvdan/sh
expand/environ.go
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { c := driverapi.Capability{ DataScope: datastore.GlobalScope, ConnectivityScope: datastore.GlobalScope, } d := &driver{ networks: networkTable{}, config: config, } if data, ok := config[netlabel.GlobalKVClient]; ok { ...
Go
block
native
Ubuntu Mono
14
false
docker/libnetwork
drivers/windows/overlay/overlay_windows.go
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { c := driverapi.Capability{ DataScope: datastore.GlobalScope, ConnectivityScope: datastore.GlobalScope, } d := &driver{ networks: networkTable{}, config: config, } if data, ok := config[netlabel.GlobalKVClient]; ok { ...
Go
block
default
Ubuntu Mono
20
true
docker/libnetwork
drivers/windows/overlay/overlay_windows.go
func objectFields(obj valueObject, h Hidden) []string { var r []string for fieldName, hide := range objectFieldsVisibility(obj) { if h == withHidden || hide != ast.ObjectFieldHidden { r = append(r, fieldName) } } return r }
Go
block
material
DejaVu Sans Mono
15
false
google/go-jsonnet
value.go
func objectFields(obj valueObject, h Hidden) []string { var r []string for fieldName, hide := range objectFieldsVisibility(obj) { if h == withHidden || hide != ast.ObjectFieldHidden { r = append(r, fieldName) } } return r }
Go
block
tango
Liberation Mono
20
false
google/go-jsonnet
value.go
desiredStateOfWorld cache.DesiredStateOfWorld, actualStateOfWorld cache.ActualStateOfWorld, snapshotter snapshotter.VolumeSnapshotter) Reconciler { return &reconciler{ loopPeriod: loopPeriod, syncDuration: syncDuration, disableReconciliationSync: disableReconciliationSync, desire...
Go
fragment
solarized-light
Liberation Mono
18
false
kubernetes-incubator/external-storage
snapshot/pkg/controller/reconciler/reconciler.go
desiredStateOfWorld cache.DesiredStateOfWorld, actualStateOfWorld cache.ActualStateOfWorld, snapshotter snapshotter.VolumeSnapshotter) Reconciler { return &reconciler{ loopPeriod: loopPeriod, syncDuration: syncDuration, disableReconciliationSync: disableReconciliationSync, desire...
Go
fragment
nord
DejaVu Sans Mono
20
false
kubernetes-incubator/external-storage
snapshot/pkg/controller/reconciler/reconciler.go
func InOrder(calls ...*Call) { for i := 1; i < len(calls); i++ { calls[i].After(calls[i-1]) } }
Go
fragment
material
Liberation Mono
16
false
golang/mock
gomock/call.go
func InOrder(calls ...*Call) { for i := 1; i < len(calls); i++ { calls[i].After(calls[i-1]) } }
Go
fragment
pastie
Ubuntu Mono
20
true
golang/mock
gomock/call.go
parallel(0, dstH, func(ys <-chan int) { for dstY := range ys { i := dstY * dst.Stride srcY := dstY src.scan(0, srcY, src.w, srcY+1, dst.Pix[i:i+rowSize]) reverse(dst.Pix[i : i+rowSize]) } }) return dst
Go
fragment
native
Ubuntu Mono
16
false
disintegration/imaging
transform.go
parallel(0, dstH, func(ys <-chan int) { for dstY := range ys { i := dstY * dst.Stride srcY := dstY src.scan(0, srcY, src.w, srcY+1, dst.Pix[i:i+rowSize]) reverse(dst.Pix[i : i+rowSize]) } }) return dst
Go
fragment
nord
DejaVu Sans Mono
20
false
disintegration/imaging
transform.go
func (s *ToxicStub) Run(toxic *ToxicWrapper) { s.running = make(chan struct{}) defer close(s.running) if rand.Float32() < toxic.Toxicity { toxic.Pipe(s) } else { new(NoopToxic).Pipe(s) } }
Go
block
gruvbox-dark
Liberation Mono
18
true
Shopify/toxiproxy
toxics/toxic.go
func (s *ToxicStub) Run(toxic *ToxicWrapper) { s.running = make(chan struct{}) defer close(s.running) if rand.Float32() < toxic.Toxicity { toxic.Pipe(s) } else { new(NoopToxic).Pipe(s) } }
Go
block
xcode
DejaVu Sans Mono
14
false
Shopify/toxiproxy
toxics/toxic.go
func (b *bufWriter) finish() *os.File { b.flush() f := b.file f.Seek(0, 0) return f }
Go
block
github-dark
Liberation Mono
15
true
google/codesearch
index/write.go
func (b *bufWriter) finish() *os.File { b.flush() f := b.file f.Seek(0, 0) return f }
Go
block
gruvbox-light
DejaVu Sans Mono
18
true
google/codesearch
index/write.go
func (c *LexModelBuildingService) DeleteBotChannelAssociationRequest(input *DeleteBotChannelAssociationInput) (req *request.Request, output *DeleteBotChannelAssociationOutput) { op := &request.Operation{ Name: opDeleteBotChannelAssociation, HTTPMethod: "DELETE", HTTPPath: "/bots/{botName}/aliases/{aliasN...
Go
block
solarized-dark
DejaVu Sans Mono
18
true
aws/aws-sdk-go
service/lexmodelbuildingservice/api.go
func (c *LexModelBuildingService) DeleteBotChannelAssociationRequest(input *DeleteBotChannelAssociationInput) (req *request.Request, output *DeleteBotChannelAssociationOutput) { op := &request.Operation{ Name: opDeleteBotChannelAssociation, HTTPMethod: "DELETE", HTTPPath: "/bots/{botName}/aliases/{aliasN...
Go
block
pastie
Ubuntu Mono
15
false
aws/aws-sdk-go
service/lexmodelbuildingservice/api.go
func drawProperty(win *Window, style *nstyle.Property, bounds, labelrect rect.Rect, ws nstyle.WidgetStates, name string) { out := &win.cmds font := win.ctx.Style.Font if style.DrawBegin != nil { style.DrawBegin(out) } if style.DrawEnd != nil { defer style.DrawEnd(out) } if style.Draw != nil { style.Draw(o...
Go
block
solarized-light
DejaVu Sans Mono
14
true
aarzilli/nucular
drawing.go
func drawProperty(win *Window, style *nstyle.Property, bounds, labelrect rect.Rect, ws nstyle.WidgetStates, name string) { out := &win.cmds font := win.ctx.Style.Font if style.DrawBegin != nil { style.DrawBegin(out) } if style.DrawEnd != nil { defer style.DrawEnd(out) } if style.Draw != nil { style.Draw(o...
Go
block
xcode
Liberation Mono
15
true
aarzilli/nucular
drawing.go
for _, name := range f.Plugins { if p, ok := plugins[name].(Opener); ok { if err := p.Open(f); err != nil { return err } } } return nil }
Go
fragment
monokai
Ubuntu Mono
15
false
apex/apex
function/function.go
for _, name := range f.Plugins { if p, ok := plugins[name].(Opener); ok { if err := p.Open(f); err != nil { return err } } } return nil }
Go
fragment
pastie
Ubuntu Mono
16
true
apex/apex
function/function.go
func NewAsPathPrependAction(action config.SetAsPathPrepend) (*AsPathPrependAction, error) { a := &AsPathPrependAction{ repeat: action.RepeatN, } switch action.As { case "": if a.repeat == 0 { return nil, nil } return nil, fmt.Errorf("specify as to prepend") case "last-as": a.useLeftMost = true defaul...
Go
block
gruvbox-dark
Ubuntu Mono
20
true
osrg/gobgp
internal/pkg/table/policy.go
func NewAsPathPrependAction(action config.SetAsPathPrepend) (*AsPathPrependAction, error) { a := &AsPathPrependAction{ repeat: action.RepeatN, } switch action.As { case "": if a.repeat == 0 { return nil, nil } return nil, fmt.Errorf("specify as to prepend") case "last-as": a.useLeftMost = true defaul...
Go
block
solarized-dark
Ubuntu Mono
20
true
osrg/gobgp
internal/pkg/table/policy.go
func (api *API) ShardNodes(ctx context.Context, indexName string, shard uint64) ([]*Node, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.ShardNodes") defer span.Finish() if err := api.validate(apiShardNodes); err != nil { return nil, errors.Wrap(err, "validating api method") } return api.cluster.sh...
Go
block
github-dark
Liberation Mono
18
false
pilosa/pilosa
api.go
func (api *API) ShardNodes(ctx context.Context, indexName string, shard uint64) ([]*Node, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.ShardNodes") defer span.Finish() if err := api.validate(apiShardNodes); err != nil { return nil, errors.Wrap(err, "validating api method") } return api.cluster.sh...
Go
block
github-dark
Ubuntu Mono
18
false
pilosa/pilosa
api.go
func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) { tf, err := ioutil.TempFile("", "") if err != nil { return nil, errwrap.Wrap(errors.New("error creating tempfile"), err) } os.Remove(tf.Name()) // no need to keep the tempfile around defer func() { if tf != nil { tf.Close() } }() // TO...
Go
block
solarized-light
Liberation Mono
15
false
rkt/rkt
rkt/pubkey/pubkey.go
func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) { tf, err := ioutil.TempFile("", "") if err != nil { return nil, errwrap.Wrap(errors.New("error creating tempfile"), err) } os.Remove(tf.Name()) // no need to keep the tempfile around defer func() { if tf != nil { tf.Close() } }() // TO...
Go
block
one-dark
Liberation Mono
16
true
rkt/rkt
rkt/pubkey/pubkey.go
func Verify(token string, key *rsa.PublicKey) error { parts := strings.Split(token, ".") if len(parts) != 3 { return errors.New("jws: invalid token received, token must have 3 parts") } signedContent := parts[0] + "." + parts[1] signatureString, err := base64.RawURLEncoding.DecodeString(parts[2]) if err != nil...
Go
block
default
Liberation Mono
18
true
golang/oauth2
jws/jws.go
func Verify(token string, key *rsa.PublicKey) error { parts := strings.Split(token, ".") if len(parts) != 3 { return errors.New("jws: invalid token received, token must have 3 parts") } signedContent := parts[0] + "." + parts[1] signatureString, err := base64.RawURLEncoding.DecodeString(parts[2]) if err != nil...
Go
block
zenburn
Liberation Mono
15
true
golang/oauth2
jws/jws.go
func (v Optional) Get(deflt A) A { if !v.Defined { return deflt } return v.V }
Go
block
xcode
Ubuntu Mono
16
true
mailru/easyjson
opt/optional/opt.go
func (v Optional) Get(deflt A) A { if !v.Defined { return deflt } return v.V }
Go
block
friendly
Liberation Mono
18
true
mailru/easyjson
opt/optional/opt.go
func (store *LimitedStore) ensureSpace(size int64) error { if (store.usedSize + size) <= store.StoreSize { // Enough space is available to store the new upload return nil } sortedUploads := make(pairlist, len(store.uploads)) i := 0 for u, h := range store.uploads { sortedUploads[i] = pair{u, h} i++ } so...
Go
block
github-dark
DejaVu Sans Mono
16
false
tus/tusd
limitedstore/limitedstore.go
func (store *LimitedStore) ensureSpace(size int64) error { if (store.usedSize + size) <= store.StoreSize { // Enough space is available to store the new upload return nil } sortedUploads := make(pairlist, len(store.uploads)) i := 0 for u, h := range store.uploads { sortedUploads[i] = pair{u, h} i++ } so...
Go
block
gruvbox-dark
Liberation Mono
20
true
tus/tusd
limitedstore/limitedstore.go
cursor.init = func(buf *pktque.Buf, videoidx int) pktque.BufPos { i := buf.Tail - 1 if buf.IsValidPos(i) { end := buf.Get(i)
Go
fragment
nord
Ubuntu Mono
20
false
nareix/joy4
av/pubsub/queue.go
cursor.init = func(buf *pktque.Buf, videoidx int) pktque.BufPos { i := buf.Tail - 1 if buf.IsValidPos(i) { end := buf.Get(i)
Go
fragment
solarized-dark
DejaVu Sans Mono
18
false
nareix/joy4
av/pubsub/queue.go
func min(n *node) Item { if n == nil { return nil } for len(n.children) > 0 { n = n.children[0] } if len(n.items) == 0 { return nil } return n.items[0] }
Go
block
solarized-dark
Liberation Mono
14
true
google/btree
btree.go
func min(n *node) Item { if n == nil { return nil } for len(n.children) > 0 { n = n.children[0] } if len(n.items) == 0 { return nil } return n.items[0] }
Go
block
gruvbox-light
Liberation Mono
20
true
google/btree
btree.go
func (af *avgFunction) GetType() *types.FieldType { ft := types.NewFieldType(mysql.TypeNewDecimal) ft.Charset = charset.CharsetBin ft.Collate = charset.CollationBin ft.Decimal = af.Args[0].GetType().Decimal return ft
Go
fragment
gruvbox-dark
DejaVu Sans Mono
20
true
chrislusf/gleam
sql/expression/aggregation.go
func (af *avgFunction) GetType() *types.FieldType { ft := types.NewFieldType(mysql.TypeNewDecimal) ft.Charset = charset.CharsetBin ft.Collate = charset.CollationBin ft.Decimal = af.Args[0].GetType().Decimal return ft
Go
fragment
pastie
Liberation Mono
20
false
chrislusf/gleam
sql/expression/aggregation.go
func (ints *Ints) ScanColumn(colIdx int, colName string, rd types.Reader, n int) error { num, err := types.ScanInt64(rd, n) if err != nil { return err } *ints = append(*ints, num) return nil }
Go
block
pastie
Ubuntu Mono
18
false
go-pg/pg
pg.go
func (ints *Ints) ScanColumn(colIdx int, colName string, rd types.Reader, n int) error { num, err := types.ScanInt64(rd, n) if err != nil { return err } *ints = append(*ints, num) return nil }
Go
block
github-dark
Liberation Mono
18
true
go-pg/pg
pg.go
func Flush() { circuitBreakersMutex.Lock() defer circuitBreakersMutex.Unlock() for name, cb := range circuitBreakers { cb.metrics.Reset() cb.executorPool.Metrics.Reset() delete(circuitBreakers, name) } }
Go
block
xcode
DejaVu Sans Mono
15
true
afex/hystrix-go
hystrix/circuit.go
func Flush() { circuitBreakersMutex.Lock() defer circuitBreakersMutex.Unlock() for name, cb := range circuitBreakers { cb.metrics.Reset() cb.executorPool.Metrics.Reset() delete(circuitBreakers, name) } }
Go
block
monokai
Ubuntu Mono
16
true
afex/hystrix-go
hystrix/circuit.go
v := reflect.ValueOf(struct{}{}) switch field.Kind() { case reflect.Slice, reflect.Array: m := reflect.MakeMap(reflect.MapOf(field.Type().Elem(), v.Type())) for i := 0; i < field.Len(); i++ { m.SetMapIndex(field.Index(i), v) } return field.Len() == m.Len() case reflect.Map: m := reflect.MakeMap(refle...
Go
fragment
monokai
Liberation Mono
14
false
go-playground/validator
baked_in.go
v := reflect.ValueOf(struct{}{}) switch field.Kind() { case reflect.Slice, reflect.Array: m := reflect.MakeMap(reflect.MapOf(field.Type().Elem(), v.Type())) for i := 0; i < field.Len(); i++ { m.SetMapIndex(field.Index(i), v) } return field.Len() == m.Len() case reflect.Map: m := reflect.MakeMap(refle...
Go
fragment
material
DejaVu Sans Mono
14
false
go-playground/validator
baked_in.go
func (win *Window) SliderInt(min int, val *int, max int, step int) bool { value := float64(*val) ret := win.SliderFloat(float64(min), &value, float64(max), float64(step)) *val = int(value) return ret }
Go
block
tango
Liberation Mono
18
true
aarzilli/nucular
nucular.go
func (win *Window) SliderInt(min int, val *int, max int, step int) bool { value := float64(*val) ret := win.SliderFloat(float64(min), &value, float64(max), float64(step)) *val = int(value) return ret }
Go
block
nord
Liberation Mono
14
false
aarzilli/nucular
nucular.go
func (state *TextEditor) tofp(start int, dir int) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if !(unicode.IsLetter(c) || unicode.IsDigit(c) || (c == '_') || (c == '-') || (c == '+') || (c == '/') || (c == '=') || (c =...
Go
block
friendly
Ubuntu Mono
18
true
aarzilli/nucular
text.go
func (state *TextEditor) tofp(start int, dir int) int { first := (dir < 0) notfirst := !first var i int for i = start; (i >= 0) && (i < len(state.Buffer)); i += dir { c := state.Buffer[i] if !(unicode.IsLetter(c) || unicode.IsDigit(c) || (c == '_') || (c == '-') || (c == '+') || (c == '/') || (c == '=') || (c =...
Go
block
default
Liberation Mono
20
true
aarzilli/nucular
text.go
func (ac *AMQPConnector) DeleteQueue(channel *amqp.Channel, queueName string) error { // First return value is number of messages removed _, err := channel.QueueDelete( queueName, // name false, // ifUnused false, // ifEmpty false, // noWait ) return err }
Go
block
zenburn
Ubuntu Mono
14
true
RichardKnop/machinery
v1/common/amqp.go
func (ac *AMQPConnector) DeleteQueue(channel *amqp.Channel, queueName string) error { // First return value is number of messages removed _, err := channel.QueueDelete( queueName, // name false, // ifUnused false, // ifEmpty false, // noWait ) return err }
Go
block
monokai
Ubuntu Mono
14
false
RichardKnop/machinery
v1/common/amqp.go
func NewCCache() *CCache { if maxSize == 0 { return nil } cc := &CCache{ metricCache: make(map[schema.AMKey]*CCacheMetric), metricRawKeys: make(map[schema.MKey]map[schema.Archive]struct{}), accnt: accnt.NewFlatAccnt(maxSize), stop: make(chan interface{}), tracer: opentracing.No...
Go
block
nord
Ubuntu Mono
14
false
grafana/metrictank
mdata/cache/ccache.go
func NewCCache() *CCache { if maxSize == 0 { return nil } cc := &CCache{ metricCache: make(map[schema.AMKey]*CCacheMetric), metricRawKeys: make(map[schema.MKey]map[schema.Archive]struct{}), accnt: accnt.NewFlatAccnt(maxSize), stop: make(chan interface{}), tracer: opentracing.No...
Go
block
nord
Liberation Mono
14
true
grafana/metrictank
mdata/cache/ccache.go
func (sink *influxdbSink) keyToSelector(key core.HistoricalKey) string { typeSel := fmt.Sprintf("type = '%s'", key.ObjectType) switch key.ObjectType { case core.MetricSetTypeNode: return fmt.Sprintf("%s AND %s = '%s'", typeSel, core.LabelNodename.Key, key.NodeName) case core.MetricSetTypeSystemContainer: return...
Go
block
nord
DejaVu Sans Mono
16
false
kubernetes-retired/heapster
metrics/sinks/influxdb/influxdb_historical.go
func (sink *influxdbSink) keyToSelector(key core.HistoricalKey) string { typeSel := fmt.Sprintf("type = '%s'", key.ObjectType) switch key.ObjectType { case core.MetricSetTypeNode: return fmt.Sprintf("%s AND %s = '%s'", typeSel, core.LabelNodename.Key, key.NodeName) case core.MetricSetTypeSystemContainer: return...
Go
block
native
Liberation Mono
15
false
kubernetes-retired/heapster
metrics/sinks/influxdb/influxdb_historical.go