text stringlengths 11 4.05M |
|---|
package passwordcombiner
import "github.com/cloudfoundry-incubator/cloud-service-broker/internal/encryption/gcmencryptor"
type CombinedPassword struct {
Label string
Secret string
Salt []byte
Encryptor gcmencryptor.GCMEncryptor
configuredPrimary bool
storedPrimary ... |
package sqlutil
type TestDB struct {
DriverName string
ConnStr string
}
var TestDB_Sqlite3 = TestDB{DriverName: "sqlite3", ConnStr: ":memory:"}
var TestDB_Mysql = TestDB{DriverName: "mysql", ConnStr: "logdisplayplatform:password@tcp(localhost:3306)/logdisplayplatform_tests?collation=utf8mb4_unicode_ci"}
var Test... |
package main
import (
"fmt"
"github.com/akamensky/argparse"
"os"
"log"
"github.com/dariusbakunas/govirt-api/models"
"github.com/dariusbakunas/govirt-api/server"
)
func main() {
parser := argparse.NewParser("govirt-api", "Libvirt Rest API")
uri := parser.String("u", "uri", &argparse.Options{Required: true, He... |
/*
* Go Library (C) 2017 Inc.
*
* @project Project Globo / avaliacao.com
* @author @jeffotoni
* @size 01/03/2018
*/
package handler
import (
"github.com/jeffotoni/gmongocrud/lib/context"
"github.com/jeffotoni/gmongocrud/repo"
"log"
"net/http"
)
func Ping(ctx *context.Context) {
pathNewOrg := re... |
// Copyright 2018 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 grains
import (
"errors"
"math"
"sync"
)
const NUMBER_OF_SQUARE = 64
const ZERO = 0
const BASE_TWO = 2.0
func Square(num int) (uint64 ,error) {
if num > NUMBER_OF_SQUARE || num <= ZERO {
return ZERO, errors.New("error")
}
return uint64(math.Pow(BASE_TWO,float64(num-1))), nil
}
func Total() uint64 {
... |
package el
//Handle packet morphing
import (
"math/rand"
"time"
)
type ElMorpher interface {
// return next packet size
NextPackSize() int
// TODO: take interarival time into account
// NextSizeAndInterval() (int, int)
// Close()
}
// randMopher is the most naive mopher
type randMorpher struct {
// channel ... |
package repository
import (
"github.com/GoGroup/Movie-and-events/booking"
"github.com/GoGroup/Movie-and-events/model"
"github.com/jinzhu/gorm"
)
// CommentGormRepo implements menu.CommentRepository interface
type BookingGormRepo struct {
conn *gorm.DB
}
// NewHALLGormRepo returns new object of CommentGormRepo
fu... |
package pathfileops
import "testing"
func TestDirMgr_MoveDirectoryTree_01(t *testing.T) {
baseDir := "../dirmgrtests/TestDirMgr_MoveDirectoryTree_01"
srcDir := baseDir + "/source"
targetDir := baseDir + "/target"
fh := FileHelper{}
err := fh.DeleteDirPathAll(baseDir)
if err != nil {
t.Errorf("Te... |
//go:build demo
package main
func init() {
globals.ReleaseMode = "demo"
}
|
//author xinbing
//time 2018/9/3 16:56
package sms
import (
"common-utilities/http_utils"
"common-utilities/utilities"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"net/url"
"sort"
"strings"
"time"
)
type AliCloudSMSClient struct {
AccessKeyId string //必填
AccessKeySecr... |
package middleware
import (
"context"
"crypto/hmac"
"encoding/hex"
"hash"
"io/ioutil"
"net/http"
"strings"
// this is only used for signature decryption, not for any sensitive content encryption
// nolint: gosec
"crypto/sha1"
"github.com/krostar/logger/logmid"
"github.com/pkg/errors"
)
type ctxEnsureGit... |
// Copyright 2017 The Fuchsia 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 daemon
import (
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"sync"
"time"
)
type BlobRepo struct {
Address string
Inte... |
package dushengchen
/**
Submission:
https://leetcode.com/submissions/detail/371249931/
*/
// https://leetcode.com/submissions/detail/371249931/
//O(n^2)的复杂度
// func insert(intervals [][]int, newInterval []int) [][]int {
// intervals = append(intervals, newInterval)
// return merge(intervals)
// }
//O(n)的复杂度
fu... |
package main
import (
"log"
"net/http"
"os"
"sync"
"time"
"github.com/skriptble/gabble/transport/bosh"
"github.com/skriptble/nine/bind"
"github.com/skriptble/nine/element/stanza"
"github.com/skriptble/nine/namespace"
"github.com/skriptble/nine/sasl"
"github.com/skriptble/nine/stream"
)
var dflt = bosh.Bod... |
package main
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/square/p2/pkg/grpc/podstore/client"
"github.com/square/p2/pkg/logging"
"github.com/square/p2/pkg/manifest"
"github.com/square/p2/pkg/types"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"gopkg.in/alecthomas/kingpin.v2... |
package main
import (
"fmt"
"math"
"math/rand"
"strings"
)
func calcQuality(min, max, equipQuality, continueMatNumb int32, jewelQualityMap map[int32]int32) int32 {
base := make(map[int32]float32)
for i := min; i <= max; i++ {
if i == equipQuality {
base[i] = float32(jewelQualityMap[i]) + float32(continueMa... |
package server
import (
"net"
"strings"
"sync"
"../log"
)
/*
Internal Communication Structure
*/
type CommUnit struct {
ConnMap map[string]net.Conn
RpcCh map[string]chan interface{}
cl sync.Mutex
rl sync.Mutex
}
var Comm *CommUnit
func NewCommUnit() *CommUnit {
comm := &CommUnit{
ConnMap:... |
package spatial
import (
"bytes"
"encoding/binary"
"errors"
)
type GeometryType uint32
type Srid uint32
const (
GEOMETRY_TYPE_GENERIC GeometryType = iota
GEOMETRY_TYPE_POINT
GEOMETRY_TYPE_LINE_STRING
GEOMETRY_TYPE_POLYGON
GEOMETRY_TYPE_MULTI_POINT
GEOMETRY_TYPE_MULTI_LINE_STRING
GEOMETRY_TYPE_MULTI_POLYGON... |
// Package irc contains a Bot implementation that works over the IRC protocol
package irc
|
package main
import (
"bytes"
"compress/zlib"
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
flag "github.com/spf13/pflag"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
const (
userAgent = "Mozilla/3.0 (compatible; Indy Library)"
urlCopywrite = "http://updat... |
package pie
import (
"golang.org/x/exp/constraints"
)
// Min is the minimum value, or zero.
func Min[T constraints.Ordered](ss []T) (min T) {
if len(ss) == 0 {
return
}
min = ss[0]
for _, s := range ss {
if s < min {
min = s
}
}
return
}
|
package counter
import "sync/atomic"
var _ Counter = new(gaugeCounter)
// A value is a thread-safe counter implementation.
type gaugeCounter int64
// NewGauge return a guage counter.
func NewGauge() Counter {
return new(gaugeCounter)
}
// Add method increments the counter by some value and return new value
func (... |
package redisz
// "fmt"
// "testing"
// "github.com/futurez/litego/util"
const (
PostsPerPage = 10
)
//func TestListCommon(t *testing.T) {
// redisPool := NewRedisPool("hash", "192.168.1.141:6379", "", 1)
// curPage := int(util.RandRange(0, 10))
// start := (curPage - 1) * PostsPerPage
// end := curPage*PostsPerP... |
package main
import (
"fmt"
)
func main() {
array := [5]int{10, 20, 30, 40, 50}
for i, v := range array {
fmt.Println(i, v)
}
fmt.Printf("%T", array)
}
|
package catalog
import (
"encoding/json"
"fmt"
"sort"
"github.com/pkg/errors"
"github.com/spf13/afero"
)
// CatalogFileName is the file where coback stores the catalog in json format
const CatalogFileName = "coback.catalog"
type catalogState int
// Checksum is a string type that helps avoiding confusion betwe... |
package downcase
func Downcase(s string) (string, error) {
str := make([]byte, len(s))
for i := 0; i < len(s); i++ {
tmp := s[i]
if tmp > 64 && tmp < 91 {
tmp = s[i] + 32
}
str[i] = tmp
}
return string(str), nil
}
|
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package export
import (
tcontext "github.com/pingcap/tidb/dumpling/context"
"go.uber.org/zap"
)
func filterDatabases(tctx *tcontext.Context, conf *Config, databases []string) []string {
tctx.L().Debug("start to filter databases")
newDatabases := make([]s... |
package task
import (
"bitbucket.org/inehealth/idonia-pacs/configuration"
"bitbucket.org/inehealth/idonia-pacs/model"
"bitbucket.org/inehealth/idonia-pacs/repository"
"bitbucket.org/inehealth/idonia-pacs/service/idonia/idonia-core"
"database/sql"
"encoding/json"
"errors"
"fmt"
"github.com/google/uuid"
"githu... |
// Copyright (c) 2013-2016 by Michael Dvorkin. All Rights Reserved.
// Use of this source code is governed by a MIT-style license that can
// be found in the LICENSE file.
package mop
// Stock stores quote information for the particular stock ticker. The data
// for all the fields except 'Advancing' is fetched using ... |
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func getInput() [][]string {
file, _ := os.Open("input.txt")
defer file.Close()
var lines [][]string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, strings.Split(scanner.Text(), ""))
}
return lines
}
func countTreesOnSlo... |
package service
import (
"go/internal/pkg/model"
"gorm.io/gorm"
)
type Users interface {
Create(m *model.Users, tx *gorm.DB) (*model.Users, error)
FindOneBy(criteria map[string]interface{}) (*model.Users, error)
Count(criteria map[string]interface{}) int
}
//private struct
type userServices struct {
db *gorm.... |
package main
import "testing"
func TestSolve(t *testing.T) {
var cases = []struct {
n int
arr []int
out int64
}{
{4, []int{1, 2, 3}, 4},
{10, []int{2, 5, 3, 6}, 5},
}
for _, c := range cases {
if out := Solve(c.n, c.arr); out != c.out {
t.Errorf("Solve(%v)=%v, expected %v", c.arr, out, c.out)
... |
// return先于defer执行,defer对有名返回值或者指针返回值会产生影响。对无名返回值不会产生影响。
package main
func main() {
println(DeferFunc1(1))
println(DeferFunc2(1))
println(DeferFunc3(1))
println(*DeferFunc4(1))
}
//return 时 t=1; defer对t操作 t+=3; t为有名返回值,所以返回4
func DeferFunc1(i int) (t int) {
t = i
defer func() {
t += 3
}()
return t
}
//retu... |
package seev
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00400104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.004.001.04 Document"`
Message *MeetingInstructionV04 `xml:"MtgInstr"`
}
func (d *Document00400104) AddMessage() *... |
package main
import "fmt"
import "github.com/roessland/gopkg/mathutil"
func Next(n int64) int64 {
factorialSum := int64(0)
for _, digit := range mathutil.ToDigits(n, 10) {
factorialSum += mathutil.Factorial(digit)
}
return factorialSum
}
func ChainLength(n int64) int64 {
terms := make(map[int64]bool)
terms[n... |
package graphicgo
import (
"fmt"
"os"
)
const screenSize = screenWidth * screenHeight * pixWidth
var drawBuff [screenSize]byte
var dev *os.File
var bgColor = BLACK
/**
* @Description: to start the module
* @return error
*/
func GraphInit() error {
file, err := os.OpenFile(devPath, os.O_RDWR, 0664)
if err !=... |
//go:generate enumer -type K8sState -trimprefix K8s
package types
// This package contains the go code for a enumeration that represents the application
// state for the go runner. This code will be scanned and used by the enumer code generator
// to produce utility methods for the enumeration
// K8sState represent... |
// Copyright 2019 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 "strings"
/*
* @lc app=leetcode id=140 lang=golang
*
* [140] Word Break II
*/
// 超时的暴力解法
func wordBreak_TLE(s string, wordDict []string) []string {
hash := make(map[string]interface{})
for _, w := range wordDict {
hash[w] = nil
}
contains := func(s string) bool {
_, ok := hash[s]
re... |
package Problem0347
import "sort"
func topKFrequent(nums []int, k int) []int {
res := make([]int, 0, k)
// 统计每个数字出现的次数
rec := make(map[int]int, len(nums))
for _, n := range nums {
rec[n]++
}
// 对出现次数进行排序
counts := make([]int, 0, len(rec))
for _, c := range rec {
counts = append(counts, c)
}
sort.Ints(co... |
/* _ _
*__ _____ __ ___ ___ __ _| |_ ___
*\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
* \ V V / __/ (_| |\ V /| | (_| | || __/
* \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
*
* Copyright © 2016 - 2019 Weaviate. All rights reserved.
* LICENSE: https://github.com/semi-techno... |
package philifence
import (
"fmt"
)
type Coordinate struct {
lat, lon float64
}
func (c Coordinate) Lon() float64 {
return c.lon
}
func (c Coordinate) Lat() float64 {
return c.lat
}
func (c Coordinate) String() string {
return fmt.Sprintf("[%.5f, %.5f]", c.lat, c.lon)
}
|
package cache
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"testing"
"github.com/docker/go-units"
)
func benchmarkBackendSequentialReadBuf(b *testing.B, c Cacher, size int64) {
key := make([]byte, 32)
rand.Read(key)
// Put non-empty cacheline in
info := make([]byte, size)
rand.Read(info)
... |
package orm
import "database/sql"
var dbConn *sql.DB
var err error
func init() {
dbConn, err = sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/soup?charset=utf8")
if err != nil {
panic(err.Error())
}
}
|
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-17 09:32
# @File : lt_76_Minimum_Window_Substring.go
# @Description :
# @Attention :
*/
package slide_window
import (
"fmt"
"testing"
)
func Test_minWindow(t *testing.T) {
window := minWindow2("ADOBECODEBANC", "ABC")
fmt.Println(window)
}
|
/*
Package web handle requests and send HTML pages for general browsers.
*/
package web
import (
"html/template"
"net/http"
"strconv"
"newton449.com/dao"
)
func init() {
/* NOTE Patterns ending with "/" will be treated as prefix-matching. Others are exact-matching.*/
// registers handlers
http.Han... |
package middleware
import (
"bytes"
"net/http"
"testing"
"github.com/stretchr/testify/require"
"github.com/root-gg/plik/server/common"
)
func TestLog(t *testing.T) {
ctx := newTestingContext(common.NewConfiguration())
log := ctx.GetLogger()
ctx.GetConfig().Debug = true
buffer := &bytes.Buffer{}
log.SetOu... |
package sdk
import (
"testing"
rmTesting "github.com/brigadecore/brigade/sdk/v3/internal/restmachinery/testing" // nolint: lll
"github.com/stretchr/testify/require"
)
func TestNewSystemAuthzClient(t *testing.T) {
client, ok := NewSystemAuthzClient(
rmTesting.TestAPIAddress,
rmTesting.TestAPIToken,
nil,
).... |
/**
Create TYPED and UNTYPED constants. Print the values of the constants.
*/
package main
import "fmt"
const (
typedConstant int = 10
untypedConstant = 20
)
func main() {
fmt.Println("Typed Constant :: ", typedConstant)
fmt.Println("Untyped Constant :: ", untypedConstant)
}
|
package pie
//go:generate pie Strings.*
type Strings []string
|
/*
* @lc app=leetcode.cn id=1122 lang=golang
*
* [1122] 数组的相对排序
*/
// @lc code=start
package main
import "sort"
import "fmt"
func main() {
var a, b []int
// a = []int{2,3,1,3,2,4,6,7,9,2,19}
// b = []int{2,1,4,3,9,6}
a = []int{28,6,22,8,44,17}
b = []int{22,28,8,6}
c := relativeSortArray(a,b)
fmt.Prin... |
package meta_test
import (
"fmt"
"reflect"
"testing"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/messagedb/messagedb/sql"
"github.com/messagedb/messagedb/meta"
)
// Ensure a node can be created.
func TestData_CreateNode(t *testing.T) {
var data meta.Data
if err := data.CreateNode("host0"); err != n... |
package go_ping_sweep
import (
"errors"
"fmt"
"strings"
)
// struct to create the table
type Table struct {
Title string //table title
Header []string // table header
Data [][]string // table row * column
tail int // hold the index for the end data row
}
// function to set the table title
fu... |
package main
import (
"fmt"
)
func main() {
var a [3]int
a[1] = 1
a[2] = 3
fmt.Println(a)
v := a[1]
fmt.Println(v)
} |
/*
* Create a new server. Does not support creation of bare-metal servers (yet).
*/
package cmd
import (
"encoding/hex"
"log"
"time"
"github.com/grrtrr/clcv2"
"github.com/spf13/cobra"
)
// createFlags wraps the flags used by create
var createFlags struct {
srcPass string // when using a source-serv... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package main
import (
"fmt"
)
func main() {
fmt.Println("Sutawee Taenkratok"[0:7])
fmt.Println("Sutawee Taenkratok"[7:18])
}
|
package main
import (
"math/rand"
"time"
"github.com/forestgiant/eff"
"github.com/forestgiant/eff/sdl"
)
const (
windowW = 1024
windowH = 768
pixelSize = 3
)
type sprite struct {
frames [][]eff.Point
frameIndex int
ticks int
frameTickCount int
point eff.Point
}
func (s... |
package handshake
import (
"bytes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Crypto Stream Conn", func() {
var (
stream *bytes.Buffer
csc *cryptoStreamConn
)
BeforeEach(func() {
stream = &bytes.Buffer{}
csc = newCryptoStreamConn(stream)
})
It("buffers writes", fun... |
package jcmd
import (
"github.com/chroblert/jgoutils/jconfig"
"github.com/chroblert/jgoutils/jlog"
"github.com/spf13/cobra"
)
var cfgFile string
var isVerbose bool
var RootCmd = &cobra.Command{
Use:"Z0SecT00ls",
Short: "Zer0ne Sec T00ls",
Long: "A tools that contains some attack tool....developing",
Run:func(... |
package series
import (
"fmt"
)
func All(n int, s string) []string {
var i int
var res []string
fmt.Println(len(res))
for i = 0; i < len(s)-n+1; i = i + 1 {
res = append(res, s[i:i+n])
}
return res
}
func UnsafeFirst(n int, s string) string {
var res string
res = s[0:n]
return res
}
func First(n int,... |
/*
* Copyright (c) 2014-2015, Yawning Angel <yawning at torproject dot org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyr... |
// Copyright © 2017 Aeneas Rekkas <aeneas+oss@aeneas.io>
//
// 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 appl... |
package main
import (
"bufio"
"encoding/base64"
"flag"
"fmt"
"os"
"strings"
"time"
"github.com/valyala/fastjson"
)
var (
from = flag.String("from", "/tmp/lb-log", "")
to = flag.String("to", "/tmp/lb-log-new", "")
clear = flag.Bool("clear", false, "")
testLine = flag.Int("test-line", 1000, ""... |
package develop
import (
"errors"
"net/http"
"testing"
"github.com/cli/cli/v2/context"
"github.com/cli/cli/v2/git"
"github.com/cli/cli/v2/internal/config"
"github.com/cli/cli/v2/internal/ghrepo"
"github.com/cli/cli/v2/internal/run"
"github.com/cli/cli/v2/pkg/httpmock"
"github.com/cli/cli/v2/pkg/iostreams"
... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-14 10:18
# @File : of_Offer_04_二维数组中的查找.go
# @Description :
在一个 n * m 的二维数组中,每一行都按照从左到右递增的顺序排序,
每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
# @Attention :
*/
package offer
func findNumberIn2DArray2(matrix [][]int, target int) bool {
if len(m... |
// 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 (
"log"
"math/rand"
"strings"
"sync"
"time"
"opentsp.org/contrib/collect-netscaler/nitro"
"opentsp.org/internal/tsdb"
... |
package c12_ecb_decription_simple
import (
"bytes"
"errors"
"github.com/vodafon/cryptopals/set1/c7_aes_ecb"
)
type Enc struct {
key []byte
tail []byte
}
type Encryptor interface {
Encrypt([]byte) []byte
}
func NewEnc(key, tail []byte) Enc {
return Enc{
key: key,
tail: tail,
}
}
func (e Enc) Encrypt(... |
package files
import (
"io"
"mime/multipart"
"testing"
)
var text = "Some text! :)"
func getTestMultiFileReader(t *testing.T) *MultiFileReader {
sf := NewMapDirectory(map[string]Node{
"file.txt": NewBytesFile([]byte(text)),
"boop": NewMapDirectory(map[string]Node{
"a.txt": NewBytesFile([]byte("bleep")),
... |
package duck
import "design-patterns-go/strategyPattern/flyingBehavior"
type MallardDuck struct {
name string
}
func NewMallardDuck() MallardDuck {
return MallardDuck{
name: "Mallard Duck",
}
}
func (md MallardDuck) Swim() string {
return "I swim"
}
func (md MallardDuck) Display() string {
return md.name... |
package files
import (
"errors"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"net/url"
"path"
"strings"
)
const (
multipartFormdataType = "multipart/form-data"
multipartMixedType = "multipart/mixed"
applicationDirectory = "application/x-directory"
applicationSymlink = "application/symlink"
applicationF... |
package semt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01600105 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.016.001.05 Document"`
Message *IntraPositionMovementPostingReportV05 `xml:"IntraPosMvmntPstngRpt"`... |
package main
import (
"fmt"
"unsafe"
)
const (
a="abc"
b=len(a)
c=unsafe.Sizeof(a)
)
//interface
type Books struct {
title string
author string
}
type Phone interface {
call()
}
type NokiaPhone struct {
}
func (nokiaPhone NokiaPhone)call(){
fmt.Println("I am Nokia, I can call you!")
}
type IPhone s... |
package proxyMonitor
import (
"github.com/stretchr/testify/assert"
"master/master"
"net/http"
"net/http/httptest"
"testing"
"time"
)
const (
TEST_SLAVE_IP = "10.0.214"
TEST_SLAVE_URL = "http://10.0.214:8686"
TEST_SLAVE_NAME = "yoyo"
)
// TODO: There is a pretty much identical function in slave for SendUR... |
package server
import (
"log"
"net"
"time"
// "github.com/lexkong/log"
"google.golang.org/grpc"
pb "logstream/pkg/proto"
"logstream/pkg/utils"
)
func NewServer(hostPort string, writeFx time.Duration) *Server {
return &Server{
grpcSrv: grpc.NewServer(),
localAddr: hostPort,
writeFx: writeFx,
}
}
... |
package helper
import "testing"
func TestPluralize(t *testing.T) {
t.Log(Plural("addresses"))
}
|
package concur
import (
"fmt"
"time"
"errors"
)
// Runner is an interface describing anything
// that is capable of running Tasks.
type Runner interface {
Run(tasks ...Task) error
}
// Concurrent creates a new ConcurrentRunner
// which is responsible for running Tasks
// concurrently.
func Concurrent() Concurre... |
package Collections
type Dict struct {
Root *MapTrieNode
Words []*MapTrieNode //所有单词的指针列表,方便遍历
TotalFrequency int //总词频
}
func NewDict() *Dict {
NewDict := &Dict{}
NewDict.Root = newMapTrieNode()
return NewDict
}
//树节点 用Hash表存储<Character, Node>
type MapTrieNode struct {
Sons ... |
package pkg
import (
b64 "encoding/base64"
"errors"
"io/ioutil"
"log"
"net/http"
)
type ScheduleClientConfig struct {
User string
Password string
Date string
BaseURL string
}
func RequestXML(config ScheduleClientConfig) ([]byte, error) {
requestURL := config.BaseURL + config.Date + ".xml"
httpCli... |
package main
import (
"github.com/funkygao/gobench/util"
"sync"
"testing"
)
var nop = func() {}
func main() {
b := testing.Benchmark(benchmarkNop)
util.ShowBenchResult("nop", b)
b = testing.Benchmark(benchmarkOnceNop)
util.ShowBenchResult("once.do(nop)", b)
}
func benchmarkNop(b *testing.B) {
for i := 0; i ... |
package api
import (
"context"
"encoding/json"
"errors"
"log"
"net/http"
"strings"
)
type Handler func(w http.ResponseWriter, r *http.Request)
type Response struct {
Res interface{} `json:"response"`
Base Base `json:"base"`
}
type Base struct {
Error string
}
var ErrUnAuthorized = errors.New("unau... |
package tstune
import (
"bufio"
"io"
"os"
)
const exitLabel = "exit"
var exitFn = os.Exit
// ioHandler manages the reading and writing for a Tuner
type ioHandler struct {
p printer // handles output
br *bufio.Reader // handles input
out io.Writer
outErr io.Writer
}
func (h *ioHandler) exit... |
package Services
import (
"fmt"
"github.com/james-vaughn/PersonalWebsite/Models"
"github.com/james-vaughn/PersonalWebsite/Repositories"
)
type PagesService struct {
PagesRepository *Repositories.PagesRepository
}
func NewPagesService(PagesRepository *Repositories.PagesRepository) *PagesService {
return &PagesSe... |
package service
import (
"github.com/jinzhu/gorm"
)
//Group model used for all groups
type Group struct {
gorm.Model
Name string `json:"name";gorm:not null`
Private bool `json:"private"`
}
//GroupMember many2many for groups
type GroupMember struct {
UserID uint `js... |
package Models
type Tarefa struct {
ID int `json:NOT NULL AUTO_INCREMENT`
Text string `json:"text"`
Feito bool `json:"feito"`
Status string `json:"status"`
IDUsuario int `json:NOT NULL AUTO_INCREMENT`
}
func (b *Tarefa) TableName() string {
return "tarefa"
}
|
// Copyright 2021 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 constants
const (
CTX_FIXER_CLIENT = "CTX_FIXER_CLIENT"
CTX_PROJECT = "CTX_PROJECT"
CTX_PROJECTS = "CTX_PROJECTS"
)
|
package main
import "testing"
func TestGreeting( t *testing.T) {
mensagem := "Code.education Rocks!"
retorno := greeting(mensagem)
esperado := "<b>"+mensagem+"</b>"
if retorno == "" {
t.Error("greeting function returned empty string")
}
if retorno != esperado {
... |
package main
const Name string = "aliyundisk-provisioner"
const Version string = "1.1.0"
// GitCommit describes latest commit hash.
// This value is extracted by git command when building.
var GitCommit string
|
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSetupConfigDefaults(t *testing.T) {
config := parseConfig("")
assert.Equal(t, config.SourceDir, "_source", "Is source directory set?")
assert.Equal(t, config.LayoutDir, "_layout", "Is layout directory set?")
assert.Equal(t, config.... |
package blocksutil
import "testing"
func TestBlocksAreDifferent(t *testing.T) {
gen := NewBlockGenerator()
blocks := gen.Blocks(100)
for i, block1 := range blocks {
for j, block2 := range blocks {
if i != j {
if block1.String() == block2.String() {
t.Error("Found duplicate blocks")
}
}
}
... |
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/url"
"os"
"time"
"github.com/gorilla/websocket"
)
// TODO: reconnect functionality
// instead of ending the program in a dead end with error
// Failed to receive pong: write tcp 127.0.0.1:58146->127.0.0.1:8000: write: broken pipe202... |
package models
import (
"github.com/jinzhu/gorm"
)
//研发推广
type Cursor struct {
BaseModel
Name string `json:"name" form:"name"` //名称
Image string `json:"image" form:"image"`
Desc string `json:"desc" form:"desc"`
Alt string `json:"alt" form:"alt"`
Url string `json:"url" form:"url"`
}
func (csor *Cursor) C... |
package httpmanager
import (
"encoding/json"
"net/http"
)
// ListHandler A new worker registers
func (m* Manager) ListHandler(w http.ResponseWriter, r *http.Request) {
ret, err := m.platformManager.ListFunction()
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
jsonRet, err := json... |
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
if len(os.Args) < 3 {
fmt.Println("You should pass [values] and \"unit\".")
os.Exit(1)
}
originalUnit := os.Args[len(os.Args)-1]
originalValues := os.Args[1 : len(os.Args)-1]
var finalUnit string
if originalUnit == "celsius" {
finalUnit = "f... |
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
package middleware
import (
"bytes"
"context"
"crypto/md5"
"fmt"
"io/ioutil"
"net/http"
model "github.com/cloudreve/Cloudreve/v3/models"
"github.com/cloudreve/Cloudreve/v3/pkg/auth"
"github.com/cloudreve/Cloudreve/v3/pkg/cache"
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/onedrive"
"github.com/... |
package post
import (
"errors"
"github.com/gin-gonic/gin"
"time"
postModel "yj-app/app/model/system/post"
userService "yj-app/app/service/system/user"
"yj-app/app/yjgframe/utils/convert"
"yj-app/app/yjgframe/utils/page"
)
//根据主键查询数据
func SelectRecordById(id int64) (*postModel.Entity, error) {
entity := &postM... |
package fbmessenger
import (
"bytes"
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/url"
)
var defaultMessengerEndpoint = &url.URL{
Scheme: "https",
Host: "graph.facebook.com",
Path: "/v2.6/me/messages",
}
// A SenderOption set options on a sender.
type SenderOption func(*Sender) error
// ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.