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 leaktest provides tools to detect leaked goroutines in tests.
// To use it, call "defer util.Check(t)()" at the beginning of each
// test that may use goroutines.
// copied out of the cockroachdb source tree with slight modifications to be
// more re-useable
package leaktest
import (
"runtime"
"sort"
"s... | vendor/github.com/fortytw2/leaktest/leaktest.go | 0.578567 | 0.415551 | leaktest.go | starcoder |
package transcoder
var UnicodeMap = map[string]string{
// No marks
`α`: `a`, // \u03b1 GREEK SMALL LETTER ALPHA
`β`: `b`, // \u03b2 GREEK SMALL LETTER BETA
`γ`: `g`, // \u03b3 GREEK SMALL LETTER GAMMA
`δ`: `d`, // \u03b4 GREEK SMALL LETTER DELTA
`ε`: `e`, // \u03b5 GREEK SMALL LETTER EPSILON
`ζ`: `z`, // ... | transcoder/unicode_map.go | 0.546012 | 0.617426 | unicode_map.go | starcoder |
package main
import (
"github.com/ByteArena/box2d"
"github.com/wdevore/RangerGo/api"
"github.com/wdevore/RangerGo/engine/nodes/custom"
)
// BasicLandCompoent represents both the visual and physic components
type BasicLandCompoent struct {
land api.INode
b2Body *box2d.B2Body
categoryBits uint16 // I am a...
m... | examples/physics/complex/scrolling/basic_land_component.go | 0.637934 | 0.606557 | basic_land_component.go | starcoder |
package go3mf
import "image/color"
// Texture2DType defines the allowed texture 2D types.
type Texture2DType uint8
const (
// TextureTypePNG defines a png texture type.
TextureTypePNG Texture2DType = iota + 1
// TextureTypeJPEG defines a jpeg texture type.
TextureTypeJPEG
)
func (t Texture2DType) String() strin... | materials.go | 0.833494 | 0.602763 | materials.go | starcoder |
package nom
import (
"bytes"
"encoding/gob"
"fmt"
)
// MACAddr represents a MAC address.
type MACAddr [6]byte
var (
MaskNoneMAC MACAddr = [6]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
BroadcastMAC MACAddr = [6]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
CDPMulticastMAC MACAddr = [6... | nom/addr.go | 0.664323 | 0.420838 | addr.go | starcoder |
package objects
type NDPGlobal struct {
baseObj
// placeholder to create a key
Vrf string `SNAPROUTE: "KEY", CATEGORY:"L3", ACCESS:"w", MULTIPLICITY:"1", AUTOCREATE: "true", DESCRIPTION: "System Vrf", DEFAULT:"default"`
RetransmitInterval int32 ` DESCRIPTION: "The time between re... | objects/ndpObjects.go | 0.642881 | 0.457318 | ndpObjects.go | starcoder |
package eval
import (
"fmt"
"github.com/apaxa-go/helper/goh/constanth"
"go/constant"
"reflect"
)
// ValueKind specifies the kind of value represented by a Value.
type ValueKind int
// Possible values for value's kind:
const (
Datas ValueKind = iota // value is Data
Type // type
B... | back/vendor/github.com/apaxa-go/eval/value.go | 0.69946 | 0.545407 | value.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// UnifiedRoleScheduleBase
type UnifiedRoleScheduleBase struct {
Entity
// Re... | models/unified_role_schedule_base.go | 0.672439 | 0.426262 | unified_role_schedule_base.go | starcoder |
package builders
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/juliosueiras/terraform-provider-packer/packer/communicators"
)
func VirtualboxISOResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeSt... | vendor/github.com/juliosueiras/terraform-provider-packer/packer/builders/virtualboxiso.go | 0.672547 | 0.40157 | virtualboxiso.go | starcoder |
package code
import (
"encoding/binary"
"fmt"
"strings"
)
// Opcode represents an opcode.
type Opcode byte
const (
// OpConstant is an opcode to push a constant value on to the stack.
OpConstant Opcode = iota
// OpPop is an opcode to pop the topmost element off the stack.
OpPop
// OpAdd is an opcode for addi... | code/code.go | 0.717012 | 0.618636 | code.go | starcoder |
package keeper
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/incentive/types"
savingstypes "github.com/kava-labs/kava/x/savings/types"
)
// AccumulateSavingsRewards calculates new rewards to distribute this block and updates the global indexes
func (k Keeper) AccumulateSav... | x/incentive/keeper/rewards_savings.go | 0.765681 | 0.403655 | rewards_savings.go | starcoder |
package generic
import (
"fmt"
"io"
"math"
"sync"
"sync/atomic"
"github.com/VividCortex/gohistogram"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/internal/lv"
)
// Counter is an in-memory implementation of a Counter.
type Counter struct {
bits uint64 // bits has to be the first word in or... | vendor/github.com/go-kit/kit/metrics/generic/generic.go | 0.839603 | 0.480174 | generic.go | starcoder |
package state
import (
"encoding/json"
"errors"
"math"
"math/rand"
"github.com/stellentus/cartpoles/lib/logger"
"github.com/stellentus/cartpoles/lib/rlglue"
)
// SensorDriftWrapper is used to wrap an environment, adding sensor drift.
type SensorDriftWrapper struct {
logger.Debug
Env rlglue.Environment
// Wr... | lib/state/sensor_drift_wrapper.go | 0.705176 | 0.433921 | sensor_drift_wrapper.go | starcoder |
// Prototyping is important, as well as writing proof of concept and solving problem in the
// concrete first. Then we can ask ourselves: What can change? What change is coming? so we can
// start decoupling and refactor.
// Refactoring need to become a part of the development cycle.
// Here is the problem that we a... | go/design/decoupling_1.go | 0.632389 | 0.747961 | decoupling_1.go | starcoder |
package kdtree
import "math"
type Axis int
const (
AxisX Axis = iota
AxisY
)
// two dimension tree implement
type KDNode struct {
X, Y float32
Dist float32
Left, Right, Parent *KDNode
Country string
Axis Axis
}
func (node *KDNode) distance(x, y float3... | kdtree/kdtree.go | 0.606265 | 0.576363 | kdtree.go | starcoder |
package apigatewayv2
// The authorization type. Valid values are NONE for open access, AWS_IAM for
// using AWS IAM permissions, and CUSTOM for using a Lambda authorizer.
type AuthorizationType string
// Enum values for AuthorizationType
const (
AuthorizationTypeNone AuthorizationType = "NONE"
AuthorizationTypeA... | service/apigatewayv2/api_enums.go | 0.73782 | 0.407098 | api_enums.go | starcoder |
package types
import (
"fmt"
"math"
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NOTE: we don't need to implement proto interface on this file
// these are not used in store or rpc response
// VoteForTally is a convenience wrapper to reduce redundant lookup cost
type VoteForTally struct {
Deno... | x/oracle/types/ballot.go | 0.707101 | 0.444806 | ballot.go | starcoder |
package storetest
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/xzl8028/xenia-server/model"
"github.com/xzl8028/xenia-server/store"
)
func TestSchemeStore(t *testing.T, ss store.Store) {
createDefaultRoles(t, ss)
t.Run("Save", func(t *testing.T) {... | store/storetest/scheme_store.go | 0.511229 | 0.597197 | scheme_store.go | starcoder |
package query
/*
Query processing involves multiple steps to produce a query to evaluate.
To unify multiple concerns, query processing is abstracted to a sequence of
steps that entail parsing, validity checking, transformation, and conditional
processing logic driven by external options.
*/
// A step performs a tran... | internal/search/query/query.go | 0.820469 | 0.72498 | query.go | starcoder |
package iso20022
// Specifies rates related to a corporate action option.
type CorporateActionRate37 struct {
// Rate used for additional tax that cannot be categorised.
AdditionalTax *RateAndAmountFormat14Choice `xml:"AddtlTax,omitempty"`
// Cash dividend amount per equity before deductions or allowances have be... | CorporateActionRate37.go | 0.860237 | 0.591841 | CorporateActionRate37.go | starcoder |
package sets
import (
"fmt"
"math"
"github.com/mitchellh/hashstructure/v2"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
)
// Set is a logical set of string values for the requirements.
// It supports representations using complement operator.
// e.g., if C={"A", "B"}, setting complement = true m... | pkg/utils/sets/sets.go | 0.717903 | 0.505798 | sets.go | starcoder |
package arib
import (
"bytes"
"sort"
"golang.org/x/text/encoding/japanese"
"golang.org/x/text/transform"
)
type code uint16
const (
kanji code = iota
alphanumeric
hiragana
katakana
mosaicA
mosaicB
mosaicC
mosaicD
propAlphanumeric
propHiragana
propKatakana
jisX0201Katakana
jisKanjiPlane1
jisKanjiP... | tsparser/arib/str.go | 0.5564 | 0.403684 | str.go | starcoder |
package test
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
)
const (
graniticHomeEnvVar = "GRANITIC_HOME"
goPathEnvVar = "GOPATH"
)
// FilePath finds the absolute path of a file that is provided relative to the testdata directory of the current package under test.
func ... | test/tools.go | 0.663778 | 0.510008 | tools.go | starcoder |
package regression
import (
"errors"
"fmt"
"gonum.org/v1/gonum/mat"
"math"
"strconv"
"strings"
)
var (
errNotEnoughData = errors.New("Not enough data points")
errTooManyvars = errors.New("Not enough observations to to support this many variables")
errRegressionRun = errors.New("Regression has already been ... | regression.go | 0.692538 | 0.54577 | regression.go | starcoder |
package strategy
import (
"fmt"
"k8s.io/kubernetes/pkg/kubectl/apply"
)
func createMergeStrategy(options Options, strategic *delegatingStrategy) mergeStrategy {
return mergeStrategy{
strategic,
options,
}
}
// mergeStrategy merges the values in an Element into a single Result
type mergeStrategy struct {
st... | vendor/k8s.io/kubernetes/pkg/kubectl/apply/strategy/merge_visitor.go | 0.743354 | 0.535827 | merge_visitor.go | starcoder |
package allegro
// #include <allegro5/allegro.h>
import "C"
type Transform C.ALLEGRO_TRANSFORM
// Sets the transformation to be used for the the drawing operations on the
// target bitmap (each bitmap maintains its own transformation). Every drawing
// operation after this call will be transformed using this transfo... | allegro/transform.go | 0.864611 | 0.496948 | transform.go | starcoder |
package missing_identity_store
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-identity-store",
Title: "Missing Identity Store",
Description: "The modeled architecture does not contain an identity store, which might be the risk ... | risks/built-in/missing-identity-store/missing-identity-store-rule.go | 0.666497 | 0.453867 | missing-identity-store-rule.go | starcoder |
package parser
type Visitor interface {
VisitPre(n Node) Node
VisitPost(n Node) Node
}
func Walk(n Node, v Visitor) Node {
n = v.VisitPre(n)
n.Accept(v)
return v.VisitPost(n)
}
type Node interface {
Accept(v Visitor)
}
// Query Statements
type TabularStmt struct {
TabularExpr *TabularExpr
}
func (s *Tabu... | internal/query/parser/ast.go | 0.587588 | 0.53206 | ast.go | starcoder |
package detector
import (
"fmt"
"os"
"talisman/git_repo"
"talisman/utility"
"github.com/olekukonko/tablewriter"
"gopkg.in/yaml.v2"
)
type FailureData struct {
FailuresInCommits map[string][]string
}
//DetectionResults represents all interesting information collected during a detection run.
//It serves as a c... | detector/detection_results.go | 0.610337 | 0.422803 | detection_results.go | starcoder |
// Package srnn implements the SRNN (Shuffling Recurrent Neural Networks) by <NAME> Wolf, 2020.
// (https://arxiv.org/pdf/2007.07324.pdf)
package srnn
import (
"encoding/gob"
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/nn"
"github.com/nlpodyssey/spago/nn/activ... | nn/recurrent/srnn/srnn.go | 0.773644 | 0.493653 | srnn.go | starcoder |
package chromath
import (
"math"
"sync"
)
func clip(v float64) float64 {
if v < 0.0 {
v = 0.0
} else if v > 1.0 {
v = 1.0
}
return v
}
type scaler8bClamping struct{}
// Scaler8bClamping is a simple mapping of values [0,255] to [0,1], clamping all out of bounds values
var Scaler8bClamping scaler8bClamping
... | vendor/github.com/jkl1337/go-chromath/ops.go | 0.683842 | 0.503906 | ops.go | starcoder |
package yasup
import (
crypto "crypto/rand"
"math/big"
"math/rand"
)
var zeroValueBool bool
//BoolInsert will append elem at the position i. Might return ErrIndexOutOfBounds.
func BoolInsert(sl *[]bool, elem bool, i int) error {
if i < 0 || i > len(*sl) {
return ErrIndexOutOfBounds
}
*sl = append(*sl, elem)... | boolSlices.go | 0.630799 | 0.452959 | boolSlices.go | starcoder |
package assertions
import (
"fmt"
"reflect"
"github.com/smartystreets/assertions/internal/oglematchers"
)
// ShouldContain receives exactly two parameters. The first is a slice and the
// second is a proposed member. Membership is determined using ShouldEqual.
func ShouldContain(actual interface{}, expected ...in... | vendor/github.com/smartystreets/assertions/collections.go | 0.84699 | 0.681051 | collections.go | starcoder |
package termboxUtil
import "github.com/nsf/termbox-go"
// Label is a field for inputting text
type Label struct {
id string
value string
x, y, width, height int
cursor int
fg, bg termbox.Attribute
bordered bool
wrap bool
multil... | vendor/github.com/br0xen/termbox-util/termbox_label.go | 0.68215 | 0.417925 | termbox_label.go | starcoder |
package timing
import (
"github.com/elainaaa/gosu-pp/math/mutils"
"math"
"sort"
)
type ControlPoint struct {
Time float64
beatLengthBase float64
beatLength float64
SampleSet int
SampleIndex int
SampleVolume float64
Signature int
Inherited bool
Kiai bool
OmitFirstBarLine bool
}
f... | beatmap/timing/timing.go | 0.794943 | 0.543469 | timing.go | starcoder |
package optimized_goroutine_k_way_merge_sort
import (
"runtime"
"sort"
"sync"
)
// MergeSort performs the merge sort algorithm.
// Please supplement this function to accomplish the home work.
func MergeSort(src []int64) {
srcLength := int64(len(src))
// 获取由src分割排序所得的有序子数组
sortedSubArrays ... | sort/external_sort/k_way_merge_sort/optimized_goroutine_k_way_merge_sort/mergesort.go | 0.547222 | 0.475544 | mergesort.go | starcoder |
package utils
import (
"bufio"
"bytes"
"errors"
"io"
)
type ByteStream struct {
buffer *bytes.Buffer
}
// Read reads up to len(b) bytes from the ByteStream.
// It returns the number of bytes read and any error encountered.
// At end of file, Read returns 0, io.EOF.
func (buffer *ByteStream) Read(b []byte) (n in... | utils/bytesstream.go | 0.733929 | 0.409988 | bytesstream.go | starcoder |
package allhic
import (
"bufio"
"fmt"
"os"
"sort"
"strings"
)
// merge is a generic type that stores the merges
type merge struct {
a int
b int
score float64
}
// Clusters stores all the contig IDs per cluster
type Clusters map[int][]int
// clusterLen helps sorting based on the length of a cluster
t... | cluster.go | 0.523664 | 0.474509 | cluster.go | starcoder |
package processor
import (
"archive/tar"
"archive/zip"
"bytes"
"context"
"fmt"
"os"
"time"
"github.com/benthosdev/benthos/v4/internal/batch"
"github.com/benthosdev/benthos/v4/internal/bloblang/field"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/co... | internal/old/processor/archive.go | 0.724968 | 0.510313 | archive.go | starcoder |
package math
import (
"bytes"
"encoding/binary"
"io"
"sort"
)
const VECTOR_COMPONENT_BYTES_SIZE = 4
type Vector []float32
func (v Vector) Len() int { return len(v) }
func (v Vector) Swap(i, j int) { v[i], v[j] = v[j], v[i] }
func (v Vector) Less(i, j int) bool { return v[i] < v[j] }
func (v Vector) Sort() Ve... | math/vector.go | 0.678859 | 0.490236 | vector.go | starcoder |
package processor
import (
"errors"
"fmt"
"time"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/response"
"github.com/Jeffail/benthos/v3/lib/types"
)
//------------------------------------------------------------------------------
func ... | lib/processor/resource.go | 0.641871 | 0.617628 | resource.go | starcoder |
// Package ledger implements a modified map with three unique characteristics:
// 1. every unique state of the map is given a unique hash
// 2. prior states of the map are retained for a fixed period of time
// 2. given a previous hash, we can retrieve a previous state from the map, if it is still retained.
package le... | vendor/istio.io/pkg/ledger/ledger.go | 0.829768 | 0.657937 | ledger.go | starcoder |
package asts
import (
"fmt"
"github.com/jschaf/bibtex/ast"
"github.com/jschaf/bibtex/token"
"strconv"
"strings"
)
func UnparsedBraceText(s string) *ast.UnparsedText {
return &ast.UnparsedText{
Kind: token.BraceString,
Value: s,
}
}
// BraceTextExpr return parsed text delimited by braces.
func BraceTextEx... | asts/asts.go | 0.690246 | 0.476214 | asts.go | starcoder |
package expogluster
import (
"strconv"
"strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
)
const (
namespace = "gluster"
allVolumes = "_all"
)
var (
up = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "up"),
"... | expogluster/prometheus.go | 0.541166 | 0.431944 | prometheus.go | starcoder |
package pike
import "runtime"
// LoadBalancer creates a Node that allocates a portion of its files to each
// of its connected outputs. It will preserve the ordering of files, so the
// first output gets the first N files, the second output gets the second N
// files, etc.
func LoadBalancer() *Node {
f := func(in, o... | fork.go | 0.627495 | 0.413063 | fork.go | starcoder |
// Package types provides the types that are used internally within the roomserver.
package types
import (
"github.com/matrix-org/dendrite/common"
"github.com/matrix-org/gomatrixserverlib"
)
// EventTypeNID is a numeric ID for an event type.
type EventTypeNID int64
// EventStateKeyNID is a numeric ID for an event... | src/github.com/matrix-org/dendrite/roomserver/types/types.go | 0.753285 | 0.605653 | types.go | starcoder |
package main
import (
"image"
_ "image/jpeg"
_ "image/png"
"io"
"math"
"os"
)
type TextureWrap int
// Extension point to allow custom processing
type TextureOnMapUv func(u, v float64, ii *IntersectionInfo) (float64, float64) // Triggers after u and v are fetched, but before they are used
type TextureOnImage f... | texture.go | 0.68679 | 0.4133 | texture.go | starcoder |
package fptower
import (
"errors"
"math/big"
)
// E6 is a degree-three finite field extension of fp2
type E6 struct {
B0, B1, B2 E2
}
// Equal returns true if z equals x, fasle otherwise
// TODO can this be deleted? Should be able to use == operator instead
func (z *E6) Equal(x *E6) bool {
return z.B0.Equal(&x... | ecc/bw6-761/internal/fptower/e6.go | 0.51562 | 0.560614 | e6.go | starcoder |
package compiler
import (
. "goluar/common"
"math"
)
/*
@description
Compute logical 'and', 'or' in the expression.
@param
exp BinopExp "binary opertor expression"
@return
exp Exp "Exp struct is defiend in ast_exp.go"
*/
func optimizeLogicalAndOr(exp *BinopExp) Exp {
switch exp.Op {
case LEX_OP_AND:
... | compiler/parse_optimizer.go | 0.607547 | 0.442817 | parse_optimizer.go | starcoder |
package life
import (
"math/rand"
"time"
)
// World represents a Game of Life world.
type World struct {
cells [][]int
width int
height int
}
// newWorld generates a new, empty World and returns a pointer to it.
func newWorld(width, height int) *World {
cells := make([][]int, height)
for row := range cells ... | internal/life/world.go | 0.829319 | 0.558628 | world.go | starcoder |
package pancake
import (
"reflect"
"regexp"
"errors"
)
// Strings takes a multidimensional slice of strings and flattens it into
// a 1-dimensional slice of strings in row major order.
func Strings(a interface{}) ([]string, error){
// Yep, I get it. I think I want Generics too...
return flattenDepthString(... | pancake.go | 0.688468 | 0.456894 | pancake.go | starcoder |
package moving_average
import (
"github.com/influxdata/flux/array"
"github.com/influxdata/flux/arrow"
"github.com/influxdata/flux/values"
)
type ArrayContainer struct {
array array.Array
}
func NewArrayContainer(a array.Array) *ArrayContainer {
return &ArrayContainer{a}
}
func (a *ArrayContainer) IsNull(i int)... | internal/moving_average/array_container.go | 0.671471 | 0.600481 | array_container.go | starcoder |
package hashmultimaps
// New factory that creates a new Hash Multi Map
func New[K, V comparable]() *HashMultiMap[K, V] {
multiMap := HashMultiMap[K, V]{data: make(map[K][]V)}
return &multiMap
}
// HashMultiMap a data structure representing a map of keys with lists of values
type HashMultiMap[K, V comparable] struct... | datastructures/maps/hashmultimaps/hash_multi_map.go | 0.82379 | 0.454896 | hash_multi_map.go | starcoder |
package dst
// Decorations returns the decorations that are common to all nodes (Before, Start, End, After).
func (n *ArrayType) Decorations() *NodeDecs {
return &n.Decs.NodeDecs
}
// Decorations returns the decorations that are common to all nodes (Before, Start, End, After).
func (n *AssignStmt) Decorations() *Nod... | vendor/github.com/dave/dst/decorations-node-generated.go | 0.90187 | 0.65426 | decorations-node-generated.go | starcoder |
package genworldvoronoi
import (
"github.com/fogleman/delaunay"
"math"
)
type Vertex [2]float64
type TriangleMesh struct {
RVertex []Vertex
RInS []int
TVertex []Vertex
Triangles []int
Halfedges []int
numBoundaryRegions int
numSolidSides int
numSide... | genworldvoronoi/triangle_mesh.go | 0.578686 | 0.537466 | triangle_mesh.go | starcoder |
package day22
import (
"fmt"
"math/big"
"strings"
)
// Technique is an interface for methods of shuffling a deck of cards.
type Technique interface {
Multiplier() int64
Constant() int64
}
// ParseTechnique reads a technique from a string description.
func ParseTechnique(s string) (Technique, error) {
if s == "... | day22/technique.go | 0.761627 | 0.524029 | technique.go | starcoder |
package timex
import (
"math"
"time"
)
type timeFmt string
func (tf timeFmt) String() string {
return string(tf)
}
const (
// XYear format
XYear timeFmt = "yy"
// XMonth format
XMonth timeFmt = "mm"
// XDay format
XDay timeFmt = "dd"
// XHour format
XHour timeFmt = "HH"
// XMinute format
XMinute timeFm... | timex.go | 0.70619 | 0.531817 | timex.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"math"
"strconv"
"strings"
)
type mask struct {
ones int64 // bitmask with 1s set where 1s appear in the original string
zeros int64 // bitmask with 1s set where 0s appear in the original string
xes []int // indices (zero-based) of the digits where Xs appear in the o... | day14/main.go | 0.728072 | 0.46223 | main.go | starcoder |
package extremegen
import (
"math"
"time"
"github.com/paulidealiste/goalgs/sortgen"
"github.com/paulidealiste/goalgs/utilgen"
)
type Extreme struct {
index int
value float64
min, max bool
}
type ExtremeDiff struct {
index []int
value float64
values []float64
min, max bool
}
type ExtremeSli... | extremegen/extremegen.go | 0.583678 | 0.481393 | extremegen.go | starcoder |
package nmea
import "fmt"
const (
// TypeGNS type for GNS sentences
TypeGNS = "GNS"
// NoFixGNS Character
NoFixGNS = "N"
// AutonomousGNS Character
AutonomousGNS = "A"
// DifferentialGNS Character
DifferentialGNS = "D"
// PreciseGNS Character
PreciseGNS = "P"
// RealTimeKinematicGNS Character
RealTimeKine... | gns.go | 0.502441 | 0.425426 | gns.go | starcoder |
package plaid
import (
"encoding/json"
"time"
)
// Transaction A representation of a transaction
type Transaction struct {
// Please use the `payment_channel` field, `transaction_type` will be deprecated in the future. `digital:` transactions that took place online. `place:` transactions that were made at a phy... | plaid/model_transaction.go | 0.876502 | 0.598576 | model_transaction.go | starcoder |
package unicornify
import (
. "github.com/balpha/go-unicornify/unicornify/core"
. "github.com/balpha/go-unicornify/unicornify/elements"
"math"
)
type Unicorn struct {
Figure
Head, Snout, Shoulder, Butt, HornOnset, HornTip *Ball
EyeLeft, EyeRight, PupilLeft, PupilRight *Ball
TailStart, TailEnd ... | unicornify/unicorn.go | 0.614047 | 0.485783 | unicorn.go | starcoder |
package geom
import (
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/gls"
"github.com/g3n/engine/math32"
"github.com/roboticeyes/gorexfile/encoding/rexfile"
)
// NewRexMeshGeometry returns a new geometry information for the given REX mesh datablock
func NewRexMeshGeometry(mesh rexfile.Mesh) *geometry.Ge... | geom/rexmeshgeometry.go | 0.583915 | 0.487673 | rexmeshgeometry.go | starcoder |
package main
import "fmt"
type set map[int]bool
// Define Graph structure
type Graph struct {
adjList map[int]set
}
// Create a graph and initialize its adjacency list, and return a pointer to it.
func createGraph() *Graph {
var g = Graph{}
g.adjList = make(map[int]set)
return &g
}
// Add an edge bet... | Algo_Ds_Notes-master/Algo_Ds_Notes-master/Depth_First_Search/Depth_First_Search.go | 0.685739 | 0.466116 | Depth_First_Search.go | starcoder |
package box2d
import (
"fmt"
)
/// Mouse joint definition. This requires a world target point,
/// tuning parameters, and the time step.
type B2MouseJointDef struct {
B2JointDef
/// The initial world target point. This is assumed
/// to coincide with the body anchor initially.
Target B2Vec2
/// The maximum co... | DynamicsB2JointMouse.go | 0.823825 | 0.581808 | DynamicsB2JointMouse.go | starcoder |
package term
import (
"fmt"
)
// prettyMessage helps formatting text for the convenience functions defined in this
// file. It prefixes a message with square brackets containing a (colored, if supported)
// marker like [*] (info), [!] (warning) and so on.
func prettyMessage(format, prefix string, data ...interface{}... | term/pretty.go | 0.627152 | 0.404155 | pretty.go | starcoder |
package main
import "strings"
// "fmt"
type Hand []string
var RANKS string = "--23456789TJQKA"
// findWinners returns the slice of winning players.
func (g *Game) findWinners(players []*Player) []*Player {
if len(players) == 0 {
return nil
} else if len(players) == 1 {
return players
}
hands := make([]Han... | hand.go | 0.650578 | 0.431165 | hand.go | starcoder |
package testutils
import (
"bytes"
"errors"
"sync"
"testing"
)
const (
// FailWrite is the string that should be sent to a WriteVerfier to test
// Write failures. This string will cause Write calls to return -1,
// errors.New("I was told to fail this!")
FailWrite = "Fail this write!"
)
// WriteVerifier funct... | WriteVerifier.go | 0.537527 | 0.428771 | WriteVerifier.go | starcoder |
package goavro
import (
"encoding/binary"
"fmt"
"io"
"math"
)
func booleanDecoder(buf []byte) (interface{}, []byte, error) {
if len(buf) < 1 {
return nil, nil, io.ErrShortBuffer
}
var b byte
b, buf = buf[0], buf[1:]
switch b {
case byte(0):
return false, buf, nil
case byte(1):
return true, buf, nil
... | primitives.go | 0.698741 | 0.407274 | primitives.go | starcoder |
package iso20022
// Set of elements providing information specific to the individual transaction(s) included in the message.
type TransactionAgents1 struct {
// Financial institution servicing an account for the debtor.
DebtorAgent *BranchAndFinancialInstitutionIdentification3 `xml:"DbtrAgt,omitempty"`
// Financi... | TransactionAgents1.go | 0.672977 | 0.493897 | TransactionAgents1.go | starcoder |
package slice
//FindString func
//Returns a pointer to the first element that the function returns truthy for, otherwise returns nil if the element is not found.
func FindString(input []string, f func(string) bool) *string {
for _, value := range input {
if f(value) {
return &value
}
... | slice/find.go | 0.871119 | 0.492554 | find.go | starcoder |
package geoip2
import (
"encoding/binary"
"errors"
"math"
"strconv"
)
func readControl(buffer []byte, offset uint) (byte, uint, uint, error) {
controlByte := buffer[offset]
offset++
dataType := controlByte >> 5
if dataType == dataTypeExtended {
dataType = buffer[offset] + 7
offset++
}
size := uint(contr... | vendor/github.com/IncSW/geoip2/common.go | 0.534855 | 0.512937 | common.go | starcoder |
// Package png provides a steganography implementation that outputs PNG image
// steganograms. It accepts both JPEG and PNG images as input.
package png
import (
"fmt"
"image"
"image/color"
_ "image/jpeg"
"image/png"
"io"
"log"
"math"
"math/rand"
"time"
"github.com/zanicar/stegano"
)
var (
_ stegano.Ste... | png/png.go | 0.772702 | 0.491761 | png.go | starcoder |
package should
import (
"fmt"
"reflect"
"strings"
)
const (
singleValueWithTypeLogFormat string = "\n assumption: [ %s ]\n should: %s \n expected: %v\n actual: %v\ntype actual: %T"
valuesWithTypeLogFormat string = "\n assumption: [ %s ]\n should: %s \n expected: %v\n actual: %v\ntype exp... | should/should.go | 0.61659 | 0.480174 | should.go | starcoder |
package util
import (
"math"
)
// Equatorial radius
const a = 6378137.0
// Polar radius
const b = 6356752.314245
// central meridian of zone
const long0 = 121. / 180 * math.Pi
// scale along long0
const k0 = 0.9999
// delta x in meter
const dx = 250000.
//WGS84ToTWD97 convert wgs84 lat lon ... | util/coordinate.go | 0.589244 | 0.402275 | coordinate.go | starcoder |
package games
import (
"bytes"
"me.dev/go-board-game/common"
)
/*
SIAM is played on a 5x5 board
Each players has 5 directional pieces
The board have three mountains
The winning player pushes a mountain off the board
*/
var board = common.Board(5)
// Direction ...
type Direction byte
const (
directionUp... | backend/src/games/siam.go | 0.591841 | 0.410579 | siam.go | starcoder |
package clang
// #include "go-clang.h"
import "C"
/*
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.
*/
type TranslationUnit_Flags uint32
const (
... | clang/tu_flags.go | 0.550366 | 0.446736 | tu_flags.go | starcoder |
package interop
import (
"encoding/json"
"errors"
"strings"
"github.com/cucumber/godog"
"github.com/google/uuid"
"github.com/trustbloc/edv/pkg/restapi/models"
"github.com/trustbloc/edv/test/bdd/pkg/common"
"github.com/trustbloc/edv/test/bdd/pkg/context"
)
const statusCode409Msg = "status code 409"
// Steps... | test/bdd/pkg/interop/edv_interop_steps.go | 0.677261 | 0.436742 | edv_interop_steps.go | starcoder |
package suffix
import (
"bytes"
"sort"
)
// Return
// the first index of the mismatch byte (from right to left, starts from 1)
// len(left)+1 if left byte sequence is shorter than right one
// 0 if two byte sequences are equal
// -len(right)-1 if left byte sequence is longer than right one
func suffixDiff(left, rig... | suffix.go | 0.740644 | 0.490297 | suffix.go | starcoder |
package input
import (
"fmt"
)
// BytePosition represents the byte position in a piece of code.
type BytePosition int
// Position represents a position in an arbitrary source file.
type Position struct {
// LineNumber is the 0-indexed line number.
LineNumber int
// ColumnPosition is the 0-indexed column positio... | pkg/schemadsl/input/inputsource.go | 0.879432 | 0.749718 | inputsource.go | starcoder |
package typeahead
import (
"bytes"
)
// Root represents the root of the radix tree.
type Root struct {
Node Node
}
// New returns a new tree.
func New() *Root {
return &Root{
Node: NewNode(),
}
}
// Insert adds a key value pair into the tree.
func (r *Root) Insert(key []byte, value interface{}) {
insert(&(r.... | typeahead.go | 0.733261 | 0.52756 | typeahead.go | starcoder |
package muxgo
// An object containing one or more reasons the input file is non-standard. See [the guide on minimizing processing time](https://docs.mux.com/guides/video/minimize-processing-time) for more information on what a standard input is defined as. This object only exists on on-demand assets that have non-sta... | model_asset_non_standard_input_reasons.go | 0.849971 | 0.577555 | model_asset_non_standard_input_reasons.go | starcoder |
package jet
import (
"fmt"
"reflect"
"time"
)
// Arguments holds the arguments passed to jet.Func.
type Arguments struct {
runtime *Runtime
args CallArgs
pipedVal *reflect.Value
}
// IsSet checks whether an argument is set or not. It behaves like the build-in isset function.
func (a *Arguments) IsSet(arg... | func.go | 0.712832 | 0.427935 | func.go | starcoder |
package toml
import (
"fmt"
"math"
"reflect"
"strings"
"sync"
)
type target interface {
// Dereferences the target.
get() reflect.Value
// Store a string at the target.
setString(v string)
// Store a boolean at the target
setBool(v bool)
// Store an int64 at the target
setInt64(v int64)
// Store a f... | vendor/github.com/pelletier/go-toml/v2/targets.go | 0.688259 | 0.505066 | targets.go | starcoder |
package server
import (
"log"
"math"
)
// AIGameState represents the state of a game and implements game domain-specific logic.
type AIGameState interface {
// Score evaluates the desirability of a state from the perspective of the AI player.
Score() float64
// AITurn returns true if the next move will be perfo... | pkg/server/ai_lib.go | 0.767603 | 0.582105 | ai_lib.go | starcoder |
package sqltest
import (
"context"
"database/sql"
"fmt"
"log"
"testing"
"github.com/networknext/dd-trace-go/tracer"
"github.com/networknext/dd-trace-go/tracer/tracertest"
"github.com/stretchr/testify/assert"
)
// Prepare sets up a table with the given name in both the MySQL and Postgres databases and return... | contrib/internal/sqltest/sqltest.go | 0.592195 | 0.498291 | sqltest.go | starcoder |
package mp4
import "github.com/wader/fq/pkg/scalar"
// based on https://github.com/HexFiend/HexFiend/blob/master/templates/Media/MOV.tcl
var boxDescriptions = scalar.StrToDescription{
"dimg": "Derived image",
"cdsc": "Content description",
"ainf": "Asset information to identify, license and play",
"albm": "Album... | format/mp4/desc.go | 0.71423 | 0.475362 | desc.go | starcoder |
package arc
import (
"github.com/golang-plus/caching"
"github.com/golang-plus/caching/container/memory"
)
func min(x, y int) int {
if x < y {
return x
}
return y
}
func max(x, y int) int {
if x > y {
return x
}
return y
}
// Container represents a ARC caching container.
type Container struct {
Capaci... | container/memory/arc/arc.go | 0.710126 | 0.404213 | arc.go | starcoder |
package jio
import (
"errors"
"math"
"strconv"
)
// Number Generates a schema object that matches number data type
func Number() *NumberSchema {
return &NumberSchema{
rules: make([]func(*Context), 0, 3),
}
}
var _ Schema = new(NumberSchema)
// NumberSchema match number data type
type NumberSchema st... | number.go | 0.840815 | 0.455925 | number.go | starcoder |
package metric
import (
"fmt"
"math"
)
var _ SeriesRecorder = &Series{}
type SeriesRecorder interface {
Values() []float64
Record(observation float64)
Count() int
Name() string
Capacity() int
Reset()
}
type Series struct {
name Name
count int
values []float64
}
type SeriesOption func(s *Series) error... | pkg/metric/series.go | 0.845815 | 0.509886 | series.go | starcoder |
package raftchunking
import "github.com/mitchellh/copystructure"
type ChunkStorage interface {
// StoreChunk stores Data from ChunkInfo according to the other metadata
// (OpNum, SeqNum). The bool returns whether or not all chunks have been
// received, as in, the number of non-nil chunks is the same as NumChunks.... | github.com/hashicorp/go-raftchunking/chunking.go | 0.605799 | 0.506103 | chunking.go | starcoder |
package timeseries
import (
"github.com/grokify/mogo/time/month"
"github.com/grokify/mogo/time/timeutil"
"gonum.org/v1/gonum/stat"
)
// LinearRegression returns the `alpha` and `beta` for the data series.
// It currently only supports `month` and `year` time intervals. When
// `month` is used, the time is converte... | data/timeseries/time_series_regression.go | 0.757884 | 0.518912 | time_series_regression.go | starcoder |
package main
// Imports are generally written at the top of the program.
// We're only importing "fmt" because that's all we need for this simple program.
import "fmt"
// Now, the actual code goes in the main function.
func main1() {
// We'll start out by just printing Hello, world!
fmt.Println("Hello, world!")
}
... | s2t1/main.go | 0.537527 | 0.471649 | main.go | starcoder |
package main
import (
"fmt"
"math"
"sort"
"strings"
"github.com/abates/AdventOfCode/coordinate"
)
func init() {
d10 := &D10{}
challenges[10] = &challenge{"Day 10", "input/day10.txt", d10}
}
type clockwise struct {
asteroids
center coordinate.Coordinate
}
func (c clockwise) Less(i, j int) bool {
a := c.as... | 2019/day10.go | 0.711832 | 0.404243 | day10.go | starcoder |
Spline interpolation by Hobby's algorithm results in aesthetically pleasing
curves superior to "normal" spline interpolation (as used in many graphics
programs). The primary source of information for "Hobby-splines" is:
Smooth, Easy to Compute Interpolating Splines -- <NAME>
Computer Science Dept. Stanford Univ... | jhobby/doc.go | 0.727007 | 0.600598 | doc.go | starcoder |
package main
import (
"fmt"
"strconv"
"strings"
)
type Graph struct {
VertexArray []*Vertex
}
type Vertex struct {
Id string
Visited bool
AdjEdge []*Edge
}
type Edge struct {
Source *Vertex
Destination *Vertex
Weight int
}
func NewGraph() *Graph {
return &Graph{
make([]*Vertex, 0),
}
}... | dijkstra/dijkstra.go | 0.567697 | 0.400192 | dijkstra.go | starcoder |
package extime
import (
"errors"
"time"
)
// TimeNop 格式: 20060102150405
type TimeNop time.Time
// MarshalJSON implemented interface Marshaler
func (t TimeNop) MarshalJSON() ([]byte, error) {
tt := time.Time(t)
if y := tt.Year(); y < 0 || y >= 10000 {
// RFC 3339 is clear that years are 4 digits exactly.
// ... | time_nop.go | 0.612773 | 0.422326 | time_nop.go | starcoder |
package ruleevaluation
import (
"github.com/SOMAS2020/SOMAS2020/internal/common/rules"
"github.com/pkg/errors"
"gonum.org/v1/gonum/mat"
)
func RuleMul(variableFormalVect mat.VecDense, ApplicableMatrix mat.Dense) *mat.VecDense {
nRows, _ := ApplicableMatrix.Dims()
actual := make([]float64, nRows)
c := mat.NewV... | internal/clients/team3/ruleevaluation/ruleevaluator.go | 0.679391 | 0.482429 | ruleevaluator.go | starcoder |
package cli
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
// Parsers for arguments and flag values.
// parseFunc is the type of functions that parse argument or flag strings into values.
type parseFunc func(string) (interface{}, error)
// buildParser constructs a parser for type t, or for the list of ... | parsers.go | 0.712932 | 0.4917 | parsers.go | starcoder |
package aoc2021
import (
"fmt"
"strconv"
"strings"
)
/*
--- Day 2: Dive! ---
Now, you need to figure out how to pilot this thing.
It seems like the submarine can take a series of commands like forward 1, down 2, or up 3:
forward X increases the horizontal position by X units.
down X increases the depth by X unit... | app/aoc2021/aoc2021_02.go | 0.628977 | 0.711706 | aoc2021_02.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.