text stringlengths 11 4.05M |
|---|
package logger
import (
"bytes"
"fmt"
"io"
"math/rand"
"runtime"
"strings"
"testing"
"time"
)
func TestReleaseMemory(t *testing.T) {
// This isn't a functional test, and I don't want it to be a gate on
// future changes. But I'd like to leave it in place, because I
// suspect that we may need to confirm ... |
package morloop
import "log"
type Logger struct {
}
// Info - log info
func (logger *Logger) Info(content string) {
log.Printf(content)
}
// Error - log error
func (logger *Logger) Error(content string) {
log.Printf(content)
}
func (logger *Logger) Debug(content string) {
log.Printf(content)
}
|
package main
import (
"io/ioutil"
"strings"
"testing"
)
// TestSelfPass makes sure all the code in this project passes spell checking.
func TestSelfPass(t *testing.T) {
cts, err := CheckAll(gopaths("."))
if err != nil {
t.Fatal(err)
}
rejects := 0
for _, ct := range cts {
if strings.Contains(ct.ctok.lit,... |
package usecase
import "fmt"
func reportUnexpected(name string, actual, expected interface{}) error {
return fmt.Errorf("unepxected %s: got %v, expected %v", name, actual, expected)
}
|
package main
/**
104. 二叉树的最大深度
给定一个二叉树,找出其最大深度。
二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。
说明: 叶子节点是指没有子节点的节点。
示例1:
```
给定二叉树 `[3,9,20,null,null,15,7]`
3
/ \
9 20
/ \
15 7
```
*/
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
*... |
package game
type Game struct {
participant1 *Player
participant2 *Player
}
|
package main
import (
"errors"
"flag"
"fmt"
"os"
"path/filepath"
"strings"
optionsgen "github.com/kazhuravlev/options-gen/options-gen"
)
func main() {
var (
inFilename string
outFilename string
optionsStructName string
outPackageName string
defaultsFrom string
muteWarnings ... |
package mhfpacket
import (
"errors"
"github.com/Andoryuuta/Erupe/network"
"github.com/Andoryuuta/Erupe/network/clientctx"
"github.com/Andoryuuta/byteframe"
)
// MsgMhfPostBoostTimeLimit represents the MSG_MHF_POST_BOOST_TIME_LIMIT
type MsgMhfPostBoostTimeLimit struct{}
// Opcode returns the ID associated with t... |
// zap是日志功能的一种实现。
// 支持特性:
// 1. 支持2种日志格式: json 和 logfmt
// 2. 支持日志轮换: 可按文件大小,时间轮换,可设置保留备份文件数。
// 3. 动态调整日志等级:
//
// 如果启动了level server,可以通过 http://localhost:80001/log_level 查看并动态调整日志等级。
//
// curl -X PUT -d '{"level":"debug"}' http://localhost:8003/log_level
// curl -X GET http://localhost:8003/log_level
package zap
... |
package router
import (
"map-friend/src/interface/handler"
"map-friend/src/internal/middleware"
"net/http"
"github.com/gorilla/mux"
)
const (
GetMethod = "GET"
PostMethod = "POST"
PutMethod = "PUT"
DeleteMethod = "DELETE"
)
type Route struct {
Path string
Methods []string
Handler func(w http.R... |
package main
import "fmt"
func main() {
var polo int = 3
fmt.Println(polo)
} |
package normal
import (
"fmt"
"gostudy/003/modelprivate/internal"
)
func NornHello() {
fmt.Println("hello world norn")
}
func NornUsage() {
internal.InterHello()
}
|
package goHelpers
import (
"fmt"
"log"
"runtime"
"strings"
)
// NotImplemented ... Call this function to return an error in a non implemented function or print it.
func NotImplemented() error {
pc := make([]uintptr, 10) // at least 1 entry needed
runtime.Callers(2, pc)
f := runtime.FuncForPC(pc[0])
file, line... |
package controller
import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"projja_api/model"
"strconv"
"strings"
"time"
"github.com/go-martini/martini"
"github.com/scylladb/go-set"
)
func (c *Controller) Register(w http.ResponseWriter, r *http.Request) (int, string) {
contentType := ... |
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V.
//
// 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
//
// Un... |
package client
import (
"io"
"github.com/wish/ctl/pkg/client/helper"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/remotecommand"
)
// ExecInPod executes a command on a pod interactively
func (c *Cl... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-18 16:53
# @File : of_剑指_Offer_31_栈的压入_弹出序列.go
# @Description :
# @Attention :
*/
package offer
func validateStackSequences(pushed []int, popped []int) bool {
stack := make([]int, 0)
index := 0
for _, v := range pushed {
stack = append(stack, v)
... |
// Copyright 2016 IBM Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or... |
/*
This package includes some usefull methods for displaying data on the terminal.
This package depends on termbox which is a crossplatform library written by Georg Reinke.
Termbox is available at github.com/nsf/termbox-go
*/
package console
import (
//"fmt"
"github.com/indidev/vocable-o/util/mathutil"
"github.... |
package azure
// SecurityTypes represents the SecurityType of the virtual machine.
type SecurityTypes string
const (
// SecurityTypesConfidentialVM defines the SecurityType of the virtual machine as a Confidential VM.
SecurityTypesConfidentialVM SecurityTypes = "ConfidentialVM"
// SecurityTypesTrustedLaunch define... |
package idg
import (
"encoding/base64"
"github.com/PathDNA/atoms"
"github.com/itsmontoya/mum"
"github.com/missionMeteora/toolkit/errors"
)
const (
// ErrInvalidLength is returned when an ID is not 16 bytes in length
ErrInvalidLength = errors.Error("invalid length")
)
var (
// Base64 RawURLEncoding alias
b64... |
package gosnowth
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"time"
)
const textTestData = `[[1380000000,"hello"],[1380000300,"world"]]`
func TestTextValue(t *testing.T) {
t.Parallel()
tvr := TextValueResponse{}
if err := json.Unmarshal([]byte(textTestD... |
package main
import (
"context"
"net/http"
"github.com/avaldevilap/greenlight/internal/data"
)
type contextKey string
const userContextKey = contextKey("user")
func (app *application) contextSetUser(r *http.Request, user *data.User) *http.Request {
ctx := context.WithValue(r.Context(), userContextKey, user)
r... |
package main
import (
"fmt"
"time"
"github.com/TruthHun/DocHub/controllers/HomeControllers"
"github.com/TruthHun/DocHub/helper"
"github.com/TruthHun/DocHub/models"
_ "github.com/TruthHun/DocHub/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"lazybug.me/util"
)
//初始化函数
func init() {
//数... |
package filter
import (
"poliskarta/api/helperfunctions"
"poliskarta/api/structs"
"strings"
)
func FilterPoliceEvents(policeEvents *structs.PoliceEvents) {
eventsCopy := *policeEvents
filterOutTime(&eventsCopy)
filterOutEventType(&eventsCopy)
if policeEvents.Value == "stockholm" {
addAllWordsAsLocationWords(... |
package runtime
import (
"fmt"
"github.com/tornadoyi/viking/log"
"strings"
)
var (
catchErrCallback = func(info *PanicInfo){
if info == nil { return }
msgs := make([]string, 0)
msgs = append(
msgs,
fmt.Sprintf("A panic occured as below"),
fmt.Sprintf("%v", info.stack),
fmt.Sprintf("error: %v\n",... |
/*
Tests aborting transactions at different times, successive calls do not succeed.
Usage:
go run 4_AbortTests.go
*/
package main
import "../kvservice"
import (
"fmt"
)
func main() {
var nodes []string
nodes = []string{"52.233.45.243:2222", "52.175.29.87:2222", "40.69.195.111:2222", "13.65.91.243:2222", "51.140.... |
package serve
import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"github.com/go-chi/chi"
"github.com/stellar/go/keypair"
"github.com/stellar/go/txnbuild"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTxApproveHandler_isRejec... |
package mavlink2
/*
Generated using mavgen - https://github.com/ArduPilot/pymavlink/
Copyright 2020 queue-b <https://github.com/queue-b>
Permission is hereby granted, free of charge, to any person obtaining a copy
of the generated software (the "Generated Software"), to deal
in the Generated Software without restric... |
package main
import "fmt"
func main() {
//var words []Word
query := "dog"
words, err := getWords(query)
if err != nil {
fmt.Println("Error: ", err.Error())
}
for _, word := range words {
if word.Text == query {
for j, meaning := range word.Meanings {
fmt.Println(j, meaning.Translation.Text)
}
}... |
package models
import (
"time"
jwt "github.com/dgrijalva/jwt-go"
)
type CallbackData struct {
Device string
Data string
Time int64
}
type DeviceEvent struct {
Id int
DeviceId int
Name string
CreateTime time.Time
}
type DeviceCommand struct {
Id int
DeviceId int
Command... |
// Copyright 2021 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 push
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/10gen/realm-cli/internal/cli"
"github.com/10gen/realm-cli/internal/cloud/atlas"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/local"
"github.com/10gen/rea... |
package handler
import (
"encoding/json"
"fmt"
"net/http"
"runtime"
utils "github.com/agungdwiprasetyo/go-utils"
"github.com/agungdwiprasetyo/reverse-proxy/config"
"github.com/agungdwiprasetyo/reverse-proxy/src/shared"
)
// Root handling root gateway request
func Root(w http.ResponseWriter, req *http.Request)... |
package main
import "fmt"
const M = 10
func hash(d int) int {
return d % M
}
func main() {
var m [M]int
m[hash(23)] = 10
fmt.Println(m)
}
|
// Copyright 2021 The Swarm 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 pricer_test
import (
"encoding/binary"
"io/ioutil"
"reflect"
"testing"
mockkad "github.com/ethersphere/bee/pkg/kademlia/mock"
"github.com/eth... |
package main
import (
"bufio"
"fmt"
"io"
"os"
)
// WordCount takes a file and returns a map
// with each word as a key and it's number of
// appearances as a value
func WordCount(f io.Reader) map[string]int {
result := make(map[string]int)
// make a scanner to work on the file
// io.Reader interface
scanner ... |
package resolvers
import (
"context"
"github.com/syncromatics/kafmesh/internal/graph/generated"
"github.com/syncromatics/kafmesh/internal/graph/model"
"github.com/pkg/errors"
)
//go:generate mockgen -source=./source.go -destination=./source_mock_test.go -package=resolvers_test
// SourceLoader is the dataloader... |
// Copyright 2021 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... |
/*
Copyright (c) 2017 SAP SE or an SAP affiliate company. 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 app... |
// Package engine runs graw bots.
package engine
import (
"container/list"
"fmt"
"sync"
"time"
"github.com/turnage/graw/internal/botfaces"
"github.com/turnage/graw/internal/monitor"
"github.com/turnage/graw/internal/operator"
"github.com/turnage/redditproto"
)
const (
// blockTime is the amount of time to b... |
package controller
import (
"bytes"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
ctl "github.com/go-jar/gohttp/controller"
"github.com/go-jar/gohttp/idgen"
"blog/resource/log"
)
const (
RemoteRealIpHeaderKey = "REMOTE-REAL-IP"
RemoteRealPortHeaderKey = "REMOTE-REAL-PORT"
DownstreamServerIp = "12... |
package cmd
import (
"testing"
)
func TestIsExistDifupLogBranch(t *testing.T) {
}
func TestSaveRevision(t *testing.T) {
}
func TestGetCurrentRevision(t *testing.T) {
}
|
package main
import (
"fmt"
"log"
)
func main() {
calculator()
}
func calculator() {
var a, b, result float64
var operator string
fmt.Println("Введите первое чило")
_, err := fmt.Scan(&a)
if err != nil {
log.Fatal("Введено неверное число!")
}
_, err = fmt.Println("Введите второе число")
if err != nil ... |
// 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... |
package main
import "fmt"
func main() {
panic("Hello panic")
text := recover()
fmt.Println(text)
}
|
package cart
import (
"context"
"encoding/json"
"net/http"
"time"
"cinemo.com/shoping-cart/framework/web/httpresponse"
"cinemo.com/shoping-cart/internal/errorcode"
"cinemo.com/shoping-cart/internal/orm"
"cinemo.com/shoping-cart/internal/users"
"cinemo.com/shoping-cart/pkg/auth"
"github.com/google/uuid"
"gi... |
// MIT License
//
// Copyright (c) 2017 Ryan Fowler
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify,... |
/*
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
*
* file: main.go
* details: Kafka Consumer based on confluent-kafka-go library
*
*/
package kafkaconsumer
import (
"os"
"os/signal"
msghandler "github.com/Juniper/collector/flow-translator/msg-handler"
opts "github.com/Juniper/collector... |
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
type album struct {
ID string `json:"id"`
Title string `json:"title"`
Artist string `json:"artist"`
Price float64 `json:"price"`
}
var albums = []album{
{ID: "1", Title: "Blue Train", Artist: "John Coltrane", Price: 56.99},
{ID: "2", Title: "Jeru... |
package auth0
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccClientGrant(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
},
Steps: []resource.TestStep... |
package lemonadeChange
func lemonadeChange(bills []int) bool {
m := [3]int{}
for _, bill := range bills {
switch bill {
case 5:
m[0]++
case 10:
m[1]++
if m[0] > 0 {
m[0]--
} else {
return false
}
case 20:
m[2]++
if m[0] > 0 && m[1] > 0 {
m[0]--
m[1]--
} else {
if m... |
package general
import (
"errors"
"fmt"
"github.com/lfxnxf/protobuf_to_sdk/tpl"
"github.com/lfxnxf/protobuf_to_sdk/utils"
"io/ioutil"
"os"
"strings"
"sync"
)
type General struct {
OutModel string
OutSdk string
Content []string
NeedCommon int64
ModelPackage s... |
package handlers
import (
"bufio"
"fmt"
"io"
"mime/multipart"
"os"
"path/filepath"
"strings"
"time"
"github.com/decentraland/content-service/data"
"github.com/decentraland/content-service/metrics"
"github.com/fatih/structs"
"github.com/ipsn/go-ipfs/gxlibs/github.com/ipfs/go-cid"
"github.com/ipsn/go-ipfs/... |
package Ant
import (
"fmt"
"github.com/yhat/scrape"
"golang.org/x/net/html"
"nqc.cn/utils"
"net/http"
"github.com/gin-gonic/gin"
"encoding/json"
"io/ioutil"
"nqc.cn/log"
)
/*
{
"url": "http://company.zhaopin.com/zhengzhou/210500/",
"ant": [
{
"parend": {
"class":... |
/*
* Copyright (c) 2020. Ant Group. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package model
type BuildTimeInfo struct {
PackageVer string `json:"package_ver"`
GitCommit string `json:"git_commit"`
BuildTime string `json:"build_time"`
Profile string `json:"profile"`
Rustc string... |
package scan
import "bytes"
type Expr interface {
String() string
}
type exprs []Expr
func (es exprs) capture(captured bool) Pattern {
var w exprWriter
for i, e := range es {
if i > 0 {
w.WriteByte('|')
}
if captured {
w.capture(Pat(e.String()).simplify())
} else {
w.group(e)
}
}
return w.pa... |
package tasker_test
import (
// "errors"
"fmt"
"github.com/ztxmao/vii/library"
"testing"
"time"
)
var (
p = fmt.Println
f = func(expire time.Duration) error {
p(time.Now(), " task runing!")
return nil
}
)
func TestTasker(t *testing.T) {
rate := time.Second * 1
expire := time.Second * 2
tasker, _ := li... |
package _95_Unique_Binary_Search_Trees_2
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func generateTrees(n int) []*TreeNode {
if n == 0 {
return []*TreeN... |
// 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 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 The OpenSDS 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 agre... |
package hunter
func Watching() {
}
func Hunting() {
}
func Logs() {
}
|
package core
import (
"net/http"
"github.com/gin-gonic/gin"
)
// lsNotifications godoc
// @Summary List notifications
// @Description Lists all notifications generated by thread and account activity.
// @Tags notifications
// @Produce application/json
// @Success 200 {object} pb.NotificationList "notifications"
//... |
package cloudconfig
import (
"fmt"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
"github.com/giantswarm/aws-operator/service/controller/legacy/v27/encrypter"
)
const (
FileOwnerUser = "root"
FileOwnerGroup = "root"
FilePermission = 0700
)
// Config represents the configuration used... |
package main
import (
"time"
"github.com/BorisBorshevsky/GolangDemos/catapult/api"
"github.com/k0kubun/pp"
)
func main() {
for i := 0; i < 3; i++ {
start := time.Now()
val, err := locationSvc.Alive()
if err == nil {
pp.Println("stop1", time.Since(start).Nanoseconds()/1e6, val.Commit)
} else {
pp.... |
package priorityqueue
import "container/heap"
// Item with priority
type Item struct {
value interface{}
priority int
}
type _PriorityQueue []*Item
// Len length of queue
func (pq _PriorityQueue) Len() int {
return len(pq)
}
// Less returns relation within index i and index j
func (pq _PriorityQueue) Less(i, j ... |
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"strconv"
"strings"
"time"
"github.com/coreyog/board-discovery"
"github.com/coreyog/microcontroller"
)
var scanner = bufio.NewReader(os.Stdin)
func main() {
devices, _ := discovery.DiscoverNow(true, false)
targetDevice := ""
switch len(devices) {
... |
// Package debounce implement Golang version debounce.
// The passed function which will postpone its execution until after `time.Duration`
// have elapsed since the last time it was invoked.
package debounce
import (
"errors"
"sync"
"sync/atomic"
"time"
)
// ErrStoped raised by Trigger or Stop a stoped Debouncer... |
// 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 main
import (
"fmt"
"unicode/utf8"
)
func main() {
var ja string = "Go言語"
fmt.Println(ja, "count:", utf8.RuneCountInString(ja))
}
|
package txt
import (
"os"
"encoding/base64"
"strings"
"fmt"
"io"
)
//对txt文件内容进行base64加密生成.encode文件
func Base64EncodeTxtFile(filePath string)(err error){
f,err := os.Open(filePath)
defer f.Close()
if err != nil {
return err
}
writePath := filePath[:strings.LastIndex(filePath,".")]
writePath = fmt.Sprint(w... |
package main
import (
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"strings"
)
func hasGoBGP() bool {
_, err := os.Stat("/gobgpd")
return err == nil
}
func writeGoBGPConfig() error {
cfg := fmt.Sprintf(`
[global.config]
as = 64512
router-id = "10.96.0.102"
port = 2179
[[neighbors]]
[neighbors.config]
... |
package prometheuscustomexporter
import (
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/collector/config/configmodels"
)
// Config defines configuration for Prometheus exporter.
type Config struct {
configmodels.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correct... |
package main
import ()
func lexText(l *lexer) stateFunc {
switch l.next() {
case "[":
return LJump
case "]":
return RJump
case ">":
return RShift
case "<":
return LShift
case "+":
return Inc
case "-":
return Dec
case ".":
return Get
case ",":
return Set
case "eof":
return nil
default:
r... |
package 二叉树
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
const flagOfCannotFind = 100000000000000 // 该值不能存在于树中
var curOrder int
func kthLargest(root *TreeNode, k int) int {
curOrder = 0
return getKthLargest(root, k)
}
func... |
package main
import (
"fmt"
"github.com/sap/gorfc/gorfc"
)
func abapSystem() gorfc.ConnectionParameters {
return gorfc.ConnectionParameters{
"user": "",
"passwd": "",
"ashost": "172.1.0.1",
"sysnr": "",
"client": "",
"lang": "ZH",
}
}
func main(){
c, _ := gorfc.ConnectionFromParams(abapSyste... |
package test
import (
"log"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/xerrors"
)
type User struct {
ID int
Name string
}
func Test_Example1(t *testing.T) {
u1 := &User{
ID: 1,
Name: "yukpiz",
}
u2 := &User{
ID: 1,
Name: "yukpiz",
}
assert.Equal(t, u1, u2)
u... |
package taxjar
type Tax struct {
Breakdown Breakdown `json:"breakdown"`
OrderTotalAmount float64 `json:"order_total_amount"`
Shipping float64 `json:"shipping"`
TaxableAmount float64 `json:"taxable_amount"`
Rate float64 `json:"rate"`
AmountToCollect float64 `json:"amount_t... |
package function
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strings"
"testing"
"time"
)
func TestFunctionDeployment(t *testing.T) {
BuildHash := os.Getenv("BUILD_HASH")
if BuildHash == "" {
t.Errorf("Didn't find build hash env var")
return
}
WhatWeWant := []string{
BuildHash,
"o... |
package list
import (
"testing"
)
func TestInit(t *testing.T) {
l := New()
checkListPointers(t, l, []*Node{})
if l.Head() != nil {
t.Errorf("Head of empty list should be nil but was not")
}
if l.Tail() != nil {
t.Errorf("Tail of empty list should be nil but was not")
}
}
func TestLazyInit(t *testing.T) {
... |
package shell
import (
"fmt"
"github.com/hoop33/perm/config"
)
type exit int
func (exit) name() string {
return "exit"
}
func (exit) description() string {
return fmt.Sprintf("exit %s", config.AppName)
}
func (e exit) usage() string {
return e.name()
}
func (exit) run(_ *env, _ []string) error {
return err... |
// Core memory handling package for CANiBUS
package core
import (
"github.com/ghetzel/canibus/api"
"github.com/ghetzel/canibus/logger"
)
type CoreData struct {
CConfig api.Configer
Users []api.User
}
var CData CoreData
func SetConfig(conf api.Configer) {
CData.CConfig = conf
}
func GetConfig() api.Configer ... |
package main
import (
"encoding/json"
"io/ioutil"
"path/filepath"
"github.com/GomuGomuMan/go-cleanup/internal/usecases"
"github.com/spf13/cobra"
)
var (
settingPath string
)
func main() {
// cobra command
rootCmd := &cobra.Command{
Use: "go-cleanup",
Short: "go-cleanup is an utility to clean up files ... |
package example
import (
"database/sql"
"io/ioutil"
"os"
"reflect"
"strings"
"testing"
"time"
"github.com/go-sql-driver/mysql"
"github.com/mackee/go-sqlla/v2"
_ "github.com/mattn/go-sqlite3"
)
var columns = "`id`, `name`, `age`, `rate`, `created_at`, `updated_at`"
func TestSelect(t *testing.T) {
q := New... |
package middlewares
import (
"github.com/astaxie/beego"
)
func Sign(name string, password string, message string)([]byte, error){
url := beego.AppConfig.String("BasecoinUrl")+ "/sign?name="+name+"&password="+password+"&message="+message
return SendRequest(url)
}
func Verify(name string, signature string, message... |
/*
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
nYou 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
d... |
package server
import (
"net/http"
"strings"
)
func enableCors(w *http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.Referer(), "https://guschnwg.github.io") {
(*w).Header().Set("Access-Control-Allow-Origin", "https://guschnwg.github.io")
} else if strings.HasPrefix(r.Referer(), "https://evening-rid... |
package config_test
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/davidsbond/mona/internal/config"
"github.com/stretchr/testify/assert"
)
func deleteLockFile(t *testing.T) {
require.NoError(t, os.Remove("mona.lock"))
}
func TestNewLockFile(t *testing.T) {
tt := []struct {
Name ... |
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"html/template"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ses"
)
// SELECTORS
const BES... |
package main
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"testing/quick"
"unicode/utf16"
//"unicode/utf8"
)
type String string
func (m *String) ReadFrom(r io.Reader) (n int64, err error) {
var length uint16
// Read length of string, 2 bytes
err = binary.Read(r, binary.BigEndian, &length)
if err != nil ... |
package subscriber
import (
"context"
"fmt"
"time"
log "github.com/sirupsen/logrus"
)
type Subscriber interface {
Fetch(context.Context) (*Message, error)
Commit(context.Context, *Message) error
Close() error
}
type handler struct {
subscriber Subscriber
fn func([]byte)
}
func NewHandler(subscribe... |
package web
import (
"github.com/gorilla/mux"
"github.com/domac/ats_check/app"
)
//加载路由
func loadRouter(applicationContext *app.App) (r *mux.Router, err error) {
atsHandler := &ATSHandler{applicationContext: applicationContext}
r = mux.NewRouter()
v1Subrouter := r.PathPrefix("/ats").Subrouter()
ih := NewATSHand... |
package main
import (
"fmt"
"regexp"
)
func main() {
// use regex to identiy how many caps are present. Num words = reg match + 1
var in string
fmt.Scanf("%s", &in)
r := regexp.MustCompile("[A-Z]")
match := r.FindAllString(in, -1)
fmt.Println(len(match) + 1)
}
|
package main
import "testing"
func Test_requiresAccessToken(t *testing.T) {
type args struct {
name string
}
tests := []struct {
name string
args args
want bool
}{
{"Require", args{"summary_intent"}, true},
{"Require2", args{"notifications_intent"}, true},
{"Require3", args{"assigned_issues_intent"}... |
package finder
import (
"bufio"
"fmt"
"log"
"os"
"regexp"
)
func Find(filename string, expression string) string {
var results string
file, err := os.Open(filename)
log.Println("Searching in: ", filename, expression)
if err != nil {
log.Fatal(err)
}
defer file.Close()
lineNumber := 0
scanner := bufio.... |
package database
import (
"blog/config"
"fmt"
"github.com/go-redis/redis/v7"
"os"
"strconv"
"time"
)
var redisClent *redis.Client
func RedisInit() {
client := redis.NewClient(&redis.Options{
Addr: config.Conf.Redis.Host + ":" + strconv.Itoa(config.Conf.Redis.Port),
Password: "",
DB: config.Con... |
package main
import (
"fmt"
r "github.com/dancannon/gorethink"
)
type User struct {
Id string `gorethink:"id,omitempty"`
Name string `gorethink:"name"`
}
func main() {
session, err := r.Connect(r.ConnectOpts {
Address: "localhost:28015",
Database: "rtsupport",
})
if err != nil {
fmt.Println(err)
return... |
package pkg
import (
"k8s.io/client-go/util/workqueue"
"k8s.io/client-go/tools/cache"
"k8s.io/apimachinery/pkg/util/runtime"
"fmt"
"k8s.io/apimachinery/pkg/util/wait"
"time"
core "k8s.io/api/core/v1"
)
type Controller struct {
indexer cache.Indexer
queue workqueue.RateLimitingInterface
informer cache.Contro... |
// Copyright 2019 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.