text
stringlengths
11
4.05M
package abbreviation import "testing" type testCase struct { name string a string b string want bool } var testCases = []testCase{ {"simple", "abcd", "ABCD", true}, {"match", "ABCD", "ABCD", true}, {"0", "daBcd", "ABC", true}, {"1", "abcDE", "ABDE", true}, {"2", "AbcDE", "AFDE", false}, {"can replace...
package main import "testing" func TestIdentityInit(t *testing.T) { identity := Identity{} identity.Init() if len(identity.Id) != 64 { t.Errorf("Error creating identity thumbprint (identity.id), character length is %d instead of 64.", len(identity.Id)) } jwk, err := identity.GetPrivateKey() if jwk == nil ||...
package emotiva import ( "fmt" ) func (ec *EmotivaController) Status(commands []string, target interface{}) (string, error) { var command string for _, c := range commands { command = fmt.Sprintf("%s<%s/>", command, c) } body, err := ec.rw(fmt.Sprintf("<emotivaSubscription>%s</emotivaSubscription>", command), ...
//+build wireinject package network import ( "github.com/google/wire" "github.com/raba-jp/primus/pkg/backend" "github.com/raba-jp/primus/pkg/operations/network/handlers" "github.com/raba-jp/primus/pkg/operations/network/starlarkfn" "github.com/raba-jp/primus/pkg/starlark" ) func HTTPRequest() starlark.Fn { wir...
package common type BlockStoreSourceType string const ( FileStore BlockStoreSourceType = "file" BlockDevice BlockStoreSourceType = "block" ) type BlockStoreType string const ( KernelImage BlockStoreType = "kernel" DiskImage BlockStoreType = "image" ) type BlockStoreSource struct { SourceType BlockStoreSo...
package main import ( "encoding/json" "fmt" ) type Person struct { First string Last string Age int notExported string } func main() { p := Person{First: "Tyler", Last: "Mizuyabu", Age: 20, notExported: "This string won't be marshalled"} fmt.Println(p) //Will only marshal fields that ca...
// 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 rpccalls import ( "crypto/tls" "io" "net" "net/rpc" "net/rpc/jsonrpc" ) // Client - to hold RPC connections streams type Client struc...
package app import ( "fmt" "log" "net" "reflect" "github.com/math2001/boatsinker/server/utils" "github.com/mitchellh/mapstructure" ) // makes sure that there is a right amount of boats, of the right size, etc... func validBoats(boats []Boat) error { if len(boats) != len(boatsizes) { return fmt.Errorf("Inval...
package main import ( "fmt" "libofm" ) func main() { mycontent := "Dear my golang" email := libofm.NewEmail("seafooler@hust.edu.cn", "test golang email", mycontent) err := libofm.SendEmail(email) fmt.Println(err) }
package system import ( "errors" "github.com/caddyserver/caddy" ) // ParseCorefile parses a CoreDNS Corefile's 'contracore' config block. func ParseCorefile(c *caddy.Controller) { c.Next() if c.Val() != "contracore" { panic(errors.New("unexpected plugin name '" + c.Val() + "'")) } c.Next() if c.Val() != ...
package main import ( "fmt" ) func is_prime(n int64) bool { var i int64; for i = 2; i < n; i++ { if n % i == 0 { return false } } return true } func main() { var count int64 = 0 var max int64 = 100000 var i int64 for i = 2; i <= max; i++ { if ...
package main import ( "encoding/csv" "log" "os" "strings" "github.com/gocolly/colly" "github.com/wagnerfonseca/scraper-fundamentus/model" ) func main() { fileName := "fundamentus.csv" file, err := os.Create(fileName) if err != nil { log.Fatalf("Cannot create file %q: %s\n", fileName, err) return } d...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package firmware import ( "context" "fmt" "time" "chromiumos/tast/remote/firmware/fixture" "chromiumos/tast/ssh" "chromiumos/tast/testing" "chromiumos/tast/testing/h...
package service import ( "errors" "fmt" "net/http" "golang-seed/apps/auth/pkg/authconst" "golang-seed/apps/auth/pkg/models" "golang-seed/apps/auth/pkg/repo" "golang-seed/pkg/database" "golang-seed/pkg/httperror" "golang-seed/pkg/pagination" "golang-seed/pkg/sorting" ) type PermissionsService struct { } fu...
package parser_test import ( "github.com/bytesparadise/libasciidoc/pkg/types" . "github.com/bytesparadise/libasciidoc/testsupport" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("inline elements", func() { Context("in final documents", func() { It("bold text without parenthesis"...
/** * (C) Copyright IBM Corp. 2021. * * 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 agree...
package websockethub import ( "context" "errors" "net/http" "sync/atomic" "nhooyr.io/websocket" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/runtime/event" ) var ( ErrWebsocketServerUnavailable = errors.New("websocket server unavailable") ErrClientDisconnected = errors.New(...
package testsupport_test import ( "github.com/bytesparadise/libasciidoc/pkg/types" "github.com/bytesparadise/libasciidoc/testsupport" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("parse document fragment groups", func() { expected := []types.DocumentFragment{ { Position: typ...
package Copy_List_with_Random_Pointer type Node struct { Val int Next *Node Random *Node } func copyRandomList(head *Node) *Node { if head == nil { return nil } refMap := make(map[*Node]*Node) newHead := &Node{ Val: head.Val, } refMap[head] = newHead preNew := newHead cNew, cOld := newHead.Next,...
package main import ( "fmt" "google.golang.org/appengine" "google.golang.org/appengine/log" "net/http" "strings" ) func main() { http.HandleFunc("/", handleRedirection) appengine.Main() } // Handle redirection to somewhere func handleRedirection(w http.ResponseWriter, r *http.Request) { ctx := appengine.NewC...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package firmware import ( "context" "regexp" "time" "github.com/golang/protobuf/ptypes/empty" "chromiumos/tast/errors" "chromiumos/tast/remote/firmware/fixture" "ch...
package vat import ( "fmt" "testing" ) var tests = []struct { number string valid bool }{ {"", false}, {"A", false}, {"AB123A01", false}, {"ATU12345678", true}, {"ATU15673009", true}, {"ATU1234567", false}, {"BE0123456789", true}, {"BE1234567891", true}, {"BE0999999999", true}, {"BE9999999999", true}, ...
package rtmapi import ( "sync" "testing" ) func TestNewOutgoingEventID(t *testing.T) { eventID := NewOutgoingEventID() if eventID.id != 0 { t.Errorf("id value is not starting from 0. id was %d", eventID.id) return } } func TestOutgoingEventID_Next(t *testing.T) { eventID := OutgoingEventID{ id: 0, ...
package eth import ( "context" "sync" "github.com/ethereum/go-ethereum/common" ) // DecodeContractAddresses decode the contract address out of the given txs // indexed by the hashes func DecodeContractAddresses(tx []common.Hash) ([]common.Address, error) { c, err := Dial() if nil != err { return nil, err } ...
package sqlbuilder_test import ( "sqlbuilder" "testing" "github.com/stretchr/testify/assert" ) func TestParsePostgresqlURL(t *testing.T) { dbconn := sqlbuilder.ParsePostgresqlURL("postgres://postgres:password@localhost:5432/testdb1?sslmode=disable") assert.Equal(t, dbconn != nil, true) assert.Equal(t, dbconn.D...
// 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 windowarrangementcuj contains helper util and test code for // WindowArrangementCUJ. package windowarrangementcuj import ( "context" "net/http" "net/http/httpt...
package prices import ( "time" "github.com/jeb2239/diframeworks/lib/chrono" ) type PriceRecord struct { Price int Name string TimeStamp time.Time } type IStore interface { GetPrices() []PriceRecord } type Store struct { timeProvider chrono.ITimeProvider } func NewPricesStore(tp chrono.ITimeProvide...
package github import ( "testing" "github.com/stretchr/testify/assert" ) func Test_resolveEndpoint(t *testing.T) { // test that returns resolved endpoint s, err := resolveEndpoint("foo//bar/.///././../baz/../qux?q=a&x=y") assert.NoError(t, err) assert.Equal(t, "/foo/bar/qux?q=a&x=y", s) // test that returns ...
package scalar2 import ( "time" "github.com/MagalixCorp/magalix-agent/v2/kuber" "github.com/MagalixTechnologies/log-go" ) func InitScalars( logger *log.Logger, kube *kuber.Kube, observer_ *kuber.Observer, dryRun bool, ) { sl := NewScannerListener(logger, observer_) oomKilledProcessor := NewOOMKillsProcesso...
// Package match is used to test matching a bundles to a target on the command line. // // It's not used by fleet, but it is available in the fleet CLI as "test" sub // command. The tests in fleet-examples use it. package match import ( "bytes" "context" "errors" "fmt" "io" "os" "github.com/rancher/fleet/inter...
// https://leetcode.com/problems/flood-fill/ package leetcode_go func floodFill(image [][]int, sr int, sc int, newColor int) [][]int { vis := [][]bool{} for i := 0; i < len(image); i++ { tmp := []bool{} for j := 0; j < len(image[0]); j++ { tmp = append(tmp, false) } vis = append(vis, tmp) } helperP733(...
// pseudo.go implements pseudo3.23. // NOTES: // 1. Input is from stdin - c_src#readDimacsFileCreateList. // This looks a little cludgy. main()/Testxxx() should pass in a file // handle that may be os.Stdin. // 2. In RecoverFlow() use gap value based on pseudoCtx.Lowestlabel value. // 3. All timing/profiling is...
package main import ( "fmt" "os/exec" "strconv" "strings" ) // dependency describes a dependency type dependency struct { Name string // name of dependency Version string // minimum version, a.b.c Cmd string // cmd to get version } // loadDependencies load dependencies and version requirements // // TO...
/* * Copyright (C) 2018 eeonevision * * 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, publish...
package rpcconn import _ "reflect"
package entity import "time" type RecordNotFound error type MoreThanOneRecordFound error type Property int const ( Username Property = iota ID BookID StartTime EndTime StartLocation EndLocation DateCreated DateModified Version ) type Entry struct { Username *string `json:"username"` ID ...
package main import "fmt" func main() { c := make(chan int) defer close(c) go recChan(c) sendChan(c) fmt.Println("Done") } func recChan(c chan<- int) { c <- 33 } func sendChan(c <-chan int) { fmt.Printf("%v\n", <-c) }
package main import "fmt" type person struct { first string last string age int } func main() { p1 := person { first: "James", last: "Bond", age: 22, } p2 := person{ first: "Miss", last: "Moneypenny", age: 21, } fmt.Println(p1) fmt.Println(p2) fmt.Println(p1.age, p1.last) fmt.Printl...
package main import ( "github.com/lethal-bacon0/WebnovelYoinker/pkg/terminal" ) func main() { terminal.StartTerminal() }
package main import ( "math" "github.com/davecgh/go-spew/spew" ) type Point struct { x float64 y float64 } // 構造体をコピーせずに、構造体のポインタを受け取る。 func distance(p, q *Point) float64 { dx := p.x - q.x dy := p.y - q.y return math.Sqrt(dx*dx + dy*dy) } func main() { // 構造体のポインタを定義する。 var p *Point = &Point{} // va...
package main import ( "container/list" "container/ring" "fmt" ) func main() { // list l := list.New() l.PushBack("123") l.PushFront("000") for it := l.Front(); it != nil; it = it.Next() { fmt.Println(it.Value) } // ring r := ring.New(7) for i := 0; i < 10; i++ { r.Value = i r = r.Next() } for i :...
package main import "fmt" import "./src/uc" func main() { str1 := "USING package uc!" fmt.Println(uc.UpperCase(str1)) }
package main /* 题目 # Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 ...
package cmd import ( "bufio" "encoding/json" "os" "time" "github.com/freecracy/todo/task" "github.com/google/uuid" ) func AppendData(p string) error { os.Chdir(workDir) f, err := os.OpenFile(pendFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) defer f.Close() if err != nil { return err } u1, _ := uuid....
package main import "fmt" func crary(s string, num int) string { str := []byte(s) var nums = make([]int, len(str)) for i := 0; i < len(str); i++ { nums[i] = int(str[i] - 'a') } nums[0] = nums[0] + num for i := 1; i < len(nums); i++ { nums[i] = nums[i] + nums[i-1] } for i := 0; i < len(str); i++ { str[i]...
package main import ( "fmt" "syscall/js" ) var c chan bool func init() { c = make(chan bool) } func add(this js.Value, i []js.Value) interface{} { js.Global().Set("output", js.ValueOf(i[0].Int()+i[1].Int())) println(js.ValueOf(i[0].Int() + i[1].Int()).String()) return js.ValueOf(i[0].Int() - i[1].Int()) } fu...
package models import ( db "github.com/SlaF/goinbar/lib" ) type Event struct { Title string Body string } func (e Event) Say() string { stmt, err := db.DBCon.Prepare("INSERT events SET name=?, description=?") checkErr(err) _, err = stmt.Exec(e.Title, e.Body) checkErr(err) return e.Title } func checkErr(er...
package services import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "seeder/models" "time" ) type DeployerService struct { HomePageUrl string AccessToken string ApiResponse *models.ApiResponse ServerDeployments []*models.ServerDeployment HttpClient *http.Client } func ...
package main import ( "fmt" "math/big" "strconv" ) func main() { fmt.Printf("%d\n", sum(fac(100).String())) } func fac(n int) *big.Int { var result *big.Int = big.NewInt(1) for i := n; i > 0; i-- { result.Mul(result, big.NewInt(int64(i))) } return result } func sum(number string) int { var result int fo...
package main import ( "bytes" "crypto/x509" "encoding/pem" "io/ioutil" "os" "github.com/ONSdigital/go-ns/log" "github.com/ONSdigital/s3crypto" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) func main() { f, err := ioutil.ReadFile("testdata...
package mysql import ( "github.com/jinzhu/gorm" "go-sql/app/repositories" ) type Storage struct { readConn *gorm.DB writeConn *gorm.DB } func NewStorage(readConn, writeConn *gorm.DB) repositories.StorageInterface { return &Storage{ readConn:readConn, writeConn:writeConn, } }
package datagrid import ( "flood_go/graphicsx" "flood_go/text" "flood_go/misc" cfg "flood_go/config" ) // Import external packages import ( "github.com/veandco/go-sdl2/sdl" ) func NormalizeSmellColor(smell int) int { if smell == 0 { return 0} if smell < 20 { return 20} if smell < 100 { return smell} if ...
package main import ( "fmt" // "strconv" // "strings" "time" ) type IPAddr struct { When time.Time What string } //func test() { // hosts := map[string]IPAddr{ // "loopback": {127, 0, 0, 1}, // "googleDNS": {8, 8, 8, 8}, // } // // for _, ip := range hosts { // res := []string{} // for _, val := range ip ...
package main import ( "binding" "fmt" ) func main() { mas := []float64{3.0, 3.0} fmt.Println(binding.Sphere_function(mas)) fmt.Println(binding.Rastrigin_function(mas)) fmt.Println(binding.Stibinski_Tanga_function(mas)) fmt.Println(binding.Ekli_function(mas)) fmt.Println(binding.Rosenbrock_function(mas)) fmt.P...
package main import ( "bufio" "flag" "fmt" "os" "runtime" ) // a sensible default is to use the number of CPUs available var parallelism = flag.Int("parallelism", runtime.NumCPU(), "how many commands to run at a time") // parse flags and commandline args func parseArgs() { flag.Parse() if len(flag.Args()) !=...
package interaction type InteractionSaver struct{ inner Interactor responsesReceived map[string]*Response } var _ Interactor = InteractionSaver{} func NewInteractionSaver(inner Interactor) InteractionSaver { return InteractionSaver{ inner: inner, responsesReceived: map[string]*Response{}, } } func (is Inter...
package main import ( "CRUDtutor/app" "CRUDtutor/controllers" "fmt" "github.com/gorilla/mux" "net/http" "os" ) func main() { router := mux.NewRouter() router.HandleFunc("/view", controllers.ViewImage).Methods("GET") router.HandleFunc("/register", controllers.CreateAccount).Methods("POST") router.HandleFun...
// 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, ...
var res [][]int func permute(nums []int) [][]int { res = [][]int{} backTrack(nums,len(nums),[]int{}) return res } func backTrack(nums []int,numsLen int,path []int) { if len(nums)==0{ p:=make([]int,len(path)) copy(p,path) res = append(res,p) } for i:=0;i<numsLen;i++{ cur:=nums[i] path = append(path,cur)...
package main import ( "Tarea1/Logistica/logistica" "bufio" "fmt" "google.golang.org/grpc" "log" "net" "os" "strings" "sync" ) //GetOutboundIP is func GetOutboundIP() net.IP { conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { log.Fatal(err) } defer conn.Close() localAddr := conn.LocalAddr().(...
package resolver import ( "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/opsee/basic/schema" opsee_aws_ec2 "github.com/opsee/basic/schema/aws/ec2" opsee_aws_rds "github.com/opsee/basic/schema/aws/rds" opsee "github.com/opsee/basic/service" log "github.com/opsee/logrus" "golang.org/x/net/context" ) func (c...
package utils import ( "testing" ) func TestGetLinkForMessage(t *testing.T) { link := GetLinkForMessage("!linkMe mhwi_deco_rates") if link != "mhwi_deco_rates : https://mhworld.kiranico.com/decorations " { t.Errorf("link incorrect, got: %s, want: %s.", link, "mhwi_deco_rates : https://mhworld.kiranico.com/deco...
// REST API for TODO application // // Provides REST API for create, read, update and delete tasks. // // Schemes: http // BasePath: / // Version: 0.0.1 // Host: localhost // // Consumes: // - application/json // // Produces: // - application/json // // swagger:meta package rest import ...
package primitives type Lambertian struct { C Vector } func (l Lambertian) Bounce(input Ray, hit HitRecord) (bool, Ray) { direction := hit.Normal.Add(VectorInUnitSphere()) return true, Ray{hit.Point, direction} } func (l Lambertian) Color() Vector { return l.C }
// Copyright 2023 Gravitational, 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 agree...
// 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 apputil implements the libraries used to control ARC apps package apputil import ( "context" "time" "chromiumos/tast/local/chrome" ) // ARCMediaPlayer specif...
// 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 core import ( log "github.com/sirupsen/logrus" ) type Subscriber interface { Subscribe(done <-chan struct{}) (<-chan interface{}, <-chan error) Convert(done <-chan struct{}, in <-chan interface{}) <-chan interface{} Enqueue(done <-chan struct{}, in <-chan interface{}) (<-chan interface{}, <-chan error) } ...
package main type person struct { first string last string } func main() { x := person{ first: "rudi", last: "visagie", } println(x.first, x.last) changeme(&x) println(x.first, x.last) } func changeme(p *person) { (*p).first = "Hahahaha" }
package check_whether_two_strings_are_almost_equivalent func checkAlmostEquivalent(word1 string, word2 string) bool { frequencies := make(map[int32]int) for _, c := range word1 { frequencies[c]++ } for _, c := range word2 { frequencies[c]-- } for _, num := range frequencies { if abs(num) > 3 { return...
// Package reltest for unit testing database interaction. package reltest
package main import "fmt" // 定义结构体表示对象属性 type Student struct { Name string age int } // 对象的行为用方法表示 // func (方法接受者)方法名(参数)(返回值){ return value} // 值传递 func (stu Student) SayHiByValue() { stu.Name = "修改值传递对象的名字" fmt.Println("大家好,欢迎到Wovert大学。我是", stu.Name) } // 引用传递 func (stu *Student) SayHiByRef() { stu.Name = "...
package acknowledge type Acknowledge struct { SegIDX int32 } var ClosingAck = Acknowledge{ SegIDX: -1, }
package httppool import ( "net" "sync/atomic" "time" ) type Conn struct { usedAt int64 // atomic netConn net.Conn Inited bool pooled bool createdAt time.Time } func NewConn(netConn net.Conn) *Conn { cn := &Conn{ netConn: netConn, createdAt: time.Now(), } cn.SetUsedAt(time.Now()) return cn }...
// package main // import "fmt" // func main() { // var a = [...]int{1, 3, 5, 7, 8} // var sum int = 8 // for i := 0; i < len(a); i++ { // sum += a[i] // if i == len(a)-1 { // fmt.Println("这个数组的和是:", sum) // } // } // } package main import "fmt" func main() { a := [...]int{1, 2, 3, 4, 5, 6} sum :=...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "web/3w/token" ) type Instance struct { Idc string `json:"idc"` Env string `json:"env"` EnvDesc string `json:"env_desc"` Product string `json:"product"` ProductDesc string `json:"product_desc"` Ap...
package graph import ( "fmt" "sort" "sync" "time" ) const ( debug = false maxLoadAttempts = 3 ) // NodeFetcher is a function that can lazily load Node data. type NodeFetcher func(*Node) error var defaultNodeFetcher NodeFetcher = func(n *Node) error { n.SetData(true) return nil } // Node represent...
package server import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/http/httptest" "testing" ) func BenchmarkFastSimpleServer_NoParam(b *testing.B) { cfg := &Config{RouterType: "fast", HealthCheckType: "simple", HealthCheckPath: "/status"} srvr := NewSimpleServer(cfg) RegisterHealthHandler(cfg...
package main import ( "bufio" "fmt" "gopkg.in/gomail.v2" "log" "net/mail" "net/smtp" "os" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) var dial = "127.0.0.1:25" fmt.Print("dial: ") dial1, _ := reader.ReadString('\n') dial1 = strings.Replace(dial1, "\n", "", -1) if dial1 != "" { dial ...
// Package cmd provides command line processing functions // for the authentication services. package cmd import ( "fmt" "os" "github.com/dhaifley/dauth/lib" "github.com/spf13/cobra" "github.com/spf13/viper" ) var rootCmd = &cobra.Command{ Use: lib.ServiceInfo.Name, Short: lib.ServiceInfo.Short, Long: lib...
package main //641. 设计循环双端队列 //设计实现双端队列。 // //实现 MyCircularDeque 类: // //MyCircularDeque(int k):构造函数,双端队列最大为 k 。 //boolean insertFront():将一个元素添加到双端队列头部。 如果操作成功返回 true,否则返回 false 。 //boolean insertLast():将一个元素添加到双端队列尾部。如果操作成功返回 true,否则返回 false 。 //boolean deleteFront():从双端队列头部删除一个元素。 如果操作成功返回 true,否则返回 false 。 //boolea...
// よくわからんけど嘘解法っぽい // 普通に数えすぎているのに差分をとるとあっているのが、偶然なのか必然なのかわからん package main import "fmt" const ( n0 = 1 n1 = 1 n2 = 2 * n1 n3 = 3 * n2 n4 = 4 * n3 n5 = 5 * n4 n6 = 6 * n5 n7 = 7 * n6 ) var frac = [8]int{n0, n1, n2, n3, n4, n5, n6, n7} func count(n int, A [10]int) int { c := 0 var q []int for i := 0; i < ...
package syncLog import ( "fmt" "sync" ) func syncLog() func(string) { mutex := sync.Mutex{} return func(msg string) { mutex.Lock() fmt.Println(msg) mutex.Unlock() } } var Println func(string) = syncLog()
package main import ( "github.com/jyggen/advent-of-go/util" "github.com/stretchr/testify/assert" "testing" ) func TestSolvePartOne(t *testing.T) { assert.Equal(5, solvePartOne(parseInput("R2, L3"))) assert.Equal(2, solvePartOne(parseInput("R2, R2, R2"))) assert.Equal(12, solvePartOne(parseInput("R5, L5, R5, R3"...
package main import "testing" func BenchmarkPipeline(b *testing.B) { in, out := pipe(1000000) for i := 0; i < b.N; i++ { in <- 1 <-out } }
package bvg import ( "encoding/binary" // "fmt" // "fmt" "io" "math" // "os" ) // This stores the writer and commands to be written type Bvg struct { Writer io.Writer Reader io.Reader Points []*Point Lines []*Line Circles []*Circle Triangles []*Triangle Polys []*Poly Bezs ...
package _0_Front_Controller_Pattern import ( "testing" ) //步骤 4 //使用 FrontController 来演示前端控制器设计模式。 func TestFrontControllerPattern(t *testing.T) { frontController := FrontController{} tests := []struct { name string args string want string }{ {"HOME", "HOME", "Displaying Home Page"}, {"STUDENT", "STUDEN...
package modifiers import ( "fmt" "strings" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/activegate/capability" "github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/activegate/consts" "github.com/Dynatrac...
package verification import "testing" func TestConsume(t *testing.T) { t.Log(Consume("13216817777")) } func TestProduce(t *testing.T) { key := "13216817777" value := Consume(key) t.Log(Produce(key, value)) }
package grains import "errors" const Version = "1" const maxSquares int = 64 func Square(n int) (uint64, error) { if n < 1 || n > maxSquares { return uint64(0), errors.New("Invalid") } return uint64(1 << uint(n-1)), nil } func Total() uint64 { return uint64((1 << maxSquares) - 1) }
package resolver import ( "context" "shared/grpc/module" "shared/utility/glog" "shared/utility/key" clientv3 "go.etcd.io/etcd/client/v3" ) // watch status of server type watcher struct { client *clientv3.Client receiver chan []*module.ResolverMessage } func newWatcher(ctx context.Context, client *clientv3...
package jobbuilder type Trigger struct { } type SCM struct { Class string `xml:"class,attr"` Value string `xml:",chardata"` } type project struct { Description string `xml:"description"` KeepDependencies bool `xml:"keepDependencies"` SCM SC...
// Copyright 2018 The gVisor 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 agree...
package main import ( "fmt" "os" "bufio" // "strings" ) // 文字列を1行入力 func StrStdin() (chan string) { fmt.Printf("Could you put your name?:") scanner := bufio.NewScanner(os.Stdin) scanner.Scan() a := scanner.Text() j := make(chan string) j <- a return j } func main() { // ...
package component import "github.com/maxence-charriere/go-app/v7/pkg/app" type MainLayout struct { app.Compo } func (l *MainLayout) Render() app.UI { return app.Div().ID("layout").Class("content").Body( NewNoteList(), NewArticle(), ) }
// 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 Routes import ( "github.com/victorneuret/WatcherUpload/server/Config" "log" "net/http" "os" ) func remove(_ http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { log.Println(err) return } filePath := r.Form.Get("file") if filePath == "" { log.Println("Missing 'file' para...
package ledger import "embed" //go:embed frontend var Frontend embed.FS
package handler import ( "errors" "fmt" "time" redis "github.com/tokopedia/go-redis-server" "github.com/tokopedia/redisgrator/config" "github.com/tokopedia/redisgrator/connection" ) type RedisHandler struct { redis.DefaultHandler Start time.Time } // GET func (h *RedisHandler) Get(key string) ([]byte, error...
// 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, ...