text stringlengths 11 4.05M |
|---|
package commands
import (
"errors"
"fmt"
"regexp"
"strings"
"github.com/LiveSocket/bot/command-runner/helpers"
"github.com/LiveSocket/bot/conv"
"github.com/LiveSocket/bot/service"
"github.com/LiveSocket/bot/service/socket"
)
type addInput struct {
Channel string
Username string
Name string
Response... |
package main
import (
"fmt"
)
func coin(deno []int, v int) int {
n := len(deno)
dp := make([][]int, 0, n)
for i := 0; i < n; i++ {
dp = append(dp, make([]int, v+1))
dp[i][0] = 1
}
for j := 0; j <= v; j++ {
if j%deno[0] == 0 {
dp[0][j] = 1
}
/*else {
dp[0][j] = 0
}*/
}
for i := 1; i < n; i++ ... |
package main
import (
"fmt"
"math"
)
// Geometry interface requires an area() and perim() method for each type implementing it
type geometry interface {
area() float64
perim() float64
}
// Define 2 types - circle and rectangle
type rectangle struct {
width, height float64
}
type circle struct {
radius float64... |
package main
import (
"context"
"github.com/wuzuoliang/log"
"os"
)
func main() {
newLog := log.New()
newLog.Info("newLog", "test1", log.JSON(&struct {
A int
B string
}{1, "2"}))
newLog.Log("newLog", "test2", &struct {
A int
B string
}{3, "4"})
newLog2 := log.New("withinit", "test2")
newLog2.Error(... |
package args_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/go-task/task/v3/args"
"github.com/go-task/task/v3/internal/orderedmap"
"github.com/go-task/task/v3/taskfile"
)
func TestArgsV3(t *testing.T) {
tests := []struct {
Args []string
ExpectedCalls []taskfil... |
package single
import (
"fmt"
)
/*
在某个节点后面插入节点
在某个节点前面插入节点
在链表头部插入节点
链表尾部插入节点
通过索引查找节点
删除传入的节点
打印链表
*/
type ListNode struct{
next *ListNode
value interface{}
}
type LinkedList struct{
head *ListNode
len uint
}
func NewListNode(v interface{}) *ListNode {
return &ListNode{nil, v}
}
func (node *ListNode) Value() i... |
package apachetizer
import (
"encoding/json"
"log"
"os"
"reflect"
"testing"
)
func TestVHostConfDetector(t *testing.T) {
got, err := VHostConfDetector("./etc/apache2/sites-available")
if err != nil {
log.Fatal(err)
}
if reflect.TypeOf(got).Kind() != reflect.Slice {
panic(got)
} else {
log.Println("VHo... |
package main
import (
"fmt"
"io"
"log"
"os"
"os/exec"
"regexp"
"strings"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil"
"github.com/BurntSushi/xgbutil/ewmh"
"github.com/BurntSushi/xgbutil/icccm"
"github.com/chrispickard/btf/version"
"github.com/mattn/go-shellwords"
"gopkg.in/alecthom... |
package set1
import (
"bytes"
"encoding/hex"
"testing"
)
func TestRepeatingKeyXOR(t *testing.T) {
input := []byte(`Burning 'em, if you ain't quick and nimble
I go crazy when I hear a cymbal`)
key := []byte("ICE")
expected := "0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f204... |
package public
import (
"github.com/google/go-querystring/query"
"github.com/pkg/errors"
"github.com/potix/gobitflyer/client"
)
const (
getChatsPath string = "/v1/getchats"
)
type GetChatsResponse []*GetChatsChat
type GetChatsChat struct {
Nickname string `json:"nickname"`
Message string `json:"messag... |
/*
Copyright 2023 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 delivery
import (
"encoding/json"
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/vivaldy22/cleanEnigmaSchool/models"
"github.com/vivaldy22/cleanEnigmaSchool/tools/msgJson"
"github.com/vivaldy22/cleanEnigmaSchool/tools/varMux"
)
type TeacherHandler struct {
TUseCase models.TeacherUseCase
}
fun... |
/*
Copyright 2017 Mirantis
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, software
distri... |
package domains
type User struct {
UserId string `json:"user_id"`
Name string `json:"name"`
Age int `json:"age"`
}
|
package db
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
type Map map[string]any
// Value implements the driver.Valuer interface.
func (m Map) Value() (driver.Value, error) {
b, err := json.Marshal(m)
return b, err
}
// Scan implements the sql.Scanner interface.
func (m *Map) Scan(value any) error {
... |
package main
import "fmt"
import "asyncapi"
func main(){
c := asyncapi.Controller{}
fmt.Printf("%v", c)
}
|
package main
import (
"fmt"
s "strings"
)
func main() {
fmt.Println("Contains: ", s.Contains("test", "es"))
fmt.Println("Count: ", s.Count("test", "t"))
fmt.Println("HasPrefix: ", s.HasPrefix("test", "te"))
fmt.Println("HasSuffix:", s.HasSuffix("test", "st"))
fmt.Println("Index:", s.Index("test", "e"))
fmt.Pr... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package inputsimulations
import (
"context"
"fmt"
"math"
"time"
"chromiumos/tast/common/action"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/... |
// 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 wmp
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/apps"
"chromiumos/tast/local/chrome"
"chromiumos/tast... |
package goisgod
import (
"bytes"
"image"
// require
_ "image/gif"
"image/jpeg"
_ "image/png"
)
type GigImage struct {
key string
image *image.Image
}
func (gimg *GigImage) toByte() (bs []byte, err error) {
buf := new(bytes.Buffer)
if err = jpeg.Encode(buf, *gimg.image, nil); err != nil {
return
}
... |
package main
import (
"bufio"
"fmt"
"io"
"log"
"net/http"
"os"
"strings"
)
func download(url string, name string) {
// Get the data
fmt.Printf("downloading %s\n", name)
resp, err := http.Get(url)
if err != nil {
return
}
defer resp.Body.Close()
// Check server response
if resp.StatusCode != http.Sta... |
package model
import "fmt"
type TargetGraph struct {
// Targets in topological order.
sortedTargets []TargetSpec
byID map[TargetID]TargetSpec
}
func NewTargetGraph(targets []TargetSpec) (TargetGraph, error) {
sortedTargets, err := TopologicalSort(targets)
if err != nil {
return TargetGraph{}, err
}
... |
package history
import (
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"reflect"
"testing"
)
type (
ID string
)
func (p ID) IsZero() bool {
return p == "zero"
}
func TestMakePtr(t *testing.T) {
tests := []struct {
name string
value interface{}
}{
{
name: "non point... |
package main
import (
"strings"
"github.com/dghubble/go-twitter/twitter"
)
func analyzeSource(tweets []twitter.Tweet) map[string]int {
var sources = make(map[string]int)
for _, v := range tweets {
source := strings.Split(strings.Split(v.Source, ">")[1], "<")[0]
if _, ok := sources[source]; ok {
sources[so... |
package models
// QueueInterface : queue interface
type QueueInterface map[string]interface{}
// GetperiodQWeek : get hourly period queues in week
func (q *QueueInterface) GetperiodQWeek (hID, year, week string) error {
rows, err := db.Raw(`
SELECT SUBSTRING(create_time, 1, 2) as Hour, COUNT(queue_id) as Queues
... |
package main
import (
"fmt"
"time"
)
func main() {
t1 := time.Now()
t2 := t1.Add(10 * time.Second)
sub := t1.Sub(t2)
fmt.Printf("%#v\n", sub)
}
|
package main
import "fmt"
func main() {
finger := 3
switch finger {
case 1:
fmt.Println("Thumb!")
case 2:
fmt.Println("Index")
case 3:
fmt.Println("Middle")
case 4:
fmt.Println("Ring")
case 5:
fmt.Println("Pinky")
}
num := 23
switch {
case num >= 0 && num <= 50:
fmt.Println("Between 0 and 50")... |
package ftp
import (
"os"
"github.com/aws/aws-sdk-go/aws/awserr"
)
type Test struct{}
func (test Test) Upload(filepath string, bucketName string, objectKey string) (err error) {
success := os.Getenv("IS_SUCCESS")
if success == "1" {
return nil
}
return awserr.New("ReadRequestBody", "unable to initialize up... |
package resolvers
import (
"context"
"fmt"
graphql "github.com/99designs/gqlgen/graphql"
json "github.com/json-iterator/go"
dataloader "github.com/proxima-one/proxima-data-vertex/pkg/dataloaders"
models "github.com/proxima-one/proxima-data-vertex/pkg/models"
proximaIterables "github.com/proxima-one/proxima-db-... |
package kindergarten
import (
"errors"
"sort"
"strings"
)
// Garden structure
type Garden struct {
diagram string
children []string
sortedChildren []string
}
var (
plantsMap = map[byte]string{
'R': "radishes",
'C': "clover",
'G': "grass",
'V': "violets",
}
)
// NewGarden creates a new G... |
// Copyright 2019 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/
//
// or in the "license" fil... |
package model
import (
"time"
)
type User struct {
Id int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Key string `json:"key"`
Email string `json:"email"`
CreateTime int64 `json:"create_ts"`
... |
package database
import (
"bytes"
"context"
"database/sql"
"encoding/json"
"net"
"time"
"github.com/golang/glog"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/metrics"
"github.com/prebid/prebid-server/stored_requests/backends/db_provider"
"github.com/prebid/prebid-server/stored_... |
package main
import "fmt"
func main() {
board := [][]byte{{'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}}
word := "ABCCED"
fmt.Println(exist(board, word))
}
func exist(board [][]byte, word string) bool {
visited := make([][]bool, len(board))
for i := 0; i < len(board); i++ {
visited[i] = mak... |
package browsermain
import (
"math"
"capnproto.org/go/capnp/v3"
"zenhack.net/go/tempest/capnp/external"
"zenhack.net/go/tempest/internal/common/types"
"zenhack.net/go/util/exn"
)
var _ pusherHooks[types.ID[external.Package], external.Package] = pkgPusher{}
type pkgPusher struct {
}
func (pp pkgPusher) Upsert(... |
package main
func f() float64 {
}
func main() {
var a int = f()
}
|
package main
import (
"fmt"
"sync"
)
func main() {
// Структура WaitGroup имеет поле noCopy, которое дает понять, что данную структуру не стоит копировать.
// А при передачи аргументов в функцию они как раз и копируются, что недопустимо.
//Структура WaitGroup должна создаваться по указателю
wg := sync.WaitGroup... |
package webserver
import (
"net/http"
"os"
"runtime"
"strings"
"time"
"github.com/getsentry/sentry-go"
sentryecho "github.com/getsentry/sentry-go/echo"
promecho "github.com/labstack/echo-contrib/prometheus"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/prometheus/client... |
package kruskal
import "github.com/arberiii/Graph-Algorithms/graph"
type edge struct {
u int
v int
weight float64
}
// we suppose that the weight are sorted
func Kruskal(g graph.Graph, w []*edge) graph.Graph {
tree := graph.NewGraph()
components := make(map[int]int)
for v := range g {
tree[v] = []i... |
package requests
import (
"encoding/json"
"fmt"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
)
// FlaggingQuestion Set a flag on a quiz question to indicate that you want to return to it
// later.
// https://canvas.instructure.com/doc/api/quiz_submission_quest... |
package api
import (
"github.com/jamierocks/gore/models"
)
type ProjectView struct {
ID int64 `json:"id"`
Name string `json:"name"`
SafeName string `json:"safeName"`
Versions []ProjectVersionView `json:"versions"`
}
type ProjectVersionView struct {
Version string `json:"version"`
Channel ... |
package stack
type Watcher interface {
Watch(killCh <-chan struct{})
}
type Stack []Watcher
func (s Stack) Watch(killCh <-chan struct{}) {
for _, w := range s {
go w.Watch(killCh)
}
}
|
package zorm
import (
"database/sql"
"github.com/ZerQAQ/zorm/set"
"github.com/ZerQAQ/zorm/table"
)
func (d *Driver) Connect (name string, sour string) error {
var err error
d.Database, err = sql.Open(name, sour)
return err
}
func (d *Driver) init (){
d.tableSet = set.MakeSet()
rows, err := d.Database.Query("... |
package reports
import (
// mdl "diaria/models"
"fmt"
gr "github.com/mikeshimura/goreport"
"strconv"
)
func Simple1(records []interface{}) string {
r := gr.CreateGoReport()
r.SumWork["amountcum="] = 0.0
font1 := gr.FontMap{
FontName: "IPAexG",
FileName: "ttf//ipaexg.ttf",
}
fonts := []*gr.FontMap{&font1}... |
package auth
import (
"fmt"
log "git.ronaksoftware.com/blip/server/internal/logger"
"git.ronaksoftware.com/blip/server/internal/tools"
"git.ronaksoftware.com/blip/server/pkg/config"
"git.ronaksoftware.com/blip/server/pkg/msg"
"git.ronaksoftware.com/blip/server/pkg/session"
"git.ronaksoftware.com/blip/server/pkg... |
package main
import (
"fmt"
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/ec2"
"github.com/docopt/docopt-go"
"log"
"os"
"regexp"
"strconv"
"time"
)
const version = "0.1"
var usage = `amicleanup: clean up old AWS AMI backups and snapshots
Usage:
amicleanup [options] <ami_name_regex>
amiclea... |
package service
import (
"fmt"
"github.com/qianxunke/ego-shopping/ego-common-protos/go_out/user/user_info"
"github.com/qianxunke/ego-shopping/ego-plugins/db"
"log"
"sync"
)
var (
s *userInfoService
m sync.Mutex
)
//service 服务
type userInfoService struct {
}
func GetService() (*userInfoService, error) {
if s... |
package app
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
_ "github.com/akhettar/rec-engine/docs"
m "github.com/akhettar/rec-engine/model"
"github.com/akhettar/rec-engine/redrec"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
httpswag "github.com/swaggo/http-swagger"
)
// App server instan... |
package xxh3
import (
"encoding/binary"
"math/bits"
"unsafe"
)
type (
ptr = unsafe.Pointer
ui = uintptr
u8 = uint8
u32 = uint32
u64 = uint64
)
var le = binary.LittleEndian
func readU8(p ptr, o ui) uint8 { return *(*uint8)(ptr(ui(p) + o)) }
func readU16(p ptr, o ui) uint16 { return le.Uint16((*[2]byte)(... |
package core
//go:generate counterfeiter -o ./fakeOpCaller.go --fake-name fakeOpCaller ./ opCaller
import (
"bytes"
"fmt"
"github.com/opspec-io/opctl/util/pubsub"
"github.com/opspec-io/opctl/util/uniquestring"
"github.com/opspec-io/sdk-golang/pkg/managepackages"
"github.com/opspec-io/sdk-golang/pkg/model"
"git... |
// Copyright 2021 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 main
import "fmt"
// 结构体 要 比 map 自由些
// 值类型(int float bool string [x]int struct )赋值后 修改 副本 不影响 源 深cp
// 引用类型 (map slice chan interface)赋值后 修改副本 会引起 源变化,浅cp
// go 中 函数 传参 ,全是 深cp 了一个 过去,如果 &变量,才是 源 修改
type persion struct{
Name string `json:"name"`
Age int `json:"age"`
Gender string `json:"gender... |
package DB
import (
"RMQ_Project/common"
"RMQ_Project/model"
"database/sql"
"fmt"
)
type OrderInterface interface {
Conn() error
Insert(order *model.Order) (int64, error)
}
type OrderStruct struct {
table string
db *sql.DB
}
func NewOrderManger(table string, sql *sql.DB) OrderInterface {
return &OrderSt... |
package main
import "fmt"
func printEndStart() {
// Printed third
defer fmt.Println("End.")
// Printed second
defer fmt.Println("Do some stuff.")
// Printed first
fmt.Println("Start.")
}
func printNum(num int) {
defer fmt.Printf("This is the number printed in a deferred statement: %v", num)
}
func main(... |
// declaration of array
// composite literals
package main
import "fmt"
func main() {
var p [10]string
p[0] = "hello" // assign a value
p[1] = "are"
p[2] = "you"
// access the value
loc1 := p[0]
fmt.Println("At p[o]", loc1)
// len of p
fmt.Println("len of p: ", len(p))
fmt.Println("At p[3]", p[3] == "")
}... |
/*
Copyright 2019 Adobe
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it. If you have received this file from a source other than Adobe,
then your use, modification, or distribution of it requires the pri... |
package main
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/moyen-blog/client-go/client"
)
// printDiff prints the staged actions required to synchronize local with remote files
func printDiff(diff []client.AssetDiff) {
fmt.Printf("%d action(s) staged\n", len(diff))
for _, i := range diff {
switch i.Acti... |
package vsphere
const STATICIP_CUSTOM_SPEC_NAME = "static-ip-libretto"
const XML_STATIC_IP_SPEC = `
<ConfigRoot>
<_type>vim.CustomizationSpecItem</_type>
<info>
<_type>vim.CustomizationSpecInfo</_type>
<changeVersion>1505235815</changeVersion>
<description/>
<lastUpdateTime>2017-09-12T17:03:35Z</la... |
// Package objects contains object interfaces and concrete object types that can
// reside within an environment.
package objects
|
package networkcrd
const (
GroupName = "networkcrd.k8s.io"
Version = "v1"
)
|
package docker
import (
"mdocker/utils"
"fmt"
"errors"
)
type Images struct {
Manage *DockerManage
}
func NewImages() *Images {
manage := NewDockerManage()
return &Images{manage}
}
func (images *Images) ClearTemp() error {
get_tmp_image_cmd := images.Manage.getCmd("images -q -f dangling=true")
rm_cmd := im... |
// 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 camera
import (
"context"
"regexp"
"time"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/assis... |
// +build unix linux
package fuse
import (
"testing"
"bazil.org/fuse/fs"
)
func TestHashable(t *testing.T) {
table := make(map[fs.Node]int)
table[root(0)] = 42
table[directory{}] = 57
table[file{}] = 12
}
|
// Copyright (c) 2020 Tailscale Inc & 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 tshttpproxy
import (
"context"
"encoding/base64"
"fmt"
"log"
"net/http"
"net/url"
"runtime"
"strings"
"sync"
"syscall"
"time"
"... |
package http_util
type HttpRequest interface {
Path() string
Headers() map[string]string
}
type LazyHttpRequest struct {
tcpRequest string
tcpHttpParser HttpParser
}
func NewLazyHttpRequest(tcpRequest string) HttpRequest {
return &LazyHttpRequest{
tcpRequest: tcpRequest,
tcpHttpParser: NewTcpHttpParse... |
// +build linux
// This program demonstrates how to attach an eBPF program to a tracepoint.
// The program will be attached to the sys_enter_open syscall and print out the integer
// 123 everytime the sycall is used.
package main
import (
"context"
"fmt"
"os"
"runtime"
"time"
"github.com/cilium/ebpf"
"github.... |
/*******************************************************************************
* Copyright 2017 Samsung Electronics 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... |
package main
import "fmt"
// SUCCESS string constant for response
const SUCCESS = "success"
// Constant strings for APIs
const (
BASEURL = "http://dummy.restapiexample.com/api/v1/"
GETALLURL = BASEURL + "employees"
GETONEURL = BASEURL + "employee/"
CREATEURL = BASEURL + "create"
DELETEURL = BASEURL + "delete/... |
package main
import "fmt"
func main() {
colors := map[string]string{
"red": "#ff0000",
"green": "#dd0000",
"blue": "#cc0000",
}
printMap(colors)
}
func printMap(c map[string]string) {
for _, hex := range c {
fmt.Println(hex)
}
}
|
package payloads
import (
"github.com/gobuffalo/validate/v3"
"github.com/gofrs/uuid"
"github.com/transcom/mymove/pkg/gen/adminmessages"
"github.com/transcom/mymove/pkg/models"
)
// UserModel represents the user
// This does not copy over session IDs to the model
func UserModel(user *adminmessages.UserUpdatePaylo... |
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package mirbft
import (
"bytes"
"fmt"
"math"
pb "github.com/IBM/mirbft/mirbftpb"
"go.uber.org/zap"
)
type stateMachine struct {
myConfig *Config
currentEpoch *epoch
}
func (sm *stateMachine) propose(data []byte) *Action... |
package solutions
func removeInvalidParentheses(s string) []string {
var result []string
left, right := 0, 0
for _, value := range s {
if value == '(' {
left++
} else if value == ')' {
if left == 0 {
right++
} else {
left-... |
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/cheggaaa/pb"
)
// a compound word
type Compound struct {
word string
originalWords []string
}
func (c *Compound) String() string {
return fmt.Sprintf("%s {%v}", c.word, c.originalWords)
}
// a list of compound words, and th... |
package main
import "fmt"
//func main() {
// if true {
// defer fmt.Printf("a")
// }else {
// defer fmt.Printf("b")
// }
//
// fmt.Printf("c")
//}
const (
a = iota
b = iota
)
const (
name = "name" //iota已经开始计数,const每一行iota计数一次
c = iota //const关键词出现就会被重置
d = iota
)
func main() {
fmt.Println(a)
fmt.P... |
// 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 guestos provides VM guest OS related primitives.
package guestos
import (
"context"
"chromiumos/tast/common/testexec"
"chromiumos/tast/local/vm"
)
// Crostin... |
package extension
import (
"context"
"fmt"
"os"
"path/filepath"
"strings"
"sync"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runti... |
package main
import (
"flag"
"time"
"github.com/gin-gonic/gin"
"github.com/new-adventure-areolite/grpc-app-server/pd/auth"
"github.com/new-adventure-areolite/grpc-app-server/pd/fight"
auth_middle_ware "github.com/new-adventure-areolite/grpc-app-server/pkg/auth"
"github.com/new-adventure-areolite/grpc-app-serve... |
package leetcode
func singleNonDuplicate(nums []int) int {
l, m, r := 0, 0, len(nums)-1
for l < r {
m = (r-l)/2 + l
if m%2 == 1 {
m--
}
if nums[m] == nums[m+1] {
l = m + 2
} else {
r = m
}
}
return nums[r]
}
func singleNonDuplicate1(nums []int) int {
low, high := 0, len(nums)-1
for low <= ... |
package writer
import (
"bytes"
"io/ioutil"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestWriteTrigger(t *testing.T) {
buf := new(bytes.Buffer)
if err := WriteTrigger("./testdata/spec-full.yaml", buf); err != nil {
t.Fatalf("error from 'WriteTrigger': %v", err)
}
got := buf.Bytes()
path := "./testd... |
// MoreXmlParser project main.go
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
)
const url = "https://www.washingtonpost.com/news-technology-sitemap.xml"
type News struct {
Locations []string `xml:"url>loc"`
Titles []string `xml:"url>news>title"`
Keywords []string `xml:"url>news>keywor... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
)
var (
httpClient = http.Client{
Timeout: time.Second * 3,
}
)
func GetCurrentWeatherForCity(cityName string) map[string]interface{} {
configuration := GetDevelopmentConfiguration()
url := fmt.Sprintf("%s/data/2.5/weather?q... |
package main
import "strings"
// match("abba", "Beijing Hangzhou Hangzhou Beijing") -- true
// match("aabb", "Beijing Hangzhou Hangzhou Beijing") -- false
// match("baab", "Beijing Hangzhou Hangzhou Beijing") -- true
func simplePatternMatch(pattern, s string) bool {
m := make(map[byte]string)
strs := strings.Split(... |
package main
import (
"context"
"time"
)
const timeout = time.Second * 2
func main() {
// TODO: код писать здесь
}
func realMain(ctx context.Context, num int) {
// TODO: код писать здесь
}
// TODO: код писать здесь
|
/**********************************************************************
* @Author: Eiger (201820114847@mail.scut.edu.cn)
* @Date: 2020/4/23 8:55
* @Description: The file is for
***********************************************************************/
package main
import (
"fmt"
"strings"
)
const mdFormat1 = `
## %... |
package rewrite
import (
"bytes"
"go/ast"
"go/format"
"go/parser"
"go/token"
)
import "strconv"
import "hw2/expr"
import "hw2/simplify"
// rewriteCalls should modify the passed AST
func rewriteCalls(node ast.Node) {
//TODO Write the rewriteCalls function
ast.Inspect(node, func (node ast.Node) bool {
swit... |
package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
)
// 日志文件
type LogConfig struct {
Access string `json:"access"`
Error string `json:"error"`
}
type HttpConfig struct {
Listen string `json:"listen"`
Secret string `json:"secret"`
}
type RpcConfig struct {
Listen string `json:"listen"`
... |
package internal
import (
"github.com/ionous/sashimi/util/ident"
)
//
// PendingInstance records all of the classes which use an instance
//
type PendingInstance struct {
id ident.Id
name string
longName string
classes ClassReferences
}
|
package day9
import (
"log"
"regexp"
"sort"
"strconv"
)
type Place struct {
Name string
Distances map[string]int
}
type Places map[string]*Place
func (ps Places) ParseLines(lines []string) {
rx := regexp.MustCompile(`^(\w+) to (\w+) = (\d+)$`)
for i, line := range lines {
result := rx.FindStringSubma... |
package main
import (
"fmt"
"github.com/codegangsta/cli"
"io/ioutil"
"log"
"os"
"os/exec"
"regexp"
)
var commandInit = cli.Command{
Name: "init",
Usage: "copy template directory and run \"lime.sh\" in template directory",
Description: "",
Action: doInit,
}
func doInit(c *cli.Context) {
... |
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/johnantonusmaximus/grpc-golang/long_greet_stream/greetstreampb"
"google.golang.org/grpc"
)
func main() {
conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure())
if err != nil {
log.Fatalf("Connection to GRPC failed: %v", err)
}
defer ... |
package main
import (
"flag"
"fmt"
"log"
"net/http"
)
func main() {
var (
addr = flag.String("addr", "0.0.0.0:6789", "listening address")
dir = flag.String("dir", ".", "the folder to serve")
link = flag.String("link", "123456789", "the access link")
)
flag.Parse()
*link = fmt.Sprintf("/%s/", *link)
... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 ... |
package domain
type User struct {
UserID uint64
Username string
Password string
FirstName string
LastName string
Email string
}
|
package internal
import (
"log"
"net"
"os"
"strings"
"strconv"
"errors"
"io"
)
var Source string
var Target string
var openConnections int = 0
var MaxConnections int = 20
type Host struct {
address net.IP
port int
}
func (h *Host) getEndpoint() string {
return h.address.String() + ":" + strconv.Itoa(h.por... |
package titleator
import (
logger "github.com/sirupsen/logrus"
"strings"
"github.com/badoux/goscraper"
"github.com/amcleodca/pretty-pinboard/pin-enricher/enricher"
"github.com/amcleodca/pretty-pinboard/pin-enricher/pin"
)
type Titleator struct {
log logger.FieldLogger
}
const maxRedirects = 10
func init() {... |
package main
import "context"
func main() {
println("usage: go test -v")
ACLData := `{
"logger": ["/main.Admin/Logging"],
"stat": ["/main.Admin/Statistics"],
"biz_user": ["/main.Biz/Check", "/main.Biz/Add"],
"biz_admin": ["/main.Biz/*"]
}`
listenAddr := "127.0.0.1:8082"
print(StartMyMicroservice(co... |
/*
* Flow CLI
*
* Copyright 2019-2021 Dapper Labs, 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 appl... |
package controllers
import (
"encoding/json"
"fmt"
"net/http"
"Assignment/models"
"Assignment/repository"
"github.com/sirupsen/logrus"
)
type GitUserController struct {
uow *repository.UnitOfWork
gitUserRepo repository.GitUserRepository
userRepo repository.UserRepository
Logger *logrus.Logg... |
package main
import (
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"log"
"net/http"
"os"
)
func GetRequestHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("GET request: hello, world!"))
}
func PostRequestHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("POST request: ... |
package main
import (
"bytes"
"crypto/aes"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"os"
"time"
aesCMAC "github.com/aead/cmac/aes"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
)
const (
toggleCommand = "88"
lockCommand = "82"
unlockCommand = "83"
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.