text
stringlengths
11
4.05M
package lambda import ( "bytes" "context" "encoding/base64" "encoding/json" "errors" "io/ioutil" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/lambda" "github.com/luraproject/lura/v2/config" "gi...
// Copyright 2021 Google 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 required by applicable law or agreed to in ...
package lv2_rectangular func gcd(min, max int) int { rem := min % max if rem == 0 { return max } return gcd(max, rem) } func minAndMax(a, b int) (int, int) { var min, max int if a > b { max = a min = b } else { max = b min = a } return min, max } func solution(w int, h int) int64 { min, max := m...
package cashlessdevice import ( "testing" ) func Test_validateCrc(t *testing.T) { type args struct { c []byte } tests := []struct { name string args args want bool }{ { name: "test true", args: args{ c: []byte{0x03, 0x00, 0x96, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x59}, }, want: true, }, ...
package mysql import ( "fmt" "strings" ) type Index struct { Name string `yaml:"name,omitempty"` Type string `yaml:"type,omitempty"` Fields string `yaml:"fields,omitempty"` Extend string `yaml:"-"` } func (p *Index) Hash() string { return "" } func (p *Index) Complete() { p.Type = strings.ToUpper(p.Typ...
package awssqs import ( "log" "strconv" "strings" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" ) var emptyOpList = make([]OpStatus, 0) var emptyMessageList = make([]Message, 0) // this is our interface implementation type awsSqsImpl st...
package config type Config struct { DbConnString string `split_words:"true" required:"true"` Port int `split_words:"true" required:"true"` MigratesDir string `split_words:"true" required:"true"` }
package tumblr type Activity struct { Id string `json:"id"` Action string `json:"action"` Blog Blog `json:"blog"` }
package arithmetic import "testing" func TestMaxI64(t *testing.T) { if MaxI64() != LOWER_BOUND_I64 { t.FailNow() } if MaxI64(1024) != 1024 { t.FailNow() } if MaxI64(3, 5) != 5 { t.FailNow() } if MaxI64(1, 3, 5) != 5 { t.FailNow() } } func TestMinI64(t *testing.T) { if MinI64() != UPPER_BOUND_I64 ...
package system import ( "yj-app/app/controller/system/config" "yj-app/app/service/middleware/auth" "yj-app/app/yjgframe/router" ) //加载路由 func init() { // 参数路由 g1 := router.New("admin", "/system/config", auth.Auth) g1.GET("/", "system:config:view", config.List) g1.POST("/list", "system:config:list", config.List...
package cli import ( "errors" "fmt" "strings" ) type commandType uint const ( None commandType = iota Help AddResource RemoveResource Info Exit ) /* cliCommand provides default structure of cli option Args: ct - Shows the type of the command short - (optional) short name of an option long - long n...
package sqlite import ( "fmt" ) func SQLiteCount(db *SQLiteDB, tbl_name string) (int64, error) { if conn, err := db.GetConn(true); nil == err { if row := conn.QueryRow(fmt.Sprintf("SELECT COUNT(*) FROM %s", tbl_name)); nil != row { var cnt int64 if err := row.Scan(&cnt); nil == err { return cnt, nil ...
package main /* #cgo pkg-config: gstreamer-1.0 gstreamer-app-1.0 #include <stdio.h> #include <gst/gst.h> void cb_proxy_padadd(GstElement* v, GstPad *v2,gpointer v3); */ import "C" import ( "fmt" "strings" "unsafe" //"github.com/notedit/gst" "github.com/tomberek/gst" ) //export cb_proxy_padadd func cb_proxy_pa...
package main import ( "KServer/manage" "KServer/manage/config" "KServer/server/discovery/services" "KServer/server/utils" "KServer/server/utils/msg" "fmt" ) func main() { // 管理器选择开启的服务 conf := config.NewManageConfig() conf.Server.Head = msg.ServiceDiscoveryTopic conf.DB.Redis = true conf.Message.Kafka = t...
/* Given an array of ints, return True if 6 appears as either the first or last element in the array. The array will be length 1 or more. */ package main import ( "fmt" ) func first_last6(ints []int) bool { if len(ints) > 0 { return ints[0] == 6 || ints[len(ints)-1] == 6 } return false } func main(){ var stat...
// Copyright (c) 2020 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package k8s import ( "encoding/base64" "fmt" "io" "os" "github.com/pkg/errors" "github.com/vladimirvivien/gexe" ) // FetchWorkloadConfig... func FetchWorkloadConfig(clusterName, clusterNamespace, mgmtKubeConfigPath ...
package middleware import ( "context" "encoding/json" "github.com/joshia/automated-api-test-service/testapp/config/apperror" "github.com/joshia/automated-api-test-service/testapp/lib/message" "github.com/joshia/automated-api-test-service/testapp/lib/uuid" "log" "net/http" ) func InjectRequestId(r *http.Request...
/* Copyright 2020 The Kubernetes 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, ...
package crawler import ( "context" "sync" "time" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/protocol" logging "github.com/ipfs/go-log" //lint:ignore SA1019 TODO migrate away from gogo pb "githu...
package main import ( "fmt" "log" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" ethereum "github.com/ethereum/go-ethereum" hello "github.com/sanguohot/medichain/contracts/hello" "context" "math/big" "strings" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereu...
// 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 formaterror import "strings" var errorMessages = make(map[string]string) func FormatError(errString string) map[string]string { if strings.Contains(errString, "isbn") { errorMessages["Taken_isbn"] = "There is already a book with that isbn, remember it is unique" } if strings.Contains(errString, "title...
// Copyright 2017 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"...
package letter import "sync" var mutex = &sync.Mutex{} func Frequency(s string) map[rune]int { m := map[rune]int{} for _, v := range s { m[v] += 1 } return m } func Concurrent(s string, m *map[rune]int, c chan byte) { for _, v := range s { mutex.Lock() (*m)[v] += 1 mutex.Unlock() } c <- 1 } func C...
/* Copyright 2022 The KubeVela 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, so...
package main func main() { var bef = 43261596 reverseBits(uint32(bef)) } func reverseBits(num uint32) uint32 { var ret uint32 = 0 //注意十进制的反转,不是二进制的反转 不能简单的用十进制的反转来实现,23 =>32 底层 1 0111 => 10 0000 for i := 0; i < 32; i++ { final := num & 1 //任何数与1与都是他本身,与0与都是0,num&1得到最后一个二进制位数字 final <<= (31 - i) //往右移1位相当...
package main import ( "fmt" ) // https://leetcode-cn.com/problems/daily-temperatures/ // 739. 每日温度 | Daily Temperatures //------------------------------------------------------------------------------ func dailyTemperatures(T []int) []int { return dailyTemperatures0(T) } //----------------------------------------...
package chainvalidate import ( "errors" "math/big" "strings" "sync" "time" "github.com/cpusoft/goutil/belogs" "github.com/cpusoft/goutil/certutil" "github.com/cpusoft/goutil/conf" "github.com/cpusoft/goutil/convert" "github.com/cpusoft/goutil/hashutil" "github.com/cpusoft/goutil/jsonutil" "github.com/cpus...
package tasks import ( "testing" _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/assert" ) func TestRun(t *testing.T) { assert := assert.New(t) conf := &Config{ DBMaxRows: 10, DBConnections: map[string]DBConnection{ "sqlite": DBConnection{ Driver: "sqlite3", DataSource: ":memory...
/* Bhallaladeva was an evil king who ruled the kingdom of Maahishmati. He wanted to erect a 100ft golden statue of himself and he looted gold from several places for this. He even looted his own people, by using the following unfair strategy: There are N houses in Maahishmati, and the ith house has Ai gold plates. Ea...
package checksum import ( "io/ioutil" "testing" "github.com/stretchr/testify/require" ) var input = []struct { spreadsheet string checksum int }{ { spreadsheet: `5 1 9 5 7 5 3 2 4 6 8`, checksum: 18}, } func TestChecksum(t *testing.T) { assert := require.New(t) for _, in := range input { sum :=...
package engine import ( "github.com/gabrielEscame/go-engine/physics" "github.com/veandco/go-sdl2/sdl" ) type Entity interface { Update(*Input, float64) Draw(*sdl.Surface) } type CollidableEntity interface { GetShape() *physics.SquareShape OnCollisionEnter(*CollisionInfo) }
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package api import ( "fmt" "strconv" "strings" "github.com/Azure/go-autorest/autorest/to" "github.com/Azure/aks-engine/pkg/api/common" ) func (cs *ContainerService) setKubeletConfig(isUpgrade bool) { o := cs.Prope...
package xsuportal import ( "encoding/base64" "fmt" "sync/atomic" "time" "github.com/SherClockHolmes/webpush-go" "github.com/golang/protobuf/proto" "github.com/jmoiron/sqlx" "google.golang.org/protobuf/types/known/timestamppb" "github.com/isucon/isucon10-final/webapp/golang/proto/xsuportal/resources" ) type...
package utils import ( "github.com/astaxie/beego" "github.com/zwczou/jpush" ) var ( appKey = "9a11d6ce355150887087d0ca" secret = "af4025100bbfc437e3df1726" ) func init() { if str := beego.AppConfig.String("jiguang"+ "::appKey");str != ""{ appKey = str } if str := beego.AppConfig.String("jiguang"+ "::secre...
package main import ( "encoding/json" "net/http" docker "github.com/docker/docker/client" "github.com/ubclaunchpad/inertia/common" ) // statusHandler returns a formatted string about the status of the // deployment and lists currently active project containers func statusHandler(w http.ResponseWriter, r *http.Re...
package datastore import ( "database/sql" "strings" "github.com/go-kit/kit/log" // we mask the actual driver for now _ "github.com/lib/pq" "github.com/RicardoCampos/goauth/oauth2" ) type pgClientRepository struct { db *sql.DB logger log.Logger } //NewPostgresClientRepository creates a new repository bac...
package response type TextResponse struct { Response Content string `xml:"Content"` } func NewTextResponse(text string, toUser string) TextResponse { res := TextResponse{} res.Response = NewResponse("text") res.CreateTime = 11155566 res.FromUserName = "gh_fba62a0ffce7" res.ToUserName = toUser res.Content = t...
package options //import ( // "os" // "testing" // "time" // // . "github.com/onsi/gomega" //) // //func TestHandleRabbitEnvars_relay(t *testing.T) { // // g := NewGomegaWithT(t) // // envars := map[string]string{ // "PLUMBER_DEBUG": "true", // "PLUMBER_RELAY_TOKEN": "8EDB...
package app import ( "context" pb "github.com/chenzhe84/BaiCloud/metadata-service/proto/app" ) type Handler struct { Repo IRepository } func (h *Handler) SaveApp(cxt context.Context, app *pb.App, res *pb.Response) error { if err := h.Repo.SaveApp(app); err != nil { res.Result = false res.Message = err.Error(...
// client.go package main import ( "encoding/binary" "fmt" "log" "math/rand" "net" "time" ) func client(addr, name string, hangie bool) { /*Starts a client, initiates a connection*/ conn, err := net.Dial(network, addr+port) var succ int if err != nil { fmt.Println("My name is", name, "I couldn't join the ...
package main import ( "github.com/gin-gonic/gin" "github.com/joho/godotenv" "healthy-api/router" "log" ) func main() { r := gin.Default() err := godotenv.Load() if err != nil { log.Fatal("Error loading .env file") } // 血壓紀錄 //blood := r.Group("/blood") //router.BloodRouter(blood) // 設備 device := r.G...
package domain import ( commonDto "github.com/bearname/videohost/internal/common/dto" "github.com/bearname/videohost/internal/common/util" "github.com/bearname/videohost/internal/user/app/dto" ) type AuthService interface { CreateUser(newUserDto dto.SignupUserDto) (util.Token, error) Login(loginUserDto dto.Login...
package main import ( "digicert" "errors" "log" "os" ) var c *digicert.Client func main() { container() certificate() domain() orders() organization() request() user() } func checkEnv() error { if c == nil { var err error c, err = digicert.New(os.Getenv("DC_KEY")) if err != nil { log.Fatal(err)...
package messages type ReadAckRequest struct { RId int64 `json:"r_id"` UserId string `json:"user_id"` RemoteId string `json:"remote_id"` GroupId string `json:"group_id"` MsgId int64 `json:"msg_id"` Type MessageType `json:"type"` }
package main import ( "context" "flag" "log" "os" "os/signal" "runtime/pprof" "github.com/azenk/audio/stream" "github.com/golang/glog" "github.com/spf13/viper" ) func main() { cfgFile := viper.New() cfgFile.SetDefault("left.frequency", 1000) cfgFile.SetDefault("left.amplitude", 1) cfgFile.SetDefault("le...
package main import ( "fmt" "sort" ) // bucketShift returns 1<<b, optimized for code generation. func bucketShift(b uint8) uintptr { // Masking the shift amount allows overflow checks to be elided. return uintptr(1) << (b & (4<<(^uintptr(0)>>63)*8 - 1)) } func main() { fmt.Println(11 >> 56) m := make(map[strin...
package product import ( "MI/pkg/logger" service "MI/service/product" "github.com/gin-gonic/gin" "strconv" ) func Product(c *gin.Context){ Cid := c.Query("cid") Page := c.DefaultQuery("page", "1") PageSize := c.DefaultQuery("pageSize", "7") Is_recursion := c.Query("is_recursion") cid, _ := strconv.Atoi(Cid) ...
// Copyright 2013 The Go 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 dsmr4p1 const ( poly = 0xA001 ) // Table is a 256-word table representing the polynomial for efficient processing. type Table struct { entries [256...
package main import ( "os/exec" "log" "fmt" "bytes" ) func main() { cmd := exec.Command("dir", "-lah") var stdout, stderr bytes.Buffer cmd.Stderr = &stderr cmd.Stdout = &stdout err := cmd.Run() if err != nil { log.Fatalf("cmd.run() failed with %s\n", err) } outStr,errStr:=string(stdout.Bytes()),str...
package model import ( "database/sql" "github.com/fberrez/forum/datastore" "time" ) type User struct { Id int `json:"id" db:"user_id"` Pseudo string `json:"pseudo" db:"user_pseudo"` Password string `json:"password" db:"user_password"` Email string `json:"em...
package main_test import ( "fmt" "io" "os" "os/exec" "path/filepath" "sort" "strings" "testing" "github.com/stretchr/testify/assert" ) func content() []string { return []string{ "grand theft wumps", "replublics of haskell", "a sunset is a sunset because it's crimson, beautiful, and I want it to be cr...
package planner import ( "context" "time" "github.com/google/uuid" "go.uber.org/zap" ) // Scheduler takes a plan and it executes it. type Scheduler struct { // stepCounter keep track of the number of steps exectued by the scheduler. // It is used for debug and logged out at the end of every execution. stepCou...
package app import ( "main/src/gvabe/bo/user" ) const ( TableApp = "exter_app" ) // AppDao defines API to access App storage. type AppDao interface { // Delete removes the specified business object from storage. Delete(bo *App) (bool, error) // Create persists a new business object to storage. Create(bo *App)...
package _300_Longest_Increasing_Subsequence import "testing" func TestLengthOfLIS(t *testing.T) { if ret := lengthOfLIS([]int{10, 9, 2, 5, 3, 7, 19, 101, 18}); ret != 5 { t.Errorf("should be 4, wrong length with %d", ret) } } func TestFindPos(t *testing.T) { if pos := findPos([]int{1, 2, 3}, 1); pos != 0 { t....
package main //TODO write a check to to see how many things the line includes. Should be x number. If not send email to update code. //TODO set download all to execute at 2 am every night. //TODO send me an email with the error output. //TODO make monday - sunday a map //TODO make a map for seasons courses //TODO mo...
package split import ( "strings" "testing" ) func TestSplitSimple(t *testing.T) { os(t, "Hello, world!", "Hello / world") } func TestSplitTwitter(t *testing.T) { os(t, "Contact @foo.", "Contact / @foo") os(t, "Tweet with #CoolHashtag!", "Tweet / with / #CoolHashtag") } func TestSplitEmail(t *testing.T) { os(t...
package cmd import ( "fmt" "os" "path/filepath" "time" "github.com/odpf/optimus/models" "github.com/odpf/optimus/run" "github.com/odpf/optimus/utils" "github.com/odpf/salt/log" cli "github.com/spf13/cobra" ) var ( templateEngine = run.NewGoEngine() ) func renderCommand(l log.Logger, host string, jobSpecRe...
package main import ( "testing" ) func TestDay02Part1(t *testing.T) { runDayTests(t, 2, []dayTest{ { input: `1,9,10,3,2,3,11,0,99,30,40,50`, want: int64(3500), }, { input: `1,0,0,0,99`, want: int64(2), }, { input: `2,3,0,3,99`, want: int64(2), }, { input: `2,4,4,5,99,0`, wan...
package main import ( "bufio" "flag" "fmt" "os" "strings" ) var ( intFlag int ) func main() { register() col1, _ := os.Open("./chap-02/col1.txt") defer col1.Close() fmt.Println(strings.Join(tail(col1, intFlag), "\n")) } func register() { flag.IntVar(&intFlag, "int", 10, "help message for \"i\" option (de...
package saucecloud import ( "context" "testing" "time" "github.com/jarcoal/httpmock" "github.com/saucelabs/saucectl/internal/config" "github.com/saucelabs/saucectl/internal/espresso" "github.com/saucelabs/saucectl/internal/job" "github.com/saucelabs/saucectl/internal/mocks" "github.com/stretchr/testify/asser...
package jsonresult import "github.com/incognitochain/incognito-chain/metadata" type PortalCustodianWithdrawRequest struct { CustodianWithdrawRequest metadata.CustodianWithdrawRequestStatus `json:"CustodianWithdraw"` }
package ansible import ( "os" "strings" ) type Inventory struct { Role, Output string Variables map[string]map[string]interface{} } func NewInventory(role string) *Inventory { inventory := new(Inventory) inventory.Output = "[" + role + "]" + "\n" inventory.Role = role inventory.Variables = make(map[string]m...
package Problem0467 func findSubstringInWraproundString(p string) int { // count[0] = 4 表示,以 'a' 结尾的连续字符串的最大长度为 4 // 那么,在符合题意的 subString 中以 'a' 结尾的个数为 4 // 这样统计起来,既不会遗漏也不会重复 // count := [26]int{} length := 0 for i := 0; i < len(p); i++ { if 0 < i && (p[i-1]+1 == p[i] || p[i-1] == p[i]+25) { length++ ...
package database import ( "database/sql" "fmt" "os" ) var DB *sql.DB func ConnectDB() { db, err := sql.Open("pgx", os.Getenv("DATABASE_URL")) if err != nil { fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err) os.Exit(1) } DB = db }
/* * @lc app=leetcode.cn id=219 lang=golang * * [219] 存在重复元素 II */ // @lc code=start package main import "fmt" func main() { var a []int a = []int{1,2,3,1} fmt.Printf("%v, %t\n", a, containsNearbyDuplicate(a, 3)) a = []int{1,0,1,1} fmt.Printf("%v, %t\n", a, containsNearbyDuplicate(a, 1)) a = []int{1,2,...
package qpeerset import ( "testing" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/test" kb "github.com/libp2p/go-libp2p-kbucket" "github.com/stretchr/testify/require" ) func TestQPeerSet(t *testing.T) { key := "test" qp := NewQueryPeerset(key) // -----------------Ordering betwe...
package usecase import ( "context" "errors" "fmt" "sync" "time" "encoding/json" "github.com/syariatifaris/shopeetax/app/resource/usecaseres" ) var ( //HTTPServiceType service type of http HTTPServiceType ServiceType = "HTTPServiceType" //SubsriberEventType service type of subsrciber SubsriberEventType Se...
// +build !exclude_graphdriver_rbd package daemon import ( _ "github.com/docker/docker/daemon/graphdriver/rbd" )
package middleware import ( "io/ioutil" "gopkg.in/go-playground/validator.v9" "gopkg.in/yaml.v2" ) type DatabaseConfig struct { Host string `yaml:"host" validate:"required"` Port string `yaml:"port" validate:"required"` User string `yaml:"user" validate:"required"` Password string `yaml:"password"...
// This file was generated for SObject VisualforceAccessMetrics, API Version v43.0 at 2018-07-30 03:47:37.25685993 -0400 EDT m=+23.600351916 package sobjects import ( "fmt" "strings" ) type VisualforceAccessMetrics struct { BaseSObject ApexPageId string `force:",omitempty"` DailyPageViewCount int `fo...
package controllers import "github.com/astaxie/beego" type TestController struct { beego.Controller } func (this *TestController) Get() { this.Data["Username"] = "astaxie" this.Ctx.Output.Body([]byte("ok")) } func (this *TestController) List() { this.Ctx.Output.Body([]byte("i am list")) } func (this *TestContr...
package mysql import ( "database/sql" "fmt" "time" "github.com/smilga/analyzer/api" ) type ReportStore struct { DB *sql.DB } func (s *ReportStore) Save(r *api.Report) error { now := time.Now() if r.ID == 0 { r.CreatedAt = &now } // NOTE there is trigger that moves deleted reports to reports_archive tabl...
// Copyright 2018 Diego Bernardes. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package test import ( "encoding/json" "fmt" "io/ioutil" "os" "path/filepath" "runtime" "github.com/pkg/errors" "github.com/smartystreets/goconvey/con...
package main import ( "bytes" "fmt" "strings" "unicode" ) // 是否具有某个前缀 func HasPrefix(s, prefix string) bool { return len(prefix) < len(s) && s[0:len(prefix)] == prefix } // 是否以xx为结尾 func HasSuffix(s, suffix string) bool { return len(s) > len(suffix) && s[len(s) - len(suffix):] == suffix } func Join(str []stri...
package core import ( "net/http" ) func getStatus(url string) int { resp, err := http.Head(url) if err != nil { return 500 } return resp.StatusCode } func healthCheck(urls []string) map[string]int { statusMap := make(map[string]int) for x := 0; x < len(urls); x++ { statusMap[urls[x]] = getStatus(urls[x]) ...
package goSolution func generateParenthesisRecursively(n int, currentIndex int, currentString string, parValue int, results *[]string) { if n == currentIndex { *results = append(*results, currentString) return } if n - currentIndex - 1 >= parValue + 1 { generateParenthesisRecursively(n, currentIndex + 1, cur...
package array import "testing" func Test(t *testing.T) { a := array(10) println(a.len(), a.cap()) for i := 0; i < 30; i++ { a.insert(i) a.show() } }
package controller import ( "fmt" "github.com/suaas21/library-management-api/controller/authentication" "github.com/suaas21/library-management-api/database" "net/http" "strconv" "gopkg.in/macaron.v1" ) func Register(ctx *macaron.Context, user database.User) { imageName, err := FileUpload(ctx) if err != nil {...
package main import ( "log" "testing" "time" ) func TestDownload(t *testing.T) { speed := download("https://universal.bigbuckbunny.workers.dev/Consti10/LiveVideo10ms/master/Screenshots/device2.png?xprotocol=https&xhost=raw.githubusercontent.com", "104.21.90.173", 50*time.Second) log.Println((speed / 1024)) } f...
package clcv2 import ( "encoding/json" "fmt" "io/ioutil" "log" "net/url" "os" "os/user" "path" "runtime" "strings" yaml "gopkg.in/yaml.v2" "github.com/grrtrr/clcv2/utils" "github.com/pkg/errors" ) const ( // Name of the file to store the last bearer-token credentials credentialsName = "credentials.js...
package gui import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/test" "github.com/archon/backend" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("EnterEntry widget", func() { var session *backend.Session var entry *EnterEntry BeforeEach(func() { session = backend.NewSession("Untitled Sess...
/* Package account handles account requests. */ package account import ( "encoding/json" "github.com/MerinEREN/iiPackages/api" "github.com/MerinEREN/iiPackages/datastore/account" "github.com/MerinEREN/iiPackages/datastore/user" "github.com/MerinEREN/iiPackages/session" "google.golang.org/appengine/datastore" "g...
// Copyright 2020. Akamai Technologies, Inc // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed t...
package main import "fmt" func main() { i := 100 // if - else if example(1) if i >= 120 { fmt.Println("over 120") } else if i >= 100 && i < 120 { fmt.Println("over 100 under 120") } else if i < 100 && i >= 50 { fmt.Println("over 50 under 100") } else { fmt.Println("under 50") } }
package libs import ( "context" "crypto/sha256" "database/sql" "encoding/json" "errors" "fmt" "log" "math/big" "net/http" "github.com/gorilla/mux" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/...
package web import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "strings" "time" log "github.com/sirupsen/logrus" "github.com/lonnng/nex" "github.com/johnull/mop-ng/internal/errutil" "github.com/johnull/mop-ng/internal/token" "github.com/johnull/mop-ng/internal/db" "github.com/johnu...
package radware import ( "fmt" "github.com/zdnscloud/elb-controller/driver" "github.com/zdnscloud/elb-controller/driver/radware/types" ) type radwareConfig struct { RealServers map[string]*types.RealServer RealServerPort *types.RealServerPort VsID string ServerGroup *types.ServerGroup Virtual...
/* * @lc app=leetcode id=30 lang=golang * * [30] Substring with Concatenation of All Words */ func find_in_words(words []string, word_hit []int, word string) (found bool, index int) { for i, a := range words { if 0 == word_hit[i] { if 0 == strings.Compare(a, word) { return true, i } } } ret...
// examples.go show how to implement a basic crud for one data structure with the api2go server functionality // to play with this example server you can for example run some of the following curl requests // Create a new user: // `curl -X POST http://localhost:31415/v0/users -d '{"data" : [{"type" : "users" , "userna...
package bootstrap import ( rbac "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" "mobingi/ocean/pkg/constants" ) // AllowBootstrapTokensToPostCSRs creates RBAC rules in a way the makes Node Bootstrap Tokens able to post CSRs func AllowBootstrapTokensToPos...
package kafka_mock import ( "github.com/anchorfree/kafka-ambassador/pkg/kafka" k "github.com/confluentinc/confluent-kafka-go/kafka" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/mock" ) type MockedProducer struct { mock.Mock } func (m *MockedProducer) Send(topic string, message [...
package load_balance import ( "fmt" "math/rand" "testing" "time" ) func TestGetHash(t *testing.T) { fmt.Println(GetHash("new")) fmt.Println(GetHash("new2")) fmt.Println(GetHash("new3") % 3) } func TestIPHashLB_GetServer(t *testing.T) { lb := &IPHashLB{ servers: []*HServer{ {"10.13.0.5"}, {"10.13.0.9"...
// 服务常量文件 package main
package main import ( "github.com/valyala/fasthttp" "go.uber.org/zap" ) var logger *zap.Logger func init() { logger, _ = zap.NewProduction() } func fastHTTPHandler(ctx *fasthttp.RequestCtx) { logger.Info("hello, go module", zap.ByteString("uri", ctx.RequestURI())) } func main() { fasthttp.ListenAndServe(":808...
/** *@Author: haoxiongxiao *@Date: 2019/1/26 *@Description: CREATE GO FILE api_services */ package hotel_api_services import ( "encoding/json" "errors" "reflect" "github.com/spf13/cast" "github.com/xhaoxiong/ShowApiSdk/normalRequest" ) type SearchApiServices struct { ReqParams SearchRequestParams Res S...
package main import ( "flag" "image" "log" "math" "math/rand" "os" "strconv" "github.com/jcorbin/anansi" ) /* Ported from [antirez's LOLWUT](http://antirez.com/news/123) * * Creates output like: * * ⠀⡤⠤⠤⠤⠤⠤⠤⠤⠤⡤⠤⠤⠤⠤⠤⠤⠤⠤⡤⠤⠤⠤⠤⠤⠤⠤⠤⡄⠀ * ⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀ * ⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀ * ⠀⡇⠀⠀...
package main import ( "github.com/gin-gonic/gin" "net/http" ) func main() { router := gin.Default() // 简单的路由组: v1 v1 := router.Group("/v1") { v1.GET("/login", func(c *gin.Context) { c.JSON(http.StatusOK,gin.H{"m":"login1"}) }) v1.GET("/submit", func(c *gin...
package filestore_test import ( "context" "testing" "github.com/direktiv/direktiv/pkg/refactor/database" "github.com/direktiv/direktiv/pkg/refactor/filestore" "github.com/direktiv/direktiv/pkg/refactor/filestore/filestoresql" "github.com/google/uuid" ) func assertFileStoreCorrectRootCreation(t *testing.T, fs f...
/* * Copyright © 2021-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...