text
stringlengths
11
4.05M
package monitor import ( "yunion.io/x/jsonutils" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/mcclient/options" ) type AlertDashBoardCreateOptions struct { apis.ScopedResourceCreateInput NAME string `help:"Name of bashboard"` Refresh string `help:"dashboard query refresh priod e.g. 1m|5m"` } f...
package db import ( "embed" ) //nolint //go:embed migrations/* var Migrations embed.FS
// 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...
/* * Copyright (c) 2013 author: LiTao * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of condit...
// Copyright 2015 Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package services import ( "fmt" log "github.com/golang/glog" "github.com/youtube/vitess/go/tb" "github.com/youtube/vitess/go/vt/key" "github.com/youtube/vit...
package main import ( "bytes" "encoding/json" "io/ioutil" "net/http" "time" "os" "github.com/Sirupsen/logrus" "github.com/gameontext/a8-room/pkg/gameon" ) type room struct { httpClient *http.Client serverURL string } func newRoom() *room { serverURL := os.Getenv("ROOM_SERVICE_URL") if serverURL == "" ...
package nodes import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" ) func getPodsTotalRequestsAndLimits(podList *corev1.PodList) (reqs map[corev1.ResourceName]resource.Quantity, limits map[corev1.ResourceName]resource.Quantity) { reqs, limits = map[corev1.ResourceName]resource.Quantity{}, ma...
package calc // 두 값을 더한 값을 리턴한다. func Sum(a, b int) int { return a + b }
package sandbox import ( "context" "github.com/regclient/regclient/pkg/go2lua" "github.com/regclient/regclient/regclient" "github.com/sirupsen/logrus" lua "github.com/yuin/gopher-lua" "golang.org/x/sync/semaphore" ) const ( luaRepoName = "repo" luaReferenceName = "reference" luaTagName = "t...
package main import "fmt" /* A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables; in this sense the function is "bound" to the variables. */ // grouped const declaration const ( // Create a huge number by shifting a 1 bit le...
package structs /* definition of structs */ type User struct { Name string `json:"name"` Gender int `json:"gender"` // 1 = male, 2 = female TeamID []string `json:"teamId"` CreatedAt int64 UpdatedAt int64 }
// 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, ...
package tracker import ( "context" "errors" "net" "net/http" nurl "net/url" "strconv" "time" "github.com/zeebo/bencode" "github.com/jech/storrent/httpclient" ) // HTTP represents a tracker accessed over HTTP or HTTPS. type HTTP struct { base } // httpReply is an HTTP tracker's reply. type httpReply struc...
package main import ( "bytes" "index/suffixarray" "regexp" ) // suffixarray包通过使用内存中的后缀树实现了对数级时间消耗的子字符串搜索。 func main() { // 声明buffer var buf bytes.Buffer // 声明内容 var data = []byte("Hello Gopher!") var src = []byte("Gopher") // 生成一个*Index,时间复杂度O(N*log(N))。 index := suffixarray.New(data) // 返回创建x时提供的[]byt...
package http import ( "html/template" "strings" "time" ) func nl2br(in string) (out string) { out = strings.Replace(in, "\n", "<br>", -1) return } func htmlQuote(src string) string { text := string(src) text = strings.Replace(text, "&", "&amp;", -1) text = strings.Replace(text, "<", "&lt;", -1) text = strin...
package main import ( "context" "fmt" "time" ) // 取消子go中的子go func main() { ctx, cancel := context.WithCancel(context.Background()) go subgoFirst(ctx) time.Sleep(5 * time.Second) fmt.Println("notify exit") cancel() // 不发生阻塞 for { time.Sleep(1 * time.Second) fmt.Println("Continue...") } } func subgoF...
package models type Issue struct { ID int `json:"id"` IssueContent string `json:"issuecontent"` Status string `json:"status"` Comments []Comment `json:"comments"` } type Issues []Issue
package mint import ( "time" ) var ( NS NotificationService BDB BudgetDB TDB TransactionDB ) type BudgetImplementation struct {} func (b *BudgetImplementation) TotalPerCategory(username string) []MonthlyTotal { all, _ := BDB.GetAllFrom(username) return all } func (b *BudgetImplementation) Notify(mt Mon...
package main import ( "strconv" "fmt" ) /* X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotated - we cannot choose to leave it alone. A number is valid if each digit remains a digit after rotation. 0, 1, and 8...
/* * Flow CLI * * Copyright 2019-2021 Dapper Labs, 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 appl...
package main import ( "fmt" "sync" "time" ) var lock sync.Mutex var refCount int = 0 func fooFunc(i int, c chan int) { lock.Lock() refCount += 1 c <- refCount lock.Unlock() fmt.Printf("fooFunc %d\n", i) } func main() { c := make(chan int, 100) nrCoroutine := 10 for i := 0; i < nrCoroutine; i++ { go fo...
package main import "fmt" type ConfigOne struct { Daemon string } func (c *ConfigOne) String() string { return fmt.Sprintf("print: %v", c) } // 类型的 String() 方法。如果类型定义了 String() 方法,使用 Printf()、Print() 、 Println() 、 Sprintf() 等格式化输出时会自动使用 String() 方法。 // 递归调用 func main() { c := &ConfigOne{} c.String() }
package types import "github.com/dgrijalva/jwt-go" type Response struct { Status string `json:"status"` Message string `json:"message"` } type MyUserKey struct { UserId int64 `json:"user_id"` } type Claims struct { Id int64 `json:"id"` jwt.StandardClaims `json:"standardClaims"` } ...
package aoi import "github.com/LILILIhuahuahua/ustc_tencent_game/configs" func InitTowers() []*Tower { var towers []*Tower for i := int32(0); i < configs.TowerRows*configs.TowerCols; i++ { towers = append(towers, InitTower(i)) } return towers }
package model import ( "time" ) type ( // 菜单表 Menu struct { Id int64 `json:"id" gorm:"primary_key"` Path string `json:"path"` Modular string `json:"modular"` Component string `json:"component"` Name string `json:"name"` ParentId int64 `json:"parentId"` Is...
package html2article import ( "bytes" "io/ioutil" "net/http" "strings" "golang.org/x/text/encoding" "golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/transform" ) func DefCode(header http.Header, html string) string { contentType := strings.ToLower(header.Get("Content-Type")) if strings.Cont...
package user import ( "encoding/json" "net/http" "net/url" "shopping-cart/pkg/controllers/common" "shopping-cart/pkg/service" "shopping-cart/types" "shopping-cart/utils/applog" ) // RegisterUser : Register user account func RegisterUser(w http.ResponseWriter, r *http.Request) { user := &types.User{} applog.I...
package utils type Env struct { }
package templateversion import ( "fmt" "github.com/sirupsen/logrus" admissionregv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/runtime" "github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1" ctlharvesterv1 "github.com/harvester/harvester/pkg/generated/controllers/harvesterhci.io/v...
package p_00001_00100 // 34. Find First and Last Position of Element in Sorted Array, https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ // Edge cases // nums: [], target: 0 // nums: [1], target: 1 func searchRange(nums []int, target int) []int { if len(nums) < 1 { return []int...
package wgs84tiler import ( "fmt" "image" "image/color" "math" "os" "strconv" "sync" "time" "github.com/disintegration/imaging" ) // WGS84Bounds boundaries of the image in WSG84 world // // Example : // myBounds = WGS84Bounds{top: 48.8687073004617, right: 2.15657022586739, left: 2.14840505163567,bottom: 48....
package dao import ( "ekfet-golang/gorm/helper" "fmt" "github.com/rs/zerolog/log" "time" ) type UserInfo struct { Id uint32 Username string Password string `gorm:"column:password"` Sex uint `gorm:"column:sex;default:0"` BlackList uint `gorm:"column:blacklist;default:0"` Locking ui...
package design import ( "io" "github.com/gregoryv/draw" "github.com/gregoryv/draw/shape" ) // NewDiagram returns a diagram with present font and padding values. // // TODO: size and padding affects eg. records, but is related to the // styling func NewDiagram() *Diagram { return &Diagram{ Style: draw.NewStyle(...
/* Copyright 2021 The Pixiu 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, softw...
package news import ( "errors" "net/http" "time" "github.com/juliotorresmoreno/unravel-server/helper" "github.com/juliotorresmoreno/unravel-server/models" "github.com/juliotorresmoreno/unravel-server/social" "github.com/juliotorresmoreno/unravel-server/ws" "gopkg.in/mgo.v2/bson" ) // Publicar publica una not...
package models import autoscaling_v1 "k8s.io/api/autoscaling/v1" type Autoscaler struct { Name string `json:"name"` Labels map[string]string `json:"labels"` CreatedAt string `json:"createdAt"` // Spec MinReplicas int32 `json:"minReplicas"` MaxReplicas ...
package main import ( "strconv" "fmt" ) /* Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: Input: "25525511135" Output: ["255.255.11.135", "255.255.111.35"] */ func restoreIpAddresses(s string) []string { return restoreIP(0,s) } func re...
package polylabel import ( "encoding/json" "io/ioutil" "os" "reflect" "testing" "github.com/tidwall/geojson/geometry" ) func AssertEqual(t *testing.T, a interface{}, b interface{}) { if a == b { return } t.Errorf("Received %v (type %v), expected %v (type %v)", a, reflect.TypeOf(a), b, reflect.TypeOf(b)) }...
package main import "fmt" func main() { var nums, target = []int{2, 7, 11, 15}, 9 var res = twoSum(nums, target) fmt.Print(res) } func twoSum(nums []int, target int) []int { // var res = []int{0, 0} for i := 0; i < len(nums)-1; i++ { e := target - nums[i] for j := i + 1; j < len(nums); j++ { if nums[j] ...
package strfmt import ( "testing" "github.com/stretchr/testify/assert" ) func TestDate(t *testing.T) { pp := Date{} err := pp.UnmarshalText([]byte{}) assert.NoError(t, err) err = pp.UnmarshalText([]byte("yada")) assert.Error(t, err) orig := "2014-12-15" err = pp.UnmarshalText([]byte(orig)) assert.NoError(t...
package main import ( "fmt" "github.com/dtbell99/golangexamples/packages/jokes" ) func main() { fmt.Printf("Joke One: %s\n", jokes.GetJokeOne()) fmt.Printf("Joke Two: %s\n", jokes.GetJokeTwo()) }
package main import ( "fmt" ) // Rect - CREATE STRUCT TYPE type rect struct { w, h float32 } // PASSING STRUCT BY VALUE (COPY) - STRUCT NOT CHANGED // Return area of rectangle func (r Rect) area() float32 { return r.w * r.h } // Return scaled area of rectangle func (r Rect) scaleArea(s int) float32 { return (r...
// 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...
// Copyright 2019 The Cockroach Authors. // // Licensed as a CockroachDB Enterprise file under the Cockroach Community // License (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // https://github.com/cockroachdb/cockroach/blob/master/li...
// 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 feedback import ( "context" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/uiauto" "chromiumos/tast/local/chrom...
package storage import "github.com/NataliaZabelina/monitoring/internal/storage/schema" type DB struct { CPUTable CPUTable SystemTable SystemTable DiskTable DiskTable SocketTable SocketTable TCPTable TCPTable } func (db *DB) Init() { db.CPUTable = (&schema.CPULoadTable{}).Init() db.SystemTable = (&sche...
package server import ( "../config" "./routes/api" "github.com/gorilla/handlers" "github.com/gorilla/mux" "log" "net" "net/http" "strconv" ) func Listen(host string, port int) error { router := mux.NewRouter() router.Use(loggingMiddleware) api.Route(router) log.Println("goose started") go ProxyListen(con...
package middle_test import ( "bytes" "net/http" "net/http/httptest" "testing" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/shandysiswandi/echo-service/internal/infrastructure/app/middle" "github.com/stretchr/testify/assert" ) func TestHTTPCustomError_ErrJWTMissing(t *tes...
// Copyright (C) 2017 Google 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...
// Copyright 2022 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 storage import ( "errors" "github.com/button-tech/logger" "github.com/button-tech/utils-node-tool/db" "github.com/button-tech/utils-node-tool/db/schema" "github.com/imroc/req" "github.com/onrik/ethrpc" "log" "os" "runtime" "strconv" "sync" "time" ) type storedEndpoints struct { sync.RWMutex entr...
package ocpp import ( "errors" "fmt" "sync" "github.com/evcc-io/evcc/util" ocpp16 "github.com/lorenzodonini/ocpp-go/ocpp1.6" ) type CS struct { mu sync.Mutex log *util.Logger ocpp16.CentralSystem cps map[string]*CP } // Register registers a chargepoint with the central system. // The chargepoint identifie...
//go:generate mockgen -destination mock/start_service.go . StartServiceHandler package handlers import ( "context" "github.com/raba-jp/primus/pkg/cli/ui" "github.com/raba-jp/primus/pkg/exec" "golang.org/x/xerrors" ) type StartServiceHandler interface { StartService(ctx context.Context, dryrun bool, name string...
package main import ( "fmt" "github.com/codegangsta/cli" "io/ioutil" "os" ) var Commands = []cli.Command{ commandInit, commandG, commandLs, commandSetup, commandHelp, } var commandLs = cli.Command{ Name: "ls", Usage: "list lime templates", Description: "", Action: doLs, } var commandH...
package editing_test import ( "log" "os" "testing" "github.com/elhamza90/lifelog/internal/store/memory" "github.com/elhamza90/lifelog/internal/usecase/editing" ) var editor editing.Service // Instance of service we will be testing var repo memory.Repository // Repository used by service func TestMain(m *testi...
package engine import ( "fmt" "image" "image/color" "log" "math" "path/filepath" "raycaster-go/engine/raycaster" "runtime" "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/ebitenutil" ) const ( // ebiten constants screenWidth = 1024 screenHeight = 700 screenScale = 1.0 //--RaycastEngi...
package anton // fmt.Println("Hello") // The different functions we have on this file are: // - GatherMasters() // - GatherOpenBets() // - GatherSportsDict() // - PushOpenBet() // - RemoveOpenBet() /* import ( "fmt" "os" "strings" "github.com/antonsv3/helper" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aw...
package crawler import ( "encoding/json" "time" ) // ParserOfCompanyInstructions is a type for parse company products type ParserOfCompanyInstructions struct { Language string Company Company Category Category City City PageInstruction PageInstruction } // NewParserInstruction...
package domain import "time" // Podcast contains info about podcast type Podcast struct { ID int Title string Link string Description string Size float64 Created time.Time Performer string BitRate int Content []byte }
package main import "strings" //1662. 检查两个字符串数组是否相等 //给你两个字符串数组 word1 和 word2 。如果两个数组表示的字符串相同,返回 true ;否则,返回 false 。 // //数组表示的字符串是由数组中的所有元素 按顺序 连接形成的字符串。 // // // //示例 1: // //输入:word1 = ["ab", "c"], word2 = ["a", "bc"] //输出:true //解释: //word1 表示的字符串为 "ab" + "c" -> "abc" //word2 表示的字符串为 "a" + "bc" -> "abc" //两个字符串相同...
package repository import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" "github.com/hpmalinova/Money-Manager/model" "log" ) type UserRepoMysql struct { db *sql.DB } func NewUserRepoMysql(user, password, dbname string) *UserRepoMysql { connectionString := fmt.Sprintf("%s:%s@/%s", user, password, db...
package entity type User struct { Id, ClassId int Name string }
package exports import ( "encoding/csv" "fmt" "github.com/erik/mixport/mixpanel" "io" ) // CSVStreamer writes the records passed on the given chan in a schema-less // way. An initial header row containing the names of the columns is written // first. // // Format is: // event_id,key,value // // This way, it is...
package main import ( "context" "log" "net/http" "strconv" ) func main() { http.HandleFunc("/", myHander1) log.Fatal(http.ListenAndServe(":9998", nil)) } func myHander1(rw http.ResponseWriter, r *http.Request) { userContext := context.WithValue(context.Background(), "user", "gai") ageContext := context.WithV...
//go:build tools package tools import ( _ "github.com/golangci/golangci-lint/cmd/golangci-lint" _ "github.com/mattn/goveralls" _ "golang.org/x/vuln/cmd/govulncheck" )
package order import "errors" type AddOrderForm struct { OrderFormBase ExtraData OrderFormExtraData } // 自定义验证逻辑 func (form *AddOrderForm) Valid() error { if form.CheckProduct() == false { return errors.New("货物字段非法,请联系管理员.") } if err := form.PerfectArea(&form.ExtraData); err != nil { return err } // 验证通...
package cache import ( "diskclient" "page_scraper" "errors" "fmt" "io" "net/http" "os" "strings" "sync" "time" "crypto/sha256" "path/filepath" "encoding/base64" ) type Cache struct { } type C interface { InitializeCache(policy int, capacity int64, expiry int64) (error) LoadCacheFromDisk() (err...
package main import ( "fmt" "github.com/aws/aws-lambda-go/events" //"github.com/aws/aws-lambda-go/lambda" // "io" "io/ioutil" "log" "net/http" "os" ) // Handler is executed by AWS Lambda in the main function. Once the request // is processed, it returns an Amazon API Gateway response object to AWS Lambda func...
package services import ( "fmt" "github.com/ChristophBe/weather-data-server/config" "github.com/ChristophBe/weather-data-server/data/models" "github.com/ChristophBe/weather-data-server/data/repositories" "github.com/ChristophBe/weather-data-server/handlers/httpHandler" "log" "net/mail" "strconv" "time" ) typ...
package fastjob_test import ( "encoding/json" "testing" "github.com/pior/fastjob" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestNewJobRequest(t *testing.T) { job := &MockJob{} job.Value = 42 req, err := fastjob.NewJobRequest(job) require.NoError(t, err) assert.Equal...
package stringify import ( "reflect" "strings" "github.com/kr/text" ) func Slice(value []interface{}) string { return sliceReflect(reflect.ValueOf(value)) } func sliceReflect(value reflect.Value) (result string) { result += "[" newLineVersion := false for i := 0; i < value.Len(); i++ { item := value.Index...
package main import ( "fmt" "reflect" ) type Person struct { Name string Age int Sex string } func (p Person) Say(msg string) { fmt.Println("hello, ", msg) } func (p Person) PrintInfo() { fmt.Printf("姓名: %s,年龄: %d,性别: %s\n", p.Name, p.Age, p.Sex) } func main() { p1 := Person{"王二狗", 30, "女"} //x:=3.14 //...
package cmd import ( "fmt" "log" "strconv" "github.com/spf13/cobra" ) var ( Port, Out, CertFile, PrivateKey string IsSecure bool remCap = &cobra.Command{ Use: "remcap", Short: "Remote Packet Capture", Long: `Remcap is a remote network monitoring tool.`, RunE: func(cmd *cobra...
package fftw32 import ( "github.com/orfjackal/gospec/src/gospec" "testing" ) func TestAllSpecs(t *testing.T) { r := gospec.NewRunner() r.AddSpec(GCSpec) r.AddSpec(NewArraySpec) r.AddSpec(NewArray2Spec) r.AddSpec(NewArray3Spec) gospec.MainGoTest(r, t) // TODO: Investigate a less stupid way of doing tests in ...
/* * * ____ ______ * / __ \_________ _ ____ __/ ____/_ _____ * / /_/ / ___/ __ \| |/_/ / / / __/ / / / / _ \ * / ____/ / / /_/ /> </ /_/ / /___/ /_/ / __/ * /_/ /_/ \____/_/|_|\__, /_____/\__, /\___/ * /_/ ...
package model type Hdata struct { Guid string `json:"guid" pg:",pk"` Hash string `json:"hash" pg:",pk"` Data string `json:"data"` }
// github.com/Jinnboy/ZhuyinHash package zhuyinhash import ( "fmt" "io/ioutil" ) //CJK unicode的注音編碼 var _zy0 [0x312F - 0x3100 + 1]int16 var _zy1 [0x9FFF - 0x3400 + 1]int16 var _zy2 [0x2B81F - 0x20000 + 1]int16 var _zy3 [0x2FA1F - 0x2F800 + 1]int16 func init() { LoadZhuyin() } func LoadZhuyin() { b, err := iout...
// Copyright (C) 2017 Google 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...
// 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 torchprint import ( "github.com/libertylocked/torchprint/errors" ) // LogonRequestData is query params of logon request type LogonRequestData struct { KeepMeLoggedIn string `url:"KeepMeLoggedIn"` IncludePrintJobs string `url:"includeprintjobs"` IncludeDeviceActivity string `url:"includedevicea...
package web_test import ( "bytes" "encoding/json" "testing" "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/chainlink/store" "github.com/smartcontractkit/chainlink/store/models" "github.com/smartcontractkit/chainlink/utils" "github.com/smartcontractkit/chainlink/internal/cltest" "githu...
package datamodels import "time" type User struct { ID int64 `json:"id" form:"id"` Firstname string `json:"firstname" form:"firstname"` Username string `json:"username" form:"username"` HashedPassword []byte `json:"-" form:"-"` CreatedAt time.Time `json:"created_at" form:...
/* Copyright 2021 The KodeRover 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, s...
package cli import ( "bytes" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "k8s.io/cli-runtime/pkg/genericclioptions" "github.com/tilt-dev/tilt/internal/testutils" ) func TestOpenapi(t *testing.T) { out := bytes.NewBuffer(nil) streams := genericclioptions.IO...
package main //2319. 判断矩阵是否是一个 X 矩阵 //如果一个正方形矩阵满足下述 全部 条件,则称之为一个 X 矩阵 : // //矩阵对角线上的所有元素都 不是 0 //矩阵中所有其他元素都是 0 //给你一个大小为 n x n 的二维整数数组 grid ,表示一个正方形矩阵。如果 grid 是一个 X 矩阵 ,返回 true ;否则,返回 false 。 // // // //示例 1: // // //输入:grid = [[2,0,0,1],[0,3,1,0],[0,5,2,0],[4,0,0,2]] //输出:true //解释:矩阵如上图所示。 //X 矩阵应该满足:绿色元素(对角线上)都不是 0...
package set1 import ( "crypto/aes" "errors" ) /** * https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#ECB * * The message is divided into blocks, and each block is encrypted * separately. Each encrypted block is decrypted separately by taking * corresponding blocks of specific size and decrypting th...
package python3 import ( "testing" "github.com/stretchr/testify/assert" ) func TestList(t *testing.T) { Py_Initialize() list := PyList_New(0) assert.True(t, PyList_Check(list)) assert.True(t, PyList_CheckExact(list)) defer list.DecRef() s := PyUnicode_FromString("hello") assert.NotNil(t, s) i := PyLong_...
package movetaskorder_test import ( "testing" "time" "github.com/transcom/mymove/pkg/services" "github.com/transcom/mymove/pkg/models" . "github.com/transcom/mymove/pkg/services/move_task_order" "github.com/transcom/mymove/pkg/testdatagen" ) func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderFetcher() {...
package common import "net/http" //声明一个新的数据类型 type FilterHandle func(rw http.ResponseWriter, r *http.Request) error //用来存储需要拦截的URI type Filter struct { filterMap map[string]FilterHandle } func NewFilterHandle() *Filter { return &Filter{make(map[string]FilterHandle)} } func (f *Filter)RegisterFilterUri(uri stri...
package container import ( "github.com/rudiarta/refactory_test/config" "go.uber.org/dig" ) func InjectDatabase(c *dig.Container) *dig.Container { if err := c.Provide(config.NewMysqlConfigurator); err != nil { panic(err) } return c }
package web import ( "html/template" "github.com/yosssi/ace" "net/http" "github.com/jbrook/go-web-utils/i18n" "log" "strings" "time" "strconv" "fmt" ) const basePath = "templates" const baseTemplateName = "layout" type TemplateData map[string]interface{} type TemplateConfig struct { Asset func(name strin...
package ast import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // Testing Strategy: // // Create a new instance using the factory methods or FillVariables(), // and test the result of public observer methods Size(), FillInStringLength(), // Variables(), ToBytes(), and String(). // // Partitions: // /...
// 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 arc import ( "context" "time" "chromiumos/tast/common/android/ui" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/arc" "chromiumos/...
package listeners import ( envoy_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" ) type ListenerFilterChainConfigurerV3 struct { builder *FilterChainBuilder } func (c ListenerFilterChainConfigurerV3) Configure(listener *envoy_listener_v3.Listener) error { filterChain, err := c.builde...
package Utils import ( "encoding/json" "fmt" "net/http" ) func ServeEncodedJSONStruct(w http.ResponseWriter, obj interface{}) { err := json.NewEncoder(w).Encode(obj) if err != nil { fmt.Println(err) } }
package routers import ( "github.com/apulis/AIArtsBackend/models" "github.com/apulis/AIArtsBackend/services" "github.com/gin-gonic/gin" "strings" ) func AddGroupModel(r *gin.Engine) { group := r.Group("/ai_arts/api/models/") group.Use(Auth()) group.GET("/", wrapper(lsModelsets)) group.GET("/:id", wrapper(getM...
package button type RollbackAction struct { Label string `json:"label"` Range []int `json:"range"` Prev bool `json:"prev"` } func (this *RollbackAction) GetLabel() string { return this.Label }
package main import ( "context" "fmt" "time" ) func main() { ctx, cancel := context.WithCancel(context.Background()) go watch(ctx, "监控1") go watch(ctx, "监控2") go watch(ctx, "监控3") time.Sleep(40 * time.Second) fmt.Println("可以了,通知监控停止") cancel() time.Sleep(5 * time.Second) //方法是获取设置的截止时间,时间,是否到期。 // ctx....
package main import "testing" func TestReferences(t *testing.T) { repo := GitRepository{"test-data/samplerepo"} rs := repo.References() hs := repo.Heads() ts := repo.Tags() if len(rs) != len(hs) + len(ts) { t.Error("Not enough References found") } if len(rs) == 0 { t.Error("Not enough References found")...
package dbwork import ( "log" "encoding/json" influxDb "src/github.com/influxdata/influxdb/client/v2" "time" "os" "errors" ) const MaxArrPair int = 280 type InfoShares struct { Price float64 // 185.96, цена ChangePtr float64 // 1.3405994, изменение в % Change float64 // 2.46, изменение Rating float64 // 0....