text stringlengths 11 4.05M |
|---|
package rest
import "encoding/json"
type JsonrpcMessage struct {
Version string `json:"jsonrpc"`
ID json.RawMessage `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Error *jsonError `json:"error,omitempty"`
Result jso... |
package backend
import (
"encoding/json"
"fmt"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"net/http"
)
func init() {
http.HandleFunc("/api/new-game", initializeGame)
http.HandleFunc("/api/board-state", commitBoardState)
}
func initializeGame(w http.ResponseWriter, r *http.Request) {
c :=... |
// +build levigo
package storage
import (
"log"
"github.com/janelia-flyem/dvid/dvid"
"github.com/janelia-flyem/go/levigo"
)
const (
Version = "github.com/janelia-flyem/go/levigo"
// Default size of LRU cache that caches frequently used uncompressed blocks.
DefaultCacheSize = 768 * dvid.Mega
// Default # bi... |
// Copyright 2020 Yaacov Zamir <kobi.zamir@gmail.com>
// and other contributors.
//
// 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
//
// U... |
package crypto
import (
"encoding/hex"
"errors"
"fmt"
"github.com/cume-go/c-fabric-wallet/address"
"github.com/minio/blake2b-simd"
"reflect"
"sort"
"strings"
)
type Key struct {
PrivateKey []byte
PublicKey []byte
Address address.Address
}
func NewKey(pk []byte) (*Key, error) {
//pk, err := hex.DecodeS... |
package note
import (
"fmt"
"github.com/aleale2121/Golang-TODO-Hex-DDD/internal/constant/model"
"github.com/aleale2121/Golang-TODO-Hex-DDD/internal/storage/postgress"
)
//var ErrDuplicate = fmt.Errorf("title already exist")
type UseCase interface {
GetAllNotes() ([]model.Note, []error)
FindNoteByID(uint) (*mode... |
package report
import (
"encoding/json"
"fmt"
"github.com/cldcvr/api-automation-framework/model"
"github.com/gavv/httpexpect"
"github.com/slack-go/slack"
"os"
"testing"
)
var (
module = "SlackNotification"
httpRequest *model.HttpRequest
)
var section []*slack.SectionBlock
// Body to create slack body... |
package types
import (
"sync"
)
// IService
type IService interface {
Name() string
IsRunning() bool
Go(waitGroup *sync.WaitGroup)
}
|
/**
* Copyright 2019 Comcast Cable Communications Management, LLC
*
* 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 requir... |
// hash64db project doc.go
/*
hash64db document
*/
package quickdatafile
|
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00700107 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.007.001.07 Document"`
Message *TransferInConfirmationV07 `xml:"TrfInConf"`
}
func (d *Document00700107) AddMe... |
// Copyright 2020 Frederik Zipp. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This example was ported from:
// https://codepen.io/eltonkamami/pen/ECrKd
// Original copyright:
//
// Copyright (c) 2020 by Elton Kamami (https://codepen.io/... |
package utilities
import (
"os"
"path"
"time"
"github.com/lestrrat-go/file-rotatelogs"
"github.com/pkg/errors"
"github.com/rifflock/lfshook"
log "github.com/sirupsen/logrus"
)
func init() {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
// Output to stdout in... |
package fstestutil
import (
"errors"
"io/ioutil"
"log"
"os"
"testing"
"time"
"gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse"
"gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs"
)
// Mount contains information about the mount for the test to use.
type Mount struct {
// Dir is the t... |
package platform
// This file contains extensions to vsock handling on Linux. This is derived
// from github.com/linuxkit/virtsock/pkg/vsock.
/**
* Copyright 2016-2017 The authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License... |
package queues
import (
"log"
"github.com/alexis-aguirre/RabbitMQ-crash-course/util"
"github.com/streadway/amqp"
)
const (
EXCHANGE_TYPE string = "topic"
PARKING_SUFIX string = ".parking"
DEAD_LETTER_QUEUE_SUFIX string = ".dead-letter-queue"
NO_TTL int = 0
)
var globalConfig util.Config
... |
// 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 main
func main() {
server := NewServer(5000)
server.Handle("/min", "POST", HandleMin)
server.Handle("/max", "POST", HandleMax)
server.Handle("/avg", "POST", HandleAvg)
server.Handle("/median", "POST", HandleMedian)
server.Handle("/percentile", "POST", HandlePercentile)
server.Listen()
}
|
/*
NOTE :
- there's MANUAL cleaning data in input
-> you can create a script to get all unique string,then manually fix it and ctrl+h
-> this one kindda hard due extreme data
ex:
b4 : Quad-core 1.3 GHz Cortex-A53
a4 : Quad-core 1.3 GHz
b4 : 1.2 GHz
a4 : Single-core 1.2 GHz
*/
package cpu
import (
util "g... |
package plain
import (
"github.com/fogleman/gg"
"math"
)
/*Dibuja colores hasta W y H usando suma para red(izq->der) y green(arr->abj) y resta para blue(
izq+arr->der+abj)*/
func DrawBasic(w, h float64) *gg.Context {
dc := gg.NewContext(int(w), int(h))
for x := 0.0; x < w; x++ {
for y := 0.0; y < h; y++ {
... |
package service
type Event interface {
Name() string
}
type ReplyEvent struct {
InReplyToID string `json:"in_reply_to_id"`
Acct string `json:"acct"`
Body string `json:"body"`
Visibility string `json:"visibility"`
}
func (*ReplyEvent) Name() string {
return "events.reply"
}
type UpdateEvent stru... |
package main
import (
"fmt"
"github.com/gcash/bchd/chaincfg"
"github.com/gcash/bchutil"
)
func main() {
chain := &chaincfg.TestNet3Params
addrStr := "qz32sqj8jwjfs8uxa36anlnx747fln0drs4n42hu3p"
addr, err := bchutil.DecodeAddress(addrStr, chain)
if err != nil {
fmt.Printf("%v", err)
return
}
fmt.Println(... |
//
// Copyright 2020 The AVFS 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 ag... |
/*
http://www.apache.org/licenses/LICENSE-2.0.txt
Copyright 2016 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required ... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//258. Add Digits
//Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
//For example:
//Given num = 3... |
package util
import (
"context"
"fmt"
"io"
"net"
"os"
"github.com/sirupsen/logrus"
"go.elastic.co/apm/module/apmlogrus"
)
var log = &logrus.Logger{
Hooks: make(logrus.LevelHooks),
Level: logrus.DebugLevel,
Formatter: &logrus.JSONFormatter{
FieldMap: logrus.FieldMap{
logrus.FieldKeyTime: "@timestamp",... |
// Write a Go program that finds the average value of floating-point numbers that
// are given as command-line arguments.
// @author :- Ankita & Suraj
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
var average = 0.0
var sum = 0.0
if len(os.Args) == 1 {
fmt.Println("Please prvoide some input")
} e... |
// Package utilities Internal API response
package utilities
// CentralDispatcherAPIResponse The Amazon Seller Tool response
type CentralDispatcherAPIResponse struct {
Version int `json:"version"`
Success bool `json:"success"`
Status int `json:"status"`
Results []string `json:"results"`
Error str... |
package types
type Function struct {
ID string
Name string
GoPackageName string
Inputs []Field
Outputs []Field
Body string
}
// func (f *Function) GoPackageName() string {
// validchars := "abcdefghijklmnopqrstuvwxyz"
// name := ""
// for _, char := range strings.ToLower(f.Name) {
// if strings.ContainsRun... |
package usecase
import (
"TechnoParkDBProject/internal/app/forum"
"TechnoParkDBProject/internal/app/posts"
"TechnoParkDBProject/internal/app/posts/models"
"TechnoParkDBProject/internal/app/thread"
threadModels "TechnoParkDBProject/internal/app/thread/models"
"TechnoParkDBProject/internal/app/user"
"TechnoParkDB... |
package local
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
// GraphQLStructure represents the Realm app graphql structure
type GraphQLStructure struct {
Config map[string]interface{} `json:"config,omitempty"`
CustomResolvers []map[string]interface{}... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/9/5 10:00 上午
# @File : lt_69_x的平方根.go
# @Description :
# @Attention :
*/
package offer
func mySqrt(x int) int {
l, r := 0, x
ret := 0
for l <= r {
mid := l + (r-l)>>1
if mid*mid <= x {
ret = mid
l = mid + 1
} else {
r = mid - 1
}
}
retu... |
package main
import (
"fmt"
"testing"
"com/pdool/Core"
)
type TestI struct {
}
func (t *TestI)Handle(obj int, scenId int, groupId int, args interface{}){
fmt.Println(t)
}
func TestStack(t *testing.T) {
t1 := new(TestI)
t2 := new(TestI)
fmt.Println(t1 == t2)
}
func main() {
t1 := Core.NewGuid()
t2 := Core.Ne... |
package main
import (
"log"
"net/http"
"strconv"
"time"
"github.com/gin-gonic/gin"
rotatelogs "github.com/lestrrat/go-file-rotatelogs"
"github.com/skrip42/grabbitLayer/internal/config"
"github.com/skrip42/grabbitLayer/internal/executor"
"github.com/skrip42/grabbitLayer/internal/message"
"github.com/skrip42/... |
package ksuid
import (
"encoding/binary"
"net"
)
// PartitionFunc is a func which returns a partition for the
type PartitionFunc func() uint32
// StringPartitioner uses the first four bytes of the given string to partition.
func StringPartitioner(v string) PartitionFunc {
val := binary.BigEndian.Uint32([]byte(v))... |
/**
* day 03 2020
* https://adventofcode.com/2020/day/3
*
* compile: go build main.go
* run: ./main < input
* compile & run: go run main.go < input
**/
package main
import (
"bufio"
"fmt"
"os"
)
var hill []string // the grid...or ski hill
var hillLen int
/* ride the toboggan down the hill and hit some... |
package utils
import (
"archive/zip"
"bytes"
"encoding/gob"
"encoding/json"
"fmt"
"html/template"
"io"
"math"
"net/http"
"net/url"
"os"
"path/filepath"
"reflect"
"regexp"
"strconv"
"strings"
textTmpl "text/template"
"time"
"github.com/NebulousLabs/fastrand"
)
func Uuid(length int64) string {
ele ... |
package util
import (
"fmt"
"regexp"
"strings"
)
func ParseNametoHandle(name string) string {
s := strings.Split(name, " ")
for i := 0; i < len(s); i++ {
s[i] = strings.ToLower(s[i])
s[i] = removeVietnameseTones(s[i])
}
fmt.Println(strings.Join(s, "----"))
return strings.Join(s, "-")
}
func removeVietnam... |
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strings"
)
var alphabet map[rune][]byte
func main() {
if len(os.Args) != 2 {
usage()
}
phone := os.Args[1]
alphabet = map[rune][]byte{
'0': []byte{0x3E, 0x51, 0x49, 0x45, 0x43, 0x3E},
'1': []byte{0x42, 0x7F, 0x7F, 0x40},... |
package parameters
import "flag"
var (
// Verbose provide more debugging output
Verbose *bool
// Testing do not write influxdb
Testing *bool
)
func init() {
Verbose = flag.Bool("verbose", false, "provide more debugging output")
Testing = flag.Bool("test", false, "do not write influxdb")
}
|
/***
SOURCE CODE: https://github.com/goinaction/code
*/
package main
import (
"log"
"os"
_ "github.com/zhoujiagen/quickstart/matchers"
"github.com/zhoujiagen/quickstart/search"
)
// 在main之前调用
func init() {
// 输出到stdout
log.SetOutput(os.Stdout)
}
func main() {
// 执行搜索
search.Run("president")
}
|
package models
import (
"context"
"errors"
"log"
"reflect"
"sync"
"time"
"github.com/olivere/elastic/v7"
"github.com/spf13/viper"
)
type DatabaseElastic struct {
Client *elastic.Client
IndexName string `default:"terradex"`
}
var lock = &sync.Mutex{}
func (d *DatabaseElastic) newClient() error {
log.P... |
package main
import (
"github.com/semi-technologies/contextionary/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func GrpcErrFromTyped(err error) error {
if err == nil {
return nil
}
switch err.(type) {
case errors.InvalidUserInput:
return status.Error(codes.InvalidArgument, err.... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-07-05 13:22
# @File : main.go
# @Description :
# @Attention :
*/
package main
import "examples/blockchain/solo/solo_single_org/test"
func main() {
test.TestRegistration()
}
|
package utils
import (
"fmt"
"net"
)
const (
// Host is the service addr.
Host = "127.0.0.1"
// LocalPort is the client access port.
LocalPort int = 80
// RemotePort is the server listen port.
RemotePort int = 8808
)
// ClientHandler handles a conn to the server.
func ClientHandler(r net.Conn, localPort int)... |
package rank
import (
"fmt"
"strconv"
"github.com/sirupsen/logrus"
"gitlab.com/oiacow/nextfesl/network"
)
type ansUpdateStats struct {
Txn string `fesl:"TXN"`
Users []userStats `fesl:"u"`
}
type userStats struct {
OwnerID int `fesl:"o"` // 3
OwnerType int `fesl:"ot"` // 1
Stat... |
package main
import (
"fmt"
"sync"
)
type PingPong struct {
Counter int
}
func PingPongFunc() {
chA := make(chan *PingPong)
chB := make(chan *PingPong)
var p PingPong
var wg sync.WaitGroup
fmt.Println(1)
wg.Add(2)
fmt.Println(2)
go func() {
fmt.Println(5)
defer wg.... |
package verifier
import (
"archive/tar"
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"os"
"regexp"
"github.com/google/go-containerregistry/pkg/v1"
)
/*
utilities for verifying docker export tar files
it makes several very important assumptions
- the registry manifest *also* is in the tar file, name... |
package main
import (
"fmt"
)
func lengthOfLastWord(s string) int {
lastValidIndex := len(s) - 1
for j := len(s) - 1; j >= 0; j-- {
if s[j] == ' ' {
lastValidIndex--
} else {
break
}
}
var k int
for k = lastValidIndex; k >= 0; k-- {
if s[k:k+1] == " " {
break
}
}
return lastValidIndex - k
}... |
/*
* @lc app=leetcode.cn id=560 lang=golang
*
* [560] 和为K的子数组
*/
package main
import "fmt"
// 前缀和:nums 的第 0 项到 当前项 的和。
// 用数组 prefixSum 表示,prefixSum[x]:第 0 项到 第 x 项 的和。
// prefixSum[x] = nums[0] + nums[1] + …+ nums[x]
// nums 的某项 = 两个相邻前缀和的差:
// nums[x] = prefixSum[x] - prefixSum[x - 1]
// nums 的 第 i 到 j 项 的和,有:
... |
package apper
import (
"github.com/gin-gonic/gin"
"github.com/willerhe/webbase/configer"
"log"
"strconv"
)
type App struct {
*gin.Engine
}
func New(opts ...func(e *App)) *App {
a := new(App)
a.Engine = gin.Default()
if len(opts) > 0 {
opts[0](a)
}
return a
}
func (a *App) Start() {
if err := a.Run(":" ... |
package models
import (
"backend/utils/logging"
"backend/utils/setting"
"github.com/casbin/casbin"
"github.com/casbin/casbin/util"
gormadapter "github.com/casbin/gorm-adapter"
"strings"
_ "github.com/go-sql-driver/mysql"
)
type CasbinModel struct {
PType string `json:"p_type" gorm:"column:p_type" descriptio... |
package Problem0424
func characterReplacement(s string, k int) int {
// count 在 for 循环中,记录了
// s[left:right+1] 中的各个字母出现的次数
// max 保存着整个 for 循环中, count 中每次创下的新高
var max, left int
count := [128]int{}
// 在 for 循环中, s[left:right+1]
// 要么,由于 max 变大, 向右 扩张 一格
// 要么,由于 max 不变, 向右 移动 一格
// 但是,s[left:right+1] 的长度... |
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
counts := make(map[string]int)
locations := make(map[string][]string)
files := os.Args[1:]
if len(files) == 0 {
countLines(os.Stdin, counts)
} else {
for _, file := range files {
f, err := os.Open(file)
if err != nil {
fmt.Fprin... |
package main
import (
"fmt"
"net/http"
"github.com/andysctu/jobcoin/mixer"
)
func main() {
http.HandleFunc("/getDepositAddressForMixing", mixer.GetDepositAddressForMixing)
http.ListenAndServe(":9001", nil)
fmt.Println("Ready for mixing on port 9001")
}
|
package util
import (
"log"
"os"
"io"
"io/ioutil"
)
func OpenTempFile(name string) *os.File {
rw, err := ioutil.TempFile("", name + ".tmp.")
if err != nil {
log.Fatal(err)
}
return rw
}
func OpenFile(fname string) *os.File {
if fname == "" {
return nil
}
f, err := os.Create(fname)
... |
package awsclient
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"path"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
)
type mockS3Client struct {
s3iface.S3API
files map[string]interface{}
// files map[string][]byte this is for later
}
func (m *mockS3Client) GetObject... |
// 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 main
// ˄
type LazySupporter struct {
// ˅
// ˄
Supporter
// ˅
// ˄
}
func NewLazySupporter(name string) *LazySupporter {
// ˅
return &LazySupporter{Supporter{name: name}}
// ˄
}
// No troubles are handled.
func (self *LazySupporter) Handle(trouble *Trouble) bool {
// ˅
return false
// ˄... |
package uimode
import (
"github.com/pingcap/tidiff/executor"
"github.com/pingcap/tidiff/history"
"github.com/rivo/tview"
)
type UI struct {
app *tview.Application
recorder *history.Recorder
executor *executor.Executor
// panels
sqlStmt *tview.InputField
history *tview.List
mysqlPanel *tview.Text... |
package golang
import (
"github.com/CsYakamoz/leetcode/lib/golang/structure"
)
type ListNode = structure.ListNode
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func mergeInBetween(list1 *ListNode, a int, b int, list2 *ListNode) *ListNode {
head :=... |
// Disk package contains abstract data-types to define disk-related entities.
//
// PartitionTable, Partition and Filesystem types are currently defined.
// All of them can be 1:1 converted to osbuild.QEMUAssemblerOptions.
package disk
import (
"sort"
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild1"
... |
package appdynamics
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"strconv"
"testing"
)
func TestAccAppDHealthRule_basicSingleMetricAllBts(t *testing.T) {
name := accte... |
package recurring
import (
"github.com/hokora/bank/ipc"
"github.com/hokora/bank/util"
)
func (s *Server) GetAllHandler(ctx *ipc.Context) {
pr := util.NewPacketReader(ctx.Packet)
aid := string(pr.ReadBytesWithLenUInt8())
rps, err := s.processor.GetAllFrom(aid)
if err != nil {
ctx.Reply(false, []byte{})... |
package sqlc
import (
"bytes"
"database/sql"
"io"
"fmt"
"reflect"
"time"
"github.com/jmoiron/sqlx"
)
type PredicateType int
type JoinType int
type Dialect int
const (
EqPredicate PredicateType = iota
GtPredicate
GePredicate
LtPredicate
LePredicate
InPredicate
)
const (
Join JoinType = iota
LeftOuter... |
package grpc
import (
"context"
"crypto/tls"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
// ServerConfig contains the settings for a gRPC server.
type ServerConfig struct{}
// ServerFactory creates gRPC servers.
type ServerFactory struct {
Options []grpc.ServerOption
}
// Config generates ... |
package 链表
const INF = 1000000000000
func insertionSortList(head *ListNode) *ListNode {
dummyHead := &ListNode{Val: -INF}
cur := head
for cur != nil {
next := cur.Next
insertIntoList(dummyHead, cur)
cur = next
}
return dummyHead.Next
}
func insertIntoList(dummyHead *ListNode, node *ListNode) {
// 这个函数会影响... |
// Copyright (c) 2022, The Garble Authors.
// See LICENSE for licensing information.
package linker
import (
"bytes"
"crypto/sha256"
"embed"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"github.com/bluekeyes/go-gitdiff/gitdiff"
"github.com/rogp... |
/*
Copyright 2019 The Knative 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, sof... |
package httpclient
import (
"net/http"
)
// RoundTripper is the interface that handles all HTTP operations. It is almost
// exclusively used with an http.Client wrapped around it. This is included here
// for documentation purposes only.
type RoundTripper = http.RoundTripper
|
package consumergroup
import (
"github.com/dzch/kazoo-go"
"testing"
)
func Test_PartitionDivision(t *testing.T) {
consumers := kazoo.ConsumergroupInstanceList{
&kazoo.ConsumergroupInstance{ID: "consumer1"},
&kazoo.ConsumergroupInstance{ID: "consumer2"},
}
partitions := []partitionLeader{
partitionLeader{... |
package sum
func Sum(a, b int) int |
package mapxml
import (
// "encoding/xml"
)
type tmxXY struct {
X int `xml:"x,attr"`
Y int `xml:"y,attr"`
}
type tmxWidthHeight struct {
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
} |
package car
//Car is the object that will be used in traffic situations for filling stalls in a parking lot
type Car struct {
license string //License plate number for the car
}
//SetLicensePlateNum sets the license plate number for a car
func (c *Car) setLicensePlateNum(num string) {
c.license = num
}
//GetLicens... |
package main
import "fmt"
func main() {
// MAPS DEVEM SER INICIALIZADOS
// var aprovados map[int]string => ASSIM SÓ CRIA
aprovados := make(map[int]string)
aprovados[1234567897] = "Maria"
aprovados[9765432125] = "Pedro"
aprovados[5679123458] = "Ana"
fmt.Println(aprovados)
for cpf, nome := range aprovados... |
package lcd
import (
"fmt"
"net/http"
"github.com/irisnet/irishub/app/protocol"
"github.com/irisnet/irishub/app/v1/params"
"github.com/irisnet/irishub/client/context"
"github.com/irisnet/irishub/client/utils"
"github.com/irisnet/irishub/codec"
)
// nolint: gocyclo
func queryParamsHandlerFn(cdc *codec.Codec, c... |
package xmpp
import (
"encoding/base64"
"crypto/rand"
"crypto/hmac"
"hash"
"strings"
"strconv"
"fmt"
"encoding/xml"
)
func saslAuthentication(stream *Stream, user, password string, handler authHandler) error {
var challengeText []byte
initial_message, err := handler.Mechanism.initialMessage(user, passwor... |
package spool
import (
"fmt"
"google.golang.org/api/option"
)
type Config struct {
projectID string
instanceID string
databaseID string
opts []option.ClientOption
}
func NewConfig(projectID, instanceID, databaseID string, opts ...option.ClientOption) *Config {
return &Config{
projectID: projectID,
... |
package postgres
import (
"github.com/go-pg/pg/v9"
"todo/domain"
)
type TodoRepo struct {
DB *pg.DB
}
func (t *TodoRepo) GetByID(id int64) (*domain.Todo, error) {
todo := new(domain.Todo)
err := t.DB.Model(todo).Where("id = ?", id).First()
if err != nil {
return nil, err
}
return todo, err
}
func (t *To... |
package models
type GUSResource struct {
GUSResourceId int `json:"GUSResourceId,omitempty" db:"GUSResourceId"`
GUSResourceNamePl string `json:"GUSResourceNamePl" db:"GUSResourceNamePl"`
GUSResourceNameEn string `json:"GUSResourceNameEn,omitempty" db:"GUSResourceNameEn"`
GUSId string `json:"GUS... |
package worker
import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
"unicode"
"github.com/DataDog/hyperloglog"
"github.com/giolekva/unique/rpc"
"golang.org/x/net/html"
)
type StatsConsumer func(rpc.WorkerStatistics, *hyperloglog.HyperLogLog, []string)
type docStats struct {
hll *hyperloglog.Hyp... |
package unmarshalers
import (
"crypto/md5"
"errors"
"fmt"
"github.com/Hexilee/gotten/headers"
"io"
"io/ioutil"
"mime"
"net/http"
"os"
"path"
"path/filepath"
)
type (
FilenameStrategy int
FileCtrBuilder struct {
basePath string // Default: wd
extensionName string // .xxx; ord... |
package user
//Message
const (
FIND_USER_FAILED = "Failed to find tasks"
)
const (
USER_COLLECTION_NAME = "users"
)
|
/*
The MIT License (MIT)
Copyright (c) 2019 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... |
package 字符串
func maxPower(s string) int {
if len(s) == 0 {
return 0
}
curChar := s[0]
curPower := 1
maxPower := 1
for i := 1; i < len(s); i++ {
if s[i] != curChar {
curPower = 1
curChar = s[i]
continue
}
curPower++
maxPower = max(maxPower, curPower)
}
return maxPower
}
func max(a, b int) in... |
package services
import (
"github.com/MEIGUOSHU/meiguoshu_api_server/models"
"github.com/MEIGUOSHU/meiguoshu_api_server/utils"
)
func CreateApplication(app *models.Application) (*models.Application, error) {
res, err := app.Create(utils.DB)
return res, err
}
func UpdateApplication(app *models.Application) (*mode... |
package slice
func RemoveString(slice []string, element string) []string {
for i, v := range slice {
if element == v {
return append(slice[:i], slice[i+1:]...)
}
}
return slice
}
func ContainsString(slice []string, element string) bool {
for _, item := range slice {
if item == element {
return true
... |
package leetcode
import "strings"
func findOcurrences(text string, first string, second string) []string {
var prev1, prev2 string
ans := []string{}
for _, s := range strings.Split(text, " ") {
if prev1 == first && prev2 == second {
ans = append(ans, s)
}
prev1, prev2 = prev2, s
}
return ans
}
|
package scratch
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
type ProjectSearch struct {
Fields Fields `json:"fields"`
ImageURL string `json:"image_url"`
Model string `json:"model"`
Pk int `json:"pk"`
}
type Fields struct {
Creator Creator `json:"creator"`
F... |
package main
import (
"net/http"
"fmt"
"github.com/gorilla/mux"
"encoding/json"
"io/ioutil"
"os/exec"
"log"
"strconv"
"strings"
)
func EmailOU(w http.ResponseWriter, res *http.Request) {
params := mux.Vars(res)
emailAddress := params["email"]
data := []byte(emailAddress)
var hash uint32 = 0
for _, valu... |
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func init(){
r := mux.NewRouter()
r.HandleFunc("/", homeHandler)
r.HandleFunc("/about", aboutHandler)
r.HandleFunc("/games", gamesHandler)
r.HandleFunc("/pixelart",pixelartHandler)
r.HandleFunc("/test",testHandler)
r.PathPr... |
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0.
//go:build go1.18
package restore_test
import (
"testing"
backup "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/tidb/br/pkg/restore"
"github.com/pingcap/tidb/br/pkg/rtree"
"github.com/pingcap/tidb/tablecodec"
)
func FuzzMerge(f *testing.F) {... |
package chartjs
import (
"bytes"
"encoding/json"
"fmt"
"html/template"
template2 "github.com/GoAdminGroup/go-admin/template"
)
type PieChart struct {
*Chart
JsContent PieJsContent
}
type PieJsContent struct {
JsContent
Data PieAttributes `json:"data"`
}
type PieAttributes struct {
Attributes
DataSets... |
package mongo
import (
// Standard Library Imports
"context"
"time"
// External Imports
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
"github.com/ory/fosite"
"github.com/pborman/uuid"
"github.com/sirupsen/logrus"
// Internal Imports
"github.com/matthewhartstonge/storage"
)
// UserManager p... |
package cmd
import "testing"
func TestDelta(t *testing.T) {
// this is a critical fcn that must work for any rectangular
// chunk of the world, possibly spanning the 0 long and 0 lat.
deltaT(t, 100, 100, [4]float64{50, 40, 10, 0}, 10000, 10000)
deltaT(t, 1000, 1000, [4]float64{-50, -60, 10, 0}, 10000, 10000)
del... |
// Copyright 2023 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 marusia
type Request struct {
Meta struct {
ClientId string `json:"client_id"`
Locale string `json:"locale"`
Timezone string `json:"timezone"`
Interfaces struct {
Screen struct{} `json:"screen"`
} `json:"interfaces"`
} `json:"meta"`
Request struct {
Command string `json:"co... |
package other
func TwoSum(nums []int, target int) []int {
var aMap = make(map[int]int)
for i := 0; i < len(nums); i++ {
idx, ok := aMap[target-nums[i]]
if ok {
return []int{idx, i}
}
aMap[nums[i]] = i
}
return []int{-1, -1}
}
|
package wrcrux
import (
"fmt"
"io"
"sync"
"sync/atomic"
)
// Mode :nodoc:
type Mode int
const (
defaultBufferCapacity = 1024
)
// These flag defines the flushing priorities
const (
Buffered Mode = 1 << iota
Immediate
)
// Wrcrux :nodoc:
type Wrcrux interface {
io.Writer
io.Closer
AddWriter(writer io.Writ... |
/**
* Copyright (c) 2018 ZTE Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and the Apache License 2.0 which both accompany this distribution,
* and are available at http://www.eclipse.org/legal/epl-v10.html
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.