text stringlengths 11 4.05M |
|---|
// 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 hwsec
import (
"context"
"sort"
"strings"
"time"
"github.com/google/go-cmp/cmp"
uda "chromiumos/system_api/user_data_auth_proto"
cryptohomecommon "chromiumo... |
package txhash
import (
"crypto/sha256"
"encoding/binary"
"io"
"log"
"sort"
pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"
"github.com/xuperchain/xupercore/protos"
)
type encoder struct {
intbuf [8]byte
w io.Writer
}
func newEncoder(w io.Writer) *encoder {
return &encoder{
w: w,
}
... |
package owners
type Owner struct {
Name string
Cpf string
Profession string
}
|
package main
import "fmt"
type Vertex struct {
X, Y int
}
func (v *Vertex) ScaleMethod(f int) {
v.X = v.X * f
v.Y = v.Y * f
}
func ScaleFunc(v *Vertex, f int) {
v.X = v.X * f
v.Y = v.Y * f
}
func main() {
v := Vertex{3, 4}
(&v).ScaleMethod(2) // == v.ScaleMethod(2)
ScaleFunc(&v, 10)
p := &Vertex{4, 3}
... |
package migrations
import (
"github.com/jmoiron/sqlx"
)
func CreateCommandTable(tx *sqlx.Tx) error {
_, err := tx.Exec("CREATE TABLE `commands` (`channel` varchar(255),`name` varchar(255),`response` varchar(255) NOT NULL,`enabled` tinyint UNSIGNED DEFAULT 1 NOT NULL,`restricted` tinyint UNSIGNED DEFAULT 0 NOT NULL,... |
package main
import "fmt"
// создаем интерфейс
type UserInterface interface {
InterfaceMethod() bool
}
// Первый пользовательским тип
type UserType1 struct {
Values []int
}
// Второй пользовательский тип
type UserType2 struct {
Values string
}
// Реализация метода интерфейса в пользовательском типе UserType1... |
package rand
import (
"fmt"
"math/rand"
"time"
)
func RandomPairs(members []string, maxMembers int) {
var newList []string
type team []string
var teams []team
//teams := []rune{'A', 'B', 'C', 'D'}
rooms := []string{"Room B", "Room C", "Room D", "Room E", "Room F", "Room G"}
source := rand.NewSource(time.Now(... |
package Longest_Increasing_Subsequence
func lengthOfLIS(nums []int) int {
increasingArray := make([]int, 0)
replaceFirstBigerOne := func(value int) {
left, right := 0, len(increasingArray)-1
for left <= right {
mid := right - (right-left)/2
if increasingArray[mid] == value {
return
}
if increas... |
package crudcontracts
import (
"github.com/adamluzsi/frameless/internal/suites"
)
type (
EntType struct{ ID IDType }
IDType struct{}
)
var _ = []suites.Suite{
Creator[EntType, IDType](nil),
Finder[EntType, IDType](nil),
QueryOne[EntType, IDType](nil),
Updater[EntType, IDType](nil),
Saver[EntType, IDType](ni... |
/*
* HPE API
*
* API's for HPE User Interface
*
* API version: 1.0.1
* Contact: kollisreekanth@gmail.com
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package swagger
type LoginResponseModel struct {
Id string `json:"id,omitempty"`
Username string `json:"username"`... |
// Copyright (C) 2019-2020 Zilliz. 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 l... |
package currency
import "time"
// ConverterInfo holds information about converter setup
type ConverterInfo interface {
Source() string
LastUpdated() time.Time
Rates() *map[string]map[string]float64
AdditionalInfo() interface{}
}
type converterInfo struct {
source string
lastUpdated time.Time
rates ... |
package memoryds
import (
"time"
"github.com/thisiserico/golabox/domain"
)
type WriteClient struct {
products []*domain.Product
orders []*domain.Order
items []*domain.Item
payments []*domain.Payment
}
func NewWriteClient() *WriteClient {
return &WriteClient{
products: initializeProducts(),
orders: ... |
// SPDX-License-Identifier: MIT
package lang
// swift 嵌套风格的块注释。会忽略掉内嵌的注释块。
type swiftNestMCommentBlock struct {
begin string
end string
prefix []byte // 需要过滤的前缀
begins []byte
ends []byte
level int8
}
// prefix 表示每一行的前缀符号,比如:
//
// /*
// *
// */
//
// 中的 * 字符
func newSwiftNestMCommentBlock(begin, end, ... |
package handlerTable
// Handler 注册函数
type Handler interface {
CallFunc()
}
// HandlerFunc 注册函数类型
type HandlerFunc func()
// CallFunc 实现注册函数
func (f HandlerFunc) CallFunc() {
f()
}
// Table 函数注册表
type Table interface {
HandlerFunc(f func()) error
CallBack()
}
// 函数注册表结构体
type handerTable struct {
Pool
}
// New... |
package model
type StandardResponse struct {
Description string `json:"description"`
Result string `json:"result"`
Value string `json:"value"`
}
|
package imitationPool
import (
"runtime"
"time"
)
type goworker struct {
//worker所在pool的指针
pool *Pool
//接收task的channel
task chan func()
//时间标记,当worker被使用后并重新放入队列中时,更新这个字段
recycleTime time.Time
}
//启动worker,在初始话一个worker时调用
func (g *goworker) run() {
//更新pool中运行goroutine数量 +1
g.pool.incRunning()
go func()... |
package portal
import (
"fmt"
"strings"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/types"
"kope.io/auth/pkg/oauth/session"
)
func (s *HTTPServer) mapUser(session *session.Session, info *session.UserInfo) (types.UID, error) {
providerID := session.ProviderId
if providerID == "" {
return "", fmt.Error... |
package main
import "fmt"
func main() {
switch "Asepnur" {
case "Asepnur":
fmt.Println("Hello Asepnur")
fallthrough
case "Muhammad":
fmt.Println("Hello Muhammad")
fallthrough
case "Iskandar":
fmt.Println("Hello Iskandar")
case "Yusuf":
fmt.Println("Hello Yusuf")
default:
fmt.Println("Unknown")
}
... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
package sync2
import (
"context"
"sync"
"sync/atomic"
"time"
monkit "github.com/spacemonkeygo/monkit/v3"
"golang.org/x/sync/errgroup"
)
// Cycle implements a controllable recurring event.
//
// Cycle control methods PANICS after Clo... |
package models
type User struct {
ID string `json:"id"`
Contacts []Contact `json:"contacts"`
}
|
package lc
import (
"bytes"
"strings"
)
// Time: O(n)
// Benchmark: 0ms 2.1mb | 100%
func reorderSpaces(text string) string {
var spaceCount int
for _, ch := range text {
if ch == ' ' {
spaceCount++
}
}
words := strings.Fields(text)
var spacesBetween, spacesAfter int
if len(words) <= 1 {
spacesAfte... |
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package mocks
import (
"context"
"fmt"
"strings"
"sync"
"time"
"github.com/mainflux/mainflux/auth"
)
var _ auth.GroupRepository = (*groupRepositoryMock)(nil)
type groupRepositoryMock struct {
mu sync.Mutex
// Map of groups, group id as a key.... |
package dao
import (
"db"
"time"
"types"
"github.com/google/uuid"
"github.com/kisielk/sqlstruct"
)
//RecoverDAO - data access for recovery requests
type RecoverDAO struct {
}
//CreateRecovery - creates a new recovery
func (dao RecoverDAO) CreateRecovery(account *types.Account, db *db.MySQL) (*types.Recovery, e... |
/**
1. 指定类型, 声明后不赋值则使用默认值:
var 变量 类型
变量 = 值
2. 直接赋值自行判断变量类型
var 变量 = 值
3. 省略关键字var(注意: 这里变量不能是已经声明过的不然编译器会报错)
变量 := 值
eg:
var a int = 1
var b = 1
v := 1
**/
package main
var a = 1
var b string = "我是一段字符串"
var c bool
func main() {
println(a, b, c)
}
// 结果: 1 我是一段字符串 false
|
package main
import (
"testing"
)
type BubbleSorter interface {
sort()
}
type Bubble struct {
name string
}
func TestEbullition(t *testing.T) {
array := []int{4, 93, 22, 86, 57, 12, 29}
bubble := Bubble{name: "冒泡---从小到大---稳定---n*n---"}
bubble.sort(array)
t.Log(array)
}
/**
主要 冒泡排序不是两两交换, 而是把循环对比... |
package util
import (
"fmt"
"github.com/spiral/roadrunner"
"strings"
)
// LogEvent outputs rr event into given logger and return false if event was not handled.
func StdErrOutput(event int, ctx interface{}) bool {
// outputs
switch event {
case roadrunner.EventStderrOutput:
for _, line := range strings.Split(... |
// Copyright 2021 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 (C) 2019-2020 Zilliz. 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 l... |
package httpx
import (
"fmt"
"net/http"
"strings"
"github.com/socialpoint-labs/bsk/metrics"
)
// InstrumentDecorator returns an adapter that instrument requests with some metrics:
// - http.request_duration: requests duration
// - http.requests: number of requests
//
// Metrics are tagged with the HTTP method, r... |
package logger
import (
configs "github.com/fwchen/jellyfish/config"
"github.com/stretchr/testify/assert"
"testing"
)
func TestInitLogger(t *testing.T) {
err := InitLogger(configs.LoggerConfig{
Level: "info",
})
assert.Nil(t, err)
assert.NotNil(t, sugaredLogger)
}
|
/*
* Copyright 2021 American Express
*
* 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"
"math"
)
func Sqrt(x float64) float64 {
var e float64 = 0.0000001
var z float64 = 1
var e1 float64
e1 = z*z - x
for !(e1 >= -e && e1 <= e) {
if z*z > x {
z -= (z*z - x) / (2 * z)
} else if z*z < x {
z += (x - z*z) / (2 * z)
}
e1 = z*z - x
fmt.Printf("e1:%v \n", e1)
... |
package wiki
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
type Server struct {
Conf Config
httpServer *http.Server
db *Database
}
func NewServer(c Config) (*Server, error) {
db, err := NewDatabase(c)
if err != nil {
return nil, err
}
m := mux.NewRouter()
h := &http.Server{
Addr: c... |
// 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... |
//go:build !windows
// +build !windows
package main
import "github.com/sirupsen/logrus"
func HookLogger(l *logrus.Logger) {
// Do nothing, let the logs flow to stdout/stderr
}
|
package gorp
import (
"database/sql"
"github.com/chidam1994/happyfox/models"
_ "github.com/lib/pq"
"gopkg.in/gorp.v2"
)
var db *sql.DB
func InitDB() *gorp.DbMap {
dbConnString := "host=localhost port=5432 user=postgres password=postgres dbname=postgres sslmode=disable"
//dbConnString := fmt.Sprintf("host=%s p... |
package restful
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"strconv"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestIndex(t *testing.T) {
assert := assert.New(t)
mock := httptest.NewServer(NewHandler())
defer mock.Close()
res, err := http.Get(mock.URL)
ass... |
// Copyright (C) 2019-2020 Zilliz. 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 l... |
package generic
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreds(t *testing.T) {
testCases := []struct {
description string
serverUsername string
serverPassword string
expected string
}{
{
"proxy credentials match server credentials",
fromProxyUsernam... |
/*
Copyright 2019 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 core
// Meta is returned from many queries that support pagination
type Meta struct {
Results MetaResults `json:"results"`
Page MetaPage `json:"page"`
}
// MetaResults contains the total number of results
type MetaResults struct {
Total int `json:"total"`
All int `json:"all,omitempty"`
}
// MetaP... |
package pubsub
import (
"context"
"fmt"
"time"
"github.com/go-redis/redis/v7"
"github.com/apenella/go-redis-queues/internal/infrastructure/configuration"
providerredis "github.com/apenella/go-redis-queues/internal/infrastructure/provider/redis"
)
// Producer is a redis client which appends messages to a chann... |
/*
Copyright 2015 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 law or agreed to in writing, soft... |
// Copyright (c) 2018 The MATRIX Authors
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php
package amhash
import "testing"
func TestMine(t *testing.T) {
t.Logf("test")
}
|
//+build !test
package config
import (
"github.com/gobjserver/gobjserver/core/gateway"
"github.com/gobjserver/gobjserver/db"
)
// CreateObjectGateway .
func CreateObjectGateway() gateway.ObjectGateway {
var database db.CommonDatabase
database = CreateRethinkDB()
rethinkObjectGateway := db.ObjectGatewayImpl{
D... |
package main
import (
"context"
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/status"
"io"
"learnings/grpc/errors"
"learnings/grpc/greet/greetpb"
"log"
"sync"
"time"
"google.golang.org/grpc"
)
func main() {
// boilerplate
fmt.Println("hello I'm a grpc... |
package database
import (
"database/sql"
"encoding/json"
)
type (
NullString struct {
sql.NullString
}
NullInt64 struct {
sql.NullInt64
}
)
func (t NullString) MarshalJSON() ([]byte, error) {
if t.Valid {
return json.Marshal(t.String)
} else {
return json.Marshal(nil)
}
}
func (t *NullString) Unmar... |
package main
import (
"fmt"
"log"
"strconv"
"time"
)
func SysDeposit(depositNumber string, platfrom string) map[string]interface{} {
data := make(map[string]interface{})
deposit, err := dbManager.GetDeposit(depositNumber, platfrom)
if deposit == nil || err != nil {
data["code"] = ERROR_DEPOSIT_NOT_EXISTS
d... |
package notificationqueue
import (
"errors"
)
//ErrQueueDriverRequired queue driver required error.
var ErrQueueDriverRequired = errors.New("queue driver required")
//ErrIDGeneratorRequired id generator required
var ErrIDGeneratorRequired = errors.New("id generator required")
|
package writer
import "go.uber.org/zap/zapcore"
type Writer interface {
zapcore.WriteSyncer
} |
package gevent
/* ================================================================================
* gevent
* qq group: 582452342
* email : 2091938785@qq.com
* author : 美丽的地球啊 - mliu
* ================================================================================ */
type (
IEvent interface {
Subscribe(ISu... |
package main
// #include "libnative/native.h"
import "C"
func main() {
C.native_example()
}
|
/*
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 (C) 2017 Google 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 t... |
package problem0290
import "strings"
func wordPattern(pattern string, str string) bool {
strArr := strings.Split(str, " ")
if len(pattern) != len(strArr) {
return false
}
m1 := make(map[rune]string, len(strArr))
m2 := make(map[string]rune, len(strArr))
for pos, v := range pattern {
s := strArr[pos]
if... |
package bfs
import (
"testing"
"github.com/victorfernandesraton/bfs-and-dfs/node"
)
func TestIsValid(t *testing.T) {
zero := &node.Node{
Value: 0,
Index: 0,
}
one := &node.Node{
Value: 1,
Index: 0,
}
two := &node.Node{
Value: 2,
Index: 0,
}
one.AddChildren(zero)
one.AddChildren(two)
three := &... |
package containeraction
import (
"context"
"encoding/json"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"time"
commonapi "github.com/cidverse/cid/pkg/common/api"
"github.com/cidverse/cid/pkg/common/command"
"github.com/cidverse/cid/pkg/core/catalog"
"github.com/cidverse/... |
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
)
// func main() {
// // parse()
// s3()
// }
// parse arg to float, convert to C, display w/format
func parse() {
f, e := strconv.ParseFloat(os.Args[1], 64)
if e != nil {
fmt.Println("error parsing float")
os.Exit(1)
}
cValue := fToC(f)
fmt.Print... |
package strings
import (
"fmt"
)
func isRotation(str1, str2 string) bool{
var point int
for i,_ := range str1 {
if str1[i] == str2[1] {
point = i
break
}
}
longStr := str2 + str1[point-1:]
fmt.Println(point, longStr)
return isSubString(longStr, str1)
}
func isSubString(str1, str2 string) bool ... |
// Package zipper responsible to download files over HTTP, compress them on
// the fly and pipe the zip output to given destination.
package zipper
import (
"archive/zip"
"errors"
"io"
"net/http"
"time"
)
// DownloaderClient used to download files over HTTP.
var DownloaderClient = &http.Client{
Timeout: 30 * ti... |
package sinks
import (
"fmt"
"github.com/matang28/reshape/reshape/serde"
)
type DebugSink struct {
serializer serde.Serializer
}
func NewDebugSink() *DebugSink {
return &DebugSink{serializer: serde.FmtSerializer}
}
func NewCustomDebugSink(serializer serde.Serializer) *DebugSink {
return &DebugSink{serializer: ... |
package mediator
import (
"context"
)
type Sender interface {
Send(context.Context, Message) (interface{}, error)
}
|
package sysinfo
import (
"io/ioutil"
"os"
"path"
"path/filepath"
"testing"
)
func TestReadProcBool(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "test-sysinfo-proc")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpDir)
procFile := filepath.Join(tmpDir, "read-proc-bool")
if err := ioutil.WriteFi... |
package main
import "github.com/onuryartasi/scaler/pkg/protocol/grpc"
func main(){
grpc.RunServer()
} |
package exchange
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/currency"
"github.com/prebid/prebid-server/exchange/entities"
"github.com/prebid/prebid-se... |
package pando
import (
"bytes"
goContext "context"
"encoding/json"
"fmt"
"github.com/agiledragon/gomonkey/v2"
"github.com/gin-gonic/gin"
"github.com/kenlabs/pando/pkg/api/types"
. "github.com/smartystreets/goconvey/convey"
"io/ioutil"
"net/http"
"net/http/httptest"
"reflect"
"testing"
)
func TestProvider... |
package typrls
import (
"fmt"
"os"
"strings"
"github.com/typical-go/typical-go/pkg/typgo"
)
type (
// CrossCompiler compile project to various platform
CrossCompiler struct {
Targets []Target
MainPackage string
}
// Target of release contain "$GOOS/$GOARC"
Target string
)
//
// Compile
//
var _ Re... |
package actions
import "log"
import "cointhink/proto"
import "cointhink/model/algorun"
import "cointhink/model/token"
import gproto "github.com/golang/protobuf/proto"
func DoLambdaResponse(_lambda_response *proto.LambdaResponse, _token *proto.Token) []gproto.Message {
var responses []gproto.Message
log.Printf("L... |
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func Download(url string, downloadPath string) error {
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
f, err := os.OpenFile(downloadPath, os.O_RDWR|os.O_CREATE, 0755)
if err != nil {
return err
}
defer f.Close()
ret... |
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"net/url"
"strings"
"time"
"github.com/niklasfasching/goheadless"
"github.com/niklasfasching/telegram"
)
type config struct {
TelegramToken string
ServerAddress string
BrowserPort int
}
f... |
// 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 perfutil
// UnstableModels is the list of the models which appear to be not stable on
// the UI performance tests.
var UnstableModels = []string{
"esche",
"willow"... |
package main
import (
"fmt"
"time"
"math/rand"
)
const height = 20
const width = 40
var field = [height][width]int{}
var newField = [height][width]int{}
func main() {
rand.Seed(time.Now().UTC().UnixNano())
initField()
for {
clearScreen()
dumpField()
time.Sleep(100... |
package main
import (
"encoding/json"
"fmt"
"net/http"
m "github.com/keighl/mandrill"
)
type Message struct {
Token string `json:"token"`
ToEmail string `json:"email"`
Type string `json:"type"`
FromEmail string `json:"from_email"`
FromName string `json:"from_name"`
Subject string `json:"subje... |
/*
* Copyright IBM Corporation 2021
*
* 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 o... |
package jindo
import (
"github.com/fluid-cloudnative/fluid/pkg/utils"
datasetSchedule "github.com/fluid-cloudnative/fluid/pkg/utils/dataset/lifecycle"
)
func (e *JindoEngine) AssignNodesToCache(desiredNum int32) (currentScheduleNum int32, err error) {
runtimeInfo, err := e.getRuntimeInfo()
if err != nil {
retur... |
package log
import (
"bytes"
"testing"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/server"
ethlog "github.com/ethereum/go-ethereum/log"
)
const (
timeKey = "t"
lvlKey = "lvl"
msgKey = "msg"
ctxKey = "ctx"
)
... |
// Package gitwatch provides a simple tool to first clone a set of git
// repositories to a local directory and then periodically check them all for
// any updates.
package gitwatch
import (
"context"
"fmt"
"io"
"net/url"
"path/filepath"
"strings"
"time"
"github.com/pkg/errors"
"golang.org/x/xerrors"
"gopkg... |
package twitterscraper
import (
"context"
"testing"
)
func TestFetchSearchCursor(t *testing.T) {
scraper := New()
maxTweetsNbr := 150
tweetsNbr := 0
nextCursor := ""
for tweetsNbr < maxTweetsNbr {
tweets, cursor, err := scraper.FetchSearchTweets("twitter", maxTweetsNbr, nextCursor)
if err != nil {
t.Fat... |
package lo
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Map(t *testing.T) {
sourceSlice := []int{1, 2, 3}
targetSlice := Map(sourceSlice, func(item int) int {
return item * 2
})
assert.Equal(t, []int{2, 4, 6}, targetSlice, "should map the slice")
}
func Test_Reduce(t *testing... |
package notification_test
import (
"strconv"
"sync"
"sync/atomic"
"testing"
"github.com/herb-go/notification"
)
type testStore struct {
locker sync.Mutex
data []*notification.Notification
}
func (d *testStore) Open() error {
return nil
}
func (d *testStore) Close() error {
return nil
}
func (d *testStore... |
// Copyright © 2016 Jason Gardner <buhrietoe@gmail.com>
//
// 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 appli... |
package gormbatchputs_test
import "github.com/theplant/gormbatchputs"
import "github.com/jinzhu/gorm"
/*
#### A list of rows, Put to multiple databases
*/
func ExampleNew_1ToManyDBs() {
db := openAndMigrate()
bputs := gormbatchputs.New().Rows([]*Country{
{
Code: "CHN",
ShortName: "China",
},
{
... |
package geo
import (
"testing"
"github.com/paulmach/orb"
)
func TestLength(t *testing.T) {
for _, g := range orb.AllGeometries {
// should not panic with unsupported type
Length(g)
}
}
func TestLengthHaversine(t *testing.T) {
for _, g := range orb.AllGeometries {
// should not panic with unsupported type... |
/*
Copyright 2019 Adobe
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it. If you have received this file from a source other than Adobe,
then your use, modification, or distribution of it requires the pri... |
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"github.com/go-redis/redis"
)
func main() {
opt, err := redis.ParseURL(os.Getenv("REDIS_URL"))
if err != nil {
log.Fatal(err)
}
client := redis.NewClient(opt)
err = client.Set("key", "value", 0).Err()
if err != nil {
log.Fatal(err)
}
val, er... |
package eedid
var pnpLookup = map[string]PNPID{
"TTL": PNPID{
ID: "TTL",
Company: "2-TEL B.V",
Date: "03/20/1999",
},
"BUT": PNPID{
ID: "BUT",
Company: "21ST CENTURY ENTERTAINMENT",
Date: "04/25/2002",
},
"TCM": PNPID{
ID: "TCM",
Company: "3COM CORPORATION",
Date: "11/29/... |
package models
import (
"database/sql"
"time"
"github.com/LiveSocket/bot/service"
)
// ModChat Represents a ModChat message
type ModChat struct {
ID uint `db:"id" json:"id"`
Channel string `db:"channel" json:"channel"`
Message string `db:"message" json:"message"`
Name string `db:... |
// 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, ... |
/*
Copyright 2019 Transwarp All rights reserved.
*/
package v1alpha1
import (
"encoding/json"
"fmt"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/type... |
package utils
import (
"fmt"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
)
type User struct {
Id int
Name string
Age int8
}
func init() {
//mysql / sqlite3 / postgres 这三种是默认已经注册过的,所以可以无需设置
//orm.RegisterDriver("mysql", orm.DRMySQL)
maxIdle := 30
maxConn := 30
orm.RegisterDataBase(... |
package main
import "fmt"
type Student struct {
name string
age int
grade int
}
func setName(t *Student, newName string) {
t.name = newName
}
func main() {
a := Student{"phj", 20, 99}
fmt.Println("변경전", a)
setName(&a, "newName")
fmt.Println("변경후", a)
}
|
package DTO
type UsersListDTO struct {
Usernames []string `json:"usernames"`
}
|
package service
import "app/dao"
func GetUser(id int) (dao.User, error) {
user := dao.User{}
err := user.GetOne(id)
return user, err
} |
package mocks
import "github.com/stretchr/testify/mock"
import "github.com/Lunchr/luncher-api/db/model"
type RegistrationAccessTokens struct {
mock.Mock
}
func (_m *RegistrationAccessTokens) Insert(_a0 *model.RegistrationAccessToken) (*model.RegistrationAccessToken, error) {
ret := _m.Called(_a0)
var r0 *model.... |
package lfsapi
import (
"errors"
"net/url"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSSHCacheResolveFromCache(t *testing.T) {
ssh := newFakeResolver()
cache := withSSHCache(ssh).(*sshCache)
cache.endpoints["userandhost//1//path//p... |
// 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 bluetooth contains helpers to interact with the system's bluetooth
// adapters.
package bluetooth
import (
"context"
"fmt"
"chromiumos/tast/common/testexec"
... |
package indexer
import (
"fmt"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"strings"
)
// UsersIndexFunc ...
func UsersIndexFunc(obj interface{}) ([]string, error) {
pod := obj.(*v1.Pod)
usersString := pod.Annotations["users"]
return strings.Split(usersStr... |
package utils
import (
"fmt"
"github.com/jwalton/gchalk"
"hash/fnv"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"time"
)
// PatternsInPath Checks if any of the provided patterns is found in the path.
func PatternsInPath(patterns []string, path string) bool {
for _, pattern := range patterns {
... |
package pkg
import "fmt"
const (
// Методы
Get = "GET"
Post = "POST"
Put = "PUT"
Delete = "DELETE"
// Товары
Product = "/entity/product"
ProductDeleteList = Product + "/delete"
ProductAttribute = Product + "/metadata/attributes/"
)
//TakeProduct Возвращает метод и эндпоинт для того чтобы... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.