text stringlengths 11 4.05M |
|---|
package paxos
import (
"coms4113/hw5/pkg/base"
)
// Fill in the function to lead the program to a state where A2 rejects the Accept Request of P1
func ToA2RejectP1() []func(s *base.State) bool {
panic("fill me in")
}
// Fill in the function to lead the program to a state where a consensus is reached in Server 3.
f... |
package main
//region Usings
import "github.com/ravendb/ravendb-go-client"
//endregion
var globalDocumentStore *ravendb.DocumentStore
func main() {
createDocumentStore()
createDatabase()
mapIndex(2000)
globalDocumentStore.Close()
}
func createDocumentStore() (*ravendb.DocumentStore, error) {
if ... |
/*
This module is create to define all the dataType
that will be required and frequently used for the
Routing Server.
*/
package services
import "net"
// ClientsServer it is struct which combine various client's
// server parameters to clientID. So we can refer all the
// request related to clientServer can be handle... |
/*
This file include some struct about the user request:
Keep in mind: client.go is for 'wharf' and container.go is for 'docker'
*/
package server
import(
"time"
"encoding/json"
"wharf/util"
)
/*======ps request and response====*/
type PsRequest struct{
All bool
Latest bool
Name string
Image string
Type ... |
package agentconfig
import (
"errors"
"os"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/raphael-trzpit/sandgo/model"
"github.com/raphael-trzpit/sandgo/repository"
"github.com/raphael-trzpit/sandgo/repository/memory"
)
func main() {
users := make(map[int]model.User)
users[0] = model.... |
/*
Copyright 2018-2020 The Nori 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, soft... |
// Copyright 2017 Santhosh Kumar Tekuri. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package jsonschema
import "context"
// Extension is used to define additional keywords to standard jsonschema.
// An extension can implement more than ... |
package internallogger
import (
"fmt"
"testing"
)
func TestAppendInstanceID(t *testing.T) {
callpath := "/c1d87df6-56fb-4b03-a9e9-00e5122e4884"
instanceID := "105cbf37-76b9-452a-b67d-5c9a8cd54ecc"
prefix := AppendInstanceID(callpath, instanceID)
expected := callpath + "/" + instanceID
if prefix != expected {
... |
// Copyright 2016 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 camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document06100102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.061.001.02 Document"`
Message *PayInCallV02 `xml:"PayInCall"`
}
func (d *Document06100102) AddMessage() *PayInCallV02 {
d... |
package main
import (
"fmt"
"time"
"math"
"math/rand"
)
func addone(x int) int {
return x + 1
}
type Vertex struct {
Lat, Long float64
}
var m map[string]Vertex
func main() {
fmt.Println("Go in 5 minutes! By Juan F. Verhook")
fmt.Println("Go is built using packages, any program will run from ... |
// @copyright defined in aergo/LICENSE.txt
// +build !windows
package contract
const StateSqlMaxDbSize = 1024 * 1024 * 1024 * 1024
|
package main
import (
"fmt"
"os"
"strconv"
"time"
"github.com/kataras/iris"
)
func main() {
app := iris.New()
app.Get("/ping", func(ctx iris.Context) {
ctx.JSON(iris.Map{
"message": "pong",
})
})
// app.Get("/rest/hello", func(c iris.Context) {
// sleepTime, _ := strconv.Atoi(os.Args[1])
// if s... |
package sysinfo
import (
"github.com/lodastack/agent/agent/common"
)
func FsKernelMetrics() (L []*common.Metric) {
return nil
}
// exec `ps` to get all process states
func PsMetrics() (L []*common.Metric) {
return nil
}
|
package cmd
import (
"io"
"net/url"
"os"
"github.com/bkittelmann/pinboard-checker/pinboard"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func init() {
RootCmd.AddCommand(exportCmd)
}
var exportCmd = &cobra.Command{
Use: "export",
Short: "Download your bookmarks",
Long: "...",
Run: func(cmd *co... |
package main
type TrieNode struct {
endOfWordFlag bool
charToNode [26]*TrieNode
}
func NewTrieNode() *TrieNode {
return &TrieNode{false, [26]*TrieNode{}}
}
func (tn *TrieNode) AddWordFromThis(word string) {
trieNode := tn
for i := 0; i < len(word); i++ {
char := word[i]
if !trieNode.charIsExist(char) {
... |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"path/filepath"
"strings"
)
type Info struct {
Path string
Size int
}
type FileServer struct {
files map[string][]byte
}
func NewFileServer(dir string) (FileServer, error) {
m, err := LoadDirectory(dir)
if err != nil {
return FileServer{}, err
}
retur... |
package test
import "testing"
const (
Monday = iota + 1
Tuesday
Wednesday
)
const (
Readable = 1 << iota // 0001
//iota计数器,初始化为0 iota在const关键字出现时将被重置为0(const内部的第一行之前),const中每新增一行常量声明将使iota计数一次(iota可理解为const语句块中的行索引)
// 每当某个枚举被重置(即后面使用iota重新赋值时),则需要从第一个枚举数到当前的次序, ReStore的次序为3,因此重新赋值为3
Writable // 2 00... |
// Copyright 2018 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"... |
// Implementation of default vault service.
//
// @author TSS
package service
import (
"errors"
"fmt"
"os"
"path/filepath"
"github.com/mashmb/1pass/1pass-core/core/domain"
"github.com/mashmb/1pass/1pass-core/port/out"
)
type dfltVaultService struct {
itemRepo out.ItemRepo
profileRepo out.ProfileRepo
}
f... |
package configuration
type ServiceConfig struct{}
func NewServiceConfig() *ServiceConfig {
return &ServiceConfig{}
}
|
package main
import (
"github.com/dearcj/golangproj/msutil"
"github.com/dearcj/golangproj/network"
"reflect"
)
type InsertableList []msutil.Insertable
type FList []*data.Action
type ServerEffect data.Action
func IsInt32Chance(i int32) bool {
return server.Rand() < float64(i)/100.
}
func (s InsertableList) Inser... |
package main
import (
"runtime"
"time"
"fmt"
)
//go:noinline
func add(a, b int) int {
return a + b
}
func deadloop1() {
for {
add(3, 5)
}
}
func main1() {
runtime.GOMAXPROCS(1)
go deadloop1()
for {
time.Sleep(time.Second * 1)
fmt.Println("I got scheduled!")
}
}
func dummy() {
add(3, 5)
}
func de... |
package inccounter
import (
"fmt"
"github.com/iotaledger/wasp/contracts"
"github.com/iotaledger/wasp/packages/coretypes"
"github.com/iotaledger/wasp/packages/coretypes/coreutil"
"github.com/iotaledger/wasp/packages/hashing"
"github.com/iotaledger/wasp/packages/kv/codec"
"github.com/iotaledger/wasp/packages/kv/d... |
package model
import "time"
type DeleteData struct {
Path string
Recursive bool
Empty bool
CreatedBefore time.Time
NotAccessedAfter time.Time
} |
package main
import (
"fmt"
)
// 定义一个结构体,存放学生数据
type studentInfor struct{
// 注意看一下哈~~ 元素名第一个字母大写,才能被其他地方引用哦
Name string
Age int
Sex string
Address string
}
func Pout(stu map[string]studentInfor){
for k,v:=range stu{
fmt.Printf("学号:%v \n",k)
fmt.Printf("姓名:%v \n",v.Name)
fmt.Printf("性别:%v \n",v.Age)
f... |
/**
* @Author: XGH
* @Email: 55821284@qq.com
* @Date: 2020/5/14 11:42
*/
package pay
import (
"github.com/xgh2012/DesignPattern/factory/pay/alipay"
"github.com/xgh2012/DesignPattern/factory/pay/wechatpay"
)
type Methods interface {
H5() //h5支付
QrCodeFront() //正扫
QrCodePass() //被扫
App() //APP... |
package tonberry
import (
"fmt"
"github.com/zeroshade/Go-SDL/sdl"
)
type game struct {
running, fullscreen bool
screen *sdl.Surface
states []GameState
}
type Game interface {
Init(title string, w, h, bpp int, fullscreen bool)
IsRunning() bool
HandleEvents()
Draw()
Update(deltaTick... |
package service
import (
"math"
"strconv"
"github.com/fernandoporazzi/yak-shop/app/entity"
)
type HerdService interface {
GetData(days int64) (entity.HerdPayload, error)
}
type herdService struct {
herd entity.Herd
}
func NewHerdService(herd entity.Herd) HerdService {
return &herdService{herd}
}
func (s *he... |
package yaml
import "io"
type Text string
func (t Text) HasErr() bool {
return false
}
func (t Text) Output(context interface{}, prefix string, w io.Writer) {
if string(t) != "" {
_, _ = w.Write([]byte(" "))
OutputText(prefix, string(t), w)
}
}
func NewText(key interface{}, value string... |
package nude
import (
"bytes"
"fmt"
"image"
"image/color"
// register GIF to decode function
_ "image/gif"
"image/jpeg"
// register JPEG to decode function
_ "image/jpeg"
"image/png"
// register PNG to decode function
_ "image/png"
"io"
"github.com/sherifabdlnaby/prism/internal/processor/nude/gonude"
"... |
package main
import (
"flag"
"fmt"
"log"
"net"
"time"
"github.com/lab5e/lmqtt/pkg/config"
"github.com/lab5e/lmqtt/pkg/entities"
"github.com/lab5e/lmqtt/pkg/lmqtt"
_ "github.com/lab5e/lmqtt/pkg/persistence" // Default store is memory
_ "github.com/lab5e/lmqtt/pkg/topicalias/fifo" // Message handling
)
... |
package volume_test
import (
lc "github.com/LINBIT/golinstor"
lapi "github.com/LINBIT/golinstor/client"
"github.com/piraeusdatastore/linstor-csi/pkg/volume"
"github.com/stretchr/testify/assert"
"testing"
)
func TestDisklessFlag(t *testing.T) {
testcases := []struct {
name string
params volume.Paramete... |
package field
import (
"encoding/binary"
"fmt"
"io"
)
// Deck is the deck that the track is playing on in Serato.
type Deck struct {
header *Header
data []byte
}
// Value returns the deck.
func (f *Deck) Value() int {
return int(binary.BigEndian.Uint32(f.data))
}
func (f *Deck) String() string {
return fmt... |
/*
Utilizando o operador curto de declaração, atribua estes valores às variáveis com os identificadores "x", "y", e "z".
42
"James Bond"
true
Agora demonstre os valores nestas variáveis, com:
Uma única declaração print
Múltiplas declarações print
*/
package main
import (
"fmt"
)
func mai... |
package cmd
import (
"github.com/myechuri/ukd/server/api"
"github.com/spf13/cobra"
"golang.org/x/net/context"
"google.golang.org/grpc"
"log"
)
func getLog(cmd *cobra.Command, args []string) {
// TODO: TLS
serverAddress := cmd.InheritedFlags().Lookup("server-endpoint").Value.String()
conn, err := grpc.Dial(ser... |
package main
import (
"fmt"
)
func main() { //for { }
p := 0
for {
if p > 5 { // i feel if statement is a condition
break
}
fmt.Println(p)
p++
}
}
|
// GUI error dialog.
//
// @author TSS
package gui
import (
"fmt"
"github.com/jroimartin/gocui"
)
type errorDialog struct {
name string
title string
closeHandler func(ui *gocui.Gui, view *gocui.View) error
err error
}
func newErrorDialog(closeHandler func(ui *gocui.Gui, view *gocui.Vi... |
package supervisor
import (
"os/exec"
)
type Child struct {
cmd exec.Cmd
startargs string
}
func (c *Child) Start(args string) {
c.startargs = args
}
func (c *Child) Restart() {
}
|
package handlers
import (
"net/http"
"net/http/httptest"
"net/url"
"testing"
)
func TestPasswordHandlerSuccess(t *testing.T) {
req, err := http.NewRequest("POST", "/password", nil)
if err != nil {
t.Fatal(err)
}
data := url.Values{}
data.Add("password", "angryMonkey")
req.PostForm = data
req.Header.Add("... |
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
"io/ioutil"
"os/exec"
"fmt"
"runtime"
)
var filePath string
func main() {
filePath = determineFilePath()
if filePath == "" {
fmt.Errorf("can't get the file path for the operating system")
return
}
router := mux.NewRouter()
router.Handl... |
package main
import "fmt"
func main() {
var m, a, b int
fmt.Scanf("%d", &m)
fmt.Scanf("%d", &a)
fmt.Scanf("%d", &b)
oldest := m - a - b
if a > oldest {
oldest = a
}
if b > oldest {
oldest = b
}
fmt.Println(oldest)
}
|
package main
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/cfdrake/go-gdbm"
)
const MaxUint = ^uint64(0)
type Gdbm struct {
gdbm *gdbm.Database
name string
mutex sync.Mutex
}
func gdbmOpen(fname, mode string) (* Gdbm, error) {
r := new(Gdbm)
db, err := gdbm.Open(fname, mode)
r.gdbm = db
r.name = fna... |
package category
import (
"net/http"
ctl "github.com/go-jar/gohttp/controller"
"blog/controller/api"
"blog/svc/category"
)
type CategoryContext struct {
*api.ApiContext
categorySvc *category.Svc
}
func (c *CategoryContext) BeforeAction() {
c.ApiContext.BeforeAction()
c.categorySvc = category.NewSvc(c.T... |
package impl
type User struct {
Name string
}
type Tidings struct {
Name string `json:"username"`
Information string `json:"message"`
}
type DataSet struct {
Users []User
News []Tidings
}
|
package venom
import "testing"
func Test_readPartialYML(t *testing.T) {
type args struct {
btes []byte
attribute string
}
tests := []struct {
name string
args args
want string
}{
{
name: "simple",
args: args{
btes: []byte(`
foo:
- foo1
- foo2
record:
- val
- to be recorded
bar... |
package openstack
// Metadata contains OpenStack metadata (e.g. for uninstalling the cluster).
type Metadata struct {
Cloud string `json:"cloud"`
// Most OpenStack resources are tagged with these tags as identifier.
Identifier map[string]string `json:"identifier"`
}
|
package phase
import (
"github.com/davecgh/go-spew/spew"
"regexp"
"strconv"
)
var reQueryId = regexp.MustCompile(`query_id=(\d+)`)
var spewConfig = spew.ConfigState{
Indent: " ",
DisablePointerAddresses: true,
DisableCapacities: true,
SortKeys: true,
}
func getQueryId(ur... |
package main
import "fmt"
type repository interface {
Test(int) int
}
func Test(x int) int {
x = x + 1
return x
}
func (r repository) Res() {
r.Test(1)
}
func main() {
a := Res()
fmt.Println(a)
}
|
package main
import (
"html/template"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
func indexHandle(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles("templates/index.html"))
context := getData()
err := tmpl.Execute(w, context)
if err != n... |
package components
import (
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/cache"
_ "github.com/astaxie/beego/cache/redis"
)
var Cache cache.Cache
func RedisInit() {
redisconn := beego.AppConfig.String("redis_conn")
redisport := beego.AppConfig.String("redis_port")
redispwd := beego.AppConfig.Stri... |
package models
// AUser Admin User
type AUser struct {
}
func (u AUser) TableName() string {
return "a_user"
}
|
package api
import (
"github.com/gin-gonic/gin"
db "github.com/minhphong306/mindX/db/sqlc"
"github.com/spf13/cast"
"net/http"
)
func (server *Server) getListLocation(ctx *gin.Context) {
q := ctx.Request.URL.Query()
limit := cast.ToInt32(q.Get("limit"))
if limit <= 0 {
limit = 100
}
page := cast.ToInt32(q... |
package git
import (
"fmt"
"io/ioutil"
"os"
"path"
"reflect"
"runtime"
"testing"
"time"
)
func TestStash(t *testing.T) {
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)
prepareStashRepo(t, repo)
sig := &Signature{
Name: "Rand Om Hacker",
Email: "random@hacker.com",
When: time.Now(),
}
... |
package sqlite
import (
"database/sql"
"go-binar/user/domain"
"github.com/jmoiron/sqlx"
"golang.org/x/crypto/bcrypt"
)
type UserRepository struct {
DB *sqlx.DB
}
func NewUserRepositorySqlite(db *sqlx.DB) *UserRepository {
return &UserRepository{DB: db}
}
func (r UserRepository) Save(user domain.User) error {... |
package main
import "fmt"
func main() {
var num int = 10
fmt.Printf("num存放的地址——%v\n", &num)
var ptr *int
//把num的地址赋值给ptr指针变量
ptr = &num
//获取ptr指针的值,即获取指向num的地址,并修改num的值为100
*ptr = 100
fmt.Printf("num通过修改后的是存放的地址——%v\n", &num)
fmt.Printf("num通过修改后的值是存放的地址——%v", num)
}
|
package model
// User Model
type User struct {
ID uint64 `json:"_id"`
Email string `json:"email"`
Password string `json:"password"`
UUID string `json:"uuid"`
Confirmed bool `json:"confirmed"`
}
// ConfirmData --- Used in ConfirmAccount handler
type ConfirmData struct {
Email string `json:... |
package layers
type addLayerReq struct {
Name string `json:"layer_name"`
Style string `json:"style_id"`
Description string `json:"description"`
IsDefault bool `json:"is_default" description:"false"`
}
|
package fibo
import (
"testing"
)
func TestFib(t *testing.T){
var n int64 = 10
var out int64 = 55
result := Fib(n)
if result != out{
t.Error("Incorrect result", result, "not equal", out)
}
}
func TestFiboSlice(t *testing.T) {
var x, y int64
x, y = 0, 3
var arr = FiboSlice(x, y)
var arrTest = []int64{0,... |
package files
import (
"errors"
"github.com/andybar2/team/store"
"github.com/spf13/cobra"
)
var downloadParams struct {
Stage string
Path string
}
var downloadCmd = &cobra.Command{
Use: "download",
Short: "Download a file",
RunE: runDownloadCmd,
}
func init() {
downloadCmd.Flags().StringVarP(&download... |
package main
import (
"fmt"
)
var input string = "input.txt"
func Min(v ...int) int {
m := v[0]
for _, e := range v {
if e < m {
m = e
}
}
return m
}
func Max(v ...int) int {
m := v[0]
for _, e := range v {
if e > m {
m = e
}
}
return m
}
func add(nums ...int) (sum int) {
for _, n := range ... |
/*
Copyright 2022 The Flux 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, softwar... |
package codegen
import (
"context"
"path/filepath"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/solver/errdefs"
"github.com/moby/buildkit/solver/pb"
"github.com/openllb/hlb/diagnostic"
"github.com/openllb/hlb/parser"
"github.com/openllb/hlb/pkg/llbutil"
"... |
package path
import (
"encoding/json"
"fmt"
"go/build"
"os/exec"
"strings"
"github.com/pkg/errors"
"golang.org/x/tools/go/packages"
)
type Builder interface {
Build() (string, error)
ImportPackage(path string) (*build.Package, error)
}
type (
module struct {
Path string
Dir string
}
builder struct... |
package main
import (
"fmt"
"github.com/lyric-demo/wire-demo/injector"
)
func main() {
bar := injector.InitBarer()
fmt.Println(bar.Bar())
}
|
package cli
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/Ohmere03/testapplication/x/testapplication"
sdk "github.com/cosmos/cosmos-sdk/types"
authtxb "github.com/cosmos/cosmos-sdk/x... |
package main
import "math"
func primeFactors(n int) map[int]int {
factors := make(map[int]int)
i := 2
if n%i == 0 {
for n%i == 0 {
factors[i]++
n /= i
}
}
for i = 3; i <= int(math.Sqrt(float64(n))); i += 2 {
if n%i == 0 {
for n%i == 0 {
factors[i]++
n /= i
}
}
}
if n > 2 {
fact... |
package main
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
)
type PasswordSwapSystem struct {
FileName string;
Data []int;
Scratch []int;
Program []IPasswordSwapInstruction;
InstructionPointer int;
}
const PasswordSwapRotate = "rotate";
const PasswordSwapReverse = "reverse";
const PasswordSwapM... |
package ledis
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"github.com/siddontang/go/hack"
"io"
"strconv"
)
const (
kTypeDeleteEvent uint8 = 0
kTypePutEvent uint8 = 1
)
var (
errInvalidPutEvent = errors.New("invalid put event")
errInvalidDeleteEvent = errors.New("invalid delete event")
errInva... |
package kvs
import "time"
const (
// baseLockDir is the base directory for locks.
baseLockDir = "/dolb/locks"
)
var (
// lockRetryTimeout is the timeout for when a lock is active. It
// will wait for lockRetryTimeout and try again.
lockRetryTimeout = time.Millisecond * 100
)
// KLock is an interface for provin... |
package nv4
import (
"context"
"github.com/filecoin-project/go-state-types/big"
cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron"
cid "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
cron2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron"
)
type cronMigrator stru... |
package request
// id请求
type IdStruct struct {
Id uint `json:"id"`
}
|
package ghastly
import (
"fmt"
)
// Purge a URL from the CDN.
func (g *Ghastly) PurgeURL(url string) (string, error) {
resp, err := g.Purge(url)
if err != nil {
return "", err
}
pData, err := ParseJson(resp.Body)
if err != nil {
return "", err
}
if pData["status"].(string) != "ok" {
err = fmt.Errorf("St... |
package server
import (
"github.com/gin-gonic/gin"
"github.com/pgalchemy/alchemy-go-service-base/errors"
"github.com/pgalchemy/alchemy-go-service-base/logging"
"github.com/pgalchemy/alchemy-go-service-base/scope"
"github.com/sirupsen/logrus"
)
type (
// Config represents the server configuratino
Config struct ... |
// Copyright (C) 2020 Cisco Systems 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 agr... |
/*
In this challenge, you are given a date and you have to determine the correspondent season in a certain hemisphere of Earth.
You have to use the ranges given by the meteorological seasons definition, accordingly to the following table:
Start End North Hemisphere South Hemisphere
March, 1 May, 31 Spring Autumn
Jun... |
package main
import "fmt"
func main() {
// 声明一个长度为10的byte数组,并且赋值
var arr = [10]byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}
// 声明2个slice,声明方式跟数组一样;区别在于不需要声明长度
// var slice1 , slice2 []byte
var slice1 []byte
var slice2 []byte
// 赋值给slice1; 注意是冒号
slice1 = arr[2:5] // slice1=c,d,e (len = 3 , cap = 8... |
package main
import (
"net/http"
"strconv"
"io/ioutil"
)
func HandleFuck (writer http.ResponseWriter, request *http.Request) {
writer.Write([]byte("PLEASE FUCK YOURSELF\n呵呵"))
}
func main() {
http.HandleFunc("/shit", func(writer http.ResponseWriter, request *http.Request) {
writer.Write([]byte("shit你妹啊"))
})... |
package main
import (
"log"
"os"
)
var Log *log.Logger = log.New(os.Stdout, "king_albert_go ", log.Lshortfile|log.LstdFlags)
|
package memoization
import "math"
// Fibonacci Number
// time O(n)
// space O(1)
func climbStairs(n int) int {
return fibHelper(n)
}
func fibHelper(n int) int { // <=> fib(n+1)
// n is positive integer
if n <= 2 {
return n
}
c1, c2 := 1, 2
for i := 3; i <= n; i++ {
c1, c2 = c2, c1+c2
}
return c2
}
// ... |
package ibuilder
import (
"github.com/SergeyShpak/owngame/server/src/model/layers"
)
type DataLayerBuilder interface {
BuildRoomLayer() (layers.RoomsDataLayer, error)
BuildWebsocketConnectionLayer() (layers.WebsocketConnectionLayer, error)
}
|
package main
import "fmt"
func testA() {
fmt.Println("testA")
}
func testB(x int) {
//设置recover()
//在defer调用的函数中使用recover()
defer func() {
//防止程序崩溃
//recover()
fmt.Println(recover())
//if err:=recover();err!=nil {
// fmt.Println(err)
//}
}() //匿名函数
var a [3]int
a[x] = 999
}
func testC() {... |
// Copyright The OpenTelemetry 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 agre... |
package actions
func (as *ActionSuite) Test_GuestsResource_List() {
as.Fail("Not Implemented!")
}
func (as *ActionSuite) Test_GuestsResource_Show() {
as.Fail("Not Implemented!")
}
func (as *ActionSuite) Test_GuestsResource_New() {
as.Fail("Not Implemented!")
}
func (as *ActionSuite) Test_GuestsResource_Create() ... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//566. Reshape the Matrix
//In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size ... |
package main
import "fmt"
func findNumbers(nums []int) int {
count := 0
for _, num := range nums {
if len(fmt.Sprintf("%d", num))%2 == 0 {
count++
}
}
return count
}
|
package main
import (
"crypto/elliptic"
"encoding/hex"
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/mr-tron/base58"
"hash/fnv"
"math/big"
"math/rand"
"time"
)
func main() {
sKey := "04261c55675e55ff25edb50b345cfb3a3f35f60712d251cbaaab97bd50054c6ebc3... |
package proxy_test
import (
"testing"
apiconfigv1 "github.com/openshift/api/config/v1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/proxy"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
)
const (
envHTTPProxyName = "HTTP_PROXY"
envHTTPSProxyName = "HTTPS_PROXY"
envNoPr... |
package netlink
import (
"net"
)
// Link represents a link device from netlink. The Type is a string
// representing the type of device. Currently supported types include:
// "dummy", "bridge", "vlan", "macvlan", and "veth". Some of the
// members of Link only apply to some types of link devices.
type Link struct {
... |
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
//
// Copyright (c) 2011 The LevelDB Authors. All rights r... |
package paging
type Paging interface {
Next() string
Prev() string
}
|
package messages
type AuthResponse struct {
RId int64 `json:"r_id"`
UserId string `json:"user_id"`
Status int32 `json:"status"`
ErrMsg string `json:"err_msg"`
SendTime int64 `json:"send_time"`
}
|
package main
import (
"fmt"
"os"
"github.com/levigross/grequests"
homedir "github.com/mitchellh/go-homedir"
"github.com/urfave/cli"
)
func download(c *cli.Context) {
baseDir, _ := homedir.Expand("~/.atcoder_next")
os.Mkdir(baseDir, os.ModePerm)
endpointBase := "https://kenkoooo.com/atcoder/atcoder-api"
fm... |
package sleep
import (
"sync"
"time"
)
var wg sync.WaitGroup
func doSleep(v uint64) {
time.Sleep(time.Duration(v) * time.Second)
}
// Sort sorting here, consider positve integer firstly; statify stable property in this practice
func Sort(input []uint64) (result []uint64) {
for _, v := range input {
wg.Add(1)
... |
// Copyright 2023 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applica... |
/*
* @lc app=leetcode.cn id=1316 lang=golang
*
* [1316] 不同的循环子字符串
*/
package main
// @lc code=start
func distinctEchoSubstrings(text string) int {
count := 0
indexes := make([][]int, 26)
for i := 0; i < len(text); i++ {
indexes[text[i]-'a'] = append(indexes[text[i]-'a'], i)
}
for i := 0; i < len(indexes); i... |
package keeper
import (
"context"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/octalmage/gitgood/x/gitgood/types"
"google.golang.org/grpc/codes"
"google.golang.o... |
package repository
import (
"github.com/jinzhu/gorm"
. "MPPL-Modul-4-master/models/purchase"
. "MPPL-Modul-4-master/purchase"
)
type transactionRepository struct {
Conn *gorm.DB
}
func NewTransactionRepository(Conn *gorm.DB) RepositoryTransaction{
return &transactionRepository{Conn}
}
func (pr *transactionRepo... |
package coretime
import (
"testing"
"github.com/stretchr/testify/assert"
)
// TestTime runs
func TestTime(t *testing.T) {
assert := assert.New(t)
tm := Time{}
assert.True(tm.IsZero())
fixed := Fixed
assert.Equal("2009-11-10 23:00:00", DateTimeFormat(fixed))
now := Time(fixed)
assert.False(now.IsZero())
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.