text stringlengths 11 4.05M |
|---|
// 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... |
// Copyright 2022 PingCAP, Inc.
//
// 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 log
// Logger handle logs, ideally honoring the Quiet config parameter
type Logger interface {
Infof(format string, v ...interface{})
Fatalf(format string, v ...interface{})
Fatal(v ...interface{})
}
|
package models
// {“history”:[{“apple”:”gapple”},{“my”:”ymogo”},….]}
// TranslationHistoryList struct with list of translation items
type TranslationHistoryList struct {
History []map[string]string `json:"history"`
} |
package cryptonatorcom
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
"time"
"github.com/mmbros/quote/internal/quotegetter"
)
// getter gets cryptocurrrencies prices from cryptonator.com
type getter struct {
name string
client *http.Client
currency str... |
package main
import (
"image/color"
"log"
"math/rand"
"time"
"./monkey"
"./properties"
"./turtle"
"github.com/hajimehoshi/ebiten"
)
var background *ebiten.Image
var backgroundDrawOptions *ebiten.DrawImageOptions
var maxSinkingTurtles int = 1
var turtleDrawImageOptions ebiten.DrawImageOptions
var monkeyDrawI... |
package test
import (
"fmt"
"gengine/builder"
"gengine/context"
"gengine/engine"
"testing"
)
const n_m_model_rules = `
rule "100" "最高优先级" salience 100
begin
println("a")
data.Count += 2
end
rule "98" salience 97
begin
println("b")
data.Count += 2
end
rule "90" salience 90
begin
println("c")
data.Count... |
package message
import (
"fmt"
"net/http"
)
func VerifyHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Responding to challenge")
res := http.Response{
Status: "HTTP 200 OK",
Body: r.Body,
}
err := res.Write(w)
if err != nil {
// handle
}
fmt.Println("Verified!")
}
|
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
//CEP Guarda informações do CEP
type CEP struct {
DsCEP string `json:"cep"`
DsLogradouro string `json:"logradouro"`
DsComplemento string `json:""`
DsBairro string `json:"bairro"`
DsCidade string `json:"localidade"`
DsUf ... |
package request
import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
)
func Get(uri string) ([]byte, error) {
response, err := http.Get(uri)
defer response.Body.Close()
if err != nil {
return nil, err
}
return ioutil.ReadAll(res... |
package main
import (
"encoding/json"
"fmt"
"github.com/julienschmidt/httprouter"
"net/http"
"strconv"
//"strings"
)
//structure for all keys
var AllKeys KeysStructureStore
//key value Store
type KeyValueStore struct {
Key int64 `json:"key"`
Value string `json:"value"`
}
type Keys... |
package security
import (
"strconv"
"strings"
"time"
"github.com/gocql/gocql"
)
type CqlSetting struct {
cql *gocql.Session
expires time.Time
sites map[string]map[string]string
}
func NewCqlSetting(cql *gocql.Session) Setting {
s := &CqlSetting{
cql: cql,
}
return s
}
// Lookup a configuration se... |
package Facade
import "fmt"
type CarModel struct {
}
func NewCarModel() *CarModel {
return &CarModel{}
}
func (c *CarModel) SetModel() {
fmt.Println("carmodel - setmodel")
}
type CarEngine struct {
}
func NewCarEngine() *CarEngine {
return &CarEngine{}
}
func (c *CarEngine) SetEngine() {
fmt.Println("ca... |
package repository
import (
"database/sql"
"github.com/jmoiron/sqlx"
"github.com/voyagegroup/treasure-app/model"
)
func AllArticle(db *sqlx.DB) ([]model.Article, error) {
a := make([]model.Article, 0)
c := make([]model.Comment, 0)
if err := db.Select(&a, `SELECT id, title, body, user_id FROM article`); err != ... |
package main
import (
"bytes"
"fmt"
)
// IntSet is a list of unit64.
// Every element in the list has 64 bits to hash
// Every bit in an element might be either 0 (nonexist) or 1 (exist)
// As a result, every element in the IntSet takes 2**64 - 1 numbers
type IntSet struct {
words []uint64
}
// Use a simple hash ... |
package main
func main() {
defer foo()
println("first")
}
func foo() {
defer func() { println("very last") }()
println("last")
}
|
package qbuilder
import "github.com/spacycoder/cosmosdb-go-sdk/cosmos"
type Condition struct {
ConditionType string
Value string
}
type QueryBuilder struct {
selectors []string
from string
conditions []Condition
params []cosmos.QueryParam
orderBy string
}
// New creates a new QueryBuild... |
package meda
import (
"context"
"fmt"
"io"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
)
const filesTableNameBase = "files"
func (d *DB) FilesTableName() string {
return d.Config.TablePrefix + filesTableNameBase
}
const FilesMaxPathLength = 4096
// https://mariadb.com/kb/en/library/building-the-best-i... |
package main
import (
"bufio"
"fmt"
"log"
"net/http"
)
func main() {
// get the book adventures of sherlock holmes
res, err := http.Get("http://www.gutenberg.org/cache/epub/1661/pg1661.txt")
if err != nil {
log.Fatal(err)
}
// scan the page
scanner := bufio.NewScanner(res.Body)
defer res.Body.Close()
/... |
package fitbit
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestSleepLogsParamParse(t *testing.T) {
ctx := context.Background()
t.Run("ok cases", func(t *testing.T) {
cases := []struct {
in *SleepLogsParam
}{
{in: &SleepLogsParam{Date: "2006-01-02"}},
{in: &Sleep... |
package checkers
import (
"bufio"
"errors"
"os"
"strings"
)
// DoesFileHasWord reads a file line by line and checks if the line contains the word
func DoesFileHasWord(filename, word string) (bool, error) {
f, err := os.Open(filename)
if err != nil {
return false, err
}
defer f.Close()
if len(word) == 0 {
... |
package redirection
import (
"net/url"
"github.com/scjalliance/redirection/pattern"
)
// Element is an element of redirection logic. It maps URLs to redirection
// targets, is capable of matching hosts and/or paths, and can be formed into a
// processing tree.
type Element struct {
Host pattern.Set `json:"hos... |
/*
* @lc app=leetcode.cn id=55 lang=golang
*
* [55] 跳跃游戏
*/
// @lc code=start
package main
import (
"fmt"
"math"
)
func main() {
var a []int
a = []int{2, 3, 1, 1, 4}
fmt.Printf("%v, %t\n", a, canJump(a))
a = []int{3, 2, 1, 0, 4}
fmt.Printf("%v, %t\n", a, canJump(a))
a = []int{3, 2, 1, 0, 4}
fmt.Prin... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
package handler
import (
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"github.com/google/uuid"
"github.com/gorilla/mux"
. "2019_2_IBAT/pkg/pkg/models"
)
var (
vacancyParams = [...]string{
"position",
"region",
"wage",
"experience",
"type_of_employment",
"work_schedule",
}
)
func (h *Handler) Ge... |
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"io"
"log"
"synapse/src/blog/blogpb"
)
func main() {
fmt.Println("Blog client")
tls := true
opts := grpc.WithInsecure()
if tls {
creds, sslErr := credentials.NewClientTLSFromFile("ssl/ca.crt", "")
if ss... |
/*
Copyright 2022 The KubeVela 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, softw... |
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package amass
import (
"strings"
"time"
"github.com/OWASP/Amass/amass/core"
"github.com/OWASP/Amass/amass/utils"
evbus "github.com/asaskevich/EventBus"
)
// Subdo... |
package gdw
import (
"fmt"
"testing"
"time"
)
type adder struct {
count uint32
}
func (a adder) DoWork() {
a.count++
time.Sleep(1 * time.Second)
}
func TestWorkerPool(t *testing.T) {
test := adder{count: 0}
pool := NewWorkerPool(3)
defer pool.Close()
pool.Add(test, 10)
time.Sleep(1 * time.Second)
fmt.Pr... |
package config
import (
"encoding/json"
"fmt"
"testing"
)
func TestParse(t *testing.T) {
p, err := Parse("examples/simple.cfg")
if err != nil {
t.Errorf("parse: %s", err)
}
buf, err := json.MarshalIndent(p.Config, "", " ")
if err != nil {
t.Errorf("marshal: %s", err)
}
fmt.Printf("\n%s\n", buf)
}
|
// Copyright 2017 Kranz. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package web
import (
"fmt"
"net/http"
"github.com/rodkranz/fakeApi/modules/base"
"github.com/rodkranz/fakeApi/modules/context"
)
const (
Error404 base.TplName = "... |
package handlers
import "github.com/gin-gonic/gin"
type homeHandlerInterface interface {
Index(c *gin.Context)
HealthCheck(c *gin.Context)
}
type home struct{}
func NewHomeHandler() homeHandlerInterface {
return &home{}
}
func (h *home) Index(c *gin.Context) {
c.JSON(200, "Hello go-gin-lightweight API")
}
fun... |
package emailprovider
import (
"errors"
"net/mail"
)
// Enhanced string types to validate and enforce static checks of email arguments.
type EmailAddress interface {
Name() string
Address() string
}
type emailAddress struct {
address string
name string
}
func (e emailAddress) Name() string {
return e.name
... |
package main
import (
"strings"
"testing"
"github.com/temoto/phonetic-semantics/phonosem"
)
func TestParse01(t *testing.T) {
s := `
<tr>
<td>Большой-Маленький</td>
<td>2,4</td>
<td><div style='background: blue; width: 21%; height: 20px;'></div></td>
<td><span id='blue'>Большой</span></td>
</tr>
<tr>... |
package handlers
import (
"net/http"
"github.com/gorilla/mux"
)
// Application Router
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
Query *Query
Protected bool
}
type Query struct {
key string
value string
}
type Handler struct {
H func(w http.... |
package main
import (
"fmt"
// "os"
"strings"
)
// 获取tag的优先级,返回去掉()后的tag列表和分割符列表,括号内的保持原样,()不支持括号嵌套
func getTagPrio(tags string) (tag_list, sep []string) {
tags = strings.Trim(tags, " ")
tags = strings.Trim(tags, "|")
tags = strings.Trim(tags, ",")
taglen := len(tags)
tag := ""
var i, k int
for i = 0; i < t... |
package pgsql
import (
"testing"
)
func TestUUIDArray(t *testing.T) {
B := func(s string) []byte { return []byte(s) }
U := uuid16bytes
testlist2{{
valuer: UUIDArrayFromByteArray16Slice,
scanner: UUIDArrayToByteArray16Slice,
data: []testdata{
{input: [][16]byte(nil), output: [][16]byte(nil)},
{input:... |
// Copyright 2023 Google LLC. All Rights Reserved.
//
// 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 applica... |
package resources
import (
"errors"
"net/http"
"github.com/manyminds/api2go"
"gopkg.in/mgo.v2/bson"
"themis/utils"
"themis/models"
"themis/database"
)
// LinkResource for api2go routes.
type LinkResource struct {
LinkStorage *database.LinkStorage
WorkItemStorage *database.WorkItemStorage
}
func (c LinkRes... |
package collectors_test
import (
"net/http"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
"github.com/cloudfoundry-community/go-cfclient"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
. "github.com/bosh-prometheus/cf_exporter/colle... |
package entity
import (
"time"
)
type CmsTopic struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20) 'id'"`
CategoryId int64 `json:"category_id" xorm:"default NULL BIGINT(20) 'category_id'"`
Name string `json:"name" xorm:"default 'NULL' VARCHAR(255) 'name'"`
CreateTime ... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
fmt.Print("Input two Number : ")
reader := bufio.NewReader(os.Stdin)
line, _ := reader.ReadString(' ')
line = strings.TrimSpace(line)
n1, _ := strconv.Atoi(line)
line, _ = reader.ReadString('\n')
line = strings.TrimSpace(line)
... |
// Copyright (C) 2019 Cisco Systems Inc.
//
// 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 agr... |
package searching
import "fmt"
func BinarySearchCode() {
if BinarySearch() {
fmt.Println("Element found")
} else {
fmt.Println("Element not found")
}
}
func BinarySearch() bool {
s := []int{10, 23, 34, 35, 42}
element := 34
low := 0
high := len(s) - 1
for low <= high {
mid := (low + high) / 2
if s... |
package dto
type AddBookInput struct {
Title string `json:"title"`
Pages string `json:"pages"`
}
|
package memrepo
import (
"github.com/scjalliance/drivestream/collection"
"github.com/scjalliance/drivestream/page"
"github.com/scjalliance/drivestream/resource"
)
var _ page.Sequence = (*Pages)(nil)
// Pages accesses a sequence of pages in an in-memory repository.
type Pages struct {
repo *Repository
driv... |
package realm_test
import (
"fmt"
"testing"
"github.com/10gen/realm-cli/internal/cloud/realm"
u "github.com/10gen/realm-cli/internal/utils/test"
"github.com/10gen/realm-cli/internal/utils/test/assert"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func TestRealmIPAccess(t *testing.T) {
u.SkipUnlessRealmServe... |
package parser
func JobFetchCompanys(pctx *Context) error {
return nil
}
|
package error
import (
"fmt"
"testing"
)
func testHandleError(err *PathError) {
fmt.Print(err.Error() + " |=| ")
switch err.Err {
case ErrKeyNotFound:
fmt.Println("key not found")
case ErrIsNotFile:
fmt.Println("is not file")
case ErrKeyExist:
fmt.Println("key already exists")
default:
... |
package main
import (
"github.com/piquette/finance-go/quote"
"github.com/piquette/finance-go"
)
type decision struct {
symbol string
FiftyDayAverage bool
TwoHundredDayAverage bool
}
func GetData(symbols []string) *quote.Iter {
iter := quote.List(symbols)
return iter
}
func getRegularMarket... |
/*
We've all seen those online "maths hax" that look like this:
Think of a number, divide by 2, multiply by 0, add 8.
And, by magic, everyone ends up with the number 8!
Language
Let's define a programming language which uses the syntax of the text above, called "WordMath". WordMath scripts follow this template:
Thi... |
package bake
import (
"os"
"sort"
"testing"
"github.com/stretchr/testify/require"
)
func TestParseCompose(t *testing.T) {
var dt = []byte(`
services:
db:
build: ./db
command: ./entrypoint.sh
image: docker.io/tonistiigi/db
webapp:
build:
context: ./dir
dockerfile: Dockerfile-alter... |
package nodeconn
import (
"time"
"github.com/iotaledger/goshimmer/dapps/waspconn/packages/waspconn"
"github.com/iotaledger/goshimmer/packages/tangle"
"github.com/iotaledger/hive.go/events"
)
var EventMessageReceived = events.NewEvent(param1Caller)
func param1Caller(handler interface{}, params ...interface{}) {
... |
package backup
import (
"errors"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/facebook/fbthrift/thrift/lib/go/thrift"
"go.uber.org/zap"
"golang.org/x/net/context"
"golang.org/x/sync/errgroup"
// "github.com/vesoft-inc/nebula-clients/go/nebula/"
// "github.com/vesoft-inc/nebula-c... |
package table
import "sync"
type SyncTable struct {
sync.Mutex
table *Table
}
func NewSyncTable() *SyncTable {
return &SyncTable{
Mutex: sync.Mutex{},
table: NewTable(),
}
}
func (t *SyncTable) Load(row, col interface{}) (value interface{}, ok bool) {
t.Lock()
defer t.Unlock()
return t.table.Load(row, c... |
package db
import (
"fmt"
"log"
"strings"
"database/sql"
_ "github.com/mattn/go-sqlite3"
"github.com/royaloaklabs/super-genki-db/jmdict"
)
var (
//SQL is a wrapper for database/sql
SQL *sql.DB
//Driver is the database type
Driver = "sqlite3"
//Connection to the database
Connection = "./jisho-main.db"
... |
package handler
import (
"context"
"errors"
"fmt"
"github.com/jinmukeji/go-pkg/v2/crypto/hash"
proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/core/v1"
)
// ClientAuth 客户端授权
func (j *JinmuHealth) ClientAuth(ctx context.Context, req *proto.ClientAuthRequest, resp *proto.ClientAuthResponse) error... |
package app
import (
"runtime"
"strconv"
"syscall"
"time"
"github.com/gin-gonic/gin"
"github.com/itsjamie/gin-cors"
"github.com/kkurahar/go-gin-lightweight/helpers/config"
"github.com/kkurahar/go-gin-lightweight/helpers/database"
)
func Start() error {
app := setup()
env := config.GetEnvValue()
if config.... |
package integrationtest_test
import (
"fmt"
"net"
"net/http"
"testing"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/pborman/uuid"
)
func TestIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Test Suite")
}
var csb s... |
package util
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
"time"
"github.com/go-logr/logr"
csvv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io... |
package Grammar
import (
"fmt"
)
type Token interface {
GetType() uint8
GetString() string
}
type TokenOperator struct {
Info uint8
}
func (t *TokenOperator) GetType() uint8 {
return t.Info
}
func (t *TokenOperator) GetString() string {
switch t.Info {
case LParentheses: return "("
case RParentheses: retu... |
package main
import "log"
type shipped struct {
}
func (s shipped) updateState(context *deliveryContext) {
log.Println("shipped")
// will go to out for delivery
context.currentState = setCurrentState(outForDelivery{})
//dctx := &deliveryContext{}
//dctx.SetCurrentState(outForDelivery{})
}
|
// Package bmlog is log-lib in BlackMirror's GoLibs. Depends on "github.com/sirupsen/logrus".
package bmlog
import (
"github.com/alfredyang1986/blackmirror/bmerror"
"github.com/sirupsen/logrus"
"os"
"sync"
)
var (
once = sync.Once{}
loggerUser = "default"
bmLogger = logrus.StandardLogger()
)
func Stan... |
package main
import "time"
type Passport struct {
Id string `json:"id"`
DateOfIssue time.Time `json:"dateOfIssue"`
DateOfExpiry time.Time `json:"dateOfExpiry"`
Authority string `json:"authority"`
UserId int `json:"userId"`
}
|
package service
import (
"errors"
"time"
"github.com/google/uuid"
"github.com/nicobianchetti/Go-CleanArchitecture/model"
"github.com/nicobianchetti/Go-CleanArchitecture/repository"
)
//IPermisoService interact with IPermisoRepository
type IPermisoService interface {
Migrate() error
Create(*model.Permiso) (*mo... |
package timestamp
import (
"crypto"
"crypto/x509"
"encoding/asn1"
"github.com/opencontainers/go-digest"
)
var (
OIDDigestAlgorithmSHA1 = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26}
OIDDigestAlgorithmSHA256 = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 1}
OIDDigestAlgorithmSHA384 = asn1.Obj... |
package interfaces
import "gunittesting/domain"
type Serialiser interface {
// Dehydrate
//
// Serialises a Frobnicator.
Dehydrate(frob *domain.Frobnicator) (string, error)
// Hydrate
//
// Deserialises a Frobnicator.
Hydrate(frob string) (*domain.Frobnicator, error)
}
|
package model
type Deck struct {
Cards
}
func (d *Deck) Draw() (Card, bool) {
c, exist := d.Top()
d.RemoveTop()
return c, exist
}
|
package db
import (
"database/sql"
"sync"
"testing"
"github.com/segmentio/ksuid"
"github.com/textileio/go-textile/pb"
"github.com/textileio/go-textile/repo"
)
var threadPeerStore repo.ThreadPeerStore
func init() {
setupThreadPeerDB()
}
func setupThreadPeerDB() {
conn, _ := sql.Open("sqlite3", ":memory:")
... |
package main
import (
"strconv"
"strings"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/sql"
"github.com/therecipe/qt/widgets"
"github.com/therecipe/qt/xml"
)
var uniqueArtistId int
var uniqueAlbumId int
type Dialog struct {
widgets.QDialog
_ func() `constructor:"init"`
_ fu... |
package main
import (
"fmt"
"github.com/mdimec4/allrecipes"
)
func main() {
recipe, error := allrecipes.GetRecipe("11772") // Package allrecepies exports function
fmt.Println(recipe.Ingredients) // Exported names must start with uppercase.
}
|
// Package cos provides common low-level types and utilities for all aistore projects
/*
* Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
*/
package cos
import "strings"
// supported archive types (file extensions)
const (
ExtTar = ".tar"
ExtTgz = ".tgz"
ExtTarTgz = ".tar.gz"
ExtZip ... |
package app
import (
"context"
"github.com/spf13/cobra"
"github.com/xmwilldo/edge-health/cmd/app-health/app/options"
"github.com/xmwilldo/edge-health/pkg/app-health-daemon/daemon"
"github.com/xmwilldo/edge-health/pkg/util"
)
func NewAppHealthCommand(ctx context.Context) *cobra.Command {
o := options.NewAppHea... |
//https://repl.it/@kacade/Spacebot-July-1-2017
package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
func main() {
seq := []int{1, 1, 2, 2, 2, 4, 4}
//seq := []int{4, 4, 0, 0, 0, 5, 5, 5}
fragmentData := []string{"+",
"+",
"A",
"A",
"B",
"#",
"#"}
n := 3
half := 0.0
half = float64(n) / 2.0
s... |
/*****************************************************************
* Copyright©,2020-2022, email: 279197148@qq.com
* Version: 1.0.0
* @Author: yangtxiang
* @Date: 2020-07-21 09:13
* Description: 使用命名空间调用的客户端协议代理器
*****************************************************************/
package xthrift
import (
"fmt"
. "gi... |
package main
import (
"fmt"
"github.com/feng/future/grpc/protocol"
"golang.org/x/net/context"
"google.golang.org/grpc"
"io"
"log"
"net"
)
func main() {
grpcSvr := grpc.NewServer()
l, err := net.Listen("tcp", "127.0.0.1:8080")
if err != nil {
log.Fatalln(err)
}
mySvr := mySvr{}
protocol.RegisterRouteGui... |
package mcdiscord // "github.com/itszuvalex/mcdiscord/pkg/mcdiscord"
import (
"fmt"
"github.com/itszuvalex/mcdiscord/pkg/api"
mydisc "github.com/itszuvalex/mcdiscord/pkg/discord"
"github.com/itszuvalex/mcdiscord/pkg/server"
)
type McDiscord struct {
Discord api.IDiscordHandler
Servers api.IServerHandler
Confi... |
// Copyright 2023 Google LLC. All Rights Reserved.
//
// 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 applica... |
package cmd
import (
"fmt"
"os"
"github.com/nitschmann/scdns/pkg/cloudflare"
scdnsOutput "github.com/nitschmann/scdns/pkg/scdns/output"
"github.com/nitschmann/scdns/pkg/util/cli"
"github.com/nitschmann/scdns/pkg/util/output"
"github.com/spf13/cobra"
)
func newDnsCreateCmd() *cobra.Command {
cmd := &cobra.Co... |
package radar
import "testing"
func Test_Solution(t *testing.T) {
tests := []struct {
name string
input []string
expected int
}{
{
name: "allow pass",
input: []string{"CHARGE: card_country=US¤cy=USD&amount=90&ip_country=CA", "ALLOW:amount<100"},
expected: 1,
},
{
name: "allow pass (equ... |
package starportcmd
import (
"errors"
"fmt"
"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/services/scaffolder"
)
// NewIBCPacket creates a new packet in the module
func NewIBCPacket() *cobra.Command {
c := &cobra.Command{
Use: "packet [packetName] [field1] [field2] ... --module [module_n... |
package rabbitmq
import (
"GridService/Service-Updatelink/logs"
"encoding/json"
"log"
"sync"
"time"
"github.com/astaxie/beego"
"github.com/streadway/amqp"
)
type ExchangeIndex struct {
GridId string `json:"gridId"`
Count int32 `json:"count"`
}
var (
rabbitMQAddr string
rabbitMQQueueName ... |
package spot
import (
"fmt"
"unicode"
"github.com/pkg/errors"
)
// Spot holds all the method to handle a spot
type Spot interface {
GetRoutes() []Route
Validate() error
}
// Details holds the information about a spot
type Details struct {
Name string `json:"name,omitempty"`
Routes []Rou... |
package mat
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestDefaultMaterial(t *testing.T) {
m := NewDefaultMaterial()
assert.True(t, TupleEquals(NewColor(1, 1, 1), m.Color))
assert.Equal(t, 0.1, m.Ambient)
assert.Equal(t, 0.9, m.Diffuse)
assert.Equal(t, 0.9, m.Specular)
assert.Equal(t, 200.... |
package server
import (
"context"
"net/http"
"runtime/debug"
"github.com/apex/log"
"github.com/go-chi/chi/middleware"
"github.com/google/uuid"
)
type requestContextKey int
const (
requestIDKey requestContextKey = iota
)
// RequestIDMiddleware creates random request ids and adds them to the request context.
... |
package main
import (
"io"
"net/http"
"regexp"
)
// serveBytes serves bytes from a source in a given range
// /endpoint?s=somesource.domain.com&range=20-50
// queryParams:
// 1) s: the source
// 2) range: the range of bytes to serve. End range is inclusive and
// optional
func serveBytes(res http.ResponseWriter... |
package leetcode
/*A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.
We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.)
The rules of Goat Latin are as follows:
If a word begins with a vowel (a, e, i... |
package main
type ListNode struct {
Val int
Next *ListNode
}
// 优美的解法
func reverseList(head *ListNode) *ListNode {
var pre *ListNode = nil
var next *ListNode = nil
for head != nil {
next = head.Next
head.Next = pre
pre = head
head = next
}
return pre
}
// 递归解法
func reverseList(head *ListNode) *ListNo... |
package rltetris
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"net"
"github.com/eltrufas/tetriscore"
)
type RemotePlayer struct {
conn net.Conn
}
func CreateRemotePlayer(address string) *RemotePlayer {
var player RemotePlayer
conn, err := net.Dial("tcp", address)
if err != nil {
fmt.Println("No se pud... |
package client
import (
"fmt"
"log"
"strconv"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/raft-kv-store/common"
"github.com/raft-kv-store/raftpb"
"github.com/stretchr/testify/assert"
)
const coordAddr = "127.0.0.1:17000"
const clientTimeout = 5 * time.Second
func (c *... |
package shortenertest
import (
"testing"
"github.com/toms1441/urlsh/internal/shortener"
)
var invalidmodel = [4]shortener.Model{
// first one empty
{},
// should be invalid cause id is empty
{
URLString: "awd",
},
// should be invalid cause url is empty
{
ID: "12341234",
},
// should be invalid cause ... |
package mint
import (
"fmt"
"time"
sdk "github.com/ColorPlatform/color-sdk/types"
)
const (
weeklyProvision int64 = 362880000000
mintingSpeed int64 = 600000
deflationtime = 60 * 60 * 24 * 7 * 52
)
// Minter represents the minting state.
type Minter struct {
Deflation sdk.Dec `json:"deflat... |
package models
import (
"errors"
"strings"
uuid "github.com/satori/go.uuid"
)
type Comment struct {
ID uuid.UUID `json:"id" gorm:"primaryKey"`
PostID uuid.UUID `json:"post_id"`
UserID uuid.UUID `json:"user_id"`
Comment string `json:"comment"`
InReplyToUserID string ... |
/*
Copyright 2021 RadonDB.
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, software
distri... |
package main
import (
"./fibonacci"
"fmt"
)
func main() {
n := 5
op := "+"
res := fibonacci.Fibonacci(op, n)
fmt.Printf("op=%s, n=%d, res=%d\n", op, n, res)
op = "*"
res = fibonacci.Fibonacci(op, n)
fmt.Printf("op=%s, n=%d, res=%d\n", op, n, res)
}
|
package model
import "fmt"
type Customer struct {
Id int
Name string
Gender string
Age int
Phone string
Email string
}
// 获取一个 Customer
func NewCustomer(id int, name string, gender string, age int, phone string, email string) *Customer {
return &Customer{
Id: id,
Name: name,
Gender: gender,
Age: age,
... |
package ownership_test
import (
. "github.com/onsi/ginkgo"
"github.com/kumahq/kuma/test/e2e/ownership"
)
var _ = Describe("Test Multizone Ownership for Universal", ownership.MultizoneUniversal)
|
package sqsmv
import (
"errors"
)
type QueueConfig struct {
Source string
Destination string
}
type Config struct {
Queues []QueueConfig
}
type Queue interface {
Describe(queueName string) (QueueDetails, error)
Create(queueName string, queueDetails QueueDetails) (string, error)
}
type QueueDetails struc... |
package v30
import (
"github.com/giantswarm/versionbundle"
)
func VersionBundle() versionbundle.Bundle {
return versionbundle.Bundle{
Changelogs: []versionbundle.Changelog{
{
Component: "TODO",
Description: "TODO",
Kind: versionbundle.KindAdded,
},
},
Components: []versionbundle.Com... |
package model
import (
"time"
)
type Post struct {
PostId int `json:"post_id"`
PostUserId int `json:"post_user_id"`
PostRestaurantId int `json:"post_restaurant_id"`
PostImage string `json:"post_image"`
Good int `json:"good"`
Text string `json:"text"`
CreatedAt time.Tim... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.