text stringlengths 11 4.05M |
|---|
package evaluation
import (
"errors"
flatbuffers "github.com/google/flatbuffers/go"
"github.com/wolffcm/flatbuffers-example/tree"
)
// EvalFromBytes evaluates the expression tree contained in the given flatbuffer.
func EvalFromBytes(bs []byte) (float64, error) {
root := tree.GetRootAsRoot(bs, 0)
unionTable := ... |
package nmstask
import (
"fmt"
"github.com/Centny/gwf/util"
"github.com/Centny/nms/nmsdb"
"testing"
"time"
)
var mv = map[string]int{}
func echo(a *nmsdb.Action, args ...interface{}) {
fmt.Println(util.S2Json(a))
mv[a.Uri] += 1
}
func TestTask(t *testing.T) {
var fcfg = util.NewFcfg3()
fcfg.InitWithFilePath... |
//sqlite是一个嵌入式数据库,嵌入到程序当中的数据库.
//几乎每个发行版都会预装sqlite.
//这是一个sqlite的测试程序.
//首先需要安装sqlite3的驱动
// go get -u github.com/mattn/go-sqlite3
//date:2018-06-11
//by:JuZhen
package main
import (
"database/sql"
"fmt"
"time"
_ "github.com/mattn/go-sqlite3"
)
func main() {
//打开数据库,不存在就创建
db, err := sql.Open("sqlite3", "./fo... |
package file
import (
"fmt"
"os"
"path/filepath"
)
// Path 文件路径
type Path struct {
parts []string
}
// NewPath 创建路径对象
func NewPath(parts ...string) *Path {
return &Path{parts}
}
// Join 连接路径
func (p *Path) Join(parts ...string) *Path {
p.parts = append(p.parts, parts...)
return p
}
func (p *Path) String(par... |
package core
func NewList(args ...Type) *Type {
slice := make([]Type, 0)
for _, arg := range args {
slice = append(slice, arg)
}
return &Type{List: &slice}
}
func (node *Type) IsList() bool {
return node.List != nil
}
|
package sdk
// ImagePullPolicy represents a policy for whether container hosts already
// having a certain OCI image should attempt to re-pull that image prior to
// launching a new container based on that image.
type ImagePullPolicy string
const (
// ImagePullPolicyIfNotPresent represents a policy wherein container... |
package main
import (
"fmt"
"strings"
)
func main() {
boardingPass := "InSight Mission to Mars"
mars := strings.Contains(boardingPass, "Mars")
if mars {
fmt.Printf("Boarding pass: %v\n", boardingPass)
}
if strings.Contains(boardingPass, "Mars") {
fmt.Printf("Mars: %v", boardingPass)
} else {
fmt.Print... |
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
)
type App struct {
Router *mux.Router
DB *sql.DB
}
func (a *App) Initialize(user, password, dbname, host, port string) {
connectionString :=
fmt.Sprintf("user=%s pas... |
// DO NOT REMOVE TAGS BELOW. IF ANY NEW TEST FILES ARE CREATED UNDER /osde2e, PLEASE ADD THESE TAGS TO THEM IN ORDER TO BE EXCLUDED FROM UNIT TESTS.
//go:build osde2e
// +build osde2e
package osde2etests
import (
"context"
"time"
"github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/ap... |
/*
Description
We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder elements of the set. For example, one can define a permutation of the set {1,2,3,4,5} as follows:
http://poj.org/images/2369_1.jpg
This record defines a permutation... |
package exec
func CToF(c C) F {
return F(c*9/5 + 32)
}
func FToC(f F) C {
return C((f-32)*5/9
}
|
package factory
func RandNum() int {
}
|
// package wantlist implements an object for bitswap that contains the keys
// that a given peer wants.
package wantlist
import (
"sort"
"sync"
cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
)
type ThreadSafe struct {
lk sync.RWMutex
set map[cid.Cid]*Entry
}
// not threadsafe
type Wantlis... |
/**
* Copyright 2017 IBM Corp.
*
* 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 job_test
import (
"context"
"fmt"
"testing"
"time"
"github.com/google/uuid"
"github.com/odpf/optimus/core/tree"
"github.com/odpf/optimus/job"
"github.com/odpf/optimus/mock"
"github.com/odpf/optimus/models"
"github.com/odpf/optimus/store"
"github.com/odpf/salt/log"
"github.com/pkg/errors"
"github.... |
/*
* Copyright 2018 Haines Chan
*
* This program is free software; you can redistribute and/or modify it
* under the terms of the standard MIT license. See LICENSE for more details
*/
package app
import (
"strings"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
... |
// test-closure-packet project main.go
package main
import (
"fmt"
)
func playerGen(name string) func() (string, int) {
hp := 150
return func() (string, int) {
return name, hp
}
}
func main() {
fmt.Println("Hello World!")
generator := playerGen("sand and wood")
name, hp := generator()
fmt.Println(name, hp)
... |
package fwatch
import (
"os"
"path/filepath"
"github.com/BurntSushi/toml"
)
// Config - config data
type Config struct {
path string
Targets []Target
}
// Target - target
type Target struct {
Path string
Script string
Type []string
}
// Load - load config yml file
func Load(path string) (config *Con... |
// Copyright 2015 Matthew Collins
//
// 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... |
/*
Copyright © 2022 SUSE LLC
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
dist... |
package tmp
import (
"errors"
"github.com/rendau/lily"
lilyHttp "github.com/rendau/lily/http"
"github.com/rendau/lily/zip"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
)
var (
_dirPath string
_dirName string
_dirFullPath string
_timeLimit ... |
package main
import "fmt"
func main() {
//fmt.Println(2 & 3)
//fmt.Println(2 | 3)
//fmt.Println(2 ^ 3)
fmt.Println(-2 ^ 2)
fmt.Println(-2^3)
//fmt.Println(5 << 1)
//fmt.Println(-5 >> 1)
//fmt.Println(-5 >> 100)
//fmt.Println(-5 << 2)
//fmt.Println(-5 << 4)
//fmt.Println(-4<<2 )
}
|
// Copyright 2016 Google Inc. 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 applicable... |
// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Blue Oak Model License
// that can be found in the LICENSE file.
package cache
import (
"context"
docker "github.com/docker/docker/client"
)
// Wrap returns a wrapped copy of the Docker client that
// collects detai... |
package main
import (
"os"
"fmt"
"bufio"
//"sort"
)
func main() {
reader := bufio.NewReader(os.Stdin)
var n int
fmt.Fscan(reader, &n)
a := make([]int, n)
ps := make([]int, n)
for i:=0; i<n; i++ {
fmt.Fscan(reader, &a[i])
}
for i:=0; i<n; i++ {
va... |
package superhero
import (
"context"
"github.com/go-kit/kit/log"
"github.com/jace-ys/go-library/postgres"
pb "github.com/jace-ys/super-smash-heroes/services/superhero/api/superhero"
)
type Server interface {
Init(ctx context.Context, server pb.SuperheroServiceServer) error
Serve() error
Shutdown(ctx context.... |
package cleanup
import (
"github.com/devspace-cloud/devspace/cmd/flags"
"github.com/devspace-cloud/devspace/pkg/util/factory"
"github.com/spf13/cobra"
)
// NewCleanupCmd creates a new cobra command
func NewCleanupCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
cleanupCmd := &cobra.Command{... |
package caozuoliang
import (
"sort"
"time"
)
type Data struct {
Bawu_un string
ThreadCount int
PostCount int
SameThreads map[int]*SameThread
SameAccounts map[string][]*PostLog
OldPosts OldPosts
Distribution []int //以小时为单位
Speed []int
RecoveredThreads []R... |
package main
import (
"context"
"io"
"log"
"net/http"
"os"
"runtime/debug"
"github.com/julienschmidt/httprouter"
"github.com/justinas/alice"
)
var (
Version string
BuildTime string
)
const (
defaultLogFile = "/tmp/apiserver.log"
defaultListenPort = ":9090"
defaultMemcacheHost = "127.0.0.1:1121... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//355. Design Twitter
//Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most... |
package commands
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/appfile/storage/driver"
"github.com/oam-dev/kubevela/pkg/application"
cmdutil "github.com/oam-dev/kubevela/pkg/commands/util"
"github.com/oam-dev/kubevela/pkg/serverlib"
)
... |
package postgres
import (
"database/sql"
"github.com/idena-network/idena-go/common"
"github.com/idena-network/idena-indexer/explorer/types"
"math/big"
"time"
)
const (
addressQuery = "address.sql"
addressPenaltiesCountQuery = "addressPenaltiesCount.sql"
addressPenaltiesQuery ... |
package ksqlparser
import "fmt"
type aliasedExpression struct {
Expression Expression
Alias string
}
func (e aliasedExpression) String() string {
if e.Alias != "" {
return fmt.Sprintf("%s %s %s", e.Expression.String(), ReservedAs, e.Alias)
}
return e.Expression.String()
}
|
package rsrch
import (
"fmt"
"reflect"
"testing"
)
func TestReflectInvariants(t *testing.T) {
describe := func(thing interface{}) {
rt := reflect.TypeOf(thing)
fmt.Printf("type: %#v (%q)\n", rt, rt)
fmt.Printf("kind: %#v (%q)\n", rt.Kind(), rt.Kind())
fmt.Printf("name: %q\n", rt.Name())
fmt.Printf("PkgP... |
package config
import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
log "github.com/golang/glog"
"lib/config"
)
type Config struct {
XMLName xml.Name `xml:"config"`
ServerConf *config.ServerConfig `xml:"serverconfig"`
ClientConf *config.ClientC... |
package flags
type Byte byte
func (f Byte) Add(b ...Byte) Byte {
for i := 0; i < len(b); i++ {
f = f | b[i]
}
return f
}
func (f Byte) Remove(b ...Byte) Byte {
for i := 0; i < len(b); i++ {
f = f ^ b[i]
}
return f
}
func (f Byte) Intersect(b ...Byte) Byte {
s := Byte(0).Add(b...)
return f & s
}
func (f... |
package inversions
import (
"io/ioutil"
"strconv"
"strings"
)
func Inversions(lines []int) ([]int, int) {
n := len(lines)
if n < 2 {
return lines, 0
}
left, leftInv := Inversions(lines[0:(n / 2)])
right, rightInv := Inversions(lines[(n / 2):])
combined, splitInv := countSplitInversions(left, right)
ret... |
package app
import (
"github.com/tarm/serial"
)
// Connect opens and returns serial port as defined in config
func Connect(config *serial.Config) (*serial.Port, error) {
conn, err := serial.OpenPort(config)
return conn, err
}
|
package command
type VersionCommand struct {
*baseCommand
Version string
}
func (c *VersionCommand) Help() string {
return ""
}
func (c *VersionCommand) Name() string { return "version" }
func (c *VersionCommand) Run(_ []string) int {
c.ui.Output(c.Version)
return 0
}
func (c *VersionCommand) Synopsis() strin... |
package futures
import (
"log"
"testing"
"github.com/stretchr/testify/suite"
)
type commissionRateServiceTestSuite struct {
baseTestSuite
}
func TestCommissionRateService(t *testing.T) {
suite.Run(t, new(commissionRateServiceTestSuite))
}
func (commissionRateService *commissionRateServiceTestSuite) TestCommis... |
// Copyright 2018 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package wifi
import "unsafe" // yuck
// This file is from the linux wifi definitions. We leave the
// original in here for reference. We'll probably remove... |
package models
import (
"database/sql"
"git.hoogi.eu/snafu/go-blog/logger"
"time"
)
// SQLiteTokenDatasource providing an implementation of TokenDatasourceService using MariaDB
type SQLiteTokenDatasource struct {
SQLConn *sql.DB
}
// Create creates a new token
func (rdb *SQLiteTokenDatasource) Create(t *Token) (... |
package tokenbucket
import (
"errors"
"time"
)
func CreateTokenBucket(
sizeOfBucket int,
numOfTokens int,
tokenFillingInterval time.Duration) chan time.Time {
bucket := make(chan time.Time, sizeOfBucket)
for j := 0; j < sizeOfBucket; j++ {
bucket <- time.Now()
}
go func() {
for t := range time.Tick(toke... |
package api
import (
"context"
"strings"
"github.com/inconshreveable/log15"
"github.com/opentracing/opentracing-go/log"
"github.com/pkg/errors"
"github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/stores/lsifstore"
"github.com/sourcegraph/sourcegraph/internal/observation"
)
// Hover returns the h... |
package float128ppc
import (
"math/big"
"testing"
)
func TestRoundTrip(t *testing.T) {
golden := []struct {
h, l uint64
}{
{h: 0x0000000000000000, l: 0x0000000000000000}, // "0xM00000000000000000000000000000000"
{h: 0x3DF0000000000000, l: 0x0000000000000000}, // "0xM3DF00000000000000000000000000000"
{h: 0... |
package main
import (
"fmt"
"strings"
"github.com/chzyer/readline"
parsec "github.com/prataprc/goparsec"
)
func main() {
fmt.Println("LispG Version 0.0.0.0.1")
fmt.Println("Interactive LispG - Press Ctrl+c to exit")
rl, err := readline.NewEx(&readline.Config{Prompt: "lispg> ", HistoryFile: ".lispg_history", D... |
package main
import (
"encoding/json"
"fmt"
"os"
"time"
)
// RepositoryMetadata is metadata for each gist.
type RepositoryMetadata struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
URL string `json:"url"`
GitURL string `json:"git_url"`
Owner string `json:"owner"`
Created int6... |
package zlog
import (
"go.uber.org/zap"
"testing"
)
func Test_zlog(t *testing.T) {
//logger := ZlogInitSplitFile(&ZlogCfg{
// Level: "DEBUG",
// Compress: false,
// MaxAge: 10,
// MaxSize: 1,
// MaxBackups: 30,
// FileName: "./log/signal.log",
// FlushInterval: 300,
// Buf... |
package delete_container
import (
"net/http"
"sync"
"github.com/cloudfoundry-incubator/executor/registry"
"github.com/cloudfoundry-incubator/garden/warden"
"github.com/cloudfoundry/gosteno"
)
type handler struct {
wardenClient warden.Client
registry registry.Registry
waitGroup *sync.WaitGroup
logger ... |
package spider
import (
"spider/entity"
"spider/parser"
)
type MySpider interface {
DocumentParsing(url string, parser parser.Parser) []entity.JobInfo //执行爬虫
}
|
package collector
import (
"context"
"fmt"
"net/http"
"time"
io_prometheus_client "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
)
type NodeStats struct {
CPUUser float64 `json:"user"`
CPUSystem float64 `json:"system"`
CPUIdle float64 `json:"idle"`
CPUIOWait float64 `json... |
package gatekeeper
import (
"fmt"
"log"
)
type Protocol uint
const (
HTTPPublic Protocol = iota + 1
HTTPInternal
HTTPSPublic
HTTPSInternal
)
var formattedProtocols = map[Protocol]string{
HTTPPublic: "http-public",
HTTPInternal: "http-internal",
HTTPSPublic: "https-public",
HTTPSInternal: "https-inte... |
package main
import (
"fmt"
"github.com/tarantool/go-tarantool"
"log"
"net/http"
"time"
)
func info(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "{\"status\": \"OK\"}")
}
const (
masterUri string = "127.0.0.1:3315"
slaveUri string = "127.0.0.1:3316"
)
var (
node *tarantool.Connection
master... |
package main
import (
"github.com/gin-gonic/gin"
)
var (
conf *Conf
)
func getServiceOrFail(c *gin.Context, sn string) *Service {
service, ok := conf.Services[sn]
if !ok {
c.JSON(200, gin.H{
"message": "unknown service",
"service": sn,
"error": true,
})
return nil
}
return service
}
func get... |
package netutil_test
import (
"encoding/json"
"fmt"
"os"
"strings"
"github.com/AdguardTeam/golibs/netutil"
)
func ExampleHostPort_MarshalText() {
resp := struct {
Hosts []netutil.HostPort `json:"hosts"`
}{
Hosts: []netutil.HostPort{{
Host: "example.com",
Port: 12345,
}, {
Host: "example.org",
... |
package queries
import (
"database/sql"
_ "github.com/lib/pq"
"golang.org/x/crypto/blake2b"
"log"
"strings"
)
func getDb() *sql.DB {
connStr := "user=anani dbname=lims port=5050 host=localhost password=mypassword sslmode=disable"
db, err := sql.Open("postgres", connStr)
if err != nil {
log.Fatal(err)
retu... |
package main
import "fmt"
//结构体嵌套结构体
//父类
type Person struct {
id int
name string
age int
}
//子类
type Student struct {
Person //匿名字段
score int
}
func main0101() {
//对象创建
//顺序初始化
var s1 Student = Student{Person{101,"小明",18},98}
fmt.Println(s1)
//var p1 Person = Person{102,"小亮",28}
//fmt.Println(... |
package enter
import (
"encoding/json"
"github.com/ttooch/payment/helper"
)
type QueryEnter struct {
*QueryConf
BaseCharge
}
type QueryConf struct {
AccountNo string `json:"accountNo"` //商户登陆账号
}
type QueryReturn struct {
AccountNo string `json:"accountNo"`
Status string `json:"status"`
AccountType... |
package leetcode
/*
* LeetCode T509. 斐波那契数
* https://leetcode-cn.com/problems/fibonacci-number/
* 面试题10- I. 斐波那契数列
* https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/
* 斐波那契数,通常用 F(n) 表示,形成的序列称为斐波那契数列。
* 该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。
* 给定 N,计算 F(N)。
*/
// 方法 1:递归法(暴力解)
// 时间复杂度 O(N^2)
// 由于存在大量重复... |
//-----------------------------------------------Paquetes E Imports-----------------------------------------------------
package Metodos
import (
"../Variables"
"fmt"
)
//---------------------------------------------------Variables----------------------------------------------------------
var miDisco int
... |
package localcache
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/JokeTrue/otus-golang/hw12_13_14_15_calendar/pkg/models"
"github.com/google/uuid"
)
func createEvent(t *testing.T) *models.Event {
ev, err := models.NewEvent(
uuid.New(),
1,... |
package bbox
import (
"fmt"
"time"
"github.com/siggy/bbox/beatboxer/wavs"
)
const (
DEFAULT_BPM = 120
MIN_BPM = 30
MAX_BPM = 480
SOUNDS = 4
BEATS = 16
DEFAULT_TICKS_PER_BEAT = 10
DEFAULT_TICKS = BEATS * DEFAULT_TICKS_PER_BEA... |
package odor
import (
"syscall"
"github.com/chifflier/nfqueue-go/nfqueue"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
var netFilterStatic *NetFilter
// PacketHandler interface that implements the callback to handle a packet.
type PacketHandler interface {
HandlePacket(context *Context) F... |
package logger
import (
"fmt"
"io"
)
type Logger struct {
Stdout io.Writer
Stderr io.Writer
Verbose bool
}
func (l *Logger) Outf(s string, args ...interface{}) {
if len(args) == 0 {
s, args = "%s", []interface{}{s}
}
fmt.Fprintf(l.Stdout, s+"\n", args...)
}
func (l *Logger) VerboseOutf(s string, args ..... |
/**********************************************************************************
*
* Given two binary strings, return their sum (also a binary string).
*
* For example,
* a = "11"
* b = "1"
* Return "100".
*
*
**********************************************************************************/
package main
import ... |
package utils
import (
"crypto/rand"
"encoding/base64"
)
func GenerateToken(len int) (string, error) {
t := make([]byte, len)
if _, err := rand.Read(t); err != nil {
return "", err
}
t64 := base64.RawURLEncoding.EncodeToString(t)
return t64, nil
}
|
package client
import (
"sync"
)
var registeredChannels map[interface{}]chan int64 = make(map[interface{}]chan int64)
var rcLock sync.Mutex
const BUF = 2
// called by the reciever of a value across a channel to find out what event sent the value
// the argument 'channel' should be any channel the goroutine is wait... |
package client
import (
"context"
"testing"
"time"
"github.com/drand/drand/chain"
"github.com/drand/drand/test"
)
func TestClientConstraints(t *testing.T) {
if _, e := New(); e == nil {
t.Fatal("client can't be created without root of trust")
}
if _, e := New(WithChainHash([]byte{0})); e == nil {
t.Fata... |
package linkedlists
//import "fmt"
func sumForward(l1, l2 *ListNode, carry int) *ListNode {
if l1 == nil && l2 == nil {
if carry == 0 {
return nil
}
return &ListNode{carry, nil}
}
var v1, v2 int
var l1next, l2next *ListNode
if l1 == nil {
v2 = l2.value
l2next = l2.next
} else if l2 == nil {
v1... |
//TODO
package logger
import(
"fmt"
)
func InitLogger(){
}
|
package main
import (
"context"
"encoding/json"
"testing"
"github.com/aws/aws-lambda-go/events"
)
const req1 string = `
{
"requestContext": {
"elb": {
"targetGroupArn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a"
}... |
package env
import (
"errors"
"github.com/andybar2/team/store"
"github.com/spf13/cobra"
)
var deleteParams struct {
Stage string
Name string
}
var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete an environment variable",
RunE: runDeleteCmd,
}
func init() {
deleteCmd.Flags().StringVarP(&delet... |
package services
import (
"github.com/danielhood/quest.server.api/entities"
"github.com/danielhood/quest.server.api/repositories"
)
// DeviceService provides a CRUD interface for Devices
type DeviceService interface {
ReadAll() ([]entities.Device, error)
Read(string, string) (*entities.Device, error)
Update(*ent... |
package solutions
import (
"fmt"
"testing"
)
func TestMerge(t *testing.T) {
t.Run("Test [[1,3],[2,6],[8,10],[15,18]]", func(t *testing.T) {
input := [][]int{{1, 3}, {2, 6}, {8, 10}, {15, 18}}
want := [][]int{{1, 6}, {8, 10}, {15, 18}}
r := merge(input)
if fmt.Sprint(input) != fmt.Sprint(want) {
t.Errorf... |
package module
import (
"accountBook/models/beans"
"accountBook/models/beans/customer"
"accountBook/models/beans/dbBeans"
"accountBook/models/endpoints"
"accountBook/models/endpoints/web"
"accountBook/models/service"
"strings"
"github.com/kinwyb/go/db"
"github.com/kinwyb/go/err1"
)
func init() {
endpoints.... |
// Mandelbrot creates PNG of Mandelbrot N**4-1
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"math/cmplx"
"os"
"runtime"
"sync"
)
type job struct {
xstart, xend, ystart, yend int
}
const (
xmin, ymin, xmax, ymax = -2, -2, 2, 2
width, height = 1920, 1080
chunks ... |
// Copyright 2014 The Sporting Exchange Limited. All rights reserved.
// Use of this source code is governed by a free license that can be
// found in the LICENSE file.
package collect
import (
"os"
"syscall"
)
// BUG(masiulaniecj): On Windows, plugin rescheduling on exit code 13 is not supported.
func reschedule(... |
package test
import (
"testing"
// "os"
// "path/filepath"
"portal/service"
// "portal/database"
)
func TestCreateApp(t *testing.T) {
// database.OpenDB("root:scut2018@tcp(192.168.80.243:3306)/portal2?parseTime=true")
var name string = "测试_A"
code, err := service.CreateApp(name)
if err != nil {
t.Error(er... |
package full
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-proje... |
package loadtest
import (
"time"
)
// An Endpoint represents a URL and a weight indicating the "importance" of the URL.
type Endpoint struct {
// The URL on which the request will be performed.
URL string
// The "importance" of the URL. The higher the number,
// the more often a request on the endpoint will be ... |
package databases
import (
"WhereIsMyDriver/adapters"
"WhereIsMyDriver/helper"
"log"
)
//MigrateDB ...
func MigrateDB(v interface{}) {
db, err := adapters.ConnectDB()
db.Set("gorm:table_options", "ENGINE=InnoDB").AutoMigrate(v)
if err != nil {
log.Println("error when migrate", err)
}
errorCloseDB := db.C... |
package gacha_odds
import (
"Golang-API-Game/pkg/repository"
"database/sql"
"log"
)
// gacha_oddsテーブルデータ
type GachaOdds struct {
CharacterID string
Odds int
}
type Total struct {
sum int
}
//gacha_OddsTableのOddsを合計したrowデータをとる
func OddsSum() (int, error) { //selectにするとoddsのsumを取ってくるという意味になってしまう
row := ... |
package api
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
"time"
"github.com/golang/protobuf/proto"
"github.com/hashicorp/raft"
"github.com/robustirc/robustirc/internal/config"
"github.com/robustirc/robustirc/internal/ircserver"
"github.com/robustirc/robustirc/internal/privacy"
"github.com/rob... |
package datastruct
import (
"container/list"
"fmt"
)
func ExampleDeque() {
// list.New()は双方向の連結リストを生成する→dequeとして利用できる
deque := list.New()
// 先頭に要素を追加する
deque.PushFront(-5) // [-5]
deque.PushFront(10) // [10, -5]
// 先頭の要素を取得する
// Valueはinterface型なので,型を意識した操作 (構造体の属性へのアクセス等) を
// したい場合にはキャストする必要がある
fmt.Pri... |
package main
import (
"encoding/json"
"log"
"math/rand"
"net/http"
"strconv"
"github.com/gorilla/mux"
)
// Book Struct (Model)
type Book struct {
ID string `json:"id"`
Isbn string `json:"isbn"`
Title string `json:"title"`
Author *Author `json:"author"`
}
// Author Struct (Mod... |
/*
* Copyright 2017 StreamSets 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... |
package rest
type webHandler struct {
res *Resource
}
func newWebHandler(configFile string) *webHandler {
res, _ := LoadResourceFile(configFile)
return &webHandler{
res: res,
}
}
|
package metrics
import (
"os/exec"
)
const REBOOT_CMD = "/system/bin/reboot"
func (tcp *TcpStats) performReboot() {
cmd := exec.Command(REBOOT_CMD)
cmd.Start()
}
|
// test is an example package containing the most basic
// tests possible.
package presentation
import (
"testing"
)
// Double doubles the provided value
func Double(n int) int {
return n * 2
}
// Fibonacci will what you'd think
func Fibonacci(n int) int {
if n < 2 {
return n
}
return Fibonacci(n-1) + Fibonac... |
package msg
import (
"server/msg/protocolfile"
"github.com/name5566/leaf/network"
"github.com/name5566/leaf/network/json"
)
var Processorbak network.Processor
// 使用默认的 JSON 消息处理器(默认还提供了 protobuf 消息处理器)
var Processor = json.NewProcessor()
func init() {
Processor.Register(&Protocol.UserLogin{})
}
// 一个结构体定义了一个 ... |
package main
import (
"bytes"
"fmt"
)
func main(){
var slice1 [4]int
slice1 = [...]int{1,2,3,0} // `...` -> denote as: origin of any value
var slice2 [4]int
fmt.Printf("%p\n",&slice1)
fmt.Printf("%p\n",&slice1)
alamat := &slice1
var thisCompareByValue bool = (slice1 == slice2)
var thisCompareByRefrence boo... |
package irc
import "awesome-dragon.science/go/goGoGameBot/pkg/event"
func (i *IRC) handleNickInUse(e event.Event) {
rawEvent := event2RawEvent(e)
if rawEvent == nil {
i.log.Warn("Got an invalid 433 event")
return
}
newNick := rawEvent.Line.Params[1] + "_"
if _, err := i.writeLine("NICK", newNick); err != n... |
package common
import (
"net/url"
)
// Client ecapsulates client details
type Client interface {
// URL returns a URL; unless there was a problem parsing it, in which case
// it returns an error
URL() (*url.URL, error)
// APIKey returns the API Key you are using, or an error if it is missing
APIKey() (string, e... |
addressSvc := svc.AddressSvc{store.AddressStore{cruder, lister}}
brandSvc := svc.BrandSvc{store.BrandStore{cruder, lister, beginer}}
categorySvc := svc.CategorySvc{store.CategoryStore{cruder, lister, beginer}}
companySvc := svc.CompanySvc{store.CompanyStore{cruder, lister, beginer}}
feedbackSvc := svc.FeedbackSvc{store... |
package chapter10
import (
"fmt"
"testing"
)
func TestMergeSortedArrays(t *testing.T) {
arrs := [][]int{
{24, 45, 49},
{12, 59, 87},
{44, 99},
}
result := MergeSortedArrays(arrs)
fmt.Println(result)
fmt.Println()
}
|
package httpd
import (
. "gopkg.in/check.v1"
"testing"
)
// test framework tie-in /////////////////////
func Test(t *testing.T) { TestingT(t) }
type XLSuite struct{}
var _ = Suite(&XLSuite{})
// end test framework setup //////////////////
|
// This file was generated for SObject FeedTrackedChange, API Version v43.0 at 2018-07-30 03:47:33.895560215 -0400 EDT m=+20.238926072
package sobjects
import (
"fmt"
"strings"
)
type FeedTrackedChange struct {
BaseSObject
FeedItemId string `force:",omitempty"`
FieldName string `force:",omitempty"`
Id ... |
package lineartable
import (
"bytes"
"fmt"
)
// SortedArrayInterface 有序数组 接口
type SortedArrayInterface interface {
Add(int64)
Remove(int64)
Find(int64) int
}
// NewSortedArray 创建新的有序数组
func NewSortedArray(cap int) *SortedArray {
return &SortedArray{
data: make([]int64, cap, cap),
cap: cap,
len: 0,
}
}... |
package concat
import (
"fmt"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/common/model"
"regexp"
"sync"
"time"
)
type Config struct {
// Empty string results in disabling
MultilineStartRegexpStr... |
package keeper
import (
"testing"
"github.com/irisnet/irishub/app/v1/auth"
"github.com/irisnet/irishub/app/v2/htlc/internal/types"
sdk "github.com/irisnet/irishub/types"
"github.com/stretchr/testify/require"
)
func TestKeeper_CreateHTLC(t *testing.T) {
ctx, keeper, ak, accs := createTestInput(t, sdk.NewInt(500... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.