image image | text string | language string | kind string | style string | font string | font_size int64 | line_numbers bool | repo string | file string |
|---|---|---|---|---|---|---|---|---|---|
func (r *Store) getStore(ctx context.Context, name string) (context.Context, store.Store, string) {
name = strings.TrimSuffix(name, "/")
mp := r.MountPoint(name)
if sub, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx), sub, strings.TrimPrefix(name, sub.Alias())
}
return r.cfg.Root.WithCon... | Go | block | github-dark | Liberation Mono | 16 | true | gopasspw/gopass | pkg/store/root/mount.go | |
func (r *Store) getStore(ctx context.Context, name string) (context.Context, store.Store, string) {
name = strings.TrimSuffix(name, "/")
mp := r.MountPoint(name)
if sub, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx), sub, strings.TrimPrefix(name, sub.Alias())
}
return r.cfg.Root.WithCon... | Go | block | dracula | Liberation Mono | 18 | true | gopasspw/gopass | pkg/store/root/mount.go | |
func (l *State) SetTable(index int) {
l.checkElementCount(2)
l.setTableAt(l.indexToValue(index), l.stack[l.top-2], l.stack[l.top-1])
l.top -= 2 | Go | fragment | monokai | DejaVu Sans Mono | 16 | true | Shopify/go-lua | lua.go | |
func (l *State) SetTable(index int) {
l.checkElementCount(2)
l.setTableAt(l.indexToValue(index), l.stack[l.top-2], l.stack[l.top-1])
l.top -= 2 | Go | fragment | gruvbox-dark | Liberation Mono | 20 | true | Shopify/go-lua | lua.go | |
func (sp *ServerPeer) pushSendHeadersMsg() error {
if sp.VersionKnown() {
if sp.ProtocolVersion() > wire.SendHeadersVersion {
sp.QueueMessage(wire.NewMsgSendHeaders(), nil)
}
}
return nil
} | Go | block | zenburn | DejaVu Sans Mono | 16 | false | lightninglabs/neutrino | neutrino.go | |
func (sp *ServerPeer) pushSendHeadersMsg() error {
if sp.VersionKnown() {
if sp.ProtocolVersion() > wire.SendHeadersVersion {
sp.QueueMessage(wire.NewMsgSendHeaders(), nil)
}
}
return nil
} | Go | block | zenburn | Liberation Mono | 15 | true | lightninglabs/neutrino | neutrino.go | |
func (s *Sheet) handleMerged() {
merged := make(map[string]*Cell)
for r, row := range s.Rows {
for c, cell := range row.Cells {
if cell.HMerge > 0 || cell.VMerge > 0 {
coord := GetCellIDStringFromCoords(c, r)
merged[coord] = cell
}
}
}
// This loop iterates over all cells that should be merged a... | Go | block | zenburn | Ubuntu Mono | 14 | false | tealeg/xlsx | sheet.go | |
func (s *Sheet) handleMerged() {
merged := make(map[string]*Cell)
for r, row := range s.Rows {
for c, cell := range row.Cells {
if cell.HMerge > 0 || cell.VMerge > 0 {
coord := GetCellIDStringFromCoords(c, r)
merged[coord] = cell
}
}
}
// This loop iterates over all cells that should be merged a... | Go | block | tango | Liberation Mono | 15 | false | tealeg/xlsx | sheet.go | |
func (api *API) Info() serverInfo {
si := api.server.systemInfo
// we don't report errors on failures to get this information
physicalCores, logicalCores, _ := si.CPUCores()
mhz, _ := si.CPUMHz()
mem, _ := si.MemTotal()
return serverInfo{
ShardWidth: ShardWidth,
CPUPhysicalCores: physicalCores,
CPULog... | Go | block | monokai | Liberation Mono | 18 | true | pilosa/pilosa | api.go | |
func (api *API) Info() serverInfo {
si := api.server.systemInfo
// we don't report errors on failures to get this information
physicalCores, logicalCores, _ := si.CPUCores()
mhz, _ := si.CPUMHz()
mem, _ := si.MemTotal()
return serverInfo{
ShardWidth: ShardWidth,
CPUPhysicalCores: physicalCores,
CPULog... | Go | block | friendly | Liberation Mono | 16 | true | pilosa/pilosa | api.go | |
func (windows *windowsRecord) Install(args ...string) (string, error) {
installAction := "Install " + windows.description + ":"
execp, err := execPath()
if err != nil {
return installAction + failed, err
}
m, err := mgr.Connect()
if err != nil {
return installAction + failed, err
}
defer m.Disconnect()
... | Go | block | default | DejaVu Sans Mono | 15 | false | takama/daemon | daemon_windows.go | |
func (windows *windowsRecord) Install(args ...string) (string, error) {
installAction := "Install " + windows.description + ":"
execp, err := execPath()
if err != nil {
return installAction + failed, err
}
m, err := mgr.Connect()
if err != nil {
return installAction + failed, err
}
defer m.Disconnect()
... | Go | block | native | DejaVu Sans Mono | 18 | true | takama/daemon | daemon_windows.go | |
func (sink *influxdbSink) labelsToPredicate(labels map[string]string) string {
if len(labels) == 0 {
return ""
}
parts := make([]string, 0, len(labels))
for k, v := range labels {
parts = append(parts, fmt.Sprintf("%q = '%s'", k, v))
}
return strings.Join(parts, " AND ")
} | Go | block | pastie | Ubuntu Mono | 15 | false | kubernetes-retired/heapster | metrics/sinks/influxdb/influxdb_historical.go | |
func (sink *influxdbSink) labelsToPredicate(labels map[string]string) string {
if len(labels) == 0 {
return ""
}
parts := make([]string, 0, len(labels))
for k, v := range labels {
parts = append(parts, fmt.Sprintf("%q = '%s'", k, v))
}
return strings.Join(parts, " AND ")
} | Go | block | solarized-light | Ubuntu Mono | 20 | true | kubernetes-retired/heapster | metrics/sinks/influxdb/influxdb_historical.go | |
func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA {
bgBounds := background.Bounds()
bgW := bgBounds.Dx()
bgH := bgBounds.Dy()
bgMinX := bgBounds.Min.X | Go | fragment | default | Liberation Mono | 18 | true | disintegration/imaging | tools.go | |
func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA {
bgBounds := background.Bounds()
bgW := bgBounds.Dx()
bgH := bgBounds.Dy()
bgMinX := bgBounds.Min.X | Go | fragment | gruvbox-dark | Liberation Mono | 15 | true | disintegration/imaging | tools.go | |
func (os OracleString) Value() (driver.Value, error) {
if !os.Valid || os.String == "" {
return nil, nil
}
return os.String, nil
} | Go | block | zenburn | Liberation Mono | 18 | false | go-gorp/gorp | gorp.go | |
func (os OracleString) Value() (driver.Value, error) {
if !os.Valid || os.String == "" {
return nil, nil
}
return os.String, nil
} | Go | block | native | Ubuntu Mono | 20 | true | go-gorp/gorp | gorp.go | |
func (actor Actor) GetApplicationSummaryByNameAndSpace(appName string, spaceGUID string, withObfuscatedValues bool, routeActor RouteActor) (ApplicationSummary, Warnings, error) {
app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
if err != nil {
return ApplicationSummary{}, allWarnings,... | Go | block | one-dark | Ubuntu Mono | 20 | false | cloudfoundry/cli | actor/v7action/application_summary.go | |
func (actor Actor) GetApplicationSummaryByNameAndSpace(appName string, spaceGUID string, withObfuscatedValues bool, routeActor RouteActor) (ApplicationSummary, Warnings, error) {
app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
if err != nil {
return ApplicationSummary{}, allWarnings,... | Go | block | gruvbox-dark | Ubuntu Mono | 20 | false | cloudfoundry/cli | actor/v7action/application_summary.go | |
func (c *LexModelBuildingService) CreateSlotTypeVersionRequest(input *CreateSlotTypeVersionInput) (req *request.Request, output *CreateSlotTypeVersionOutput) {
op := &request.Operation{
Name: opCreateSlotTypeVersion,
HTTPMethod: "POST",
HTTPPath: "/slottypes/{name}/versions",
}
if input == nil {
inp... | Go | block | native | Ubuntu Mono | 16 | true | aws/aws-sdk-go | service/lexmodelbuildingservice/api.go | |
func (c *LexModelBuildingService) CreateSlotTypeVersionRequest(input *CreateSlotTypeVersionInput) (req *request.Request, output *CreateSlotTypeVersionOutput) {
op := &request.Operation{
Name: opCreateSlotTypeVersion,
HTTPMethod: "POST",
HTTPPath: "/slottypes/{name}/versions",
}
if input == nil {
inp... | Go | block | nord | DejaVu Sans Mono | 20 | true | aws/aws-sdk-go | service/lexmodelbuildingservice/api.go | |
func LinkSubscribeWithOptions(ch chan<- LinkUpdate, done <-chan struct{}, options LinkSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return linkSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | Go | block | vs | DejaVu Sans Mono | 18 | false | vishvananda/netlink | link_linux.go | |
func LinkSubscribeWithOptions(ch chan<- LinkUpdate, done <-chan struct{}, options LinkSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return linkSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | Go | block | gruvbox-light | Liberation Mono | 16 | true | vishvananda/netlink | link_linux.go | |
func (search *Search) Tags(tag string) (*SearchResult, error) {
insta := search.inst
body, err := insta.sendRequest(
&reqOptions{
Endpoint: urlSearchTag,
Query: map[string]string{
"is_typeahead": "true",
"rank_token": insta.rankToken,
"q": tag,
},
},
)
if err != nil {
return ... | Go | block | github-dark | Liberation Mono | 18 | true | ahmdrz/goinsta | search.go | |
func (search *Search) Tags(tag string) (*SearchResult, error) {
insta := search.inst
body, err := insta.sendRequest(
&reqOptions{
Endpoint: urlSearchTag,
Query: map[string]string{
"is_typeahead": "true",
"rank_token": insta.rankToken,
"q": tag,
},
},
)
if err != nil {
return ... | Go | block | github-dark | Liberation Mono | 16 | false | ahmdrz/goinsta | search.go | |
// shed load which accumulates due to the increasing ratio of active commands to incoming requests.
cmd.Lock()
select {
case cmd.ticket = <-circuit.executorPool.Tickets:
ticketChecked = true
ticketCond.Signal()
cmd.Unlock()
default: | Go | fragment | default | DejaVu Sans Mono | 15 | true | afex/hystrix-go | hystrix/hystrix.go | |
// shed load which accumulates due to the increasing ratio of active commands to incoming requests.
cmd.Lock()
select {
case cmd.ticket = <-circuit.executorPool.Tickets:
ticketChecked = true
ticketCond.Signal()
cmd.Unlock()
default: | Go | fragment | github-dark | Liberation Mono | 20 | true | afex/hystrix-go | hystrix/hystrix.go | |
}
if v.Autoscroll && len(v.viewLines) > maxY {
v.oy = len(v.viewLines) - maxY
}
y := 0
for i, vline := range v.viewLines {
if i < v.oy {
continue
}
if y >= maxY {
break
}
x := 0 | Go | fragment | material | DejaVu Sans Mono | 20 | true | jroimartin/gocui | view.go | |
}
if v.Autoscroll && len(v.viewLines) > maxY {
v.oy = len(v.viewLines) - maxY
}
y := 0
for i, vline := range v.viewLines {
if i < v.oy {
continue
}
if y >= maxY {
break
}
x := 0 | Go | fragment | solarized-dark | Ubuntu Mono | 18 | false | jroimartin/gocui | view.go | |
case *Error:
kiteErr = err
case *dnode.ArgumentError:
kiteErr = &Error{
Type: "argumentError",
Message: err.Error(),
}
default:
kiteErr = &Error{
Type: "genericError",
Message: fmt.Sprint(r),
}
} | Go | fragment | github-dark | Liberation Mono | 15 | false | koding/kite | errors.go | |
case *Error:
kiteErr = err
case *dnode.ArgumentError:
kiteErr = &Error{
Type: "argumentError",
Message: err.Error(),
}
default:
kiteErr = &Error{
Type: "genericError",
Message: fmt.Sprint(r),
}
} | Go | fragment | material | Ubuntu Mono | 20 | true | koding/kite | errors.go | |
func (set LiteralFieldSet) Clone() LiteralFieldSet {
clonedSet := NewLiteralFieldSet()
for elem := range set {
clonedSet.Add(elem)
}
return clonedSet
} | Go | block | solarized-dark | Liberation Mono | 16 | true | google/go-jsonnet | parser/literalfield_set.go | |
func (set LiteralFieldSet) Clone() LiteralFieldSet {
clonedSet := NewLiteralFieldSet()
for elem := range set {
clonedSet.Add(elem)
}
return clonedSet
} | Go | block | default | Ubuntu Mono | 14 | false | google/go-jsonnet | parser/literalfield_set.go | |
func shouldIgnoreFile(filename string) bool {
for _, regex := range ignoredFilesRegExps {
r, err := regexp.Compile(regex)
if err != nil {
beeLogger.Log.Fatalf("Could not compile regular expression: %s", err)
}
if r.MatchString(filename) {
return true
}
continue
}
return false
} | Go | block | vs | DejaVu Sans Mono | 20 | true | beego/bee | cmd/commands/run/watch.go | |
func shouldIgnoreFile(filename string) bool {
for _, regex := range ignoredFilesRegExps {
r, err := regexp.Compile(regex)
if err != nil {
beeLogger.Log.Fatalf("Could not compile regular expression: %s", err)
}
if r.MatchString(filename) {
return true
}
continue
}
return false
} | Go | block | one-dark | Liberation Mono | 18 | true | beego/bee | cmd/commands/run/watch.go | |
func (sf *sumFunction) GetType() *types.FieldType {
ft := types.NewFieldType(mysql.TypeNewDecimal)
ft.Charset = charset.CharsetBin
ft.Collate = charset.CollationBin
ft.Decimal = sf.Args[0].GetType().Decimal
return ft
} | Go | block | one-dark | Liberation Mono | 14 | false | chrislusf/gleam | sql/expression/aggregation.go | |
func (sf *sumFunction) GetType() *types.FieldType {
ft := types.NewFieldType(mysql.TypeNewDecimal)
ft.Charset = charset.CharsetBin
ft.Collate = charset.CollationBin
ft.Decimal = sf.Args[0].GetType().Decimal
return ft
} | Go | block | one-dark | Liberation Mono | 16 | true | chrislusf/gleam | sql/expression/aggregation.go | |
case 'a' <= c && c <= 'f':
return c - 'a' + 10, true
case 'A' <= c && c <= 'F':
return c - 'A' + 10, true
}
return 0, false | Go | fragment | material | Ubuntu Mono | 20 | false | gobuffalo/packr | v2/file/resolver/encoding/hex/hex.go | |
case 'a' <= c && c <= 'f':
return c - 'a' + 10, true
case 'A' <= c && c <= 'F':
return c - 'A' + 10, true
}
return 0, false | Go | fragment | native | DejaVu Sans Mono | 15 | false | gobuffalo/packr | v2/file/resolver/encoding/hex/hex.go | |
func (r *Store) GetSubStore(name string) (store.Store, error) {
if name == "" {
return r.store, nil
}
if sub, found := r.mounts[name]; found {
return sub, nil
}
return nil, errors.Errorf("no such mount point '%s'", name)
} | Go | block | zenburn | Ubuntu Mono | 15 | false | gopasspw/gopass | pkg/store/root/mount.go | |
func (r *Store) GetSubStore(name string) (store.Store, error) {
if name == "" {
return r.store, nil
}
if sub, found := r.mounts[name]; found {
return sub, nil
}
return nil, errors.Errorf("no such mount point '%s'", name)
} | Go | block | nord | Ubuntu Mono | 20 | true | gopasspw/gopass | pkg/store/root/mount.go | |
func (user *User) ResetOAuthToken() error {
err := user.saveProtectedSetting("OAuthToken", "")
if err != nil {
user.ctx.Log().WithError(err).Error("ResetOAuthToken error")
}
return err
} | Go | block | one-dark | Liberation Mono | 14 | true | requilence/integram | data.go | |
func (user *User) ResetOAuthToken() error {
err := user.saveProtectedSetting("OAuthToken", "")
if err != nil {
user.ctx.Log().WithError(err).Error("ResetOAuthToken error")
}
return err
} | Go | block | solarized-dark | Liberation Mono | 18 | false | requilence/integram | data.go | |
func (c *Client) RegionList(lr *ListRange) ([]Region, error) {
req, err := c.NewRequest("GET", "/regions", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var regionsRes []Region
return regionsRes, c.DoReq(req, ®ionsRes)
} | Go | block | one-dark | Liberation Mono | 16 | true | remind101/empire | pkg/heroku/region.go | |
func (c *Client) RegionList(lr *ListRange) ([]Region, error) {
req, err := c.NewRequest("GET", "/regions", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var regionsRes []Region
return regionsRes, c.DoReq(req, ®ionsRes)
} | Go | block | gruvbox-dark | DejaVu Sans Mono | 15 | false | remind101/empire | pkg/heroku/region.go | |
func SetDebugHook(l *State, f Hook, mask byte, count int) {
if f == nil || mask == 0 {
f, mask = nil, 0
}
if ci := l.callInfo; ci.isLua() {
l.oldPC = ci.savedPC
}
l.hooker, l.baseHookCount = f, count
l.resetHookCount()
l.hookMask = mask
l.internalHook = false
} | Go | block | native | Liberation Mono | 14 | true | Shopify/go-lua | debug.go | |
func SetDebugHook(l *State, f Hook, mask byte, count int) {
if f == nil || mask == 0 {
f, mask = nil, 0
}
if ci := l.callInfo; ci.isLua() {
l.oldPC = ci.savedPC
}
l.hooker, l.baseHookCount = f, count
l.resetHookCount()
l.hookMask = mask
l.internalHook = false
} | Go | block | gruvbox-dark | Ubuntu Mono | 18 | true | Shopify/go-lua | debug.go | |
func looksInternal(tok string) bool {
internal := []string{")", `’`, `”`, `"`, `'`}
for _, punc := range internal {
if strings.HasSuffix(tok, punc) {
return true
}
}
return false
} | Go | block | solarized-light | Liberation Mono | 14 | false | jdkato/prose | tokenize/punkt.go | |
func looksInternal(tok string) bool {
internal := []string{")", `’`, `”`, `"`, `'`}
for _, punc := range internal {
if strings.HasSuffix(tok, punc) {
return true
}
}
return false
} | Go | block | native | DejaVu Sans Mono | 16 | true | jdkato/prose | tokenize/punkt.go | |
func (j *Job) Tuesday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 2
job = j.Weeks()
return
} | Go | block | dracula | Ubuntu Mono | 15 | true | jasonlvhit/gocron | gocron.go | |
func (j *Job) Tuesday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 2
job = j.Weeks()
return
} | Go | block | solarized-dark | Ubuntu Mono | 16 | false | jasonlvhit/gocron | gocron.go | |
func (r *raftLog) DeleteRange(min, max uint64) (retErr error) {
r.Lock()
defer r.Unlock()
start := time.Now()
r.log.Noticef("Deleting raft logs from %v to %v", min, max)
err := r.deleteRange(min, max)
dur := time.Since(start)
durTxt := fmt.Sprintf("Deletion took %v", dur)
if dur > 2*time.Second {
r.log.Error... | Go | fragment | vs | Ubuntu Mono | 18 | false | nats-io/nats-streaming-server | server/raft_log.go | |
func (r *raftLog) DeleteRange(min, max uint64) (retErr error) {
r.Lock()
defer r.Unlock()
start := time.Now()
r.log.Noticef("Deleting raft logs from %v to %v", min, max)
err := r.deleteRange(min, max)
dur := time.Since(start)
durTxt := fmt.Sprintf("Deletion took %v", dur)
if dur > 2*time.Second {
r.log.Error... | Go | fragment | pastie | Liberation Mono | 18 | true | nats-io/nats-streaming-server | server/raft_log.go | |
return &UnsubackPacket{FixedHeader: fh}, nil
case Pingreq:
return &PingreqPacket{FixedHeader: fh}, nil
case Pingresp:
return &PingrespPacket{FixedHeader: fh}, nil
}
return nil, fmt.Errorf("unsupported packet type 0x%x", fh.MessageType) | Go | fragment | gruvbox-dark | Ubuntu Mono | 16 | true | eclipse/paho.mqtt.golang | packets/packets.go | |
return &UnsubackPacket{FixedHeader: fh}, nil
case Pingreq:
return &PingreqPacket{FixedHeader: fh}, nil
case Pingresp:
return &PingrespPacket{FixedHeader: fh}, nil
}
return nil, fmt.Errorf("unsupported packet type 0x%x", fh.MessageType) | Go | fragment | solarized-light | Ubuntu Mono | 14 | false | eclipse/paho.mqtt.golang | packets/packets.go | |
func FromStruct(m Manifest) (*DeserializedManifest, error) {
var deserialized DeserializedManifest
deserialized.Manifest = m
var err error
deserialized.canonical, err = json.MarshalIndent(&m, "", " ")
return &deserialized, err
} | Go | block | solarized-light | DejaVu Sans Mono | 14 | true | docker/distribution | manifest/schema2/manifest.go | |
func FromStruct(m Manifest) (*DeserializedManifest, error) {
var deserialized DeserializedManifest
deserialized.Manifest = m
var err error
deserialized.canonical, err = json.MarshalIndent(&m, "", " ")
return &deserialized, err
} | Go | block | gruvbox-dark | Liberation Mono | 20 | false | docker/distribution | manifest/schema2/manifest.go | |
func Parse(t Tokens) (ast.Node, error) {
p := makeParser(t)
expr, err := p.parse(maxPrecedence)
if err != nil {
return nil, err
}
if p.peek().kind != tokenEndOfFile {
return nil, MakeStaticError(fmt.Sprintf("Did not expect: %v", p.peek()), p.peek().loc)
}
addContext(expr, &topLevelContext, anonymous)
ret... | Go | block | material | Liberation Mono | 15 | true | google/go-jsonnet | parser/parser.go | |
func Parse(t Tokens) (ast.Node, error) {
p := makeParser(t)
expr, err := p.parse(maxPrecedence)
if err != nil {
return nil, err
}
if p.peek().kind != tokenEndOfFile {
return nil, MakeStaticError(fmt.Sprintf("Did not expect: %v", p.peek()), p.peek().loc)
}
addContext(expr, &topLevelContext, anonymous)
ret... | Go | block | gruvbox-dark | Ubuntu Mono | 15 | true | google/go-jsonnet | parser/parser.go | |
func printConfigChangeHelp(conf jsonconfig.Obj) {
// rename maps from old key names to the new ones.
// If there is no new one, the value is the empty string.
rename := map[string]string{
"keyId": "identity",
"publicKeyBlobref": "",
"selfPubKeyDir": "",
"secretRing": "identitySecretRing",... | Go | block | gruvbox-dark | Ubuntu Mono | 15 | true | perkeep/perkeep | pkg/client/config.go | |
func printConfigChangeHelp(conf jsonconfig.Obj) {
// rename maps from old key names to the new ones.
// If there is no new one, the value is the empty string.
rename := map[string]string{
"keyId": "identity",
"publicKeyBlobref": "",
"selfPubKeyDir": "",
"secretRing": "identitySecretRing",... | Go | block | vs | Liberation Mono | 16 | false | perkeep/perkeep | pkg/client/config.go | |
func NewBox(path string) Box {
var cd string
if !filepath.IsAbs(path) {
_, filename, _, _ := runtime.Caller(1)
cd = filepath.Dir(filename)
}
// this little hack courtesy of the `-cover` flag!!
cov := filepath.Join("_test", "_obj_test")
cd = strings.Replace(cd, string(filepath.Separator)+cov, "", 1)
if !file... | Go | block | nord | DejaVu Sans Mono | 16 | false | gobuffalo/packr | box.go | |
func NewBox(path string) Box {
var cd string
if !filepath.IsAbs(path) {
_, filename, _, _ := runtime.Caller(1)
cd = filepath.Dir(filename)
}
// this little hack courtesy of the `-cover` flag!!
cov := filepath.Join("_test", "_obj_test")
cd = strings.Replace(cd, string(filepath.Separator)+cov, "", 1)
if !file... | Go | block | vs | Ubuntu Mono | 20 | false | gobuffalo/packr | box.go | |
func extractMetric(m string) string {
start := 0
end := 0
curlyBraces := 0
quoteChar := byte(0)
allowEqual := false
for end < len(m) {
c := m[end]
if (c == '\'' || c == '"') && (end == 0 || m[end-1] != '\\') {
// Found a non-escaped quote char
if quoteChar == 0 {
quoteChar = c
start = end + 1
... | Go | block | nord | Liberation Mono | 18 | false | grafana/metrictank | expr/parse.go | |
func extractMetric(m string) string {
start := 0
end := 0
curlyBraces := 0
quoteChar := byte(0)
allowEqual := false
for end < len(m) {
c := m[end]
if (c == '\'' || c == '"') && (end == 0 || m[end-1] != '\\') {
// Found a non-escaped quote char
if quoteChar == 0 {
quoteChar = c
start = end + 1
... | Go | block | solarized-dark | Liberation Mono | 18 | true | grafana/metrictank | expr/parse.go | |
func New(url string) *Client {
return &Client{
url: url,
logger: log.New(os.Stderr, "[discovery] ", log.LstdFlags),
}
} | Go | block | solarized-dark | DejaVu Sans Mono | 20 | false | rqlite/rqlite | disco/client.go | |
func New(url string) *Client {
return &Client{
url: url,
logger: log.New(os.Stderr, "[discovery] ", log.LstdFlags),
}
} | Go | block | one-dark | Ubuntu Mono | 20 | true | rqlite/rqlite | disco/client.go | |
func (r RegexpTokenizer) Tokenize(text string) []string {
var tokens []string
if r.gaps {
temp := r.regex.Split(text, -1)
if r.discard {
for _, s := range temp {
if s != "" {
tokens = append(tokens, s)
}
}
} else {
tokens = temp
}
} else {
tokens = r.regex.FindAllString(text, -1)
}
... | Go | block | solarized-dark | DejaVu Sans Mono | 15 | false | jdkato/prose | tokenize/regexp.go | |
func (r RegexpTokenizer) Tokenize(text string) []string {
var tokens []string
if r.gaps {
temp := r.regex.Split(text, -1)
if r.discard {
for _, s := range temp {
if s != "" {
tokens = append(tokens, s)
}
}
} else {
tokens = temp
}
} else {
tokens = r.regex.FindAllString(text, -1)
}
... | Go | block | default | Ubuntu Mono | 16 | true | jdkato/prose | tokenize/regexp.go | |
func NewTunnelConnection(name string, spec TunnelConnectionSpecV2) (TunnelConnection, error) {
conn := &TunnelConnectionV2{
Kind: KindTunnelConnection,
SubKind: spec.ClusterName,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := conn.Chec... | Go | block | pastie | Ubuntu Mono | 15 | false | gravitational/teleport | lib/services/tunnelconn.go | |
func NewTunnelConnection(name string, spec TunnelConnectionSpecV2) (TunnelConnection, error) {
conn := &TunnelConnectionV2{
Kind: KindTunnelConnection,
SubKind: spec.ClusterName,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := conn.Chec... | Go | block | xcode | Ubuntu Mono | 15 | true | gravitational/teleport | lib/services/tunnelconn.go | |
func ConvertHTML(r io.Reader, readability bool) (string, map[string]string, error) {
meta := make(map[string]string)
buf := new(bytes.Buffer)
_, err := buf.ReadFrom(r)
if err != nil {
return "", nil, err
}
cleanXML, err := Tidy(buf, false)
if err != nil {
log.Println("Tidy:", err)
// Tidy failed, so we n... | Go | block | tango | DejaVu Sans Mono | 16 | true | sajari/docconv | html.go | |
func ConvertHTML(r io.Reader, readability bool) (string, map[string]string, error) {
meta := make(map[string]string)
buf := new(bytes.Buffer)
_, err := buf.ReadFrom(r)
if err != nil {
return "", nil, err
}
cleanXML, err := Tidy(buf, false)
if err != nil {
log.Println("Tidy:", err)
// Tidy failed, so we n... | Go | block | tango | Ubuntu Mono | 20 | true | sajari/docconv | html.go | |
}
return BlackList(str, chars)
} | Go | fragment | one-dark | Liberation Mono | 16 | false | asaskevich/govalidator | utils.go | |
}
return BlackList(str, chars)
} | Go | fragment | solarized-light | DejaVu Sans Mono | 20 | true | asaskevich/govalidator | utils.go | |
func (t *ImageCarouselTemplate) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type TemplateType `json:"type"`
Columns []*ImageCarouselColumn `json:"columns"`
}{
Type: TemplateTypeImageCarousel,
Columns: t.Columns,
})
} | Go | block | gruvbox-dark | Liberation Mono | 15 | false | line/line-bot-sdk-go | linebot/template.go | |
func (t *ImageCarouselTemplate) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type TemplateType `json:"type"`
Columns []*ImageCarouselColumn `json:"columns"`
}{
Type: TemplateTypeImageCarousel,
Columns: t.Columns,
})
} | Go | block | solarized-dark | Liberation Mono | 14 | false | line/line-bot-sdk-go | linebot/template.go | |
func truncateSheetXML(r io.Reader, rowLimit int) (io.Reader, error) {
var rowCount int
var token xml.Token
var readErr error
output := new(bytes.Buffer)
r = io.TeeReader(r, output)
decoder := xml.NewDecoder(r)
for {
token, readErr = decoder.Token()
if readErr == io.EOF {
break
} else if readErr != nil... | Go | block | dracula | Ubuntu Mono | 15 | false | tealeg/xlsx | lib.go | |
func truncateSheetXML(r io.Reader, rowLimit int) (io.Reader, error) {
var rowCount int
var token xml.Token
var readErr error
output := new(bytes.Buffer)
r = io.TeeReader(r, output)
decoder := xml.NewDecoder(r)
for {
token, readErr = decoder.Token()
if readErr == io.EOF {
break
} else if readErr != nil... | Go | block | gruvbox-light | DejaVu Sans Mono | 14 | false | tealeg/xlsx | lib.go | |
func isSSN(fl FieldLevel) bool {
field := fl.Field()
if field.Len() != 11 {
return false
}
return sSNRegex.MatchString(field.String())
} | Go | block | native | Liberation Mono | 20 | false | go-playground/validator | baked_in.go | |
func isSSN(fl FieldLevel) bool {
field := fl.Field()
if field.Len() != 11 {
return false
}
return sSNRegex.MatchString(field.String())
} | Go | block | tango | DejaVu Sans Mono | 14 | false | go-playground/validator | baked_in.go | |
func (c *DocDB) DescribeDBClustersRequest(input *DescribeDBClustersInput) (req *request.Request, output *DescribeDBClustersOutput) {
op := &request.Operation{
Name: opDescribeDBClusters,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"Marker"},
OutputT... | Go | block | pastie | DejaVu Sans Mono | 20 | true | aws/aws-sdk-go | service/docdb/api.go | |
func (c *DocDB) DescribeDBClustersRequest(input *DescribeDBClustersInput) (req *request.Request, output *DescribeDBClustersOutput) {
op := &request.Operation{
Name: opDescribeDBClusters,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"Marker"},
OutputT... | Go | block | solarized-dark | Liberation Mono | 20 | false | aws/aws-sdk-go | service/docdb/api.go | |
func (s *IssueService) GetTransitions(id string) ([]Transition, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/transitions?expand=transitions.fields", id)
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, nil, err
}
result := new(transitionResult)
resp, e... | Go | block | one-dark | Ubuntu Mono | 14 | false | andygrunwald/go-jira | issue.go | |
func (s *IssueService) GetTransitions(id string) ([]Transition, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/transitions?expand=transitions.fields", id)
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, nil, err
}
result := new(transitionResult)
resp, e... | Go | block | xcode | DejaVu Sans Mono | 18 | true | andygrunwald/go-jira | issue.go | |
func NewTokenHandler(transport http.RoundTripper, creds CredentialStore, scope string, actions ...string) AuthenticationHandler {
// Create options...
return NewTokenHandlerWithOptions(TokenHandlerOptions{
Transport: transport,
Credentials: creds,
Scopes: []Scope{
RepositoryScope{
Repository: scope,
... | Go | block | nord | Ubuntu Mono | 20 | false | docker/distribution | registry/client/auth/session.go | |
func NewTokenHandler(transport http.RoundTripper, creds CredentialStore, scope string, actions ...string) AuthenticationHandler {
// Create options...
return NewTokenHandlerWithOptions(TokenHandlerOptions{
Transport: transport,
Credentials: creds,
Scopes: []Scope{
RepositoryScope{
Repository: scope,
... | Go | block | friendly | Ubuntu Mono | 16 | true | docker/distribution | registry/client/auth/session.go | |
func (b *GetLabelChunkBody) Serialize(version uint8) ([]byte, error) {
buf := make([]byte, 8)
pos := 0
if version > 4 {
buf[pos] = b.Proto
binary.BigEndian.PutUint16(buf[pos+1:pos+3], b.Instance)
pos += 3
}
buf[pos] = b.Keep
binary.BigEndian.PutUint32(buf[pos+1:pos+5], b.ChunkSize)
pos += 5
return buf[0:p... | Go | block | gruvbox-dark | DejaVu Sans Mono | 18 | false | osrg/gobgp | internal/pkg/zebra/zapi.go | |
func (b *GetLabelChunkBody) Serialize(version uint8) ([]byte, error) {
buf := make([]byte, 8)
pos := 0
if version > 4 {
buf[pos] = b.Proto
binary.BigEndian.PutUint16(buf[pos+1:pos+3], b.Instance)
pos += 3
}
buf[pos] = b.Keep
binary.BigEndian.PutUint32(buf[pos+1:pos+5], b.ChunkSize)
pos += 5
return buf[0:p... | Go | block | material | Ubuntu Mono | 20 | false | osrg/gobgp | internal/pkg/zebra/zapi.go | |
func (n *Negroni) With(handlers ...Handler) *Negroni {
currentHandlers := make([]Handler, len(n.handlers))
copy(currentHandlers, n.handlers)
return New(
append(currentHandlers, handlers...)...,
)
} | Go | block | tango | DejaVu Sans Mono | 20 | true | urfave/negroni | negroni.go | |
func (n *Negroni) With(handlers ...Handler) *Negroni {
currentHandlers := make([]Handler, len(n.handlers))
copy(currentHandlers, n.handlers)
return New(
append(currentHandlers, handlers...)...,
)
} | Go | block | monokai | DejaVu Sans Mono | 15 | false | urfave/negroni | negroni.go | |
func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error) {
var aciinfos []*ACIInfo
rows, err := tx.Query("SELECT * from aciinfo WHERE hasPrefix(blobkey, $1)", prefix)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
aciinfo := &ACIInfo{}
if err := aciinfoRowScan(row... | Go | block | gruvbox-dark | Ubuntu Mono | 20 | true | rkt/rkt | store/imagestore/aciinfo.go | |
func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error) {
var aciinfos []*ACIInfo
rows, err := tx.Query("SELECT * from aciinfo WHERE hasPrefix(blobkey, $1)", prefix)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
aciinfo := &ACIInfo{}
if err := aciinfoRowScan(row... | Go | block | vs | DejaVu Sans Mono | 14 | false | rkt/rkt | store/imagestore/aciinfo.go | |
func QuotePattern(pattern string) string {
any := false
loop:
for _, r := range pattern {
switch r {
case '*', '?', '[', '\\':
any = true
break loop
}
}
if !any { // short-cut without a string copy
return pattern
}
var buf bytes.Buffer
for _, r := range pattern {
switch r {
case '*', '?', '[', ... | Go | block | gruvbox-dark | DejaVu Sans Mono | 20 | true | mvdan/sh | syntax/pattern.go | |
func QuotePattern(pattern string) string {
any := false
loop:
for _, r := range pattern {
switch r {
case '*', '?', '[', '\\':
any = true
break loop
}
}
if !any { // short-cut without a string copy
return pattern
}
var buf bytes.Buffer
for _, r := range pattern {
switch r {
case '*', '?', '[', ... | Go | block | solarized-light | Ubuntu Mono | 18 | false | mvdan/sh | syntax/pattern.go | |
func (g *Generator) printHeader() {
if g.buildTags != "" {
fmt.Println("// +build ", g.buildTags)
fmt.Println()
}
fmt.Println("// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.")
fmt.Println()
fmt.Println("package ", g.pkgName)
fmt.Println()
byAlias := map[string]string{}
var aliases ... | Go | block | solarized-dark | DejaVu Sans Mono | 15 | true | mailru/easyjson | gen/generator.go | |
func (g *Generator) printHeader() {
if g.buildTags != "" {
fmt.Println("// +build ", g.buildTags)
fmt.Println()
}
fmt.Println("// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.")
fmt.Println()
fmt.Println("package ", g.pkgName)
fmt.Println()
byAlias := map[string]string{}
var aliases ... | Go | block | friendly | DejaVu Sans Mono | 14 | true | mailru/easyjson | gen/generator.go | |
func (c *Context) EditPressedMessageText(text string) error {
if c.Callback == nil {
return errors.New("EditPressedMessageText: Callback is not presented")
}
return c.EditMessageText(c.Callback.Message, text)
} | Go | block | gruvbox-dark | DejaVu Sans Mono | 20 | false | requilence/integram | context.go | |
func (c *Context) EditPressedMessageText(text string) error {
if c.Callback == nil {
return errors.New("EditPressedMessageText: Callback is not presented")
}
return c.EditMessageText(c.Callback.Message, text)
} | Go | block | zenburn | Ubuntu Mono | 16 | false | requilence/integram | context.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.