text stringlengths 11 4.05M |
|---|
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// GetReportExecutionReader is a Reader for the GetReportExecution struct... |
package siprocket
import (
"bytes"
"fmt"
"strings"
)
var sip_type = 0
var keep_src = true
type SipMsg struct {
Req sipReq
From sipFrom
To sipTo
Contact sipContact
Via []sipVia
Cseq sipCseq
Ua sipVal
Exp sipVal
MaxFwd sipVal
CallId sipVal
ContType sipVal
ContLen ... |
package taxes
import (
"fmt"
"github.com/julienschmidt/httprouter"
"github.com/mpdroog/invoiced/config"
"github.com/mpdroog/invoiced/db"
"github.com/mpdroog/invoiced/hour"
"github.com/mpdroog/invoiced/invoice"
"github.com/mpdroog/invoiced/writer"
"github.com/shopspring/decimal"
"github.com/xuri/excelize/v2"
... |
package main
import (
"testing"
)
// Test configuration loading and parsing
// using the default config
func TestLoadConfigs(t *testing.T) {
config, err := loadConfig("../etc/alicelg/alice.conf")
if err != nil {
t.Error("Could not load test config:", err)
}
if config.Server.Listen == "" {
t.Error("Listen ... |
package history
import (
"context"
"errors"
"fmt"
"io"
"math/rand"
"reflect"
"sync"
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"github.com/jinzhu/copier"
)
const (
pluginName = "gorm-history"
createCbName = pluginName + ... |
package pod_mutator
import (
"testing"
"github.com/Dynatrace/dynatrace-operator/src/kubeobjects/address"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
)
func TestCreateInstallInitContainerBase(t *testing.T) {
t.Run("should create the init container with ... |
package main
import (
"errors"
"fmt"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/node/bindnode"
)
const (
UndefTime = Time(0)
)
type Status int64
type Time int64
type PopTask struct {
Status Status
WorkedBy string
Tag []string
}
type RetrievalTask struct {
Miner string
... |
// +build !linux
package kernel
import (
"github.com/lavaorg/telex"
"github.com/lavaorg/telex/plugins/inputs"
)
type Kernel struct {
}
func (k *Kernel) Description() string {
return "Get kernel statistics from /proc/stat"
}
func (k *Kernel) SampleConfig() string { return "" }
func (k *Kernel) Gather(acc telex.... |
package cmd
import(
"rediproxy/cmd/strings"
)
type Cmd struct{
strings.Strings
}
|
package bd
import (
"github.com/Estiven9644/twittor-backend/models"
"golang.org/x/crypto/bcrypt"
)
func IntentoLogin(email, password string) (models.Usuario, bool) {
usu, encontrado, _ := ChequeoYaExisteUsuario(email)
if !encontrado { // si esto es igual a false entonces returne así
return usu, false
}
passw... |
package cmd
import (
"errors"
"github.com/geospace/sac"
"github.com/spf13/cobra"
)
func createReplacesCmd(sacJSON *sac.Sac) *cobra.Command {
cmd := &cobra.Command{
Use: "replaces",
Short: "Indicate which module you want to replace",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < ... |
package main
import (
"fmt"
)
func main(){
s:="hello"
//将字符串转换为 []byte 类型
c:=[]byte(s)
c[0]='c'
fmt.Println(c) // [104 101 108 108 111]
// 再转换回string 类型
s2:=string(c)
fmt.Printf("%s\n",s2) // cello
} |
// 公众号服务列表
// 1. 获取已托管的公众号列表
// 2. 获取公众号基本信息
package controllers
import (
"github.com/1046102779/common/utils"
. "github.com/1046102779/official_account/logger"
"github.com/1046102779/official_account/models"
"github.com/astaxie/beego"
"github.com/pkg/errors"
)
// OfficialAccountsController oprations for Officia... |
package router
import (
"fmt"
"github.com/futurehomeno/fimpgo"
"github.com/futurehomeno/fimpgo/edgeapp"
log "github.com/sirupsen/logrus"
"github.com/thingsplex/thingsplex_service_template/model"
"path/filepath"
"strings"
)
type FromFimpRouter struct {
inboundMsgCh fimpgo.MessageCh
mqt *fimpgo.MqttTr... |
package utils
import (
"fmt"
"log"
"os"
"os/exec"
)
func Check(e error) {
if e != nil {
panic(e)
}
}
func CheckFileLsExist(filename string) bool {
var exist = true
if _, err := os.Stat(filename); os.IsNotExist(err) {
exist = false
}
return exist
}
func ExecCommand(commands string) string {
out, err :... |
package template
import (
"bufio"
"bytes"
"io/ioutil"
"os"
"os/exec"
txttmpl "text/template"
"github.com/n0rad/go-erlog/data"
"github.com/n0rad/go-erlog/errs"
"github.com/n0rad/go-erlog/logs"
"gopkg.in/yaml.v2"
)
type TemplateFile struct {
Uid int `yaml:"uid"`
Gid int `yaml:"gid"`
CheckC... |
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"github.com/G-Research/armada/internal/armada/repository"
"github.com/G-Research/armada/internal/armada/scheduling"
"github.com/G-Research/armada/internal/common"
)
const MetricPrefix = "armada_"
func Exp... |
package channel
import (
"fmt"
"sync"
"testing"
"time"
)
func TestGorCounter(t *testing.T) {
var mut sync.Mutex
counter := 0
for i := 0; i < 5000; i++ {
go func() {
//defer mut.Unlock() // 1
defer func() { // 2
mut.Unlock()
}()
mut.Lock()... |
package kiteroot
// Stack implements the stack container
type Stack []*Element
// Push adds the given element to the stack.
func (s *Stack) Push(e *Element) {
*s = append(*s, e)
}
// Top returns the last element in the stack if it is not empty.
// Otherwise, nil is returned.
func (s *Stack) Top() (e *Element) {
if... |
package taskqueueworker
import (
"context"
"fmt"
"log"
"reflect"
"sync"
"time"
"pkg.agungdwiprasetyo.com/candi/codebase/factory"
"pkg.agungdwiprasetyo.com/candi/codebase/factory/types"
"pkg.agungdwiprasetyo.com/candi/config/env"
"pkg.agungdwiprasetyo.com/candi/logger"
)
var (
registeredTask map[string]str... |
package mention
import (
"bytes"
"context"
"crypto/md5"
"fmt"
"image"
_ "image/gif"
_ "image/jpeg"
"image/png"
_ "image/png"
"io"
"io/ioutil"
"net/http"
"net/url"
"sort"
"strings"
"time"
"cloud.google.com/go/datastore"
"google.golang.org/api/iterator"
"willnorris.com/go/microformats"
"willnorris.c... |
package postgres
const QueryMarkerSQL string = "/* pganalyze-collector */ "
|
// 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 lacros
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
"time"
"google.golang.org/grpc"
lacroscommon "chromi... |
package ravendb
import (
"net/http"
"reflect"
)
var (
_ IOperation = &PatchOperation{}
)
// PatchOperationPayload represents payload of patch operation
// Note: in Java it's Payload nested in PatchOperation
type PatchOperationPayload struct {
patch *PatchRequest
patchIfMissing *PatchRequest
}
// Patch... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
package sync2_test
import (
"context"
"errors"
"sync/atomic"
"testing"
"time"
"golang.org/x/sync/errgroup"
"storj.io/common/sync2"
"storj.io/common/testcontext"
)
func TestFence(t *testing.T) {
t.Parallel()
ctx := testcontext.... |
package router
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/sudarshan-reddy/benjerry/httputils"
)
type fakeAuthHandler struct {
AuthHandler
err *httputils.HandlerError
}
func (f *fakeAuthHandler) Authenticate(r *http.Request) (*http.Request, *httputils.Ha... |
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
// 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 util
import (
"context"
"fmt"
"time"
"chromiumos/tast/common/hwsec"
"chromiumos/tast/common/pkcs11"
"chromiumos/tast/common/servo"
"chromiumos/tast/errors"
... |
package main
import (
"fmt"
"io"
"os"
)
func read() {
file, err := os.Open("./test.txt")
defer file.Close()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(file)
var tmpSlice = make([]byte, 128)
var strSlice []byte
for {
n, err := file.Read(tmpSlice)
if err == io.EOF {
break
}
if err !... |
// Copyright 2020 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, ... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
package datasource
import (
"fmt"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
_ "github.com/go-sql-driver/mysql"
"gopkg.in/yaml.v2"
"gotest/common"
"io/ioutil"
"path/filepath"
)
func Instance() (*xorm.Engine,error){
var c DBconfigs
c,err := xdb_config("./configs/databases.yml")
if(err !=nil){
com... |
package constant
type ItemJson struct {
Cid string
Pid int
Cname string
Pname string
Price float32
Energy int
Img string
Flag string
Tag string
Note string
}
type ProductJson struct {
classification string
tid int
items ItemJson
}
type ResJson struct {
Header struct {
Code int `json:"code"`
Msg ... |
package problem0054
func spiralOrder(matrix [][]int) []int {
r := len(matrix)
if r == 0 {
return []int{}
}
c := len(matrix[0])
if c == 0 {
return []int{}
}
if len(matrix) == 1 {
return matrix[0]
}
res := make([]int, 0, r*c)
res = append(res, matrix[0]...)
for i := 1; i < r-1; i++ {
res = appe... |
/*
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... |
package store
import "context"
type Reducer func(ctx context.Context, engineState *EngineState, action Action)
var EmptyReducer = Reducer(func(ctx context.Context, s *EngineState, action Action) {})
|
package proxycommands
import (
"github.com/spf13/cobra"
)
// NewProxyCommands creates a new cobra command
func NewProxyCommands() *cobra.Command {
reverseCommandsCmd := &cobra.Command{
Use: "proxy-commands",
Short: "Execute Commands on a remote environment",
Args: cobra.NoArgs,
}
reverseCommandsCmd.AddC... |
package leetcode_go
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
stack1 := toStackP445(l1)
stack2 := toStackP445(l2)
carry := 0
var preNode *ListNode
head := ListNode{}
for i, j := len(stack1)-1, len(stack2)-1; i > 0 || j > 0 || carry > 0; {
var val int
if i > 0 && j > 0 {
val = stack1[i] + ... |
package main
import (
"fmt"
"io"
"os"
)
func solve(r io.Reader, w io.Writer) {
var t int
fmt.Fscan(r, &t)
for i := 0; i < t; i++ {
var a, b int
fmt.Fscan(r, &a, &b)
if i > 0 {
fmt.Fprint(w, "\n")
}
fmt.Fprint(w, a+b)
}
}
func main() {
solve(os.Stdin, os.Stdout)
}
|
package operatingsystem
import (
"bytes"
"fmt"
"os/exec"
"strings"
)
func GetOperatingSystem() (string, error) {
sw_vers, err := exec.LookPath("sw_vers")
if err != nil {
return "", fmt.Errorf("Can not find sw_vers")
}
cmd := exec.Command(sw_vers)
stdbuf := new(bytes.Buffer)
cmd.Stdout = stdbuf
if err := ... |
// Copyright 2019 Yunion
//
// 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 writi... |
package helpers
import (
"github.com/LiveSocket/bot/conv"
"github.com/LiveSocket/bot/service"
"github.com/gammazero/nexus/v3/wamp"
)
// CustomCommand The important parts of a custom command
type CustomCommand struct {
Channel string `json:"channel"`
Name string `json:"name"`
Proc string `json:... |
// Copyright 2017-2018 Authors of Cilium
//
// 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 ag... |
package main
import "regexp"
import "fmt"
import "strings"
const swear = "I absolutely fucking hate you, kill yourself you little shit"
const fword_regex = `(?i)(f+u+(k+|c+k+))|f *u |f *u[^a-z\.]`
const sword_regex = `(?i)(s+h+(t+|i+t+))|s *h *i *t`
func main() {
new1 := deleteFword(swear, "f***")
new2 := deleteSw... |
package pushover
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"github.com/TwiN/gatus/v5/alerting/alert"
"github.com/TwiN/gatus/v5/client"
"github.com/TwiN/gatus/v5/core"
)
const (
restAPIURL = "https://api.pushover.net/1/messages.json"
defaultPriority = 0
)
// AlertProvider is the configura... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
"github.com/atomicjolt/string_utils"
)
// ListActiveCoursesInAccount Retrieve a paginated l... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package announce_test
import (
"fmt"
"testing"
"time"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/bitm... |
package main
import (
"fmt"
"time"
)
func selectdriver() {
c := counts("rose")
for i := 0; i < 20; i++ {
select {
case r := <-c:
fmt.Println(r)
case <-time.After(time.Second):
fmt.Println("too slow")
}
}
}
func mainTimerDriver() {
c := counts("rose")
tc := time.After(time.Second * 5)
for {
... |
package client
import (
fmt "fmt"
"lemna/arpc"
"sync"
)
//manager 仅供client.Service使用
type manager struct {
clients map[uint32]*Target
mu sync.Mutex
}
func newMananger() *manager {
return &manager{clients: make(map[uint32]*Target)}
}
func (cm *manager) newTarget(s arpc.CAgent_ForwardServer, id uint32) (*T... |
// 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 perf
import (
"context"
"time"
"github.com/shirou/gopsutil/v3/mem"
"chromiumos/tast/common/perf"
)
// diffWait is the default duration to measure the baseline... |
package main
import (
"errors"
"fmt"
"time"
"golang.org/x/net/context"
"golang.org/x/sync/errgroup"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
g, errCtx := errgroup.WithContext(ctx)
for i := 0; i < 10; i++ {
// goroutine闭包使用的变量全用copy出来的新值,
//因为创建go需要时间,在go未被创建时for循环就跑完了
//... |
// Copyright 2020 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 Yunion
//
// 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 writi... |
package xmppcore
import (
"encoding/xml"
)
// RFC 6120 6 SASL Negotiation
const SASLNS = "urn:ietf:params:xml:ns:xmpp-sasl"
const (
SASLAuthElementName = SASLNS + " auth"
SASLSuccessElementName = SASLNS + " success"
SASLFailureElementName = SASLNS + " failure"
)
// RFC 6120 6.4.1
type SASLMechanisms stru... |
package main
import _ "fmt"
import "videocrawler/crawler"
func main() {
var youku *crawler.Youku = crawler.NewYouku()
//fmt.Println(youku.GetCna())
_, _ = youku.GetVideoInfo("http://v.youku.com/v_show/id_XMjg1Mzg0MzkyOA==.html?spm=a2hww.20023042.m_223465.5~5~5~5!2~5~5~A&f=50219377", 0)
//fmt.Println(res)
}
|
// 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 platform
import (
"context"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/resourced"
"chromiumos/tast/testing"
)
type resourcedTestParams struct {
i... |
package controller
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/gocolly/colly"
// "encoding/json"
)
type Sku struct {
Name string `gorm:"column:user_name" json:"name"`
Image string `gorm:"column:user_account" json:"image"`
}
func Index(c *gin.Context) {
c.HTML(http.StatusOK, "index.html... |
package statgo
import (
"math"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestHostInfo(t *testing.T) {
s := NewStat()
hi := s.HostInfos()
assert.NotNil(t, s)
assert.NotEmpty(t, hi.HostName, hi.OSName, hi.OSRelease, hi.OSVersion, hi.Platform)
assert.True(t, hi.NCPUs > 0, hi.MaxCPUs > 0)
t... |
package ccpa
import (
"errors"
"fmt"
gpplib "github.com/prebid/go-gpp"
gppConstants "github.com/prebid/go-gpp/constants"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/openrtb_ext"
gppPolicy "github.com/prebid/prebid-server/privacy/gpp"
)... |
package inflectlab
import (
"encoding/json"
"reflect"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
//-----------------------------------------------------------------------------
// test specific types
type Model struct {
// ID bson.ObjectId `json:"id" bson:"_id"`
ID string `json:"id" bson... |
// 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 main
import (
"fmt"
"github.com/disintegration/imaging"
"github.com/gin-gonic/gin"
"github.com/h2non/bimg"
"net/http"
"time"
)
//var pngSrc, _ = bimg.Read("/Users/svenweisker/Downloads/big_png_big.png")
//var jpgSrc, _ = bimg.Read("pexels-artem-beliaikin-853199.jpg")
//var pngSrc, _ = imaging.Open("/Us... |
package main
import (
"errors"
"fmt"
"os"
"strings"
"github.com/codegangsta/cli"
"github.com/landaire/pbo"
)
const (
version = "0.2.0"
)
var pboFile *pbo.Pbo
func main() {
app := cli.NewApp()
app.Name = "pboextractor"
app.Usage = "Extract PBO archives used in games such as Arma 3"
app.Author = "Lander... |
package main
import (
"log"
"net"
"net/http"
"time"
)
// Function to use for transport dial.
func dialTimeout(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, time.Duration(2*time.Second))
}
func newClient() http.Client {
transport := http.Transport{
Dial: dialTimeout,
}
clie... |
package day5
import "adventofcode/io"
func isNaughtyPair(p string) bool {
return p == "ab" || p == "cd" || p == "pq" || p == "xy"
}
func isVowel(c string) bool {
return c == "a" || c == "e" || c == "i" || c == "o" || c == "u"
}
func isNice(s string) bool {
prev := "" // previous letter
hasTwice := f... |
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package types
import (
"encoding/json"
)
type ID string
func (id ID) GetID() ID { return id }
func (id ID) String() string { return string(id) }
type IDArray []ID
func (p IDArray) Len() int ... |
package knife
// Only ECB/CBC aes encryption/decryption supported
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"io"
)
type AesOp string
const (
CBC AesOp = "CBC"
ECB AesOp = "ECB"
)
type Coding int
const (
_ Coding = iota
HEX
BASE64
)
fu... |
package main
import (
"cmgmt/datastore"
"encoding/json"
"log"
"strconv"
"strings"
"net/http"
)
func handleMemberByID(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
log.Println("GET /member/id")
handleGETMemberByID(w, r)
case "DELETE":
log.Println("DELETE /member/id")
handle... |
package main
import (
"binary_tree/tree"
"fmt"
"os"
)
/*
Daily Coding Problem: Problem #502 [Easy]
This problem was asked by PayPal.
Given a binary tree, determine whether or not it is height-balanced. A
height-balanced binary tree can be defined as one in which the heights
of the two subtrees of any node never ... |
package responses
import "time"
type QRcodeResponses struct {
UUID string `bson:"uuid" json:"uuid"` //UUID
Title string `bson:"title" json:"title"` //标题
Info string `bson:"info" json:"info"` //json内容
IsDel bool `bson:"is_del" json:"is_del... |
package handlers
import (
"encoding/json"
"io"
"net/http"
)
type ErrorResponse struct {
Message string `json:"message"`
}
func ApiHandler(fn ApiHandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json, err := fn(w, r)
if ... |
package seeker
import (
"context"
"math"
"strconv"
"strings"
"time"
"../logger"
"../utils"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/chromedp"
"github.com/chromedp/chromedp/client"
"github.com/chromedp/chromedp/runner"
"github.com/gorilla/websocket"
)
// Seeker seeks targets with search eng... |
// *** WARNING: this file was generated by pulumigen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package v1
import (
"fmt"
"github.com/blang/semver"
"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
type module str... |
package bgo
import "time"
/**
* Wait a few seconds.
**/
type Wait struct {
BaseNode
endTime <-chan time.Time
delay int64
}
func (this *Wait) Open(context *Context) {
t := time.Duration(this.delay) * time.Millisecond
this.endTime = time.Tick(t)
}
func (this *Wait) Tick(context Context) ... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package multivm contains utilities for working with more than one VM (ARCVM,
// Crostini, etc.) at a time.
package multivm
|
package service
import (
"testing"
ut "github.com/zdnscloud/cement/unittest"
)
func TestIngressRemoveRule(t *testing.T) {
cases := []struct {
src *Ingress
protocol IngressProtocol
leftRuleCount int
}{
{
&Ingress{
name: "i1",
rules: []IngressRule{
IngressRule{
protocol... |
package notifier
import (
"github.com/sirupsen/logrus"
mint "github.com/void616/gm.mint"
"github.com/void616/gm.mint.sender/internal/watcher/db"
"github.com/void616/gm.mint/amount"
)
const itemsPerShot = 50
// Notifier sends refilling notifications
type Notifier struct {
logger *logrus.Entry
natsTrans NatsT... |
package routes
import (
"fmt"
"math"
"strconv"
"github.com/ankithans/youtube-api/pkg/database"
"github.com/ankithans/youtube-api/pkg/models"
"github.com/gofiber/fiber/v2"
)
// GetVideos returns the videos from database
// according the queries provided by the user
func GetVideos(c *fiber.Ctx) error {
var prod... |
package handler
import (
"net/http"
"net/http/httptest"
"testing"
"gopkg.in/mgo.v2"
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
)
func TestFetchUserInfo (t *testing.T) {
session, err := mgo.Dial("mongodb://SEavanger:SEavanger@ds139964.mlab.com:39964/se_avangers")
if err != nil {
panic(er... |
package main
import (
"encoding/json"
"mime"
"net/http"
"strconv"
"strings"
)
func indexController(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
ErrorReply(r, w, ErrNotFound, ServerOptions{})
return
}
body, _ := json.Marshal(CurrentVersions)
w.Header().Set("Content-Type", "application... |
package go_benchmarks
import (
"testing"
)
const (
testStr = "This is the string that will be copied into the tests"
sliceLen = 5
)
func BenchmarkMakeWithCapacity(b *testing.B) {
var result []TextRange // Just to avoid the compiler optimizing the method call out
for i := 0; i < b.N; i++ {
MakeWithCapacity(sl... |
package pif
import (
"n64emu/pkg/core/joybus"
"n64emu/pkg/types"
"testing"
"github.com/stretchr/testify/assert"
)
// definition of dummy device
type MockJoyBusDevice struct {
wantCmd joybus.CommandType
wantTxLen types.Byte
wantRxLen types.Byte
readDatas []types.Byte
}
func (m *MockJoyBusDevice) Reset() {
... |
package main
import (
"fmt"
)
func main() {
array := []int{2, 1, 20, 5, 6, 42, -2, 4, 3, 5, 3, 25, 122, 4, -4, 300, 73, -10}
quickSort(array)
fmt.Println(array)
}
func quickSort(subArray []int) {
if len(subArray) <= 1 {
return
}
pivot := partition(subArray)
quickSort(subArray[0:pivot])
quickSort(subArra... |
package worker
import (
"context"
"time"
"github.com/sourcegraph/sourcegraph/enterprise/cmd/executor/internal/apiclient"
"github.com/sourcegraph/sourcegraph/enterprise/cmd/executor/internal/command"
"github.com/sourcegraph/sourcegraph/internal/goroutine"
"github.com/sourcegraph/sourcegraph/internal/observation"... |
package starlarkfn_test
import (
"testing"
"github.com/golang/mock/gomock"
"github.com/raba-jp/primus/pkg/operations/directory/handlers"
mock_handlers "github.com/raba-jp/primus/pkg/operations/directory/handlers/mock"
"github.com/raba-jp/primus/pkg/operations/directory/starlarkfn"
"github.com/raba-jp/primus/pkg... |
// Copyright (c) 2018 soren yang
//
// Licensed under the MIT License
// you may not use this file except in complicance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed und... |
package models
import (
"errors"
"github.com/sirupsen/logrus"
)
type Github struct {
Id int `json:"id"`
UserName string `json:"username"`
}
func NewGitUser(logger *logrus.Logger, name string) (*Github, error) {
if len(name) == 0 {
err := errors.New("name are required")
logger.Error(err)
return n... |
package models
import(
"encoding/json"
)
/**
* Type definition for RequiredPrivilegeEnum enum
*/
type RequiredPrivilegeEnum int
/**
* Value collection for RequiredPrivilegeEnum enum
*/
const (
RequiredPrivilege_KREADACCESS RequiredPrivilegeEnum = 1 + iota
RequiredPrivilege_KREADWRITEA... |
package segment_tree
// SegmentTree the data structure define
type SegmentTree struct {
data []int
sum []int
}
// NewSegmentTree the construct of the segment tree
func NewSegmentTree(array []int) *SegmentTree {
return &SegmentTree{
data: array,
sum: make([]int, len(array)<<2),
}
}
// Build build the segmen... |
package server
import "math"
// HSin haversin(θ) function
func HSin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance calculated in km between the given lat/lon coordinates.
func Distance(aLat, aLon, bLat, bLon float64) float64 {
// convert to radians
// must cast radius as float to mul... |
package uaa_test
import (
"encoding/json"
"encoding/pem"
"fmt"
"net/http"
"regexp"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
"github.com/pivotal-cf/on-demand-service-broker/config"
"github.com/pivotal-cf/on-demand-service-broker/integration_tests/helpers"
"gith... |
package manager
import (
"github.com/gin-gonic/gin"
"starter/internal/entities"
"starter/internal/manager/controllers"
managerMiddleWares "starter/internal/manager/middlewares"
"starter/pkg/app"
"starter/pkg/captcha"
"starter/pkg/database/managers"
"starter/pkg/middlewares"
"starter/pkg/rbac"
"starter/pkg/se... |
package middleware
// func Authentication(next http.Handler) http.Handler {
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// log.Println(r.RequestURI)
// type tbody struct {
// UserID, CompanyID int64
// AccessToken string
// }
// var body tbody
// err := json.Ne... |
package main
import "sort"
//852. 山脉数组的峰顶索引
//符合下列属性的数组 arr 称为 山脉数组 :
//arr.length >= 3
//存在 i(0 < i< arr.length - 1)使得:
//arr[0] < arr[1] < ... arr[i-1] < arr[i]
//arr[i] > arr[i+1] > ... > arr[arr.length - 1]
//给你由整数组成的山脉数组 arr ,返回任何满足 arr[0] < arr[1] < ... arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - ... |
package main
// Bidder represents a string name for a particular bidder
type Bidder string
const (
// Nike represents Nike as a bidder/buyer on the ad exchange
Nike Bidder = "nike"
// Amazon represents Amazon as a bidder/buyer on the ad exchange
Amazon Bidder = "amazon"
// Apple represents Apple as a bidder/buye... |
package tapo
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"encoding/hex"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"net/http"
"strings"
"time"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
"github.... |
/*
* Wager service APIs
*
* APIs for a wager system
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package models
import (
"context"
"github.com/astaxie/beego/orm"
)
type WagerPurchase struct {
Id int64 `orm:"auto;pk" json:"id"`
WagerId int64 `json:"wager_id... |
package graph
import (
_ "leetcode/topic"
"sort"
)
/*
1030
距离顺序排列矩阵单元格
思路:
- 由于输出是一个2列 R* C行的二维数组
- 所以先将矩阵转换为上面说得二维数组
- 再对二维数组中的数据排序
*/
func allCellsDistOrder(R int, C int, r0 int, c0 int) [][]int {
ret := make([][]int, 0, R*C)
for i := 0; i < R; i++ {
for j := 0; j < C; j++ {
ret = append(ret, []int{i... |
package sqlite3
import (
"database/sql"
"github.com/sohaha/zlsgo/zfile"
"github.com/sohaha/zlsgo/zutil"
"github.com/zlsgo/zdb/driver"
)
var _ driver.IfeConfig = &Config{}
var _ driver.Dialect = &Config{}
// Config database configuration
type Config struct {
driver.Typ
File string
Dsn string
P... |
package eventbus
import (
"log"
"sync"
"sync/atomic"
)
const (
maxBufSize = 1000
)
type eventbus struct {
handlers map[string]*handlers
handlersLock sync.RWMutex
replySequence int64
}
var eb *eventbus
var once sync.Once
func EventBus() *eventbus {
once.Do(func() {
eb = &eventbus{
handlers: make(m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.