text stringlengths 11 4.05M |
|---|
package proxy
import (
"github.com/devopsfaith/krakend/config"
"github.com/devopsfaith/krakend/logging"
)
// Factory creates proxies based on the received endpoint configuration.
//
// Both, factories and backend factories, create proxies but factories are designed as a stack makers
// because they are intended to ... |
package constants
import (
"time"
)
const (
EthNetwork = "Rinkeby@Ethereum"
TenderMintNetwork = "SENTTEST@Tendermint"
EthAddr = "ETHADDR"
Timestamp = "TIMESTAMP"
TimestampTM = "TIMESTAMPTM"
Node = "NODE"
NodeTM = "NODETM"
Bandwidth ... |
package models
import (
"bytes"
"crypto/hmac"
"crypto/sha1"
"errors"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"strings"
"time"
"wishCollection/utility"
"encoding/json"
"fmt"
uuid "github.com/satori/go.uuid"
)
var (
firstName []string
lastName []string
emailType []string
contrys []string
)
... |
package user
import (
"net/http"
"github.com/gorilla/mux"
"github.com/jmoiron/sqlx"
)
// Delete - deletes user
func Delete(db *sqlx.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-type", "application/json")
query := "Delete from user where id = ?"
_, er... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
"github.com/atomicjolt/string_utils"
)
// ListPagesCourses A paginated list of the wiki pages assoc... |
package main
import (
"os"
"os/signal"
"reflect"
"runtime/pprof"
"github.com/woobest/network"
"github.com/woobest/network/socket"
"github.com/woobest/protocol/pb/msgdef"
)
func main() {
f, _ := os.Create("profile_file")
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
network.Registe... |
package v2
import (
"errors"
"log"
"net/http"
"net/url"
"github.com/labstack/echo/v4"
"github.com/traPtitech/trap-collection-server/src/domain/values"
"github.com/traPtitech/trap-collection-server/src/handler/v2/openapi"
"github.com/traPtitech/trap-collection-server/src/service"
)
type GameImage struct {
ga... |
// while copying of maps, impacts both the value
// so inshort maps are not copied
package main
import "fmt"
func main() {
planets := map[string]string{
"Earth": "Sector ZZ9",
"Mars": "Sector ZZ9",
}
planetsMarkII := planets
planets["Earth"] = "whoops"
fmt.Println(planets)
fmt.Println(planetsMarkII)
// ... |
/*
Copyright 2022 The Skaffold 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, sof... |
// Package color provides color convention and useful functions
package color
var Aliceblue = NewFromHEX(0xf0f8ff)
var Antiquewhite = NewFromHEX(0xfaebd7)
var Aqua = NewFromHEX(0x00ffff)
var Aquamarine = NewFromHEX(0x7fffd4)
var Azure = NewFromHEX(0xf0ffff)
var Beige = NewFromHEX(0xf5f5dc)
var Bisque = NewFromHEX(0xff... |
package api
import (
"fmt"
"go.rock.com/rock-platform/rock/server/database"
"go.rock.com/rock-platform/rock/server/database/models"
"go.rock.com/rock-platform/rock/server/utils"
)
// insert the current deployment info into the database
func CreateDeployment(appId, envId int64, chartName, chartVersion, description... |
package routers
import (
"github.com/apulis/AIArtsBackend/models"
"github.com/apulis/AIArtsBackend/services"
"github.com/gin-gonic/gin"
)
func AddGroupUpdatePlatform(r *gin.Engine) {
group := r.Group("/ai_arts/api/version")
group.Use(Auth())
group.GET("/info", wrapper(getVersionInfo))
group.GET("/detail/:id"... |
package master
import (
"bufio"
"net"
"strings"
"time"
)
type ServerList map[string]*net.UDPAddr
type Server struct {
addr string
timeout time.Duration
cache ServerList // to re-use resolved UDP addresses
}
func New(addr string, timeout time.Duration) *Server {
return &Server{
addr: addr,
timeou... |
package ess
import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
esssdk "github.com/aliyun/alibaba-cloud-sdk-go/services/ess"
)
// LifecycleHook struct is mapped to lifecycle hook template
type LifecycleHook struct {
LifecycleHookName string
LifecycleHookID string
LifecycleTransition string
Defa... |
package main
// Leetcode 1287. (easy)
func findSpecialInteger(arr []int) int {
scan := len(arr) / 4
for i := 0; i < len(arr); i += scan {
left := leftBound(arr, arr[i])
right := rightBound(arr, arr[i])
if right-left+1 > len(arr)/4 {
return arr[i]
}
}
return -1
}
|
package diagnostic
import (
"context"
"go.uber.org/zap"
)
type DiagnosticService struct {
log *zap.SugaredLogger
UnimplementedDiagnosticServiceServer
}
func NewDiagnosticService(log *zap.SugaredLogger) DiagnosticService {
return DiagnosticService{
log: log,
}
}
func (s DiagnosticService) Ping(ctx context.Co... |
package main
import "database/sql"
type HereResult struct {
Response struct {
View []struct {
Result []struct {
Location struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"location"`
} `json:"Result"`
} `json:"View"`
} `json:"Response"`
}
type Con... |
// Copyright 2022 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
// Package gib metrics.go implements accuracy metrics for rating detection on
// several test cases.
package gib
// Labels : positive class is gibberish and n... |
package expandurl
import "net/http"
import "net/url"
//Expand URL
func Expand(uri string) (string, error) {
decodedURL, urlError := url.QueryUnescape(uri)
if urlError != nil {
return "", urlError
}
resp, err := http.Get(decodedURL)
if err != nil {
return "", err
}
return resp.Request.URL.String(), nil... |
package discovery
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseResponse(t *testing.T) {
xml, err := ioutil.ReadFile("./probe_match_example.xml")
if err != nil {
t.Fatalf("Cannot read xml: %s", err)
}
messageID := "uuid:0a6dc791-2be6-4991-9af1-454778a1917a"
device, e... |
package serix_test
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/iotaledger/hive.go/serializer/v2"
"github.com/iotaledger/hive.go/serializer/v2/serix"
)
func TestDecode_Slice(t *testing.T) {
t.Parallel()
testObj := Bools{true, false, true... |
package model
import (
"os"
"github.com/go-ini/ini"
"github.com/vinipis/project-go/showglobalstatus/structs"
)
//MyCnf realiza a leitura de um arquivo my.cnf e caso não tenha ele insere variaveis default
func MyCnf() (valueCnf []string) {
valueParameters, validaflag := structs.ParametersTerminal()
host, hostfla... |
package config
import (
"bytes"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"testing"
)
var tomlMask = []byte(`
A=1
C=1
[table]
name = "Mask"`)
var tomlBase = []byte(`
A=2
B=1
[table]
name = "Base"`)
var config Config
func init() {
arr := [2]*viper.Viper{Build(tomlMask), Build(tomlBase)}
... |
package odoo
import (
"fmt"
)
// MailMassMailingTag represents mail.mass_mailing.tag model.
type MailMassMailingTag struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Color *Int `xmlrpc:"color,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlr... |
package cockroachdb
import (
"database/sql"
"fmt"
"strconv"
nurl "net/url"
"regexp"
"strings"
"hash/crc32"
"context"
"errors"
"github.com/db-journey/migrate/direction"
"github.com/db-journey/migrate/driver"
"github.com/db-journey/migrate/file"
"github.com/lib/pq"
"github.com/cockroachdb/co... |
package storage
import "github.com/suaas21/grapgql-demo/books-authors-query/model"
var ListBook = make([]model.Book, 0)
var ListAuthor = make([]model.Author, 0)
|
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complian... |
package channel
import "testing"
func BenchmarkStart(b *testing.B) {
Start(b.N)
}
|
package acrostic
// Part : 品詞
// 接尾辞は品詞ではないが,処理の都合上,分けるのは面倒なので,品詞の一つとみなす
type Part int
const (
// UnknownPart : 不明な品詞
UnknownPart Part = iota
// VerbPart : 動詞
VerbPart
// AdjectivePart : 形容詞
AdjectivePart
// AdjectiveVerbPart : 形容動詞
AdjectiveVerbPart
// NounPart : 名詞
NounPart
// AdnominalPart : 連体詞
Adnomi... |
package passport
import "testing"
func TestPresentValidator(t *testing.T) {
validator := PresentValidator("foo")
cases := []struct {
passport Passport
expected bool
}{
{Passport{fields: map[string]string{}}, false},
{Passport{fields: map[string]string{"foo": "bar"}}, true},
{Passport{fields: map[string]... |
package main
import (
"math/rand"
"time"
)
func main() {
ci:=make(chan int,1)
// send to channel
rand.Seed(time.Now().UnixNano())
ci <- rand.Intn(100) //send to channel
b := <-ci // receive from channel
println(b)
}
|
package runtime
// Process the elements of a function call form
func EvalFnCall(env Env, fn Callable, args Sequence) (Value, error) {
args, err := EvalEach(env, args)
if err != nil {
return nil, err
}
return &Call{
Fn: fn,
Args: args,
Env: env,
}, nil
}
|
package usecases
import (
"math"
"regexp"
"sort"
"strings"
)
// SearchServiceImpl is an implementation of the SearchService
type SearchServiceImpl struct {
wordRegexp *regexp.Regexp
termCounts map[string]float64
corpus map[string]SearchObject
}
// NewSearchServiceImpl returns a new instance of SearchServi... |
package router
type chiRouter struct {}
var chiDispatcjer = chi.NewRouter()
// NewChiRouter creates a new chi router
func NewChiRouter() Router {
chiDispatcher.Use(middleware.RequestID)
chiDispatcher.Use(middleware.RealIP)
chiDispatcher.Use(middleware.Logger)
chiDispatcher.Use(middleware.Recoverer)
return &chi... |
package server
//HTTPErrorResponse dd
type HTTPErrorResponse struct {
Err bool `json:"err"`
Reason string `json:"reason"`
}
|
// Copyright 2019 The gVisor 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 agree... |
package uweb
import (
"compress/gzip"
"net/http"
"strings"
"sync"
)
// if body length less than this, no need to compress
var (
GZIP_THRESHOLD = 150
)
//
// Compress middleware, only support gzip.
//
func MdCompress() Middleware {
return NewGzip()
}
//
// @impl(http.ResponseWriter)
//
type gzipWriter struct {... |
package quic
import (
"fmt"
capnp "zombiezen.com/go/capnproto2"
"zombiezen.com/go/capnproto2/pogs"
"github.com/cloudflare/cloudflared/quic/schema"
)
// ConnectionType indicates the type of underlying connection proxied within the QUIC stream.
type ConnectionType uint16
const (
ConnectionTypeHTTP ConnectionTyp... |
package models_test
import (
. "github.com/gravida/work/models"
"github.com/gravida/work/pkg/settings"
_ "github.com/mattn/go-sqlite3"
. "github.com/smartystreets/goconvey/convey"
"os"
"testing"
)
func TestWork(t *testing.T) {
settings.DatabaseCfg.Type = "sqlite3"
settings.DatabaseCfg.Path = "data.db"
Setup(... |
package config
type CloudStorageConfig struct {
Bucket string `yaml:"bucket"` //bucket name of s3 or bos
Path string `yaml:"path"` //path in the bucket
Ak string `yaml:"ak"` //access key
Sk string `yaml:"sk"` //secrete key
Region s... |
package lex
import (
"fmt"
"github.com/felixangell/goof/cc/unit"
"strings"
"unicode"
)
var ErrorToken *unit.Token = unit.NewToken("error", unit.Invalid)
type Lexer struct {
file *unit.SourceFile
position uint
}
func (lexer *Lexer) ExecutePhase(file *unit.SourceFile) {
// TODO(Felix): resets in each phase... |
package altrudos
import (
"errors"
"github.com/jmoiron/sqlx"
)
var (
ErrDonationNotCreated = errors.New("donation on new drive not created")
ErrDriveNotCreated = errors.New("drive on new drive not created")
)
// A new drive is the result of a user submitting the New Drive form
// on the home page
// This for... |
package main
import (
"io"
"log"
"os"
"strconv"
)
var (
valid_events []string
)
func check(valid []string, el string) bool {
for _, v := range valid {
if v == el {
return true
}
}
return false
}
// Log requires a specific set of input strings
// event \in {"vote", "accept", "confirm", "broadcast", "c... |
package cmd
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/fatih/color"
"github.com/porter-dev/porter/cli/cmd/docker"
"github.com/porter-dev/porter/cli/cmd/github"
"github.com/spf13/cobra"
)
type startOps struct {
imageTag string `form:"required"`
db string `form:"oneof=sqlite ... |
package main
import (
"os"
"github.com/codegangsta/cli"
)
var (
Version = "0.0.1"
)
func main() {
newApp().Run(os.Args)
}
func newApp() *cli.App {
app := cli.NewApp()
app.Name = "pold"
app.Usage = "markdown based blog tool"
app.Version = Version
app.Author = "Konboi"
app.Email = "ryosuke.yabuki+pold@gmai... |
package model // import "model"
import (
"github.com/dgrijalva/jwt-go"
nullable "gopkg.in/guregu/null.v3"
)
// JwtCustomClaims -
type JwtCustomClaims struct {
Idx int `json:"J_Idx"`
Name string `json:"J_Name"`
Email string `json:"J_Email"`
jwt.StandardClaims
}
// Person -
type Person stru... |
package shape
import (
"math"
"testing"
"github.com/lukeshiner/raytrace/colour"
"github.com/lukeshiner/raytrace/comparison"
"github.com/lukeshiner/raytrace/material"
"github.com/lukeshiner/raytrace/matrix"
"github.com/lukeshiner/raytrace/ray"
"github.com/lukeshiner/raytrace/vector"
)
func TestShapeDefaultTra... |
package sha512
import (
"crypto/sha512"
"testing"
)
// TestSum512 tests if our custom implementation of sha512 is correct in reference
// to the standard library crypto/sha512
func TestSum512(t * testing.T) {
testInput := "Testing"
a := sha512.Sum512([]byte(testInput))
b := Sum512([]byte(testInput))
if a != b ... |
package epaxos
import (
"github.com/google/btree"
pb "github.com/nvanbenschoten/epaxos/epaxos/epaxospb"
)
// Storage allows for the persistence of EPaxos state to provide durability.
type Storage interface {
HardState() (pb.HardState, bool)
PersistHardState(hs pb.HardState)
Instances() []*pb.InstanceState
Per... |
// Copyright 2016-2018 Granitic. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be found in the LICENSE file at the root of this project.
/*
Package ioc provides an Inversion of Control component container and lifecycle hooks.
This package provides the types that defin... |
package main
import (
"bufio"
"fmt"
"github.com/miekg/dns"
"net"
"os"
)
func main() {
fmt.Println("jooo")
mx, err := dns.NewRR("miek.nl. 3600 IN MX 10 mx.miek.nl.")
fmt.Println(mx, err)
fileIn, err := os.Open("tld_clean.lst")
if err != nil {
//return err
fmt.Println(err)
}
defer fileIn.Close()
scan... |
// Package template provides a simple templating solution reusable in filters.
//
// (Note that the current template syntax is EXPERIMENTAL, and may change in
// the near future.)
package eskip
import (
"regexp"
"strings"
"github.com/zalando/skipper/filters"
)
var placeholderRegexp = regexp.MustCompile(`\$\{([^{}... |
/*
Copyright The containerd 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... |
package main
import (
"bytes"
b64 "encoding/base64"
"fmt"
"io/ioutil"
"os"
"os/exec"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
type MyEvent struct {
Scree... |
package main
import (
"fmt"
"os"
"bufio"
"strings"
)
func main() {
fmt.Print("Enter a string:")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
text := scanner.Text()
fmt.Printf("Given text : <%s>..\n", text)
words := strings.Split(text," ")
m := make(map[string]int)
for _, each_... |
// Copyright (c) 2020 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// 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/LICE... |
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package crostini
import (
"context"
"net/http"
"net/http/httptest"
"path/filepath"
"strings"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromi... |
package messaging
import (
"time"
)
const (
ADD_ACK string = "ADD_ACK"
DELETE_ACK string = "DEL_ACK"
MODIFIED_ACK string = "MOD_ACK"
)
type AcknowledgeMessage struct {
Sender string `json:"sender"`
BaseNode string `json:"base_node"`
TypeAck string `json:"type_ack"`
Component Co... |
package quantity
type ConversionMap map[Unit]map[Unit]ConversionRatio
type ConversionRatio struct {
From Unit
To Unit
Ratio int
}
const (
feet Unit = "feet"
inches Unit = "inches"
)
var feetToInches ConversionRatio = ConversionRatio{feet, inches, 12}
func NewConversionMap() ConversionMap {
result := mak... |
package oidcserver
import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"time"
oidc "github.com/coreos/go-oidc"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/gorilla/mux"
"github.com/pardot/deci/oidcserver/interna... |
package service
import (
"bytes"
"encoding/json"
"fmt"
permissions "github.com/carprks/permissions/service"
"io/ioutil"
"net/http"
"os"
"time"
)
// AllowedHandler ...
func AllowedHandler(body string) (string, error) {
r := permissions.Permissions{}
err := json.Unmarshal([]byte(body), &r)
if err != nil {
... |
package main
import "fmt"
func main() {
var i interface{}
i = 10
// 值, 值得判断 := 接口变量.(数据类型)
if value, ok := i.(int); ok {
fmt.Println("整型数据:", value)
} else {
fmt.Println("错误")
}
} |
package services
import (
"log"
"os"
"time"
)
type LoggingService struct {
Context string
}
func NewLoggingService(context string) *LoggingService {
return &LoggingService{
Context: context,
}
}
func (l *LoggingService) Log(message string) {
if os.Getenv("SERVER_DEBUG") == "true" {
log.Println(time.Now(... |
package main
import (
"net/http"
"math/rand"
"time"
"net/url"
"strings"
)
type Spider struct {
UserAgent string
Method string
URL string
ContentType string
Referer string
Data url.Values
Response *http.Response
}
func (spider *Spider) do() error {
client... |
package state
import "github.com/guregu/null"
type PostgresRelationStats struct {
SizeBytes int64 // On-disk size including FSM and VM, plus TOAST table if any, excluding indices
ToastSizeBytes int64 // TOAST table and TOAST index size (included in SizeBytes as well)
SeqScan int64 ... |
package main
import (
"flag"
"fmt"
"os"
"github.com/lestrrat-go/file-rotatelogs"
"github.com/sirupsen/logrus"
. "IRIS_WEB/config"
"IRIS_WEB/utility/db"
"IRIS_WEB/web"
)
func main() {
// 初始化配置文件
flag.Parse()
fmt.Print("InitConfig...\r")
checkErr("InitConfig", InitConfig())
fmt.Print("InitConfig Success!... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package hwsec
import (
"context"
hwsecremote "chromiumos/tast/remote/hwsec"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: Cl... |
package gevent
import (
"sync"
)
/* ================================================================================
* gevent
* qq group: 582452342
* email : 2091938785@qq.com
* author : 美丽的地球啊 - mliu
* ================================================================================ */
type (
ISubscriberHan... |
package config
import (
"log"
"os"
"github.com/joho/godotenv"
)
//AppName : application name
var AppName string
//HTTPPort : rest api port
var HTTPPort string
//GinMode : gin spesific mode
var GinMode string
//DbName : database name
var DbName string
//DbDebug : if set to true will print out the query string
... |
package easyquery
import (
"easyquery/tools/constant"
"easyquery/tools/reflection"
"easyquery/tools/stringutil"
"fmt"
"strings"
"github.com/iancoleman/strcase"
"github.com/gin-gonic/gin"
)
type QueryField struct {
Name string
Type QueryFieldType
Operation string
Value interface{}
Join ... |
package grpcserver
import (
"context"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"
"github.com/NataliaZabelina/monitoring/api"
monitoring "github.com/NataliaZabelina/monitoring/internal/app"
"github.com/NataliaZabelina/monitoring/internal/config"
"github.com/NataliaZabelina/monitoring/internal/logger"
"... |
// 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 policy
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/pci"
"chromiumos/tast/common/... |
package socks5
import (
"io"
"fmt"
"net"
"strings"
"strconv"
)
const (
ConnectCommand = uint8(1)
BindCommand = uint8(2)
AssociateCommand = uint8(3)
ipv4Address = uint8(1)
fqdnAddress = uint8(3)
ipv6Address = uint8(4)
)
const (
successReply uint8 = iota
serverFailure
ruleFailure
ne... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package serial
import (
"context"
)
// Port represends a serial port and its basic operations.
type Port interface {
// Read bytes into buffer and return number of bytes ... |
package base
type BytecodeReader struct {
code []byte
pc int
}
func (br *BytecodeReader) Reset(code []byte, pc int) {
br.code = code
br.pc = pc
}
func (br *BytecodeReader) ReadUint8() uint8 {
i := br.code[br.pc]
br.pc++
return i
}
func (br *BytecodeReader) ReadInt8() int8 {
return int8(br.ReadUint8())
}
... |
package main
import (
"fmt"
"log"
"github.com/xuperchain/xupercore/example/xchain/cmd/client/cmd"
"github.com/xuperchain/xupercore/example/xchain/cmd/client/common/global"
xdef "github.com/xuperchain/xupercore/example/xchain/common/def"
"github.com/spf13/cobra"
)
var (
Version = ""
BuildTime = ""
CommitI... |
package _5_Visitor_Pattern
import "testing"
//步骤 5
//使用 ComputerPartDisplayVisitor 来显示 Computer 的组成部分。
func TestVisitorPattern(t *testing.T) {
computer := newComputer()
wantRet := "Displaying Mouse.Displaying Monitor.Displaying Keyboard.Displaying Computer."
if gotRet := computer.accept(&ComputerPartDisplayVisitor... |
package filter
import (
"net/http"
"testing"
"time"
"github.com/caddyserver/caddy"
)
func TestSetup(t *testing.T) {
c := caddy.NewTestController("dns", `filter`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `filter hello`)
if err :... |
// Copyright 2013 Rodrigo Moraes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package htmlfilter
import (
"bytes"
"exp/html"
"testing"
)
func TestNextTextFilter(t *testing.T) {
src := `<html>
<p>
<a name="foo"/>
<small>
<fon... |
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
resp, _ := http.Get("http://google.com")
m := memoryBuffer{}
fmt.Println("Address of m", &m)
io.Copy(&m, resp.Body)
//fmt.Println(m.message)
}
type memoryBuffer struct {
message string
}
func (c *memoryBuffer) Write(p []byte) (n int, err error)... |
package irc_color
type Colour int
// Colours
const (
White Colour = iota
Black
Blue
Green
Red
Brown
Purple
Orange //, Olive
Yellow //
LightGreen //, Lime
Teal //, LightCyan
Cyan //, Aqua
LightBlue //
Pink //, Fuchsia
Grey //, Gray
LightGrey //, LightGray, Silver
Vio... |
package crudcontracts
import (
"context"
"github.com/adamluzsi/frameless/internal/suites"
"github.com/adamluzsi/frameless/ports/comproto"
"github.com/adamluzsi/frameless/ports/crud"
"testing"
)
func SuiteFor[
Entity, ID any,
Resource suiteSubjectResource[Entity, ID],
](makeSubject func(testing.TB) SuiteSubject... |
package prettyfyne
import (
"gopkg.in/yaml.v2"
"image/color"
)
// PrettyThemeConfig is used for serialization and loading from yaml
type PrettyThemeConfig struct {
BackgroundColor *color.RGBA `yaml:"background_color,omitempty"`
ButtonColor *color.RGBA `yaml:"button_color,omitempty"`
DisabledBut... |
package drivers
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"gorm.io/driver/mysql"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlserver"
_ "gorm.io/driver/clickhouse" // for tests
)
func TestDialect(t *testing.T) {
const (
myDSN = "root@tcp(0.0.0.0:3306)/test?parseTime=true"
pgDS... |
package parser
import (
"fmt"
"strconv"
"strings"
"unicode"
)
type Member struct {
Name string
Coeff float64
Exp int
Operand string
}
type Equation struct {
LMembers []Member
RMember Member
}
func parseMember(str string, memberPos int) (Member, error) {
var member Member
var err error
str = s... |
// Copyright 2020 SEQSENSE, 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 ... |
package ridemerge
import "net/http"
// getSession returns the current session if it exists, otherwise an empty
// session is returned.
func GetSession(r *http.Request) Session {
cUser, err := r.Cookie("session-id")
var session Session
if err == nil {
session.Email = cUser.Value
session.LoggedIn = true
}
retu... |
package main
import "fmt"
func vard(b ...int) (sum int) {
sum = 0
for _, val := range b {
sum += val
}
return
}
func checkIn(n int, nums ...int) bool {
var answer bool
fmt.Printf("type of nums is %T\n", nums)
for ind, val := range nums {
if n == val {
fmt.Println("Element",n," was found on position",i... |
package benchmarking
import (
"fmt"
"testing"
)
func TestGreet(t *testing.T) {
s := Greet("josh")
if s != "welcome sir!, josh" {
t.Errorf("expected: 'welcome sir!, josh' | got: %v", s)
}
}
func ExampleGreet() {
fmt.Println(Greet("josh"))
// Output:
// welcome sir!, josh
}
func BenchmarkGreet(b *testing.B)... |
package galaxy
//galacticWords are know words in galaxy
var galacticWords = map[string]string{
"glob": "I",
"prok": "V",
"pish": "X",
"tegj": "L",
}
//ConvertWords from galaxy to roman
func ConvertWords(word string) string {
if val, key := galacticWords[word]; key {
return val
} else {
return "Word Not Foun... |
package main
type Tenant struct {
Id int `json:"id"`
DatabaseId string `json:"databaseId"`
}
type TenantMember struct {
TenantId int
UserId string
}
type TenantStore interface {
GetTenantsForUser(userId string) ([]Tenant, error)
CreateTenant(tenantId, userId string) (*Tenant, error)
}
|
package main
import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"time"
"github.com/lillilli/geth_contract/config"
"github.com/lillilli/geth_contract/eth"
"github.com/lillilli/geth_contract/http"
"github.com/lillilli/geth_contract/session"
"github.com/lillilli/logger"
"github.com/lillilli/vconf"
)... |
package controllers
import (
ketov1alpha1 "github.com/ory/keto-maester/api/v1alpha1"
"github.com/ory/keto-maester/keto"
)
const (
FinalizerName = "finalizer.ory.keto.sh"
)
type KetoConfiger interface {
GetKeto() ketov1alpha1.Keto
}
type KetoClientMakerFunc func(KetoConfiger) (KetoClientInterface, error)
type c... |
/*
The card module containing the card CRUD operation and relationship CRUD.
model.go: definition of orm based data model
routers.go: router binding and core logic
serializers.go: definition the schema of return data
validators.go: definition the validator of form data
*/
package card
|
package main
import (
"fmt"
"math"
)
func drawingBook(total, page int) (turns int) {
if page == 1 || (total%2 == 0 && page == total) || (total%2 != 0 && page >= total-1) {
turns = 0
} else {
var x float64
if page <= total/2 {
x = float64(page-1) / 2.0
x = math.Ceil(x)
} else if total%2 != 0 {
x =... |
/*
Copyright 2020 The Skaffold 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, sof... |
package test
import (
"context"
"sync"
"testing"
format "github.com/ipfs/go-ipld-format"
"github.com/ipfs/go-merkledag"
"github.com/ipfs/go-unixfs/io"
testu "github.com/ipfs/go-unixfs/test"
"github.com/stretchr/testify/require"
)
type Morpher func(format.Node) (format.Node, error)
// FSDagger is a test help... |
package inventory
import (
"encoding/json"
"net/http"
"net/url"
"shopping-cart/pkg/controllers/common"
"shopping-cart/pkg/service"
"shopping-cart/types"
"shopping-cart/utils/applog"
"github.com/gorilla/mux"
)
// AddItemToInventory : handler function for POST /v1/inventory call
func AddItemToInventory(w http.... |
package geoip
import "sort"
type (
IPNetV4 struct {
Lo uint32
Hi uint32
}
IPNetListV4 []IPNetV4
)
func (a IPNetListV4) Contains(ip []byte) bool {
ip4 := ip4ToNum(ip)
i := sort.Search(len(a), func(i int) bool {
return a[i].Hi >= ip4
})
if i < len(a) {
return a[i].Lo <= ip4 && ip4 <= a[i].Hi
}
return ... |
// Package quadtree implements a quadtree using rectangular partitions.
// Each point exists in a unique node in the tree or as leaf nodes.
// This implementation is based off of the d3 implementation:
// https://github.com/mbostock/d3/wiki/Quadtree-Geom
package quadtree
import (
"errors"
"math"
"github.com/paulma... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.