text stringlengths 11 4.05M |
|---|
package main
type MemorySpec struct {
Request string
Limit string
}
|
package main
import (
_ "fmt"
"testing"
)
func TestCostAllocationMatcher(t *testing.T) {
if !monthlyCostAllocationMatcher.MatchString("376681487066-aws-cost-allocation-2013-06.csv") {
t.Fail()
}
}
func TestDetailedBillingWithResourcesMatcher(t *testing.T) {
if !detailedBillingWithResourcesMatcher.MatchString(... |
package tarextract
// hat tip https://gist.github.com/indraniel/1a91458984179ab4cf80
import (
"archive/tar"
"compress/gzip"
"fmt"
"io"
"os"
"strings"
)
func ExtractTarGz(gzipStream io.Reader) error {
uncompressedStream, err := gzip.NewReader(gzipStream)
if err != nil {
return fmt.Errorf("gzip.NewReader() f... |
package evaluator_test
import (
"testing"
"github.com/makramkd/go-monkey/evaluator"
"github.com/makramkd/go-monkey/lexer"
"github.com/makramkd/go-monkey/object"
"github.com/makramkd/go-monkey/parser"
"github.com/stretchr/testify/assert"
)
func TestEvalIntegerLiteral(t *testing.T) {
testCases := []struct {
i... |
package encoding
import (
"bytes"
"context"
"testing"
"github.com/grafana/tempo/tempodb/backend"
"github.com/grafana/tempo/tempodb/encoding/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFromVersionErrors(t *testing.T) {
encoding, err := FromVersion("definitely-... |
/*
* Neblio REST API Suite
*
* APIs for Interacting with NTP1 Tokens & The Neblio Blockchain
*
* API version: 1.3.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package neblioapi
type Error struct {
Code int32 `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Fields ... |
package adapterstest
import (
"fmt"
"net/http/httptest"
"strings"
"testing"
"net/http"
"github.com/prebid/openrtb/v19/openrtb2"
)
// OrtbMockService Represents a scaffolded OpenRTB service.
type OrtbMockService struct {
Server *httptest.Server
LastBidRequest *openrtb2.BidRequest
LastHttpRequest *... |
// Copyright 2015 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package model
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewGameID(t *testing.T) {
for i := 0; i < 100; i++ {
gID := NewGameID()
require.NotEqual(t, InvalidGameID, gID)
}
}
func TestIsValidPlayerID(t *testing.T) {
testCases := []struct {
msg ... |
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"sort"
"strings"
)
type Problem struct {
ContestID int `json:"contestId"`
Index string `json:"index"`
Name string `json:"name"`
}
type Problems []Problem
func (s Problems) Len() int { return len(s) }
func (s Problems) Swap(i, j in... |
package securityutils
import (
"crypto/cipher"
"crypto/des"
"errors"
)
// =================== ECB模式 ======================
// DES加密, 使用ECB模式,注意key必须为8位长度
func DesEncryptECB(src []byte, key []byte) ([]byte, error) {
block, err := des.NewCipher(key)
if err != nil {
return nil, err
}
blockSize := block.BlockSiz... |
package controllers
import (
"testing"
//"ncbi_proj/server/utils"
//"net/http/httptest"
//"fmt"
)
func TestShow(t *testing.T) {
//ctx := utils.NewContext()
//dc := NewDirectoryController(ctx)
//
//w := httptest.NewRecorder()
//r := httptest.NewRequest("GET", "/file", nil)
//dc.Show(w, r)
//fmt.Println(w.Bo... |
package piscine
var res string
func Itoa(nbr int) string {
result = ""
t := 1
if nbr < 0 {
result += "-"
t = -1
}
if nbr != 0 {
q := (nbr / 10) * t
if q != 0 {
Itoa(q)
}
d := ((nbr % 10) * t) + '0'
result += string(rune(d))
} else {
result += "0"
}
return result
}
/*
func cleanStr(str st... |
// Copyright (c) 2019, Arm Ltd
package main
import (
"flag"
"fmt"
"strings"
"os"
"regexp"
"syscall"
"io/ioutil"
"github.com/fsnotify/fsnotify"
"github.com/golang/glog"
"gopkg.in/yaml.v2"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)
var confFileName string
const (
devi... |
package command
import (
"fmt"
"strings"
)
type parser struct {
template *Template
command *Command
lastLink link
more bool
boolFlagUsed []bool
valueFlagUsed []bool
}
func newParser(template *Template, command *Command) *parser {
return &parser{
template: template,
command... |
package follow
import (
"encoding/json"
"net/http"
"github.com/Emoto13/photo-viewer-rest/feed-service/src/follow/models"
)
type FollowClient interface {
GetFollowing(authHeader string) ([]*models.Following, error)
GetFollowers(authHeader string) ([]*models.Follower, error)
}
type followClient struct {
client ... |
package repository
import (
"github.com/jinzhu/gorm"
"github.com/pagient/pagient-server/pkg/model"
"github.com/pkg/errors"
"github.com/pagient/pagient-server/pkg/service"
)
type tokenRepository struct {
sqlRepository
}
// NewTokenRepository returns a new instance of a TokenRepository
func NewTokenRepository(db ... |
package resource
import (
"os"
"strings"
"sync"
"testing"
"time"
)
type MockFileInfo struct {
fileName string
}
func NewMockFileInfo(filename string) *MockFileInfo {
return &MockFileInfo{fileName: filename}
}
func (m *MockFileInfo) Name() string { return m.fileName }
func (m *MockFileInfo) Size() int64 ... |
package languagecode
// Format represents a specific language code format with a specific
// serialization.
type Format int
const (
// FormatAlpha3 is an ISO-639-2 language code.
FormatAlpha3 Format = iota
// FormatAlpha3B is an ISO-639-2/B language code.
FormatAlpha3B
// FormatAlpha2 is an ISO-639-1 language co... |
package api
import (
"crypto/sha1"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"os"
"path/filepath"
"reflect"
"testing"
"github.com/boltdb/bolt"
"github.com/gorilla/mux"
"github.com/pborman/uuid"
"k8s.io/api/core/v1"
platform "kolihub.io/koli/pkg/apis/core/v1alpha1"
"kolihub.io/koli/pkg/git/conf"
... |
package main
import (
"fmt"
)
func main() {
a := 42
b := 153
fmt.Println("a:", a)
fmt.Println("b:", b)
temp := b
b = a
a = temp
fmt.Println("a:", a)
fmt.Println("b:", b)
}
|
package model
import (
"github.com/RudyDamara/golang/lib/models"
"github.com/RudyDamara/golang/pkg/user_login/structs"
)
type UserLoginModel interface {
Logout(structs.User) chan models.Result
}
|
package main
import (
"fmt"
)
// START OMIT
type CustomError struct {
Message string
}
func (e *CustomError) Error() string {
return e.Message
}
func main() {
var err error = &CustomError{Message: "It is a custom error"}
fmt.Printf("Error: %s \n", err.Error())
}
// END OMIT
|
package main
import (
"fmt"
"strings"
"bufio"
"os"
)
func main () {
var str string
var first string
var last string
fmt.Printf("Enter a string:\n")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
str = scanner.Text()
str = strings.ToUpper(str)
first = str[0:1]
last = str[len(str)-1:]
if (f... |
package main
func Generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i
}
}
/**
in <-chan int 意思为把channel输入到in, 所以 in <- chan
out chan<- int, 意思为输出到这个 channel, 所以 out chan<-
**/
func Filter(in <-chan int, out chan<- int, prime int) {
for {
println("-------- filter ------------")
i := <-in
... |
package golang_blockchain
// type Nonce []byte
func (nonce *Nonce) Next() Nonce {
len := len(*nonce)
if len == 0 {
return Nonce{0}
}
next := make(Nonce, len)
copy(next, *nonce)
index := 0
for {
if next[index] < 255 {
next[index]++
return next
}
next[index] = 0
if index == len-1 {
return appe... |
package main
import "github.com/cakazies/project-service/routes"
func main() {
api := routes.ProjectServer{}
api.Run()
}
|
package command
import "runtime"
var os = runtime.GOOS
func GetCommand(command string) string {
switch command {
case "load_avg":
return getLoadAvgCommand()
case "cpu":
return getCPUCommand()
case "disk_io":
return getDiskIOCommand()
default:
return getLoadAvgCommand()
}
}
func getLoadAvgCommand() str... |
package main
import (
"runtime"
"sync"
"fmt"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
wg:=sync.WaitGroup{}
wg.Add(10)
for i:=0;i<10 ;i++ {
go Go(&wg,i)
}
wg.Wait()
}
func Go(wg *sync.WaitGroup,index int) {
a:=1
for i:=0;i<1000000 ;i++ {
a+=i
}
fmt.Println(index,a)
wg.Done()
}
|
package address
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type scalarType interface {
bool | int | int64 | time.Time | metav1.Time
}
func Of[T scalarType](i T) *T {
return &i
}
|
package main
import "fmt"
// const (
// winter = 1
// summer = 3
// yearly = winter + summer
// )
// func main() {
// var books [yearly]string
// books[0] = "kafka's revenge"
// books[1] = "stay Golden"
// books[2] = "Everythingship"
// books[3] = books[0] + " 2nd Edition"
// fmt.Printf("books :%#v\n", books)
/... |
package cli
import (
"context"
"fmt"
"os"
"strings"
"time"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/tilt-dev/tilt/internal/analytics"
"github.com/tilt-dev/tilt/internal/container"
ctrltiltfile "github.com/tilt-dev/tilt/internal/controllers/apis/tiltfile"
"github.c... |
package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
l "frank/src/go/helpers/log"
"frank/src/go/models"
"github.com/creasty/defaults"
"github.com/radovskyb/watcher"
"time"
)
type Config struct{}
var ParsedConfig models.Config
var FileName string
func Get(key string) string {
if val, ok := Pa... |
package adapter
type Envelope struct {
// 发送者信息
User struct {
Name string
Id string
}
// 对话名称(当公共频道时设置)
Room string
// 对话ID(当私聊时设置)
Id string
}
|
package nukeprediction
import (
"fmt"
"time"
"github.com/bwmarrin/discordgo"
)
// need to implement a system to clean the cache after a restore
type NukePrediction struct {
GuildID string
SuspicionLevel int
RestorableChannels []*discordgo.Channel
RestorableRoles []*discordgo.Role
Triggere... |
package slack
type content struct {
// expected type is "mrkdwn"
Type string `json:"type,omitempty"`
// markdown compliant message
Text string `json:"text,omitempty"`
}
// Block holds the different blocks uses in the Slack block API
// Hmm... omitempty doesn't omit zero structs https://github.com/golang/go/issues... |
// Use strings.Builder
// Builder: Design a html builder
// Builder Facet: Design a PersonBuilder, PersonJobBuilder, PersonAddressBuilder
// Builder Parameter: Design an EmailBuilder => func SendEmail(action func(b *EmailBuilder) {})
// Functional Builder: Design PersonBuilder combining Facet with Builder Parameter for... |
package main
import (
"fmt"
)
func americanNames() []string {
// fmt.Println("start1")
names := []string{"NO AMERICAN NAMES ARRAY"}
//////////////////////////////////////////////////////////////////////////////////////////////////////
switch genderIndex {
case 0:
names = []string{
//MALE
"JAMES",
"JO... |
package consul
import (
"sync"
"time"
"github.com/hashicorp/consul/api"
)
type stat struct {
Svcs sync.Map
}
func (c *Consul) GetStat(svc string) {
if _, ok := c.Svcs.Load(svc); ok {
return
}
hc, meta, _ := c.cc.Health().State("passing", &api.QueryOptions{
Filter: c.Proj + " in ServiceTags and " + svc + ... |
package main
import (
"fmt"
"os"
"reflect"
"strconv"
"time"
)
// Sprint format x
func Sprint(x interface{}) string {
type Stringer interface {
String() string
}
switch x := x.(type) {
case Stringer:
return x.String()
case string:
return x
case int:
return strconv.Itoa(x)
case float64:
return str... |
package draft
import (
"regexp"
"k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// this constant represents the length of a shortened git sha - 8 characters long
const shortShaIdx = 8
var shaRegex = regexp.MustCompile(`^[\da-f]{40}$`)
// NewSha creates a raw string to a SHA. Retu... |
// Copyright 2015 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
package language
var LangEn = map[string]string{
"open": "open",
"edit": "edit",
"create": "create",
"list": "list",
}
|
package gobbus
import (
"fmt"
"strings"
)
type Message struct {
Topic string
Flags *MessageFlags
val interface{}
Rtopic string
}
type MessageFlags struct {
Instant bool
NonRecursive bool
Response bool
Error bool
}
const (
msgFlInstant = 1 << 0
msgFlNonrecursive = 1 << 1
msgFlR... |
package project
import (
"github.com/saxon134/workflow/enum"
"time"
)
const TBNProjectRs = "project_rs"
type TblProjectRs struct {
Id int64 `json:"id"`
UserId int64 `json:"userId"`
ProjectId int64 `json:"projectId"`
Status enum.Status `json:"status"`
CreateAt *time.Time `json:... |
package commands
import (
"github.com/SAP/cloud-mta/internal/logs"
"github.com/SAP/cloud-mta/internal/version"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/x-cray/logrus-prefixed-formatter"
)
var cfgFile string
func init() {
logs.Logger = logs.NewLogger()
formatter, ok := logs.Logger.Formatte... |
package main
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestSwagger_Validate(t *testing.T) {
t.Parallel()
tests := []struct {
name string
input Swagger
expected Violations
}{
{
"Missing Operation ID",
Swagger{
Paths: map[Resource]Paths{
"/items": map[Method]Path{
... |
package structil_test
import (
"fmt"
"reflect"
"testing"
"unsafe"
. "github.com/goldeneggg/structil"
)
func BenchmarkNewGetter_Val(b *testing.B) {
var g *Getter
var e error
testStructVal := newGetterTestStruct() // See: getter_test.go
b.ResetTimer()
for i := 0; i < b.N; i++ {
g, e = NewGetter(testStruct... |
package authorization
// PermissionLevel enum for different forum permissions
type PermissionLevel string
const (
// Admin legends
Admin PermissionLevel = "AUTH_ADMIN"
// Moderator chat moderators
Moderator PermissionLevel = "AUTH_MODERATOR"
// Standard plebs
Standard PermissionLevel = "AUTH_STANDARD"
// Logge... |
package main
type person struct {
name string
int age
int height
int weight
}
|
package output
import (
"github.com/afritzler/garden-examiner/cmd/gex/context"
. "github.com/afritzler/garden-examiner/pkg/data"
)
type ElementOutput struct {
source ProcessingSource
Elems Iterable
}
func NewElementOutput(chain ProcessChain) *ElementOutput {
return (&ElementOutput{}).new(chain)
}
func (this *... |
package main
import (
"bufio"
"compress/gzip"
"flag"
"fmt"
"io"
"log"
"os"
"strconv"
"github.com/tsunami42/influxdb/models"
"github.com/tsunami42/influxdb/pkg/escape"
"github.com/tsunami42/influxdb/tsdb/engine/tsm1"
)
var (
tsmPath string
compress bool
outPath string
db string
rp string... |
package schedulecontracts
import (
"context"
"github.com/adamluzsi/frameless/internal/suites"
"github.com/adamluzsi/frameless/pkg/tasker/schedule"
"github.com/adamluzsi/frameless/ports/crud/crudcontracts"
"github.com/adamluzsi/frameless/ports/guard/guardcontracts"
"github.com/adamluzsi/testcase"
"github.com/ada... |
package department
import (
"github.com/gin-gonic/gin"
//"net/http"
//"fmt"
"go-antd-admin/utils/result"
"go-antd-admin/utils/e"
"go-antd-admin/models"
"strconv"
//"go-antd-admin/middleware/jwt"
)
func Index(c *gin.Context) {
c.String(200, "Hello World2")
}
var departmentModel = new(models.Department)
// @Sum... |
// Creates a predefined color selection dialog. The user receives the color in the RGB format.
package main
import (
"fmt"
"github.com/matwachich/iup"
)
func main() {
iup.Open()
defer iup.Close()
if ret, r, g, b := iup.GetColor(100, 100); ret != 0 {
iup.Message("Color", fmt.Sprintf("RGB = %v %v %v", r, g, b)... |
package requests
import (
"encoding/json"
"fmt"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
)
// DisableAssignmentsCurrentlyEnabledForGradeExportToSIS Disable all assignments flagged as "post_to_sis", with the option of making it
// specific to a grading peri... |
// Copyright 2018 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/li... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package utils
import (
"time"
)
// Timeout & interval for verifying audio, ethernet, display, power status when a dock interacts with Chromebook.
const (
AudioTimeout = ... |
/*
* Npcf_SMPolicyControl API
*
* Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 1.0.4
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
type UeInitiatedResource... |
package root
import (
"fmt"
"os"
"strconv"
"github.com/calebcase/version/lib/version"
"github.com/inconshreveable/log15"
"github.com/spf13/cobra"
"gopkg.in/src-d/go-git.v4"
)
var (
// Log is the logger for the CLI.
Log = log15.New()
// RepoPath is the path to the repository.
RepoPath = "."
// Cmd is th... |
package session
import (
"sync"
"sync/atomic"
"github.com/diamondburned/arikawa/discord"
"github.com/diamondburned/arikawa/state"
)
type Session struct {
*state.State
id discord.Snowflake
refs uint32
}
var (
ids = make(map[string]discord.Snowflake)
sessions = make(map[discord.Snowflake]*Sessi... |
package util
import (
"bufio"
"fmt"
"io"
"os"
)
type Csv struct {
Body string
Split string
File string
Tmp string
Filter []string
Fh bool
Limit int
Offset int
Head []P
Data []P
Err error
LockHead bool
}
func (this *Csv) Scan(head []P) (count int) {
if this.L... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package Median_of_Two_Sorted_Arrays
/*
m
n
i = (1+m)/2
i+j = (n+m)/2
j=(n+m)/2-i
j>=0
n+m >= 2m
n>=m
left | right
1,2,3...i | i+1,.....m
1,2,3...j | j+1,.....n
*/
// O(log(m+n))
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
//ensure n >= m
m, n := len(nums1), len(nums2)
if m > n {
... |
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"encoding/json"
"io"
"time"
"github.com/pkg/errors"
)
const authTokenTTL = 15 * time.Minute
type AuthToken struct {
... |
// The MIT License (MIT)
//
// Copyright (c) 2018 xgfone
// Copyright (c) 2017 LabStack
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation... |
package list
import (
"context"
"encoding/json"
"fmt"
"sort"
"github.com/loft-sh/devspace/cmd/flags"
"github.com/loft-sh/devspace/pkg/util/factory"
"github.com/loft-sh/devspace/pkg/util/log"
"github.com/loft-sh/devspace/pkg/util/message"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
type varsCmd struc... |
package base
import (
"github.com/xuperchain/xupercore/kernel/common/xcontext"
cctx "github.com/xuperchain/xupercore/kernel/consensus/context"
)
// ConsensusInterface 定义了一个共识实例需要实现的接口,用于bcs具体共识的实现
type ConsensusImplInterface interface {
// CompeteMaster 返回是否为矿工以及是否需要进行SyncBlock
CompeteMaster(height int64) (bool, ... |
package main
import "fmt"
// this is the fan in pattern where two or more chan combines to give one single chan.
func fanindriver() {
ck := fanin(counts("amy"), counts("rose"))
// amychan := counts("amy")
// rosechan := counts("rose")
for i := 0; i < 10; i++ {
fmt.Println(<-ck)
}
}
func fanin(c, k <-chan str... |
package main
import (
"fmt"
)
// START OMIT
var theMine = []string{"rock", "ore", "ore", "rock", "ore"}
func finder(mine []string) []string {
foundOre := []string{}
for _, v := range mine {
fmt.Printf("from mine: %v\n", v)
if v == "ore" {
foundOre = append(foundOre, v)
}
}
return foundOre
}
func miner(... |
/*
* Wodby API Client
*
* Wodby Developer Documentation https://wodby.com/docs/dev
*
* API version: 3.0.18
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package client
type ResponseTaskApp struct {
App *App `json:"app"`
Task *Task `json:"task"`
}
|
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package tracer
import (
"fmt"
"testing"
)
var tracer *Tracer = New()
func noop(t *testing.T) {
}
// use deeper call to demo recursive calls
func deeper(depth int, n int) {
defer tracer.ScopedTrace(fmt.Sprintf("depth %4d %4d", depth, n))()
if n > 0 {
deeper(depth, n-1)
}
}
func recursive_trace(n int) {
defe... |
package monitor
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
type AlertRecordListOptions struct {
options.BaseListOptions
AlertId string `help:"id of alert"`
Level string `help:"alert level"`
State string `help:"alert state"`
ResTypes []string `json:"res_types"`... |
package tasker
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
)
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
RunAs string `json:"run_as"`
LogFile string `json:"log_file"`
Readme strin... |
package query
import (
"bytes"
"strconv"
"gophr.pm/gocql/gocql@3ac1aabebaf2705c6f695d4ef2c25ab6239e88b3"
)
// ColumnValueAssignment represents a value assignment for a specific column of
// a row.
type columnValueAssignment struct {
column string
value string
parameterized bool
}
// UpdateQuery... |
/*
Copyright 2019 The xridge kubestone contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to i... |
package webapi
import (
"time"
"github.com/decred/dcrd/dcrec"
"github.com/decred/dcrd/dcrutil/v3"
"github.com/decred/dcrd/txscript/v3"
"github.com/decred/vspd/database"
"github.com/decred/vspd/rpc"
"github.com/gin-gonic/gin"
)
// payFee is the handler for "POST /payfee".
func payFee(c *gin.Context) {
// Get... |
package core
import "fmt"
// ClusterDisabled error generated if cluster is disabled
type ClusterDisabled struct {
Name string
}
func (err ClusterDisabled) Error() string {
return fmt.Sprintf("The cluster is not enabled: %s", err.Name)
}
|
package intset
import (
"bytes"
"fmt"
)
type BitInt32Set struct {
words []uint32
}
func NewBitInt32Set() *BitInt32Set {
return &BitInt32Set{}
}
func (s *BitInt32Set) Has(x int) bool {
word, bit := x/32, uint(x%32)
return word < len(s.words) && s.words[word]&(1<<bit) != 0
}
func (s *BitInt32Set) Add(x int) {
... |
package main
// Leetcode 830. (easy)
func largeGroupPositions(s string) (res [][]int) {
cnt := 1
for i := range s {
if i == len(s)-1 || s[i] != s[i+1] {
if cnt >= 3 {
res = append(res, []int{i - cnt + 1, i})
}
cnt = 1
} else {
cnt++
}
}
return
}
|
package structs
// Platform represents a third party streaming platform.
type Platform struct {
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
Images PlatformImages `json:"images,omitempty"`
}
|
package sparsemat
import (
"encoding/json"
"math/rand"
"reflect"
"sort"
"strconv"
"testing"
)
func TestCSRMat(t *testing.T) {
tests := []struct {
rows, cols int
data []int
expected [][]int
}{
{1, 1, []int{1}, [][]int{{1}}},
{2, 2, []int{1, 0, 0, 1}, [][]int{{1, 0}, {0, 1}}},
{2, 2, []int{}... |
package main
func main() {
}
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func isSymmetric(root *TreeNode) bool {
return areSymmetricNodes(root.Left, root.Right)
}
func areSymmetricNodes(lSubTree *TreeNode, rSubTree *TreeNode) bool {
if lSubTree == nil && rSubTree == nil {
return true
... |
//
// Copyright 2020 IBM Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
package main
import "fmt"
/*
切片操作符 [low,high]
规则0 <= low <= high <= cap(原切片)
*/
func main() {
s := make([]int, 3, 9)
fmt.Println(len(s), cap(s))
s1 := s[4:8]
fmt.Println(len(s1), cap(s1))
}
|
package utils
import (
"os"
"path/filepath"
"strconv"
"github.com/Al-un/alun-api/pkg/communication"
"github.com/joho/godotenv"
)
// AlunEmailSender is a convenient interface to send an email from a specific
// no-reply Alun email
type AlunEmailSender interface {
SendNoReplyEmail(to []string, subject string, te... |
package config
import (
"io/ioutil"
"regexp"
logger "github.com/sirupsen/logrus"
"github.com/smallfish/simpleyaml"
)
type Handlers struct {
yaml *simpleyaml.Yaml
}
func (h *Handlers) ReadYaml(filename string) {
source, err := ioutil.ReadFile(filename)
if err != nil {
logger.Fatalf("ERROR: reading config fi... |
package main
import (
"projects/DesignPatternsByGo/structuralPatterns/composite"
"fmt"
)
func main(){
root := composite.NewComponent(func() {
fmt.Println("My name is:"+"root")
},true).(*composite.Composite)
root.Add(composite.NewComponent(func() {
fmt.Println("I'm Leaf.")
},false).(composite.Component))
co... |
package main
import (
"fmt"
)
func main() {
s1 := []int{2, 3, 4, 5, 6}
s2 := []int{2, 3, 5, 7, 11, 13, 7, 19, 23}
s3 := []int{0, 10, 20, 30, 40, 50}
s4 := []int{3, 4, 34, 45, 56, 67}
fmt.Println("Looking for", 5, "in:", s1)
fmt.Printf("%d\n", search(s1, 5))
fmt.Println("Looking for", 5, "in:", s2)
fmt.Prin... |
/*
Copyright 2021 The KodeRover Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, s... |
// Copyright 2017 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
// Copyright 2014 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
package container
import "fmt"
//数组是值类型
func printArray(arr *[5]int) {
arr[0] = 100
for i,v:= range arr{
fmt.Println(i,v)
}
}
func main() {
var arr1 [5] int
arr2 := [3]int{3, 5, 6}
arr3 := [...]int{2, 4, 5, 6, 7}
var grid [4][5]int
fmt.Println(arr1, arr2, arr3)
fmt.Println(grid)
//for i := 0; i < len(ar... |
package main
import (
"testing"
)
func TestFindValEffect(test *testing.T) {
stringTol := "test:test"
expectedResults := []string{"test", "test"}
test.Log("testing findValEffect")
value, effect, err := findValEffect(stringTol)
if err != nil {
test.Errorf("%v", err)
} else if value != expectedResults[0] {
... |
package server
import "github.com/go-kit/kit/log"
//Logger fazzkit logger option
type Logger struct {
Logger log.Logger
Namespace string
Subsystem string
Action string
Domain string
}
|
package v1
import (
"fmt"
"github.com/gin-gonic/gin"
"go.rock.com/rock-platform/rock/server/clients/k8s"
"go.rock.com/rock-platform/rock/server/database/api"
"go.rock.com/rock-platform/rock/server/utils"
"k8s.io/api/core/v1"
"net/http"
"strconv"
"strings"
"time"
)
type NodeLabel struct {
Key string `json... |
package persist
import (
"fmt"
"testing"
"github.com/bww/godb/test"
"github.com/bww/godb/uuid"
)
import (
"github.com/stretchr/testify/assert"
)
func TestCRUD(t *testing.T) {
cxt := test.DB()
if !assert.NotNil(t, cxt) {
return
}
pe := &entityPersister{New(cxt)}
pf := &foreignPersister{New(cxt)}
f := &... |
package logic
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_TagIncluePriorierThanExcludeOk(t *testing.T) {
assert := assert.New(t)
a := Activity{
IncludeTag: []Tag{1000101, 2000101},
ExcludeTag: []Tag{1000101, 2000101},
}
tag := []Tag{1000101, 2000101}
assert.True(a.TagOK(tag))
}
func... |
package channel
import (
"regexp"
"errors"
)
// Subscribe Operation Topics
var (
// SubscribeReceiveLightMeasurement is a regex expression to match the parameters in the ReceiveLightMeasurement subscribe operation's channel
SubscribeReceiveLightMeasurementRegex = regexp.MustCompile("smartylighting/streetlights/1/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.