code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
package testcase
import (
"fmt"
"testing"
"github.com/adamluzsi/testcase/internal"
)
// Suite meant to represent a testing suite.
// A test Suite is a collection of test cases.
// In a test suite, the test cases are organized in a logical order.
// A Suite is a great tool to define interface testing suites (contr... | Suite.go | 0.684264 | 0.511595 | Suite.go | starcoder |
package rb
import (
"github.com/dploop/golib/stl/types"
)
type Tree struct {
sentinel node
start *node
size types.Size
less types.BinaryPredicate
}
const (
red = 0
black = 1
)
type node struct {
parent *node
left *node
right *node
extra int8
data types.Data
}
func New(less types.Bina... | stl/collections/associative/rb/tree.go | 0.71103 | 0.45532 | tree.go | starcoder |
package main
import (
"flag"
"fmt"
"log"
"strconv"
"sync"
)
type Tree struct {
Left *Tree
Right *Tree
}
// Count the nodes in the given complete binary tree.
func (t *Tree) Count() int {
// Only test the Left node (this binary tree is expected to be complete).
if t.Left == nil {
return 1
}
return 1 + ... | cmd/binarytree-original/main.go | 0.671578 | 0.510252 | main.go | starcoder |
package plaid
import (
"encoding/json"
)
// StandaloneAccountType The schema below describes the various `types` and corresponding `subtypes` that Plaid recognizes and reports for financial institution accounts.
type StandaloneAccountType struct {
// An account type holding cash, in which funds are deposited. Supp... | plaid/model_standalone_account_type.go | 0.743913 | 0.517937 | model_standalone_account_type.go | starcoder |
package compiler
type jumpMap struct {
labelToPosition map[label][]int
positionToLabel map[int]label
}
func createJumpMap() *jumpMap {
return &jumpMap{
labelToPosition: make(map[label][]int),
positionToLabel: make(map[int]label),
}
}
func (j *jumpMap) registerJump(l label, i int) {
j.labelToPosition[l] = ap... | vendor/github.com/twtiger/gosecco/compiler/jump_map.go | 0.745213 | 0.521288 | jump_map.go | starcoder |
// Package gridworldmap worldmap.go Defines the map that actors live and move on.
package gridworldmap
import (
"sort"
"github.com/bluemun/munfall"
"github.com/bluemun/munfall/traits"
)
type worldMap2DGrid struct {
world munfall.World
cWidth, cHeight float32
width, height uint
grid []*... | gridworldmap/worldmap.go | 0.746878 | 0.705011 | worldmap.go | starcoder |
package main
// Builder design pattern tried to
// 1. Abstract complex creations so that object creation is seperated from object user.
// 2. Create an object step by step by filling it's fields and creating embedded objects.
// 3. Reuse the object creation algorithm between many objects.
// Builder design pattern is ... | creational/builder/builder/main.go | 0.743727 | 0.514339 | main.go | starcoder |
package boundaryh
// Computes first wSequence.
// Returns:
// "c" - wSequence class (see "wSequence rules").
// "pos" - point to first rune of next sequence (in other words "pos" is length of current wSequence).
func wFirstSequenceInString(s string) (c wClass, pos int) {
l := len(s)
if l == 0 {
return wClassO... | unicodeh/boundaryh/word-gen.go | 0.63443 | 0.546738 | word-gen.go | starcoder |
package circlepoints
import (
"math"
"math/rand"
)
type Point struct {
X, Y float64
}
type PointGenerator func() Point
type GenerationMethod int
const (
Rejection GenerationMethod = iota
SquareRoot
Triangle
Max
)
func GeneratePoints(numberToGenerate int, generationMethod GenerationMethod) []Point {
var ge... | circlepoints.go | 0.828245 | 0.528108 | circlepoints.go | starcoder |
package suffixtree
import (
"sort"
)
type node struct {
/*
* The payload array used to store the data (indexes) associated with this node.
* In this case, it is used to store all property indexes.
*/
data []int
/**
* The set of edges starting from this node
*/
edges []*edge
/**
* The suffix link as ... | node.go | 0.66072 | 0.471467 | node.go | starcoder |
package model
// Superhero is a model with custom hydration and extraction methods required to work with linkedin/goavro maps.
type Superhero struct {
ID int32
AffiliationID int32
Name string
Life float32
Energy float32
Powers []*Superpower
}
// ToMap extracts model da... | avro/model/linkedin/superhero.go | 0.667039 | 0.470797 | superhero.go | starcoder |
package chunkenc
import (
"io"
)
// bstream is a stream of bits.
type bstream struct {
stream []byte // the data stream
count uint8 // how many bits are valid in current byte
}
func newBReader(b []byte) *bstream {
return &bstream{stream: b, count: 8}
}
func newBWriter(size int) *bstream {
return &bstream{str... | functions/query/vendor/github.com/v3io/v3io-tsdb/pkg/chunkenc/bstream.go | 0.60778 | 0.426501 | bstream.go | starcoder |
package gospell
import "sort"
// Find all strings in the trie within a given deletion distance
// For example, for the Trie{"abcd", "abc", "ab", "cd"},
// Deletions("abcd", 2) would return ["ab", "cd"] and
// Deletions("abcd", 1) would return ["abc"]
func (t *Trie) Deletions(s string, distance int) []string {
return... | correction.go | 0.773986 | 0.561215 | correction.go | starcoder |
package strava
import (
"encoding/json"
"errors"
"fmt"
)
// A StreamSet is a collection of possible streams for an Activity, Segment or SegmentEffort.
// Some types may be nil if they weren't requested or do not exist.
// Time is the only required stream for Uploaded activities.
// Manually created activties have ... | vendor/github.com/strava/go.strava/streams.go | 0.740456 | 0.407687 | streams.go | starcoder |
package conf
// Int32Var defines an int32 flag and environment variable with specified name, default value, and usage string.
// The argument p points to an int32 variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) Int32Var(p *int32, name string, value int32, usage stri... | value_int32.go | 0.745861 | 0.599573 | value_int32.go | starcoder |
package src
import (
"strconv"
"strings"
"fmt"
)
/** Defines basic operations and helper functions for matrices */
/************** Begin parser for matrix **************/
func ApplyMatrixOperation(query string) (*Matrix, string) {
first, operator, second, argErr := findArgs(query);
if (argErr != ... | src/MatrixOperations.go | 0.729712 | 0.477493 | MatrixOperations.go | starcoder |
package bitfield
import (
"errors"
"math/bits"
"reflect"
)
var (
// ErrorsBitlistSize return when comparing two bitlists and don't share the same size.
ErrorsBitlistSize = errors.New("bitlists doesn't have the same size")
// ErrorBitlistOverlap return when two bitlist are being merged and they overlap
ErrorBit... | pkg/bitfield/bitfield.go | 0.657318 | 0.409575 | bitfield.go | starcoder |
package frechet
import (
"math"
"github.com/artpar/frechet/vectorutil"
// "fmt"
)
type PolyhedralDistanceFunction struct {
facets [][]float64;
facetSqrLength []float64;
}
func NewPolyhedralDistanceFunction(facets [][]float64) PolyhedralDistanceFunction {
p := PolyhedralDistanceFunction{facets:facets}
p... | frechet/polyhedraldistancefunction.go | 0.579995 | 0.558387 | polyhedraldistancefunction.go | starcoder |
package ghcrateengine
import (
"time"
"go.uber.org/zap/zapcore"
"github.com/transcom/mymove/pkg/unit"
)
// DefaultContractCode is the default contract code to assume for now
const DefaultContractCode = "TRUSS_TEST"
// minDomesticWeight is the minimum weight used in domestic calculations (weights below this are ... | pkg/services/ghcrateengine/shared.go | 0.735262 | 0.482612 | shared.go | starcoder |
package main
import (
"fmt"
"math"
)
// world with a volumetric mean radius in kilometers
type world struct {
radius float64
}
// distance calculation using the Spherical Law of Cosines.
func (w world) distance(p1, p2 location) float64 {
s1, c1 := math.Sincos(rad(p1.lat))
s2, c2 := math.Sincos(rad(p2.lat))
clo... | lesson22/distance/distance.go | 0.73307 | 0.485295 | distance.go | starcoder |
package conv
import (
"reflect"
"time"
)
// Provides a group of shortcut methods for convenient use, to avoid initializing the Conv struct.
var _defaultConv = new(Conv)
// ConvertType is equivalent to new(Conv).ConvertType() .
func ConvertType(src interface{}, dstTyp reflect.Type) (interface{}, error) {
return _... | shortcut.go | 0.845241 | 0.594904 | shortcut.go | starcoder |
// Package headhunter manages the headhunter databases, which keep track of which log segments correspond to the current revision of a given inode.
package headhunter
import (
"fmt"
"time"
"github.com/NVIDIA/sortedmap"
)
type BPlusTreeType uint32
const (
MergedBPlusTree BPlusTreeType = iota // Used only for Fe... | headhunter/api.go | 0.526586 | 0.405066 | api.go | starcoder |
package hdrbench
import (
"fmt"
"math"
"sync"
"github.com/go-errors/errors"
"github.com/octo47/hdrbench/circonusllhist"
"github.com/codahale/hdrhistogram"
)
type Histogram interface {
Name() string
// Calculate quantiles
Quantiles(qin []float64) ([]float64, error)
ValueAtQuantile(qin float64) int64
Signi... | experiment.go | 0.567218 | 0.438184 | experiment.go | starcoder |
package compare
import (
"fmt"
"reflect"
"regexp"
"github.com/fatih/color"
)
type CompareParams struct {
IgnoreValues bool `json:"ignoreValues" yaml:"ignoreValues"`
IgnoreArraysOrdering bool `json:"ignoreArraysOrdering" yaml:"ignoreArraysOrdering"`
DisallowExtraFields bool `json:"disallowExtraFields"... | compare/compare.go | 0.637144 | 0.436082 | compare.go | starcoder |
package flow
import (
"errors"
)
// ErrIsRoot is returned if deletion of the root node is attempted.
var ErrIsRoot = errors.New("cannot delete the root node")
// NodeLayout describes the layout state of a flowchart node.
type NodeLayout struct {
X, Y float64
}
func (fns *NodeLayout) Pos() (float64, float64) {
if... | flow/layout.go | 0.820397 | 0.436262 | layout.go | starcoder |
package store
import (
"bufio"
"io"
"github.com/pkg/errors"
)
const (
readerBufferSize = 32 * 1024
)
// byteRange holds information about a single byte range.
type byteRange struct {
offset int
length int
}
// byteRanges holds a list of non-overlapping byte ranges sorted by offset.
type byteRanges []byteRan... | vendor/github.com/thanos-io/thanos/pkg/store/io.go | 0.778607 | 0.453746 | io.go | starcoder |
// Package applytests provides an integration test suite for testing algorithms
// that apply catalogs.
package applytests
import (
"bytes"
"context"
"fmt"
"os"
"path/filepath"
"testing"
"github.com/zombiezen/mcm/catalog"
"github.com/zombiezen/mcm/internal/catpogs"
"github.com/zombiezen/mcm/internal/system"... | internal/applytests/applytests.go | 0.561936 | 0.481027 | applytests.go | starcoder |
package gofakeit
import (
"math/rand"
"strings"
)
// HackerPhrase will return a random hacker sentence
func HackerPhrase() string { return hackerPhrase(globalFaker.Rand) }
// HackerPhrase will return a random hacker sentence
func (f *Faker) HackerPhrase() string { return hackerPhrase(f.Rand) }
func hackerPhrase(r... | hacker.go | 0.669853 | 0.456834 | hacker.go | starcoder |
package common
// Tile is a single space within a 2D map, as read by ReadFileAsMap.
type Tile rune
// Map is a 2d map.
type Map [][]Tile
// ReadFileAsMap reads all lines from the given path and returns them as a two-dimensional map.
// If an error occurs, the function will panic.
func ReadFileAsMap(path string) Map ... | common/maps.go | 0.802439 | 0.510619 | maps.go | starcoder |
package mathsets
import (
"encoding/hex"
"errors"
"fmt"
)
func getNodeHash(txt string) string {
itm1, _ := hex.DecodeString(txt)
s := fmt.Sprintf("%x", Reversebytes(itm1))
return s
}
func getNodeRoot(sLeft string, sRight string) string {
// concat the hex from left and right
s := fmt.Sprintf("%s%s", sLeft,... | merkletree.go | 0.603932 | 0.44077 | merkletree.go | starcoder |
package sawari
import (
"github.com/jung-kurt/gofpdf"
)
const (
// RectStartingX .
RectStartingX = 25
// RectStartingY .
RectStartingY = 100
)
// MakeBody makes body
func MakeBody(pdf *gofpdf.Fpdf, entries []Entry, totalAmount int) {
width := float64(30)
pdf.Rect(RectStartingX, RectStartingY, float64(width... | body.go | 0.577019 | 0.419826 | body.go | starcoder |
package filter
import (
"image"
"image/color"
"github.com/mdouchement/hdr"
"github.com/mdouchement/hdr/hdrcolor"
"github.com/mdouchement/hdr/xmath"
)
// An Apply filter let's you apply any function on two colors.
type Apply struct {
HDRImage1 hdr.Image
HDRImage2 hdr.Image
hdrat func(x, y int) hdrcolor.Co... | filter/apply.go | 0.849472 | 0.425367 | apply.go | starcoder |
package matrix
import (
"fmt"
"strings"
)
// OneDimMatrix represents a matrix in a 1D array
type OneDimMatrix struct {
matrix []float64
nDim int
}
// NewOneDimMatrix creates and initializes a 2D array representing a matrix
func NewOneDimMatrix(initialValue float64, n int, topBoundary, bottomBoundary, leftBound... | model/matrix/one_dim_matrix.go | 0.807878 | 0.624866 | one_dim_matrix.go | starcoder |
package bytesutil
import (
"encoding/binary"
"encoding/hex"
"strings"
)
// Bytes1 returns the first byte of the little-endian representation of the supplied value.
func Bytes1(val uint64) []byte {
return bytesN(val, 1)
}
// Bytes2 returns the first two bytes of the little-endian representation of the supplied va... | bytes.go | 0.830044 | 0.745259 | bytes.go | starcoder |
package hardware
import (
"image"
"lightsaber/config"
)
type SamplesGeometry struct {
viewPort image.Rectangle
ledGeometry config.LedGeometry
margins config.Margins
size config.Size
}
func (s SamplesGeometry) Calculate() []image.Rectangle {
yResolution := s.viewPort.Max.Y
xResolution := s.viewP... | hardware/samples.go | 0.733929 | 0.425963 | samples.go | starcoder |
package main
import (
"image"
"image/color"
"image/png"
"math"
mr "math/rand"
"os"
m "github.com/go-gl/mathgl/mgl64"
)
var (
iterations int = 17
magic float64 = 0.53
volSteps int = 20
stepSize float64 = 0.1
zoom float64 = 0.800
tile ... | render/cosmic2.go | 0.625781 | 0.425904 | cosmic2.go | starcoder |
// gen.go generates the data files required to decode CEL images, which specify
// the decoding algorithms, image dimensions, palettes and colour transitions of
// each CEL image.
package main
import (
"bytes"
"flag"
"go/format"
"io/ioutil"
"log"
"path/filepath"
"text/template"
"github.com/pkg/errors"
"gith... | image/cel/config/gen.go | 0.687105 | 0.448185 | gen.go | starcoder |
package gographviz
import (
"sort"
)
// Edge represents an Edge.
type Edge struct {
Src string
SrcPort string
Dst string
DstPort string
Dir bool
Attrs Attrs
}
// Edges represents a set of Edges.
type Edges struct {
SrcToDsts map[string]map[string][]*Edge
DstToSrcs map[string]map[string][]*Edg... | vendor/github.com/awalterschulze/gographviz/edges.go | 0.668123 | 0.530297 | edges.go | starcoder |
package varis
import (
"fmt"
"math/rand"
)
// Perceptron implement Neural Network Perceptron by collect layers with Neurons and input/output channels.
type Perceptron struct {
layers [][]Neuron
input []chan float64
output []chan float64
}
// Calculate run Network calculations by wait signals from input channel... | perceptron.go | 0.659515 | 0.471832 | perceptron.go | starcoder |
package zset
import (
"math/rand"
)
/*=================================== Redis SkipList APIs ======================================
* zslCreate
* Create a new jump table. O(1)
* zslFree
* Releases the given jump table and all the nodes contained in the table. O(N), N is the Length of the jump table.
* zslInser... | zset.go | 0.656108 | 0.811415 | zset.go | starcoder |
package dline
import "github.com/filecoin-project/go-state-types/abi"
// Deadline calculations with respect to a current epoch.
// "Deadline" refers to the window during which proofs may be submitted.
// Windows are non-overlapping ranges [Open, Close), but the challenge epoch for a window occurs before
// the window... | dline/deadline.go | 0.757705 | 0.529446 | deadline.go | starcoder |
package vespyr
import (
"fmt"
"time"
"github.com/pkg/errors"
)
// RSIIndicator calculates the RSI indicator.
type RSIIndicator struct {
iterations uint
periods uint
lastValue float64
sumGains float64
sumLosses float64
lastAverageGain float64
lastAverageLoss float64
currentR... | pkg/vespyr/rsi.go | 0.810291 | 0.454351 | rsi.go | starcoder |
package sm
type Machineable interface {
GetState() string
SetState(string)
}
type transitionWhen int
const (
tunknown = iota
tbefore
tafter
taround
)
type actionFunc func(Machineable) error
type transition struct {
from string
to string
action actionFunc
when transitionWhen
}
type StateMachine st... | sm.go | 0.554229 | 0.407039 | sm.go | starcoder |
package vbge
import (
"sync"
"github.com/vikebot/vbcore"
)
// MapEntity describes a single map instance.
type MapEntity struct {
Height int
Width int
Matrix [][]*BlockEntity
SyncRoot sync.Mutex
}
// NewMapEntity allocates memory for a new map with the size specified by the
// `width` and `height` param... | vbge/mapentity.go | 0.788705 | 0.505859 | mapentity.go | starcoder |
package fitsio
import (
"bytes"
"fmt"
"reflect"
"strconv"
"strings"
)
// Column represents a column in a FITS table
type Column struct {
Name string // column name, corresponding to ``TTYPE`` keyword
Format string // column format, corresponding to ``TFORM`` keyword
Unit string // column unit, corr... | column.go | 0.618435 | 0.421492 | column.go | starcoder |
package config
var schemaV1 = `{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "config_schema_v1.json",
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"$ref": "#/definitions/service"
}
},
"additionalProperties": false,
"definitions": {
"service": {
... | vendor/github.com/hyperhq/libcompose/config/schema.go | 0.549157 | 0.484563 | schema.go | starcoder |
package aws
import (
"github.com/infracost/infracost/internal/resources"
"github.com/infracost/infracost/internal/schema"
"strings"
"github.com/shopspring/decimal"
)
type Kinesisanalyticsv2Application struct {
Address *string
Region *string
RuntimeEnvironment *s... | internal/resources/aws/kinesisanalyticsv2_application.go | 0.510741 | 0.421552 | kinesisanalyticsv2_application.go | starcoder |
package rbt
import (
"fmt"
"math"
)
/*
A binary search tree is a red-black tree if it satisfies the following
red-black properties:
1. Every node is either red or black.
2. Every leaf (NIL) is black.
3. If a node is red, then both its children are black.
4. Every simple path from a node to a descendant leaf conta... | Tree/red-black-tree/simple_rbt.go | 0.667256 | 0.558086 | simple_rbt.go | starcoder |
package astmodel
import (
"go/ast"
"sort"
)
// StructType represents an (unnamed) struct type
type StructType struct {
fields []*FieldDefinition
functions map[string]Function
}
// EmptyStructType is an empty struct
var EmptyStructType = NewStructType()
// Ensure StructType implements the Type interface corre... | hack/generator/pkg/astmodel/struct_type.go | 0.800926 | 0.424949 | struct_type.go | starcoder |
package utils
// find all indexes of the int64 element type from the array
// array []int64 : padding conversion array
// element int64 : padding conversion element
func FindInt64ElementIndex(array []int64 , element int64) []int {
indexs := make([]int , 0)
for index , value := range array {
if value == element {
... | slice_utils.go | 0.657538 | 0.624866 | slice_utils.go | starcoder |
package docs
var doc = `
{
"openapi": "3.0.0",
"servers": [
{
"url": "{{.Host}}"
}
],
"info": {
"description": "Downloads, checks and stores proxies from the web with rest api for querying results.",
"version": "{{.Version}}",
"title": "ProxyPool",
"license": {
"name": "Apa... | docs/openapi.go | 0.673621 | 0.450299 | openapi.go | starcoder |
package game
import (
"fmt"
"github.com/dougfort/gocards"
)
// StackType represents one stack of cards in the Tableau
type StackType struct {
HiddenCount int
Cards gocards.Cards
}
// TableauWidth is the number of stacks in the Tableau
const TableauWidth = 10
// Tableau is the outer (visible) game layout
... | internal/game/types.go | 0.712332 | 0.591841 | types.go | starcoder |
package darksky
// Response формат ответа от DarkSky
type Response struct {
Currently struct {
ApparentTemperature float64 `json:"apparentTemperature"`
CloudCover float64 `json:"cloudCover"`
DewPoint float64 `json:"dewPoint"`
Humidity float64 `json:"humidity"`
Icon ... | internal/weather/darksky/response.go | 0.616359 | 0.401893 | response.go | starcoder |
package fp
// MapIntInt64Ptr takes two inputs -
// 1. Function 2. List. Then It returns a new list after applying the function on each item of the list
func MapIntInt64Ptr(f func(*int) *int64, list []*int) []*int64 {
if f == nil {
return []*int64{}
}
newList := make([]*int64, len(list))
for i, v := range list {
... | fp/mapioptr.go | 0.710427 | 0.404919 | mapioptr.go | starcoder |
package ordered
import (
"fmt"
"github.com/m4gshm/gollections/c"
"github.com/m4gshm/gollections/it/impl/it"
"github.com/m4gshm/gollections/notsafe"
"github.com/m4gshm/gollections/op"
"github.com/m4gshm/gollections/slice"
)
//NewSet creates the Set and copies elements to it.
func NewSet[T comparable](elements [... | immutable/ordered/set.go | 0.742888 | 0.434041 | set.go | starcoder |
package board
import "github.com/0xhexnumbers/partysim/mp1"
//ytiBoardData holds all of the board specific data related to YTI.
type ytiBoardData struct {
Thwomps [2]int
AcceptThwompPos [2]mp1.ChainSpace
RejectThwompPos [2]mp1.ChainSpace
StarPosition mp1.ChainSpace
}
//ytiCheckThwomp checks to see if ... | mp1/board/yti.go | 0.509764 | 0.510374 | yti.go | starcoder |
package fp
func (q BoolQueue) Enqueue(e bool) BoolQueue {
in := (*q.in).Cons(e)
return BoolQueue{&in, q.out}
}
func (q StringQueue) Enqueue(e string) StringQueue {
in := (*q.in).Cons(e)
return StringQueue{&in, q.out}
}
func (q IntQueue) Enqueue(e int) IntQueue {
in := (*q.in).Cons(e)
return IntQueue{&in, q.out}... | fp/bootstrap_queue_enqueue.go | 0.770465 | 0.435601 | bootstrap_queue_enqueue.go | starcoder |
package cp
type Segment struct {
*Shape
a, b, n Vector
ta, tb, tn Vector
r float64
a_tangent, b_tangent Vector
}
func (seg *Segment) CacheData(transform Transform) BB {
seg.ta = transform.Point(seg.a)
seg.tb = transform.Point(seg.b)
seg.tn = transform.Vect(seg.n)
var l, r, b, t float64
if se... | segment.go | 0.703957 | 0.556098 | segment.go | starcoder |
package jp
import (
"strconv"
)
// Equation represents JSON Path script and filter equations. They are used to
// build a script. The purpose of the Equation is to allow scripts or filters
// to be created without using a parser which could return an error if an
// invalid string representation of the script is pro... | jp/equation.go | 0.817028 | 0.62681 | equation.go | starcoder |
package nimble
import (
"fmt"
)
// A PixMap is a reference to a 2D array or subarray of pixels.
type PixMap struct {
buf []Pixel // underlying array of pixels. [0] is pixel at (0,0).
vstride int32 // stride between vertically adjacent pixels. [vstride] is pixel at (0,1).
width int32 // width of the ar... | nimble/PixMap.go | 0.870129 | 0.631949 | PixMap.go | starcoder |
package generator
import (
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/opcode"
"github.com/pingcap/parser/types"
log "github.com/sirupsen/logrus"
"github.com/chaos-mesh/horoscope/pkg/database"
"github.com/chaos-mesh/horoscope/pkg/executor"
"github.com/chaos-mesh/horoscope/pkg/utils"
)
const (
... | pkg/generator/range.go | 0.610105 | 0.404478 | range.go | starcoder |
// Package lines defines filters to split a stream of ASCII characters (usually
// the output ascii86) into lines of text and to combine lines of text into
// a stream of ASCII charaters. These filters can be connected to other filters
// via io.Pipes.
package lines
import (
"bufio"
"fmt"
"io"
"github.com/frien... | lines/lines.go | 0.651909 | 0.406567 | lines.go | starcoder |
package wm
import (
"math"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/test"
)
// FindObjectAtPixelPositionMatching looks for objects in the given canvas that are under pixel
// position at x, y. Objects must match the criteria in 'fn' and the first match will be returned.
func FindObjectAtPixelPositionMatching(x, y int, ... | wm/util.go | 0.648466 | 0.536009 | util.go | starcoder |
package binary
// BoolSlice encodes a slice of bools into the writer.
func (c *WriteChain) BoolSlice(b []bool) *WriteChain {
for _, el := range b {
c.Bool(el)
}
return c
}
// ByteSlice encodes a slice of bytes into the writer.
func (c *WriteChain) ByteSlice(b []byte) *WriteChain {
return c.bytes(b)
}
// Comple... | write_slice.go | 0.848314 | 0.411761 | write_slice.go | starcoder |
package days
import (
"fmt"
"math"
"joshatron.io/aoc2021/input"
)
func Day09Puzzle1() string {
heightMap := parseHeightMap(input.SplitIntoLines(input.ReadDayInput("09")))
totalRisk := 0
for x := 0; x < heightMap.xSize(); x++ {
for y := 0; y < heightMap.ySize(); y++ {
if heightMap.localMin(x, y) {
tot... | days/day09.go | 0.535827 | 0.455441 | day09.go | starcoder |
package goraph
import (
"sort"
)
type Edge struct {
toNodeID int
weight float64
}
func NewEdge(toNodeID int, weight float64) Edge {
return Edge{
toNodeID: toNodeID,
weight: weight,
}
}
type Node struct {
nodeID int
adjNodes map[int]Edge
}
func NewNode(nodeID int) *Node {
g := new(Node)
g.nodeID ... | graph.go | 0.563858 | 0.470737 | graph.go | starcoder |
package main
import (
"strings"
"github.com/freddy33/graphml"
uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
)
// NoteGraphUtil converts a NoteGraph to GraphML and saves the the GraphML document to a file
type NoteGraphUtil struct {
GraphMLUtil GraphMLUtil
}
// NoteGraphID is the ID used for the... | notegraphutil.go | 0.671578 | 0.508666 | notegraphutil.go | starcoder |
package trees
import (
"github.com/DheerendraRathor/ctci-go/utils"
)
type BinaryTree struct {
Value interface{}
Left *BinaryTree
Right *BinaryTree
height int
isHeightPopulated bool // This flag will be true once height is populated for all nodes in tree.
}
func (bt *BinaryTree) Heigh... | collections/trees/binaryTree.go | 0.758063 | 0.461563 | binaryTree.go | starcoder |
package main
import (
"fmt"
"math"
"runtime"
"sync"
)
// n contains the data to sort.
var n []int
// Generate the numbers to sort.
func init() {
for i := 10; i >= 0; i-- {
n = append(n, i)
}
}
func main() {
fmt.Println("single: ", single(n))
fmt.Println("unlimited: ", unlimited(n))
fmt.Println("numCPU: "... | concurrency/goroutines/example4/example4.go | 0.50293 | 0.492798 | example4.go | starcoder |
package clang
// #include "./clang-c/Index.h"
// #include "go-clang.h"
import "C"
import "fmt"
/*
Flags that control the creation of translation units.
The enumerators in this enumeration type are meant to be bitwise
ORed together to specify which options should be used when
constructing the translation unit.
*/... | clang/translationunit_flags_gen.go | 0.631026 | 0.402421 | translationunit_flags_gen.go | starcoder |
package ellipse
import (
"math"
"github.com/adamcolton/geom/d2"
"github.com/adamcolton/geom/d2/curve/ellipsearc"
"github.com/adamcolton/geom/d2/curve/line"
"github.com/adamcolton/geom/d2/shape/triangle"
)
// Ellipse fulfills Shape
type Ellipse struct {
perimeter *ellipsearc.EllipseArc
}
// New returns an Elli... | d2/shape/ellipse/ellipse.go | 0.895099 | 0.637412 | ellipse.go | starcoder |
// This package implements a basic LISP interpretor for embedding in a go program for scripting.
// This file contains the binary primitive functions.
package golisp
import (
"errors"
"fmt"
)
func RegisterBinaryPrimitives() {
MakePrimitiveFunction("binary-and", 2, BinaryAndImpl)
MakePrimitiveFunctio... | prim_binary.go | 0.762866 | 0.555254 | prim_binary.go | starcoder |
package iso20022
// Set of elements providing information specific to the individual transaction(s) included in the message.
type TransactionParty1 struct {
// Party initiating the payment to an agent. In the payment context, this can either be the debtor (in a credit transfer), the creditor (in a direct debit), or ... | TransactionParty1.go | 0.756268 | 0.443721 | TransactionParty1.go | starcoder |
package validator
import (
"fmt"
"github.com/ccbrown/api-fu/graphql/ast"
"github.com/ccbrown/api-fu/graphql/schema"
"github.com/ccbrown/api-fu/graphql/schema/introspection"
)
type TypeInfo struct {
SelectionSetTypes map[*ast.SelectionSet]schema.NamedType
VariableDefinitionTypes map[*ast.VariableDefinitio... | graphql/validator/type_info.go | 0.538498 | 0.423756 | type_info.go | starcoder |
package functions
// Associate creates a map of comparables where key == value
func Associate[T comparable](items []T) map[T]T {
result := make(map[T]T, len(items))
for _, item := range items {
result[item] = item
}
return result
}
// AssociateBy returns a map of key O with value T. If for any items A, B key(A)... | functions.go | 0.770551 | 0.552359 | functions.go | starcoder |
package point
// Several similar sort functions. A SortXY will give more importance
// to X then to Y. If any of those characters is lowercase, it'll mean
// that the order in that case is reversed.
func SortXY(p1, p2 *Point) bool {
return (p1.X > p2.X) || (p1.X == p2.X && p1.Y >= p2.Y)
}
func SortXy(p1, p2 *Point) ... | point/sort.go | 0.825379 | 0.770508 | sort.go | starcoder |
package iso20022
// Plan that allows investors to schedule periodical investments or divestments, according to pre-defined criteria.
type InvestmentPlan10 struct {
// Frequency of the investment or divestment.
Frequency *Frequency20Choice `xml:"Frqcy"`
// Date the investment plan starts.
StartDate *ISODate `xml:... | InvestmentPlan10.go | 0.761982 | 0.434701 | InvestmentPlan10.go | starcoder |
package encryptor
import (
"context"
"github.com/cossacklabs/acra/acrastruct"
"github.com/cossacklabs/acra/encryptor/config"
"github.com/cossacklabs/acra/keystore"
)
// DataEncryptorContext store data for DataEncryptor
type DataEncryptorContext struct {
Keystore keystore.DataEncryptorKeyStore
Context context.C... | encryptor/dataEncryptor.go | 0.640861 | 0.40928 | dataEncryptor.go | starcoder |
package auth0fga
import (
"bytes"
_context "context"
_ioutil "io/ioutil"
_math "math"
_rand "math/rand"
_nethttp "net/http"
_neturl "net/url"
"strings"
"time"
)
// Linger please
var (
_ _context.Context
)
type Auth0FgaApi interface {
/*
* Check Check whether a user is authorized to access an object
... | api_auth0_fga.go | 0.880084 | 0.607183 | api_auth0_fga.go | starcoder |
package types
import (
"fmt"
sdk "github.com/Pylons-tech/cosmos-sdk/types"
)
// NewMinter returns a new Minter object with the given inflation and annual
// provisions values.
func NewMinter(inflation, annualProvisions sdk.Dec) Minter {
return Minter{
Inflation: inflation,
AnnualProvisions: annualProvi... | x/mint/types/minter.go | 0.825238 | 0.420838 | minter.go | starcoder |
package strings
import (
"fmt"
"strconv"
"strings"
)
type BingoString string
func (this BingoString) SnakeString() string {
data := make([]byte, 0, len(this)*2)
j := false
num := len(this)
for i := 0; i < num; i++ {
d := this[i]
if i > 0 && d >= 'A' && d <= 'Z' && j {
data = append(data, '_')
}
if ... | strings/strings.go | 0.568416 | 0.403743 | strings.go | starcoder |
package changes
// Splice represents an array edit change. A set of elements from the
// specified offset are removed and replaced with a new set of elements.
type Splice struct {
Offset int
Before, After Collection
}
// Revert inverts the effect of the splice.
func (s Splice) Revert() Change {
return Spl... | changes/splice.go | 0.830834 | 0.467393 | splice.go | starcoder |
package diff
import (
"fmt"
"github.com/attic-labs/noms/go/datas"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/status"
humanize "github.com/dustin/go-humanize"
)
// Summary prints a summary of the diff between two values to stdout.
func Summary(value1, value2 types.Value) {
if dat... | go/diff/summary.go | 0.546254 | 0.444324 | summary.go | starcoder |
package gofig
import (
"reflect"
"strconv"
)
// A Field represents a type that we can set a value for based on its key.
type Field interface {
// Set sets the fields value to the provided interface provided the types match.
Set(interface{}) error
// Key returns the full key path to the field
Key() string
// Va... | field.go | 0.739611 | 0.426142 | field.go | starcoder |
package controller
import (
"beam/cmd/segments/app"
"beam/model"
"encoding/json"
"fmt"
"strconv"
"strings"
uuid "github.com/gofrs/uuid"
"github.com/pkg/errors"
)
// Segment represents segment information stored in storage.
type Segment model.Segment
// SegmentCollection is the collection of Segments.
type S... | Beam/go/cmd/segments/controller/media_type.go | 0.723212 | 0.45944 | media_type.go | starcoder |
package sumcheck
import (
"gkr-mimc/circuit"
"github.com/consensys/gurvy/bn256/fr"
)
// GetClaim returns the sum of all evaluations don't call after folding
func (p SingleThreadedProver) GetClaim() fr.Element {
// Define usefull constants
n := len(p.eq.Table) // Number of subcircuit. Since we haven't fo... | sumcheck/evals.go | 0.749271 | 0.410756 | evals.go | starcoder |
package sort
// Implementation of the introspective sort algorithm, developed by
// <NAME>; implementation copied from the paper on introsort
// by <NAME>, with some modifications.
import (
"math"
)
// IntroSort sorts the array of strings using an introspective sort
// algorithm, so expect O(log(n)) running time.
... | sort/introsort.go | 0.669421 | 0.49707 | introsort.go | starcoder |
package cmd
import (
"fmt"
"math/big"
"os"
"sort"
"time"
"github.com/spf13/cobra"
"github.com/wealdtech/ethereal/cli"
"github.com/wealdtech/ethereal/util"
string2eth "github.com/wealdtech/go-string2eth"
)
var gasPriceBlocks int64
var gasPriceWei bool
var gasPriceLowest bool
var gas uint64
// gasPriceCmd r... | cmd/gasprice.go | 0.579162 | 0.46308 | gasprice.go | starcoder |
package shape
import (
"../shared"
"fmt"
"math"
"strconv"
)
/*
type shared.Point2d struct {
x int
y int
}
type shared.Path struct {
d string
fill bool
stroke string
vertexList []shared.Point2d
}
*/
// An arbitrary point outside the canvas
const INF = 10000000
// Checks if point q lies ... | shape/shape-calc.go | 0.68342 | 0.597079 | shape-calc.go | starcoder |
package advent2021
import (
"fmt"
)
// Lanternfish contains the attributes of each inidividual Lanternfish
type Lanternfish struct {
timer int
}
// School contains all the Lanternfish that are born
type School []Lanternfish
func (s School) printState() {
for _, fish := range s {
fmt.Printf("%d, ", fish.timer)
... | internal/pkg/advent2021/day6.go | 0.591959 | 0.456046 | day6.go | starcoder |
package vdf
import (
"bytes"
"fmt"
"io"
)
// Parser represents a parser.
type Parser struct {
s *Scanner
buf struct {
tok Token // last read token
lit string // last read literal
n int // buffer size (max=1)
}
}
// NewParser returns a new instance of Parser.
func NewParser(r io.Reader) *Parser {
... | vendor/github.com/andygrunwald/vdf/parser.go | 0.691393 | 0.440229 | parser.go | starcoder |
package macrocosm
import (
"fmt"
"math"
"sync"
"github.com/juju/loggo"
"github.com/dowlandaiello/eve/activation"
"github.com/dowlandaiello/eve/particle"
)
// FlattenedMacrocosm is an API-friendly macrocosm copy.
type FlattenedMacrocosm struct {
Particles [][][]particle.Particle `json:"-"` // the macrocosm's ... | macrocosm/macrocosm.go | 0.723114 | 0.54577 | macrocosm.go | starcoder |
package kol
import "fmt"
// Sequence returns lazily evaluated values.
type Sequence[E comparable] interface {
// Distinct returns a sequence containing only distinct elements.
Distinct() Sequence[E]
// Filter returns a sequence containing only elements matching the given predicate.
Filter(predicate func(element E... | sequence.go | 0.822973 | 0.667622 | sequence.go | starcoder |
package iso20022
// Cash movements into a fund as a result of investment funds transactions, eg, subscriptions or switch-in.
type CashInForecast5 struct {
// Date on which cash is available.
CashSettlementDate *ISODate `xml:"CshSttlmDt"`
// Sub-total amount of the cash flow in, expressed as an amount of money.
S... | CashInForecast5.go | 0.76986 | 0.419648 | CashInForecast5.go | starcoder |
package expression
import (
"fmt"
"regexp"
"strconv"
"strings"
"time"
errors "gopkg.in/src-d/go-errors.v1"
"github.com/dolthub/go-mysql-server/sql"
)
// Interval defines a time duration.
type Interval struct {
UnaryExpression
Unit string
}
// NewInterval creates a new interval expression.
func NewInterva... | sql/expression/interval.go | 0.695131 | 0.492676 | interval.go | starcoder |
package plaid
import (
"encoding/json"
)
// DeductionsBreakdown An object representing the deduction line items for the pay period
type DeductionsBreakdown struct {
// Raw amount of the deduction
CurrentAmount NullableFloat32 `json:"current_amount,omitempty"`
// Description of the deduction line item
Descriptio... | plaid/model_deductions_breakdown.go | 0.821939 | 0.538862 | model_deductions_breakdown.go | starcoder |
package app
// Defines the encoding we use to convert a JSON-like "document" into a binary stream for the datastore
import (
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math"
"strconv"
"strings"
"github.com/dgraph-io/badger"
)
const (
typeBool byte = 1
typeInt = 2
typeFloat = 3
typ... | app/badgertype.go | 0.606265 | 0.42919 | badgertype.go | starcoder |
package memsize
import (
"math/bits"
)
const (
uintptrBits = 32 << (uint64(^uintptr(0)) >> 63)
uintptrBytes = uintptrBits / 8
bmBlockRange = 1 * 1024 * 1024 // bytes covered by bmBlock
bmBlockWords = bmBlockRange / uintptrBits
)
// bitmap is a sparse bitmap.
type bitmap struct {
blocks map[uintptr]*bmBlock
}
... | vendor/github.com/fjl/memsize/bitmap.go | 0.627152 | 0.4016 | bitmap.go | starcoder |
// Use the template and follow the directions. You will be writing a web handler
// that performs a mock database call but will timeout based on a context if the call
// takes too long. You will also save state into the context.
package main
// Add imports.
// Declare a new type named `key` that is based on an int.
... | topics/go/packages/context/exercises/template1/template1.go | 0.785966 | 0.493226 | template1.go | starcoder |
package chunkify
import (
"errors"
)
// Represents a type which returns a receive-only channel of Chunk instances.
type Chunker interface {
Chunks() <-chan Chunk
}
// Specifies the range of indices the Chunk consists of.
// Start holds the starting index of this Chunk in the collection.
// End holds the ending ind... | chunker.go | 0.754282 | 0.48182 | chunker.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.