text stringlengths 11 4.05M |
|---|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package aws
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/kms"
kmsTypes "github.com/aws/aws-sdk-go-v2/service/kms/types"
)
// kmsCreateSymmetricKey cre... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package wire
// Address is 3 lines of address information
type Address struct {
// AddressLineOne
AddressLineOne string `json:"addressLineOne,omitempty"`
// AddressLineTw... |
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/tls"
"encoding/base64"
"encoding/binary"
"encoding/json"
"io/ioutil"
"net/http"
"os"
"os/exec"
"path/filepath"
. "qychat_middleware/config"
"strconv"
"strings"
"time"
"fmt"
"github.com/kataras/go-errors"
"github.com/labstack/echo"
... |
package mr
import "log"
import "net"
import "os"
import "net/rpc"
import "net/http"
import "sync"
import "time"
const (
todo = 0
doing = 1
finished = 2
mapTask = 0
rdcTask = 1
)
type Master struct {
// Your definitions here.
Files []string
MapStates []int
RdcStates []int
MapLock sync.Mutex
NReduce int
Ta... |
package s3filepath
import (
"fmt"
"regexp"
"time"
"github.com/Clever/pathio"
)
var (
// currently assumes no unix file created timestamp
s3Regex = regexp.MustCompile(".*_.*_(.*?)\\.(.*)")
yamlRegex = regexp.MustCompile(".*\\.yml")
)
// S3Bucket is our subset of the s3.Bucket class, useful for testing mostl... |
package protocols
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"log"
"sync/atomic"
"github.com/panjf2000/gnet"
)
// CustomLengthFieldProtocol : custom protocols
// custom protocols header contains Version, ActionType and DataLength fields
// its payload is Data field
type TcpModbusProtocol struct {
Trans... |
package utils
import (
"github.com/lestrrat/go-file-rotatelogs"
"github.com/pkg/errors"
"github.com/rifflock/lfshook"
"github.com/sirupsen/logrus"
"go-admin-starter/utils/config"
"go-admin-starter/utils/file"
"path"
"time"
)
var Log *logrus.Logger
var c = config.New()
func LogSetup() {
Log = logrus.New()
... |
package board
import "fmt"
type MoveType int
const (
HorizWall = 1
VertiWall = 2
Up = 3
Down = 4
Right = 5
Left = 6
Jump = 7
)
type Move struct {
Mt MoveType
Pos *Pos
}
func (m *Move) Copy() *Move {
return &Move{
Mt: m.Mt,
Pos: m.Pos.Copy(),
}
}
func (m *Move) Show() {
... |
package factorlib
import (
"github.com/randall77/factorlib/big"
"github.com/randall77/factorlib/primes"
"math/rand"
)
func init() {
factorizers["trial"] = trial
}
// trial tries dividing by 2,3,5,7,11,... until a factor is found.
func trial(n big.Int, rnd *rand.Rand) []big.Int {
s := &big.Scratch{}
for i := 0;... |
package services
import (
"errors"
"fmt"
"testing"
"github.com/Mangaba-Labs/ape-finance-api/mocks"
"github.com/Mangaba-Labs/ape-finance-api/pkg/domain/user"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"gorm.io/gorm"
)
func TestService(t *testing.T) {
t.Run("get an valid user by e... |
package main
import (
"bufio"
"fmt"
"html/template"
"log"
"net/http"
"os"
)
type Guestbook struct {
SignatureCount int
Signatures []string
}
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
func viewHandler(writer http.ResponseWriter, request *http.Request) {
/*
placeholder := []byte("s... |
package main
/*
* Reacts to sh.keptn.event.evaluation.finished and sh.keptn.event.remediation.finished
*/
import (
"context"
"errors"
"log"
"os"
"strconv"
cloudevents "github.com/cloudevents/sdk-go/v2" // make sure to use v2 cloudevents here
"github.com/kelseyhightower/envconfig"
keptn "github.com/keptn/g... |
package utils
import (
"encoding/json"
"fmt"
"io/ioutil"
"math"
"path"
"regexp"
"github.com/openshift/origin/test/extended/cluster/metrics"
"github.com/openshift-scale/perf-analyzer/pkg/result"
)
// WriteJSON will output all the calculated results to JSON file
func WriteJSON(resultDir string, r result.Result... |
package api
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"reflect"
"github.com/mkocikowski/libkafka/wire"
)
func Read(r io.Reader) (*Response, error) {
var size int32
err := binary.Read(r, binary.BigEndian, &size)
if err != nil {
return nil, fmt.Errorf("error reading response size: %v", err)
}
b := mak... |
// Copyright 2015 Burak Sezer
//
// 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 writ... |
package chat
import (
//"github.com/astaxie/beego"
"net/http"
"strconv"
"tripod/convert"
"tripod/timekit"
"webserver/common"
"webserver/controllers"
"webserver/models/maccount"
)
type UnseenController struct {
controllers.BaseController
}
func (c *UnseenController) Post() {
defer c.Recover()
if err := c.P... |
package httpexpect
import (
"bufio"
"crypto/tls"
"io/ioutil"
"net/http"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/valyala/fasthttp"
)
type mockHandler struct {
t *testing.T
https bool
http10 bool
chunked bool
}
func (c *mockHandler) ServeHTTP(w http.ResponseWriter, re... |
package main
// https://www.codewars.com/kata/directions-reduction/train/go
// DirReduc asdsda
func DirReduc(arr []string) []string {
if len(arr) < 2 {
return arr
}
p := point{x: 0, y: 0}
for i := 0; i < len(arr); i++ {
p.move(arr[i])
}
return p.getDirections()
}
type point struct {
x int
y int
}
func (... |
package notificationqueue
import "testing"
func TestConfig(t *testing.T) {
defer func() {
UnregisterAll()
registerTestFactory()
}()
registerTestFactory()
p := NewPublisher()
c := &Config{
Directives: []*DirectiveConfig{
&DirectiveConfig{
Directive: "testfactory",
DirectiveConfig: nil,
}... |
package ldap
import (
"gopkg.in/ldap.v2"
"log"
)
func LdapConnect() *ldap.Conn {
l, err := ldap.Dial("tcp", "127.0.0.1:389")
if err != nil {
log.Fatal("connect",err)
}
// TODO: add tls
// TODO: replace to conf cred enter
authErr := l.Bind("cn=admin,dc=explabs,dc=ru", "admin")
if authErr != nil {
log.Fata... |
package database
import (
"macaddress_io_grabber/models"
"time"
)
type VMRange struct {
ID uint64 `gorm:"primary_key"`
LeftBorder string `gorm:"column:l_border;type:varchar(100);not null;index:l_border_idx"`
RightBorder string `gorm:"column:r_border;type:varchar(100);not null;index... |
package main
import (
"fmt"
"github.com/deepak-muley/golangexamples/data-structures/linkedlist"
)
func main() {
ll := new(linkedlist.LinkedList)
ll.AddNodeToLinkedList(10)
n := ll.AddNodeToLinkedList(20)
ll.AddNodeToLinkedList(30)
ll.AddNodeToLinkedList(40)
ll.PrintLinkedList()
fmt.Println()
ll.InsertAfte... |
package main
// Define an App struct to hold our application-wide dependencies and config
// settings for our web application.
type App struct {
HTMLDir string
StaticDir string
}
|
package parser
const (
backslash = '\\'
doublequote = '"'
tab = '\t'
space = ' '
semicolon = ';'
leftParenthesis = '('
rightParenthesis = ')'
leftSquareBracket = '['
rightSquareBracket = ']'
leftCurlyBracket = '{'
rightCurlyBracket = '}'
)
|
package types
import (
"fmt"
"math/big"
"os"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
)
const (
TracerAccessList = "access_list"
TracerJSON = "json"
TracerStruct = "st... |
// +build tools
package main
import (
_ "github.com/golang/protobuf/protoc-gen-go"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"
_ "github.com/pressly/goose/cmd/goose"
)
|
/*
Copyright 2020 Docker Compose CLI 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 a... |
package model
type Table struct {
HotelId int64 `json:"-,hotel,omitempty"`
PDVId int64 `json:"-,pdv,omitempty"`
TableId int `json:"id_mesa,omitempty"`
Number int64 `json:"numero,omitempty"`
Status string `json:"situacao,omitempty"`
BirthdayPerson string `json:"aniveri... |
package book
//Exporters declares available exporters
type Exporters string
const (
//EPUB expors as epub
EPUB Exporters = "epub"
//PDF exports as PDF
PDF Exporters = "pdf"
)
|
package gotrain
import "encoding/json"
// A custom type to collect our results
// remember that anything with a capital letter will be exported.
type asciiresult struct {
ASCIINumber int
ASCIICharter string
}
// a parent type to encapsulate the result type and provide a container receiver to our function
type ASC... |
package entities
import (
"log"
"github.com/jinzhu/gorm"
//driver
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
//interface of service
type serv interface {
//create table
load()
}
var (
gormDb *gorm.DB
//service for user,currentuser,meeting and meeting participators
services []serv
)
func addServ(s serv) ... |
package api
import (
"encoding/json"
"fmt"
"github.com/go-chi/chi"
"log"
"net/http"
)
//Measurement object define
type Measurement struct {
Measurement int `json:"measurement"`
}
//NewMeasurement new object
func NewMeasurement()*Measurement{
m:= Measurement{
Measurement: 1,
}
return &m
}
//F... |
package nregexp_test
import (
"reflect"
"regexp"
"testing"
"github.com/mdouchement/nregexp"
)
const pattern = `.*\s.*\s(?P<my_capture>[^\s]*)\s.*`
func TestNamedCapture(t *testing.T) {
re := regexp.MustCompile(pattern)
matches := re.FindSubmatch([]byte("Example of nregexp package"))
actual := nregexp.NamedC... |
package options // import "yunion.io/x/onecloud/pkg/cloudid/options"
|
package main
import "encoding/json"
import "net/http"
import "fmt"
import "strconv"
func validateProfileParams(r *http.Request) (*ProfileParams, error) {
params := &ProfileParams{}
var err error
Login = r.FormValue("login")
if Login == "" {
return nil, fmt.Errorf("login must me not empty")
}
return params,... |
package rod_test
import (
"testing"
"time"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/cdp"
"github.com/go-rod/rod/lib/proto"
"github.com/go-rod/rod/lib/utils"
"github.com/ysmood/gson"
)
func TestPageEvalOnNewDocument(t *testing.T) {
g := setup(t)
p := g.newPage()
p.MustEvalOnNewDocument(`window.r... |
package backtracking
import (
"github.com/NBR41/gosudoku/model"
)
//NewGrid returns new instance of grid
func NewGrid(n int) (*model.Grid, error) {
g, err := model.NewGrid(n, newNode)
if err != nil {
return nil, err
}
for k := range g.Values {
g.Values[k].(*node).setNodes(g.Values, g.GetMax(), g.GetBlockWid... |
// generated by jsonenums -type=TestAllCaps -all_caps=true -snake_case_json=true; DO NOT EDIT
package main
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
var (
_TestAllCapsNameToValue = map[string]TestAllCaps{
"SOME_CAMEL": someCamel,
"SOME_SNAKE": some_snake,
"SO_M_MA_DN_ESS": SoMMaDnEss,
... |
// 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 firmware
import (
"context"
"strconv"
"chromiumos/tast/remote/firmware/fixture"
"chromiumos/tast/testing"
"chromiumos/tast/testing/hwdep"
)
func init() {
tes... |
package main
import . "./make_dbus"
func main() {
DBusInstall(
"setup_launcher_dbus_service",
SessionDBUS("com.deepin.dde.launcher"),
Method("Show", Callback("launcher_show")),
Method("Hide", Callback("launcher_hide")),
Method("Toggle", Callback("launcher_toggle")),
Method("Exit", Callback("launcher_quit... |
/*
author:admin
createTime: 2022-06-16
*/
package main
import "fmt"
// InsertionSort insert the special value,
// and then compare with the next value from the array.
func InsertionSort(arr []int) []int {
if len(arr) <= 1 {
return arr
}
var temp int
for i := 1; i < len(arr); i++ {
temp = arr[i]
j := i - 1
... |
package handlers
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
"strings"
"time"
"github.com/FotiadisM/homebnb/server/modules"
)
// BookingHandler is a http Handle r
type BookingHandler struct {
l *log.Logger
}
// NewBookingHandler creates a new UserHandler
func NewBookingHandler(l *log.Logger) ... |
package schema
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"github.com/pkg/errors"
)
type validatorer interface {
Validate(interface{}) error
}
type Error struct {
Code string `json:"code,omitempty"`
Detail string `json:"detail,omitempty"`
Errors []struct {
Code string `json:"code,omi... |
package main
import (
"log"
"os"
"path/filepath"
"strconv"
"gin-msgboard/config"
"gin-msgboard/controller"
"gin-msgboard/storage"
"github.com/gin-gonic/gin"
)
const (
ErrnoOk int = iota
ErrorLoadTemplates
)
func init() {
config.LoadConfig("./conf/config.json")
}
func main() {
log.Println("start running... |
package zookeeper
import (
"fmt"
"time"
"github.com/samuel/go-zookeeper/zk"
)
func ZkChildWatchApp() {
fmt.Printf("ZkChildWatchTest")
var hosts = []string{"localhost:2181"}
conn, _, err := zk.Connect(hosts, time.Second*5)
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
// try create root... |
// Copyright 2022 YuWenYu All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package languages
import (
U "github.com/yuw-pot/pot/modules/utils"
"golang.org/x/text/language"
)
var (
EN = language.English.String()
CN = language.English.Str... |
// 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 policy
import (
"context"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/pci"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/policy/... |
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
fmt.Println(now)
that := time.Date(
2020,12,24,
00,00,00,00,
time.Local)
fmt.Println(that)
fmt.Println(that.Weekday())
fmt.Println(that.Before(now))
fmt.Println(that.Equal(now))
diff := now.Sub(that)
fmt.Println(diff)
fmt.Println(... |
package chroma
import (
"math"
"testing"
assert "github.com/alecthomas/assert/v2"
)
func TestColourRGB(t *testing.T) {
colour := ParseColour("#8913af")
assert.Equal(t, uint8(0x89), colour.Red())
assert.Equal(t, uint8(0x13), colour.Green())
assert.Equal(t, uint8(0xaf), colour.Blue())
}
func TestColourString(t... |
// 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, ... |
package sejutil
import (
"io"
"os"
"time"
"h12.io/sej"
)
func NewScannerFrom(journalDir string, from time.Time) (*sej.Scanner, error) {
dir, err := sej.OpenJournalDir(sej.JournalDirPath(journalDir))
if err != nil {
return nil, err
}
startOffset := dir.First().FirstOffset
for _, file := range dir.Files {
... |
package config
import (
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
func init() {
Service = &ServiceYml{}
data, _ := ioutil.ReadFile("service.yml")
err := yaml.Unmarshal(data, Service)
if err != nil {
log.Fatal(err)
}
}
|
package repository
import (
"database/sql"
"github.com/stretchr/testify/assert"
"log"
"testing"
"github.com/DATA-DOG/go-sqlmock"
)
func NewMock() (*sql.DB, sqlmock.Sqlmock) {
db, mock, err := sqlmock.New()
if err != nil {
log.Fatalf("an error '%s' was not expected when opening a stub database connection", e... |
package controllers
import (
"bytes"
"fmt"
"strings"
"sync"
"time"
"github.com/1046102779/common/consts"
"github.com/1046102779/common/types"
"github.com/1046102779/official_account/conf"
. "github.com/1046102779/official_account/logger"
"github.com/1046102779/official_account/models"
"github.com/astaxie/b... |
package gopaxos
import (
"bytes"
"math"
"time"
)
type commitCtx struct {
conf *config
instanceID uint64
commitRet int32
isCommitEnd bool
timeoutMs int
value []byte
smCtx *SMCtx
slock *serialLock
}
func newCommitCtx(conf *config) *commitCtx {
ret := &commitCtx{}
ret.conf = c... |
package parsefb
import (
"github.com/PuerkitoBio/goquery"
)
type object interface {
Find(string) *goquery.Selection
}
func QuerySelector(s object, selector string) *goquery.Selection {
return s.Find(selector).First()
}
|
package main
import (
"fmt"
s "strings"
)
func main() {
var p = fmt.Println
p("Contains:",s.Contains("abc","bc"))
p("Count",s.Count("abcabcabca","ab"))
p("HasPrefix",s.HasPrefix("foobar","foo"))
p("HasSuffix",s.HasSuffix("foobar","bar"))
p("Index",s.Index("asrsgas","s"))
p("Join",s.Join([]string{"a","b"},"-"... |
package spec
import (
"encoding/json"
"errors"
"fmt"
"regexp"
"github.com/biensupernice/krane/internal/storage"
"github.com/biensupernice/krane/internal/utils"
)
var (
Collection = "specs"
)
type Spec struct {
Name string `json:"name" binding:"required"`
Config Config `json:"config" binding:"requir... |
// 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 Fibonacci_Number
func fib(N int) int {
if N < 2 {
return N
}
p, q, i := 0, 1, 1
for i < N {
q, p = q+p, q
i++
}
return q
}
|
package runtime
import (
"fmt"
"reflect"
"github.com/healthy-tiger/scalc/parser"
)
// Function func関数で定義されたユーザー定義関数を表す。
type Function struct {
params []parser.SymbolID // ユーザー定義関数の引数リスト
body *parser.List ... |
package sequencing
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func similarity(a byte, b byte) int {
if a == b {
return 1
}
return -1
}
func similarityStrings(a string, b string) int {
if a == b {
return 1
}
return -1
}
const maxSize = 5000
func TestNeedlemanWunsch(t *testing.T) {
... |
package elastic
import (
"testing"
"net/url"
)
func TestCanonicalize(t *testing.T) {
tests := []struct {
Input []string
Output []string
}{
// #0
{
Input: []string{"http://58.222.20.252/"},
Output: []string{"http://58.222.20.252"},
},
// #1
{
Input: []string{"http://58.222.20.252:9200/", ... |
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT License was not distributed with this
// file, you can obtain one at https://opensource.org/licenses/MIT.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
package main
import (
"fmt"
"os"
"time"
"github.com/urfave/... |
package main
import (
"github.com/gin-gonic/gin"
"github.com/joeig/dyndns-pdns/internal/auth"
"github.com/joeig/dyndns-pdns/internal/ginresponse"
"github.com/joeig/dyndns-pdns/internal/yamlconfig"
"github.com/joeig/dyndns-pdns/pkg/ingest"
"github.com/joeig/dyndns-pdns/pkg/ingest/getparameter"
"github.com/joeig/... |
package models
import (
"errors"
"strings"
"gorm.io/gorm"
)
type Venue struct {
gorm.Model
Name string `gorm:"size:100;not null;unique" json:"name"`
Description string `gorm:"not null" json:"description"`
Location string `gorm:"size:100;not null" json:"location"`
Capacity int `gorm:"not null"... |
// Copyright 2018 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
// Inspired by: https://github.com/kylegrantlucas/jsonlines/blob/master/jsonlines.go
package sandbox
import (
"bufio"
"encoding/json"
"fmt"
"io"
"reflec... |
package jumpingontheclouds
// https://www.hackerrank.com/challenges/jumping-on-the-clouds
// JumpingOnClouds - implements the solution to the problem
func JumpingOnClouds(c []int32) int32 {
n := int32(len(c))
count := int32(0)
for i := int32(0); i < n-1; {
if i+2 > n-1 {
count++
break
}
count += 1 + c[... |
package main
import(
"github.com/pmlpml/golang-learning/web/cloudgo-data/entities"
)
func main(){
entities.IntegratedTest()
} |
package handler
import (
"encoding/json"
"github.com/go-squads/comet-backend/domain"
"github.com/go-squads/comet-backend/repository"
"log"
"net/http"
)
func InsertNewApplication(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
header := r.Header.Get("Authorization")
var newAppRequ... |
package cmd
import (
"encoding/json"
"fmt"
"net"
"os"
"strings"
"github.com/evcc-io/evcc/detect"
"github.com/evcc-io/evcc/detect/tasks"
"github.com/evcc-io/evcc/util"
"github.com/korylprince/ipnetgen"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// detectCmd rep... |
// Copyright 2016 Amazon.com, Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// Unless required by appl... |
package core
import (
"testing"
"time"
"github.com/josetom/go-chain/common"
"github.com/josetom/go-chain/test_helper"
)
func TestBlockHash(t *testing.T) {
test_helper.SetTestDataDirs()
txn := getTestTxn()
block := NewBlock(
common.Hash{},
0,
uint64(time.Time{}.UnixNano()),
0,
common.Address{},
MIN... |
package flag
import (
"github.com/LavGo/lavp/model"
"flag"
)
func Parse()*model.InputFlag{
fm:=&model.InputFlag{}
flag.StringVar(&fm.FilePath,"f","./data.txt","The request data")
var methodStr string
flag.StringVar(&methodStr,"m","GET","Method of http protocol")
flag.IntVar(&fm.ParallelAmount,"p",10,"The Amoun... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"time"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/calendar/v3"
)
// Retrieve a token, saves t... |
package upgrade
import (
"github.com/sirupsen/logrus"
harvesterv1 "github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1"
)
// settingHandler do version syncs on server-version setting changes
type settingHandler struct {
versionSyncer *versionSyncer
}
func (h *settingHandler) OnChanged(key string, set... |
/* {{{ Copyright (c) 2017, Paul R. Tagliamonte <paultag@gmail.com>
*
* 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... |
package kvstore
import (
"encoding/binary"
"errors"
"sync"
)
// Sequence represents a simple integer sequence backed by a KVStore.
// A Sequence can be used to get a list of monotonically increasing integers.
type Sequence struct {
sync.Mutex
store KVStore
key []byte
interval uint64 // the interval in ... |
// Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
// Copyright (c) 2017 Yawning Angel <yawning at schwanenlied dot me>
//
// 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 restr... |
package main
func main() {
if true
print("main")
}
|
// 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 jt
import (
"./json"
jzon "encoding/json"
"fmt"
"github.com/HouzuoGuo/tiedot/db"
"log"
)
type Channel struct {
ID uint64
Name string
Title string
Topic string
Image string
Members map[string]*Connection
PM bool
}
func NewChannel(name, title, topic, image string, pm bool) *Chann... |
package testing
import (
"bytes"
"encoding/hex"
"fmt"
"regexp"
"strings"
"github.com/sardap/gos/cpu"
)
type operation struct {
re *regexp.Regexp
opcode byte
}
var (
operations []operation
)
func init() {
operations = make([]operation, 0)
for k, v := range cpu.GetOpcodes() {
... |
package dynamic_programming
import "testing"
//剪绳子
func cuttingRope(n int) int {
dp := make([]int, n+1)
dp[0] = 0
dp[1] = 1
max := func(a, b int) int {
if a > b {
return a
}
return b
}
for i := 2; i <= n; i++ {
currentMax := 0
for j := 1; j < i; j++ {
//i-j 继续拆分
currentMax = max(currentMax, m... |
package accounts
import (
"context"
"github.com/CMedrado/DesafioStone/pkg/domain/entities"
)
func (a *Storage) ReturnAccounts() ([]entities.Account, error) {
statement := `SELECT * FROM accounts`
rows, err := a.pool.Query(context.Background(), statement)
if err != nil {
return []entities.Account{}, err
}
def... |
package removeduplicates
import "golangexercises/linkedlists"
func removeDupsWithHashing(l *linkedlists.List) {
if l == nil || l.Head == nil {
return
}
hashtable := make(map[interface{}]int)
for node := l.Head; node != nil; node = node.Next {
if _, ok := hashtable[node.Value]; ok {
l.Remove(node)
} els... |
package env
import (
"fmt"
"os"
plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
)
// EnvironmentProvider provides data values from the process environment.
type EnvironmentProvider struct {
Name string
}
// ProviderFactory constructs a EnvironmentProvider.
// No configuration or credentials... |
package mvs_api
import (
"bytes"
"encoding/json"
"errors"
"net/http"
"strconv"
"strings"
"sync"
"time"
)
type RPCClient struct {
sync.RWMutex
Url string
sick bool
sickRate int
successRate int
client *http.Client
}
func MustParseDuration(s string) time.Duration {
value, err := ti... |
package gorsy_cache
import (
"container/list"
"time"
)
func init() {
cacheCollected[LRU] = func() interface{} {
return &lruCache{}
}
}
const (
LRU = "lru"
)
type lruCache struct {
baseCache
items map[interface{}]*list.Element
list *list.List
}
func (c *lruCache) getBaseCache() *baseCache {
return &c.ba... |
package service
import (
// "fmt"
"log"
// "errors"
"math/rand"
"time"
)
// CmdA ...
type CmdA struct {
Params string
}
//CmdB ...
type CmdB struct {
Params string
}
// CmdC ...
type CmdC struct {
Params string
}
const (
CMDA = "CMDA"
CMDB = "CMDB"
CMD... |
package configuration
import(
"github.com/cohesity/management-sdk-go/apihelper"
"github.com/cohesity/management-sdk-go/models"
)
/* Setting up enums for Environments and Servers
*/
type Environments int
type Servers int
// Environment Enums
const (
PRODUCTION Environments = 1 + iota
)
// Se... |
/*
Copyright 2018 The Doctl Authors 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 ... |
package main
import (
"fmt"
"flag"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"log"
"net"
"time"
pb "github.com/bioothod/grpc_test/grtest"
)
type server struct {
}
func (ts *server) PingRequest(ctx context.Context, req *pb.Ping) (*pb.Pong, error) {
reply := &pb... |
package nettests
// NDT test implementation. We use v7 of NDT since 2020-03-12.
type NDT struct {
}
// Run starts the test
func (n NDT) Run(ctl *Controller) error {
// Since 2020-03-18 probe-engine exports v7 as "ndt".
builder, err := ctl.Session.NewExperimentBuilder("ndt")
if err != nil {
return err
}
return ... |
// 正确的单词需要满足一下3点:
// 1. 全大写(单词转换成大写后与原单词相等)
// 2. 全小写(单词转换成小写后与原单词相等)
// 3. 首字母大写其余全小写(除首字母外其余字母转换成小写后与原单词的除首字母外字母相等)
package detectcapitaluse
import "strings"
func detectCapitalUse(word string) bool {
if len(word) == 0 {
return false
}
return strings.ToUpper(word) == word ||
strings.ToLower(word) == word ||
... |
package main
import (
"fmt"
wasm "github.com/CosmWasm/go-cosmwasm"
"io/ioutil"
"os"
)
// This is just a demo to ensure we can compile a static go binary
func main() {
file := os.Args[1]
fmt.Printf("Running %s...\n", file)
bz, err := ioutil.ReadFile(file)
if err != nil {
panic(err)
}
fmt.Println("Loaded!")... |
package main
import (
"github.com/michaelrk02/sysipc-go"
"os"
"os/signal"
)
var s *sysipc.Server
var sigCh chan os.Signal
func main() {
s = sysipc.NewServer(sysipc.LocalRouter, "arith", os.Stdout)
s.Handle("add", addHandler)
s.Handle("sub", subHandler)
s.Handle("mul", mulHandler)
s.Ha... |
package matchers_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/rgalanakis/golangal"
"github.com/rgalanakis/golangal/matchers"
"net/http/httptest"
)
var _ = Describe("HaveHeaderMatcher", func() {
var success bool
var err error
It("can match positives", func() {
resp := ... |
package api
type Response struct {
Body string
Code int
Error error
}
|
package main
import (
"testing"
)
func sliceContains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
func TestTheNumberOfFilesOfProject(t *testing.T) {
if FilesAvailable() != 5 {
t.Errorf("Number of files is %v", FilesAvailable())
}
}
func TestListFilesIn... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.