text
stringlengths
11
4.05M
/* Copyright 2018 The Crossplane 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...
// server.go // // REST APIs with Go and MySql. // // Usage: // // # run go server in the background // $ go run server.go package main import ( "net/http" _ "github.com/go-sql-driver/mysql" "github.com/elgs/gosqljson" "github.com/gorilla/mux" "database/sql" "log" "time" ) // Global sql.DB to access the d...
package pprof import ( "net/http" _ "net/http/pprof" ) func StartPP() { go func() { err := http.ListenAndServe("localhost:6060", nil) if err != nil { panic(err) } }() }
package main // Product model type Product struct { ID int `json:"id"` Name string `json:"name"` Category string `json:"category"` Inventory int16 `json:"inventory"` Price int16 `json:"price"` } //Products array/slice composed of Product's type Products []Product
package main import "github.com/Chris-SG/BauxeBot_Go/Discord" func main() { bauxebotdiscord.StartBotDiscord("!") }
package main import ( "testing" "os" "flag" "net/http" "net/http/httptest" "log" ) func init() { logger = log.New(os.Stdout, "rss-macine ", log.Ldate | log.Ltime | log.Lshortfile) errorsLogger = log.New(os.Stderr, "rss-macine ", log.Ldate | log.Ltime | log.Lshortfile) } func TestMain(m *testing.M) { ...
package api import ( "context" "net/http" "google.golang.org/grpc" "github.com/caos/zitadel/internal/api/authz" grpc_util "github.com/caos/zitadel/internal/api/grpc" "github.com/caos/zitadel/internal/api/grpc/server" "github.com/caos/zitadel/internal/api/oidc" authz_es "github.com/caos/zitadel/internal/authz...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package cloudflare import ( "context" cf "github.com/cloudflare/cloudflare-go" ) // MockCloudflare mocks the Cloudflarer interface type MockCloudflare struct { mockGetZoneID func(zoneName str...
package main import ( "auth0-backup-tool/pkg" "flag" "fmt" "gopkg.in/auth0.v3/management" "os" "strings" ) type Flags struct { ConfigFile string ClientId string ClientSecret string Domain string UsersFile string UserAttributes string Connection string Action string }...
package integrations import "gorm.io/gorm" // OIDCIntegrationClient is the name of an OIDC auth mechanism client type OIDCIntegrationClient string // The supported OIDC auth mechanism clients const ( OIDCKube OIDCIntegrationClient = "kube" ) // OIDCIntegration is an auth mechanism that uses oidc. Spec: // https://...
// Copyright 2020 apirator.io // // 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 commands import ( "github.com/codegangsta/cli" //"github.com/brooklyncentral/brooklyn-cli/api/entity_policies" "github.com/brooklyncentral/brooklyn-cli/command_metadata" "github.com/brooklyncentral/brooklyn-cli/net" "github.com/brooklyncentral/brooklyn-cli/scope" ) type AddPolicy struct { network *net.N...
package maximum_flow type Graph struct { VertexCount int Directed bool Edges []Edge } type Edge struct { X int Y int Capacity int } type AdjacencyMatrix [][]int func NewAdjacencyMatrix(g Graph) AdjacencyMatrix { a := newEmptyAdjacencyMatrix(g.VertexCount) for _, edge := range g.Edges ...
package middleware import ( "log" "net/http" "spectra/interfaces" "spectra/providers" "strings" "github.com/gin-gonic/gin" ) func Authentication() gin.HandlerFunc { return func(c *gin.Context) { log.Println("Authentication middleware") authHeader := c.GetHeader("Authorization") if len(authHeader) == 0 {...
package http import ( bm "github.com/go-kratos/kratos/pkg/net/http/blademaster" "github.com/go-kratos/kratos/pkg/net/http/blademaster/binding" ) func getNextCronJobList(ctx *bm.Context) { ctx.JSON(svc.GetNextCronJobList(ctx)) } func getJobCount(ctx *bm.Context) { var req struct{ Creator string `json:"creator" ...
package pb import ( "github.com/Workiva/go-datastructures/set" ) var dt_set *set.Set func init() { dt_set = set.New() } // 添加内部数据定义 func addInnerDt(dt string) { dt_set.Add(dt) } // 检查是否存在字符串描述的数据定义 func isExistInnerDt(dt string) bool { return dt_set.Exists(dt) }
// Copyright 2020 The Tekton 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" "strings" "time" //generate a manifest and compile via rsrc -manifest test.manifest -o rsrc.syso //then compile with go build -ldflags="-H windowsgui" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" //has no ability to list open com ports //but has a better serial commu...
package utils import ( "testing" "github.com/stretchr/testify/require" ) func TestRegexMustMatch(t *testing.T) { if !RegexMustMatch("Camera [0-9]+ Detection status (ACTIVE|PAUSE)", "Camera 0 Detection status ACTIVE") { t.Error("not match") } } func TestRegexFirstSubmatchString(t *testing.T) { require.Equal(...
package redis import ( "github.com/go-redis/redis" "github.com/spf13/viper" ) var Redis = &redis.Client{} func InitRedis() error { options := &redis.Options{Network:viper.GetString("network"),Addr:viper.GetString("addr")} Redis = redis.NewClient(options) return Redis.Ping().Err() }
package utils // 实现一个可以排序的Map type Map struct { Key uint32 Value string } type MapSort []Map func NewMapSort(m map[uint32]string) MapSort { ms := make(MapSort, len(m)) for k, v := range m { ms = append(ms, Map{Key: k, Value: v}) } return ms } func (this MapSort) Len() int { r...
package plugins import ( "frank/src/go/config" "frank/src/go/helpers/log" "frank/src/go/models" "gobot.io/x/gobot/drivers/gpio" "gobot.io/x/gobot/platforms/firmata" ) type PluginFirmata struct { } func NewPluginFirmata() PluginFirmata { pf := PluginFirmata{} return pf } func (ctx *PluginFirmata) ExecAction...
package models import ( "regexp" "time" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) //User data model type User struct { ID string `bson:"_id,omitempty" json:"_id"` Email string `bson:"email" json:"email"` Password string `bson:"password" json:"password"` CreatedAt time.Time `bson:"cr...
// 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 model // Onboard a request to onboard is stored in here, and all the tasks associated are created and also stored here type Onboard struct { ManagerEmail string `json:"managerEmail"` Name string `json:"name"` Email string `json:"email"` Role string `json:"role"` StartDate ...
package common const ( // app msgs MSG_SAVE_SUCCESS string = "Data Saved Successfully !!" MSG_SAVE_ERROR string = "Could not save data !!" MSG_UPDATE_SUCCESS string = "Data Updated Successfully !!" MSG_UPDATE_ERROR string = "Could not save data !!" MSG_DELET...
package main import ( "fmt" "log" "os" _ "./search" ) func init(){ log.SetOutput(os.Stdout) } func main(){ fmt.Println("Hello World!") }
package mouvement import ( "fmt" "math/rand" "sync" "time" "github.com/yanndr/rpi/bdngobot/process" "github.com/yanndr/rpi/bdngobot/situation" "github.com/yanndr/rpi/controller" ) type MouvmentCommand string const ( Stop MouvmentCommand = "StopMoving" Start MouvmentCommand = "StartMoving" ) var Started =...
// Copyright (c) 2016-2019 Uber 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...
package timeparser import ( "time" "github.com/bborbe/backup/constants" ) type TimeParser interface { TimeByName(name string) (time.Time, error) } type timeParser struct{} func New() *timeParser { return new(timeParser) } func (t *timeParser) TimeByName(name string) (time.Time, error) { return timeByName(nam...
package main import ( "net" "fmt" "os" ) func recvFile(conn net.Conn, fileName string) { // 按照文件名创建新文件 f, err := os.Create(fileName) if err != nil { fmt.Println("os.Create err:", err) return } defer f.Close() // 从 网络中读数据,写入本地文件 buf := make([]byte, 4096) for { n,_ := conn.Read(buf) if n == 0 { ...
package e7_3_test import ( "gopl/e7_3" "testing" ) func TestSort(t *testing.T) { tree := e7_3.Add(nil, 2) tree = e7_3.Add(tree, 3) tree = e7_3.Add(tree, 1) s := tree.String() expected := "[2, 1, 3, ]" if s != expected { t.Errorf("String() returned %s. expected: %s", s, expected) } }
package adminApp import ( "hd-mall-ed/packages/common/pkg/app" ) type ApiFunction struct { app.ApiFunction }
// Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). You may not // use this file except in compliance with the License. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license" fil...
// Copyright 2019 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 hw05_parallel_execution //nolint:golint,stylecheck import ( "errors" "sync" ) var ErrErrorsLimitExceeded = errors.New("errors limit exceeded") type Task func() error type errorsCounter struct { value int mu sync.Mutex } // Run starts tasks in N goroutines and stops its work when receiving M errors f...
// // Heavily influenced by https://github.com/prometheus/client_golang // https://github.com/prometheus/client_golang/blob/8184d76b3b0bd3b01ed903690431ccb6826bf3e0/prometheus/promhttp/instrument_client.go // // Copyright 2017 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // ...
package xmppversion import ( "encoding/xml" "testing" "github.com/stretchr/testify/assert" ) func TestMarshalEmptyQueryResult(t *testing.T) { result := IQQueryResult{} xmlBuf, err := xml.Marshal(&result) assert.Nil(t, err) assert.Equal(t, `<query xmlns="jabber:iq:version"><name></name><version></version></...
package app import ( "time" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" repository "github.com/shandysiswandi/echo-service/internal/adapter/mongorepo" "github.com/shandysiswandi/echo-service/internal/config" "github.com/shandysiswandi/echo-service/internal/domain/usecase" "github.com...
package plugins import ( "github.com/stretchr/testify/assert" "testing" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" appsv1 "k8s.io/api/apps/v1" "k8s.io/api/core/v1" ) func Test_customHealthProbe(t *testing.T) { tests := []struct { unstructuredObj *unstructured.Unstructured customHealthProbeArgs *Cus...
package server import ( pb "github.com/1851616111/xchain/pkg/protos" cm "github.com/1851616111/xchain/pkg/server/connection_manager" "log" "os" "time" ) var ( logger = log.New(os.Stderr, "[controller]", log.LstdFlags) ) func (n *Node) RunController() { successFunc := func(target pb.EndPoint, con cm.Connectio...
// Copyright © SAS Institute 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 in...
package main import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "qiniupkg.com/api.v7/conf" "qiniupkg.com/api.v7/kodo" "qiniupkg.com/api.v7/kodocli" "strings" "time" ) const defCfgFile = "gobak.cfg" type UplInfo struct { BakFile string AK string SK string Bucket string Key string ...
package main import ( "fmt" "net/http" ) func sayHello(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w,"<script>alert(\"hello GO\")</script>") } func main() { //路由 http.HandleFunc("/",sayHello) err :=http.ListenAndServe(":9999",nil) if err != nil { fmt.Println("建立http服务器失败",err) return } }
package conf import ( "context" "sync" kit "shylinux.com/x/toolkits" ) type Any = interface{} type Conf struct { data Any cancel context.CancelFunc ctx context.Context wg sync.WaitGroup sup *Conf } func (conf *Conf) GetBool(key string, def ...bool) bool { if val := kit.Value(conf.data, key); val ...
package Utils import ( "AlgorithmPractice/src/common/Intergration/DB" "errors" "fmt" "reflect" "strings" ) // ClazzTools // @author: liujun // @date: 2022/6/1420:16 // @author—Email: ljfirst@mail.ustc.edu.cn // @description: // 获取反射对象的所有方法 {@link ClassReflectTools#GetExecMethod} // 执行方法 {@link Class...
package cmd import ( "context" "fmt" "github.com/loft-sh/devspace/pkg/devspace/config" "github.com/loft-sh/devspace/pkg/devspace/config/loader" "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest" devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context" "github.com/loft-sh/devspace/pkg/de...
package server import ( "testing" "math/big" "time" "log" ) func TestCalcEquilibrium(t *testing.T){ pp1 := PricePoint{"AUD", big.NewFloat(2.00), time.Now()} // 2 * 1 = 2 pp2 := PricePoint{"AUD", big.NewFloat(1.50), time.Now()} // 1.50 * 2 = 3 pp3 := PricePoint{"AUD", big.NewFloat(1.00), time.Now()} // 1 * 3 = ...
package main import ( "errors" "fmt" ) type Stack struct { //最大存放的个数 MaxTop int //栈顶 Top int //模拟栈 arr [5]int } func (s *Stack) Push(val int) (err error) { if s.Top == s.MaxTop-1 { fmt.Println("stack full") return errors.New("stack full") } s.Top++ s.arr[s.Top] = val return } func (s *Stack) Lis...
package tempodb import ( "fmt" "testing" "time" "github.com/google/uuid" "github.com/grafana/tempo/tempodb/backend" "github.com/stretchr/testify/assert" ) func TestTimeWindowBlockSelectorBlocksToCompact(t *testing.T) { now := time.Now() timeWindow := 12 * time.Hour tenantID := "" tests := []struct { nam...
package kata func FindUniq(arr []float32) float32 { // Do the magic if len(arr) < 3{ return 0 } for i:= 0; i < len(arr) - 2; i++{ if arr[i] != arr[i+1] { if arr[i] == arr[i+2] { return arr[i+1] }else if arr[i+1] == arr[i+2]{ return arr[i] } } } ...
package storage import ( "context" "errors" "testing" "time" "github.com/arschles/assert" storagedriver "github.com/docker/distribution/registry/storage/driver" ) const ( objPath = "myobj" ) func TestObjectExistsSuccess(t *testing.T) { objInfo := storagedriver.FileInfoInternal{FileInfoFields: storagedriver....
package main import "fmt" func main() { var red uint8 = 255 red++ fmt.Println(red) var number int8 = 127 number++ fmt.Println(number) var green uint8 = 3 fmt.Printf("%08b\n", green) green++ fmt.Printf("%08b\n", green) var blue uint8 = 255 fmt.Printf("%08b\n", blue) blue++ fmt.Printf("%08b\n", blue) ...
package main import ( "fmt" "github.com/hectorhammett/graphs/digraph" "github.com/hectorhammett/graphs/graph" "github.com/hectorhammett/graphs/node" "github.com/hectorhammett/graphs/ugraph" ) func main() { a := node.NewNode("a", nil) b := node.NewNode("b", nil) c := node.NewNode("c", nil) d := node.NewNode(...
package tezos_test import ( "fmt" "testing" "github.com/ecadlabs/signatory/pkg/tezos" ) func TestValidate(t *testing.T) { type testCase struct { Name string KeyPair *tezos.KeyPair ExpectError bool } cases := []testCase{ testCase{ Name: "Valid case", KeyPair: tezos.NewKeyPai...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package store import ( "testing" "github.com/mattermost/mattermost-cloud/internal/testlib" "github.com/mattermost/mattermost-cloud/model" "github.com/stretchr/testify/assert" "github.com/stretchr/t...
package JwtHelper import ( "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" JwtConfig "golangdemo/rps-game/configs/jwt-conf" LogConf "golangdemo/rps-game/configs/log-conf" "golangdemo/rps-game/configs/structs" SystemCode "golangdemo/rps-game/configs/system-code" SystemPath "golangdemo/rps-game/configs/s...
package devices import ( "bytes" "log" "net/url" "strconv" "time" ) //yh-500 // 地磅数据读取 /* 232 通信 9600、19200bps 采用ascii码传数据 STX 数据开始 XON 0x2 CR 数据结束 换行 0x 采用方式一,9600,485 AB线反接 232 连续发生 采用ascii编码 倒叙模式 数据模式 .0600000=.0700000=.0700000=.0700000=.0700000= */ func znDiBangStart(id uint) { conn := getConn(id) if...
package grifts import ( "github.com/google/uuid" "github.com/icrowley/fake" "github.com/markbates/grift/grift" "github.com/daylightdata/shortbread/postgres" ) var _ = grift.Namespace("db", func() { grift.Desc("seed", "Seeds a database") grift.Add("seed", func(c *grift.Context) error { db, err := postgres.Co...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package encryption import ( "testing" "github.com/stretchr/testify/assert" ) func TestDeriveRootKey(t *testing.T) { // ensure that we can derive with no errors _, err := DeriveRootKey([]byte("password"), []byte("salt"), "", 8) asser...
package proteus import "testing" func TestEmbeddedNoSql(t *testing.T) { type InnerEmbeddedProductDao struct { Insert func(e Executor, p Product) (int64, error) `proq:"insert into Product(name) values(:p.Name:)" prop:"p"` } type OuterEmbeddedProductDao struct { InnerEmbeddedProductDao FindById func(e Querier...
package capture import ( "bufio" "bytes" "crypto/rand" "encoding/hex" "image" "image/draw" "image/png" "os" "path" "path/filepath" "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics" "gitlab.com/opennota/screengen" "golang.org/x/net/context" ) type ExtractRequest struct { Video []byte Name ...
package template import ( "os" "testing" ) func TestRender(t *testing.T) { tt := DotType{ PackageName: "goDao", Packages: []string{"github.com/jackc/pgtype"}, Functions: []Function{{ Name: "Add", // language=PostgreSQL SQL: ` -- https://en.wikipedia.org/wiki/List_of_most_popular_websites create t...
package main import ( "fmt" ) var z = 88 func main() { x := 40 fmt.Println(x) x = 50 fmt.Println(x) }
package main import ( "fmt" "sync" ) func main() { var waitGroup sync.WaitGroup //add //wait //done //cara 1 /* waitGroup.Add(1) go printText("Salam", &waitGroup) waitGroup.Add(1) go printText("Hallo", &waitGroup) */ //cara 2 waitGroup.Add(2) go printText("Salam", &waitGroup) go printText("Hallo", &w...
package util func LogNotice(traceId string, data string) { }
package generate import ( "bytes" "fmt" "github.com/lvxin0315/gapi/core/generate/services" "io/ioutil" "reflect" "strings" ) /** * @Author lvxin0315@163.com * @Description mysql生成对应model * @Date 11:29 上午 2020/12/11 **/ type GenService struct { ServiceDir string } func (gen *GenService) AutoService(models ...
package helper import ( "strconv" "strings" ) func HasValue(s string) bool { return len(strings.Trim(s, " ")) > 0 } func Atoi(v string, d int) int { s := strings.Trim(v, "\"") if len(s) == 0 { return d } else { s = strings.TrimLeft(s, "0") if len(s) == 0 { //v == "0" return 0 } } if i, err := s...
package Constants import "fmt" func DOB() { fmt.Print("I was born on ", Day, "-", Month, "-", Year) } func Myname() { fmt.Print("I am ", Name, ". ") }
package main import( "os" "fmt" "net" "time" "strconv" ) func main(){ ad:="127.0.0.1:1200" addr,er:=net.ResolveUDPAddr("udp",ad) if er !=nil{ fmt.Println("Erro ao converter endereço! ",os.Args[0]) os.Exit(1) } LocalAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:20076") if err !=nil{ fmt.Println("E...
// 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 health import ( "context" "time" "github.com/shirou/gopsutil/v3/process" "chromiumos/tast/errors" "chromiumos/tast/local/croshealthd" "chromiumos/tast/local/...
package basic //go:generate futil -type func -basics //go:generate futil -type result -basics //go:generate futil -type option -basics //go:generate futil -type array -basics
package analyzer import "spider/utils/pool" type Pool struct { pool *pool.Pool } func NewPool() *Pool { }
package main import "fmt" /** * <p> * 语言切片:参考:https://www.runoob.com/go/go-slice.html * Go 语言切片是对数组的抽象。 ---> Go中的数组是定长数组,语言切片是非定长数组,跟Redis的自定义的结构体一致 * Go 数组的长度不可改变,在特定场景中这样的集合就不太适用,Go中提供了一种灵活,功能强悍的内置类型切片("动态数组"), * 与数组相比切片的长度是不固定的,可以追加元素,在追加时可能使切片的容量增大。 * </p> * @author: zhu.chen * @date: 2020/8/5 * @version...
package odoo import ( "fmt" ) // IrQwebFieldQweb represents ir.qweb.field.qweb model. type IrQwebFieldQweb struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` DisplayName *String `xmlrpc:"display_name,omptempty"` Id *Int `xmlrpc:"id,omptempty"` } // IrQwebFieldQwebs represents array of ir...
// Worker package is responsible for fetching external websites, // and scheduling goroutines package worker import ( "context" "sync" "time" "github.com/SQLek/wp-interview/model" ) type Config struct { MinInterval uint `config:"MIN_INTERVAL"` FetchTimeout time.Duration `config:"FETCH_TIMEOUT"` } fu...
package api import ( "errors" "fmt" "net/http" "net/url" "reflect" "strings" "time" "github.com/lucassabreu/clockify-cli/api/dto" "github.com/lucassabreu/clockify-cli/strhlp" stackedErrors "github.com/pkg/errors" ) // Client will help to access Clockify API type Client struct { baseURL *url.URL http.Clie...
package JsMobile import ( "JsGo/JsConfig" "JsGo/JsHttp" . "JsGo/JsLogger" "JsGo/JsNet" "fmt" "log" "math/rand" "net/http" "time" "github.com/coocood/freecache" ) var g_smscache *freecache.Cache var g_rand_chan chan int var g_sms_cfg map[string]string //兼容老接口 func AlidayuInit() { g_smscache = freecache...
package _279_Perfect_Squares import ( "github.com/stretchr/testify/assert" "testing" ) func TestPerfectSquares(t *testing.T){ ast := assert.New(t) ast.Equal(0,numSquares(0)) ast.Equal(1,numSquares(1)) ast.Equal(2,numSquares(2)) ast.Equal(3,numSquares(3)) ast.Equal(1,numSquares(4)) ast.Equal(2,numSquares(5)...
package web import ( "fmt" "net/http" "github.com/davidnorminton/tvshowCalendar/calendar" ) func UpdateHandler(w http.ResponseWriter, r *http.Request) { if err := calendar.UpdateCalendar(); err != nil { fmt.Fprintf(w, "error") } else { fmt.Fprintf(w, "updated") } }
// 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 ui import ( "context" "time" "github.com/golang/protobuf/ptypes/empty" "github.com/google/go-cmp/cmp" "google.golang.org/grpc" "google.golang.org/protobuf/tes...
// Copyright 2022 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 2023 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 alipass import ( "testing" ) const ( AppId = "2015040200041603" PrivateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKK0PXoLKnBkgtOl0kvyc9X2tUUdh/lRZr9RE1frjr2ZtAulZ+Moz9VJZFew1UZIzeK0478obY/DjHmD3GMfqJoTguVqJ2MEg+mJ8hJKWelvKLgfFBNliAw+/9O6Jah9Q3mRzCD8pABDEHY7BM54W7aLcuGpIIOa/qShO8dbXn+FAgMB...
package main import ( "encoding/json" "fmt" "io" "log" ) type Player struct { Name string `json:"name"` Color string `json:"color"` Points int `json:"points"` } type PlayerList []Player var players PlayerList func (players PlayerList) writeJSON(w io.WriteCloser) { fmt.Fprintf(w, "\"players\": [") se...
package main import ( "fmt" "strconv" "strings" "github.com/storm84/AOC/AOC22/utils" ) type sectionRange struct { low int high int } func main() { lines, err := utils.ReadLines("input") utils.Check(err) aCnt := 0 bCnt := 0 for _, line := range lines { if line != "" { pairs := strings.Split(line, "...
package builder import ( "fmt" ) var sshAuthorizedKeyEntry = `command="/home/git/gitreceive run",no-agent-forwarding,no-pty,no-user-rc,no-X11-forwarding,no-port-forwarding %s` var gitReceiverScript =`#!/bin/bash readonly GITUSER="${GITUSER:-git}" readonly GITHOME="/home/${GITUSER}" absolute_path() { pushd "$(dir...
package commands import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) func init() { nodeCmds := []*cobra.Command{ CheckAddressCmd, } RootCmd.AddCommand(nodeCmds...) RootSubCmdGroups["node"] = nodeCmds } var CheckAddressCmd = &cobra.Command{ Use: "checkAddress", Short: "check Address",...
package awesome_mapper2 import ( "errors" "fmt" "io/ioutil" "os" "path" "reflect" "strconv" "strings" "sync" "time" "github.com/Knetic/govaluate" "github.com/superchalupa/sailfish/src/ocp/model" ) var functionsInit sync.Once var functions map[string]govaluate.ExpressionFunction func InitFunctions() map[...
package main import ( "os" "12306.com/12306/common" "12306.com/12306/stations" "12306.com/12306/trains" "12306.com/12306/users" "github.com/gin-gonic/gin" _ "github.com/go-sql-driver/mysql" "github.com/spf13/viper" ) func main() { InitConfig() db := common.InitDB() db.AutoMigrate(&users.User{}) db.AutoMi...
// Copyright (c) 2016-2019 Uber 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...
package api // ComparisonOperator compares two operands. type ComparisonOperator string const ( // Equal operator. Equal ComparisonOperator = "eq" // NotEqual operator. NotEqual ComparisonOperator = "ne" // Less operator. Less ComparisonOperator = "lt" // LessOrEqual operator. LessOrEqual ComparisonOperator =...
/** * Copyright (c) 2018-present, MultiVAC Foundation. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ package chain import ( "fmt" "github.com/multivactech/MultiVAC/base/db" "github.com/multivactech/MultiVAC/base/rlp" "github....
package quicksort import ( "testing" ) func BenchmarkQuicksortIterative(b *testing.B) { if b.N > 10 { numbers := make([]int, b.N) fillWithRandomNumbers(numbers, 1000) QuicksortIterative(numbers, 0, len(numbers)-1) } } func BenchmarkQuicksortRecursive(b *testing.B) { if b.N > 10 { numbers := make([]int, b...
// customReader project doc.go /* customReader document */ package main
package m2go const ( configurableProducts = "/configurable-products" configurableProductsOptionsRelative = "options" configurableProductsOptionsAllRelative = "options/all" configurableProductsChildRelative = "child" )
package main import "fmt" // this method does not make sense for most use cases // but if you happen to need 2+ funcs reading from one channel // you can do that - though each channel reading will contain a random // item from the channel - not sequential data func main() { // create channels c := make(chan int) d...
package ravendb import ( "encoding/json" "fmt" "io" "strconv" "strings" ) // StreamOperation represents a streaming operation type StreamOperation struct { session *InMemoryDocumentSessionOperations statistics *StreamQueryStatistics isQueryStream bool } // NewStreamOperation returns new StreamOperat...
package lc // Time: O(nlog n) // Benchmark: 480ms 169.4mb | 88% 15% type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func insert(node *TreeNode, val int) { if node == nil { node = &TreeNode{val, nil, nil} } if node.Left != nil && node.Val > val { insert(node.Left, val) } else if node.Ri...
package main import ( "fmt" ) func reverse(s []int) { sliceLength := len(s) for i := 0; i < sliceLength/2; i++ { s[i], s[sliceLength-1-i] = s[sliceLength-1-i],s[i] } } func printSlice(s []int) { for i:=0; i<len(s);i++ { fmt.Printf("%d ", s[i]); } fmt.Printf("\n"); } func main() { slice_1 := []int{1,2,3...