text
stringlengths
11
4.05M
package admission import ( "context" "fmt" "path/filepath" "strings" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" chimerav1alpha1 "github.com/chimera-kube/chimera-control...
package main // this is a front end to check-procs. it allows us to build the check // as a stand alone function import ( "fmt" "log" "os" "plugins" "plugins/metrics" "strings" ) var the_metric = plugins.PluginConfig{ Type: "metric", Command: "", Handlers: []string{}, Standalone: true, Interval...
package msutil import x "github.com/dearcj/golangproj/network" type XServerDataMsg struct { UniqueID []byte changed bool data *x.ServerData backup *x.ServerData } func (n *XServerDataMsg) WriteToMsg() *x.ServerData { n.changed = true return n.data } func (n *XServerDataMsg) Reset() { *n.data = *n.back...
package main import ( "bufio" "fmt" "log" "math/rand" "os" "time" ) var ( userAgents []string random *rand.Rand source rand.Source ) func loadUserAgents() { //Load user agents from file file, err := os.Open(*userAgentFile) if err != nil { //File not found, or whatever, use default UA userAgen...
package db import ( "testing" "github.com/GoAdminGroup/go-admin/modules/config" _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/sqlite" ) var driverTestSQLiteConn Connection func InitSqlite() { driverTestSQLiteConn = testConn(DriverSqlite, config.Database{File: "/admin.db"}) } func TestSQLiteSQL_WhereIn...
// 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 main import ( "rpc/utils" "fmt" "log" "net/rpc" ) func main() { var serverAddress = "localhost" client, err := rpc.DialHTTP("tcp", serverAddress + ":8080") if err != nil { log.Fatal("Fail", err) } args := &utils.Args{10,10} var reply int err = client.Call("MathService.Multiply", args, &reply) ...
package main import ( "context" "encoding/json" "io/ioutil" "log" "net" "net/http" "strings" ) // Client is a way of interacting with the Orbit unix socket. type Client struct { client *http.Client } // NewClient creates a new instance of the orbit socket client. func NewClient() *Client { return &Client{ ...
/* Copyright 2021 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, softw...
package main type Product interface { Size() int } type Car struct { } type Bus struct { } func(c *Car) Size() int { return 1 } func(b *Bus) Size() int { return 2 } type Factory struct { } func NewFactory() *Factory { return &Factory{} } func(f *Factory) MakeProduct(kind int) Product { if kind == 1 { ...
package websocket import ( "KServer/library/kiface/iwebsocket" "KServer/library/websocket/utils" "fmt" "strconv" ) type MsgHandle struct { Handle map[uint32]iwebsocket.IHandle //存放每个Id 所对应的处理方法的map属性 WorkerPoolSize uint32 //业务工作Worker池的数量 TaskQueue []chan iwebsocket.IRequest...
package main import ( "fmt" "net/http" ) type handlerType string func (h handlerType) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "request handled") } func main() { var handy handlerType http.ListenAndServe(":8080", handy) }
package main import ( "fmt" "github.com/araddon/dateparse" ) func main() { fmt.Println("vim-go") t, err := dateparse.ParseAny("6/10/2021, 8:26:03 AM") fmt.Printf("%+v, %+v\n", t, err) }
/* Copyright (c) 2017 GigaSpaces Technologies Ltd. All rights reserved Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable ...
package main import ( "fmt" "jblee.net/adventofcode2018/utils" ) func findSimilarString(lines []string) string { for i, line := range lines { for j := i + 1; j < len(lines); j++ { line2 := lines[j] diffPos := -1 for pos := 0; pos < len(line); pos++ { letter := line[pos] if letter != line2[pos]...
package main import ( "fmt" "io/ioutil" "strings" ) var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101} func main() { lines := read() part1(lines) part2(lines) } func part1(lines []string) { sum := 0 for _, line := range lines { seen :=...
package db import ( "fmt" "time" "github.com/jinzhu/gorm" ) //BootstrapData sets up initial data func BootstrapData(db *gorm.DB) { bootstrapTeams(db) bootstrapHeats(db) } func bootstrapTeams(db *gorm.DB) { teams := []Team{ {Slug: "team1", Description: "The first team1", }, {Slug: "team2", Descrip...
package main import ( "github.com/gorilla/mux" "github.com/itsmeadi/cart/src/entities/config" "github.com/itsmeadi/cart/src/interfaces/db/cache" "github.com/itsmeadi/cart/src/interfaces/db/mysql" "github.com/itsmeadi/cart/src/interfaces/product" "github.com/itsmeadi/cart/src/interfaces/productByCategory" "githu...
package volume import ( "errors" "fmt" "strconv" "time" "github.com/Huawei/eSDK_K8S_Plugin/src/storage/fusionstorage/client" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/taskflow" ) const ( notSupportSnapShotSpac...
package dpos import ( "testing" "time" "github.com/aergoio/aergo/consensus/impl/dpos/slot" "github.com/aergoio/aergo/types" "github.com/stretchr/testify/assert" ) const ( nSlots = 5 bpInterval = 1 ) func TestDposFutureBlock(t *testing.T) { slot.Init(bpInterval) dpos := &DPoS{} block := types.NewBloc...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-06-12 10:08 # @File : list.go # @Description : # @Attention : */ package array_list type List interface { Add(data interface{}) RemoveByIndex(index int) (interface{},error) Show() func() (interface{}, bool) Size()int } type DoublyList interface { Li...
package q_test import ( "github.com/elliotchance/gedcom" "github.com/elliotchance/gedcom/q" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" ) func TestNodesWithTagPathExpr_Evaluate(t *testing.T) { engine := &q.Engine{} doc := gedcom.NewDocument() individual := doc.AddIndi...
package buildah import ( "context" "fmt" "io" "os" "path/filepath" "runtime" "github.com/werf/werf/pkg/buildah/types" "github.com/werf/werf/pkg/werf" ) const ( DefaultShmSize = "65536k" BuildahImage = "ghcr.io/werf/buildah:v1.22.3-1" BuildahStorageContainerName = "werf-buildah-...
// Copyright 2019 The OpenSDS Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agre...
package main /* * @lc app=leetcode.cn id=11 lang=golang * * [11] 盛最多水的容器 */ // @lc code=start func maxArea(height []int) int { left := 0 right := len(height) - 1 maxArea := 0 for left < right { var w, h int w = right - left if height[left] < height[right] { h = height[left] left++ } else { h ...
package main //测试用客户端 import ( "bytes" //"encoding/json" "fmt" "io/ioutil" "net/http" ) type hust struct { s string } func main() { test := []string{"test1", "test2", "test3", "test4", "test5"} server := "http://127.0.0.1:9090/?action=log" var _test []byte for _, v := range test { _test = append(_test, [...
package kafka import ( "log" "logAgent/config" "github.com/Shopify/sarama" ) func InitKafka() (kafkaServerClient sarama.SyncProducer){ kafkaServerConf := sarama.NewConfig() kafkaServerConf.Producer.RequiredAcks = sarama.WaitForAll kafkaServerConf.Producer.Partitioner = sarama.NewRandomPartitioner kafkaServer...
// generated by stringer -type=OpCode; DO NOT EDIT package main import "fmt" const _OpCode_name = "CharMatchJumpSplitSaveNop" var _OpCode_index = [...]uint8{0, 4, 9, 13, 18, 22, 25} func (i OpCode) String() string { if i+1 >= OpCode(len(_OpCode_index)) { return fmt.Sprintf("OpCode(%d)", i) } return _OpCode_na...
package httputil import ( "encoding/json" "log" "net/http" "github.com/asaskevich/govalidator" "github.com/sirupsen/logrus" ) type ContentType int const ( JSON ContentType = iota Form HTML ) type jsonResponse struct { StatusCode int `json:"status_code"` Messages []string `json:"messages"` D...
package main import "fmt" var( as =new([3]int) ) func main() { /** 冒泡排序 */ arr:= [10]int{4, 4, 1, 2, 12, 5, 6, 834, 3, 0} //var arr = new([10]int) fmt.Println(arr) for i := len(arr)-1; i >=0; i-- { for j := 0; j < i; j++ { if arr[j]>arr[j+1]{ tem := arr[j+1] arr[j+1] = arr[j] arr[j] = tem...
// Copyright 2016 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package controllers import ( "net/http" "github.com/gin-gonic/gin" ) var statusMessage = map[int]string{ http.StatusBadRequest: "参数有误", http.StatusUnauthorized: "缺少认证信息", http.StatusForbidden: "无权限", http.StatusMethodNotAllowed: "服务器未实现的请求方法", http.StatusInternalServerError: "服务器出错", http.S...
package main import ( "fmt" "time" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) type HouseChange struct { Recordid int64 `gorm:"primary_key;type:int(11) auto_increment;not null"` Customerid int64 `gorm:"type:int(11)"` OldHouseid int64 `gorm:"type:int(11)"` PresentHouseid int...
package main import ( "github.com/hashicorp/terraform/helper/schema" ) func resourceGCPAccount() *schema.Resource { return &schema.Resource{ Create: resourceGCPAccountCreate, Read: resourceGCPAccountRead, Update: resourceGCPAccountUpdate, Delete: resourceGCPAccountDelete, Schema: map[string]*schema.Sch...
package state import ( "io" valuetransaction "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/packages/kv/buffered" ) // represents an interface to the mutable sta...
package main import "fmt" func main(){ //Go 语言的字符有以下两种: //一种是 uint8 类型,或者叫 byte 型,代表了 ASCII 码的一个字符。 //另一种是 rune 类型,代表一个 UTF-8 字符。当需要处理中文、日文或者其他复合字符时,则需要用到 rune 类型。rune 类型实际是一个 int32。 var a byte = 'a' var b uint8 ='b' var c rune = '中' var d int32 = '国' //使用 fmt.Printf 中的%T动词可以输出变量的实...
package notbearparser // func TestQuery(t *testing.T) { // queryStr := `div[data-pk="test_pk", hidden] p>.red` // queryList, err := NewQueryList(queryStr) // if err != nil { // t.Fatal(err) // } // for _, query := range queryList { // fmt.Println(query.NodeName, query.AttrList, query.Target) // } // }
// +build !windows package fs import ( "fmt" "os" "path/filepath" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "golang.org/x/sys/unix" ) type Fslock struct { FileName string fd *os.File } func (f *Fslock) Lock() error { flockF, err := os.Create(f.FileName) if err != nil { return fmt.Err...
package render import ( "testing" "github.com/sh0rez/docsonnet/pkg/docsonnet" "github.com/stretchr/testify/assert" ) func TestSortFields(t *testing.T) { api := docsonnet.Fields{ "new": dfn(), "newNamed": dfn(), "aaa": dfn(), "bbb": dobj(), "ccc": dfn(), "metadata": dobj(), } sorted := []str...
// Copyright (C) 2021 Cisco Systems Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agr...
package log import ( "io" "os" "path/filepath" "runtime" "github.com/Sirupsen/logrus" ) /************************************************* Debug Level Setting - debug - info - warning - error - fatal - panic *************************************************/ const ( fileTag = "file" lineTag = "line" funcTag...
package number_test import ( "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/ywardhana/golib/number" ) func TestToString(t *testing.T) { tests := []struct { Title string Value interface{} Expected string }{ { Title: "Test int", Value: 123, Expected: "123", }, ...
package utils import ( "io" "strings" ) func ShowPaged(w io.Writer, text string) error { return showPagedReader(w, strings.NewReader(text)) } func ShowPagedReader(w io.Writer, r io.Reader) error { return showPagedReader(w, r) }
// Package static adds a static string to i3bar. Its main purpose is // demonstrating the module API of `i3gostatus` and it acts as a template for // new modules. package static import ( "time" "github.com/pelletier/go-toml" "github.com/rumpelsepp/i3gostatus/lib/model" ) const ( name = "static" moduleName...
/* * @lc app=leetcode id=901 lang=golang * * [901] Online Stock Span */ // @lc code=start type Pair struct { Val int Res int } type StockSpanner struct { Item []Pair } func Constructor() StockSpanner { stockspanner := StockSpanner{make([]Pair, 0)} return stockspanner } func (this *StockSpanner) Next(price ...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package language import ( "html/template" "testing" "github.com/GoAdminGroup/go-admin/modules/config" "github.com/stretchr/testify/assert" ) func TestAdd(t *testing.T) { Add("cn", map[string]string{}) } func TestGetWithScope(t *testing.T) { config.Initialize(&config.Config{ Language: CN, }) cn["foo"] = "b...
package main import ( "fmt" "time" ) var workerID int var publisherID int func main() { input := make(chan string) go workerProcess(input) go workerProcess(input) go workerProcess(input) go publisher(input) go publisher(input) go publisher(input) go publisher(input) time.Sleep(1 * time.Millisecond) } /...
// outer_events.go provides EventsAPI particular outer events package slackevents import ( "encoding/json" ) // EventsAPIEvent is the base EventsAPIEvent type EventsAPIEvent struct { Token string `json:"token"` TeamID string `json:"team_id"` Type string `json:"type"` APIAppID string `js...
package echo import ( "bytes" "encoding/json" "net/http" "net/http/httptest" "testing" ) func TestContext(t *testing.T) { b, _ := json.Marshal(u1) r, _ := http.NewRequest(POST, "/users/1", bytes.NewReader(b)) c := &Context{ Response: &response{Writer: httptest.NewRecorder()}, Request: r, params: make...
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
package iproto import "github.com/DmiAS/cube_cli/internal/app/models" const cube_svc int32 = 0x00000002 // для передачи по сети используем слайс байт, соответственно нужно завернуть токен и скоуп // в пакет, сформировать структура пакета запроса и преобразовать ее в слайс байт func packRequest(token, scope string) (...
package main import ui "github.com/gizak/termui" type OnInputFn func(message string) type OnCloseFn func() type ChatWindow struct { messages [][]string messageWindow *ui.Table scrolledRows int } func (chat *ChatWindow) Height() int { numRows := chat.messageWindow.Height if chat.messageWindow.Border { /...
package main import ( "flag" "fmt" "gocomp/compiler/lexer" "io/ioutil" "log" "os" ) var ( filepath string ) func init() { flag.StringVar(&filepath, "f", "", "Path to needed file") } func readFile(path string) (string, error) { file, err := os.Open(path) if err != nil { return "", err } data, err := i...
package wrpc import ( "sync" "log" "github.com/samuel/go-zookeeper/zk" ) type Register struct { ser *Server mutex sync.Mutex } func NewRegister(ser *Server) *Register { return &Register{ser: ser} } func (r *Register) registe(){ r.mutex.Lock() //加锁 zkc := r.ser.GetZkClient() conf := r.ser.GetConf() v...
//判断链表是有存在环 package main import ( "fmt" ) type LNode struct { Data int Next *LNode } func IsLoop(head *LNode) *LNode{ if head == nil || head.Next == nil { return head } slow := head.Next fast := head.Next for fast != nil && fast.Next != nil { slow = slow.Next fast = fast.Next.Next if slow == fast {...
package cloudflare_test import ( "context" "encoding/json" "fmt" "log" cloudflare "github.com/cloudflare/cloudflare-go" ) func ExampleAPI_CreateLogpushJob() { api, err := cloudflare.New(apiKey, user) if err != nil { log.Fatal(err) } zoneID, err := api.ZoneIDByName(domain) if err != nil { log.Fatal(err...
package registry import ( "net" "net/http" "net/url" "time" "github.com/docker/docker/registry" "github.com/docker/go-connections/sockets" "golang.docker.com/go-docker/api/types" "golang.docker.com/go-docker/registry/auth" "golang.docker.com/go-docker/registry/auth/challenge" "golang.docker.com/go-docker/re...
package main import ( "fmt" ) func calc(index string, a, b int) int { ret := a + b fmt.Println(index, a, b, ret) return ret } type Users struct { Name string } func main() { //x := 1 //y := 2 //tp1 := calc("B", x, y) //defer calc("A", x, tp1) //x = 3 //tp2 := calc("D", x, y) //defer calc("C", x, tp2) /...
// Copyright 2013 Walter Schulze // // 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...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //58. Length of Last Word //Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in t...
package main import ( "fmt" "io/ioutil" "log" "net/http" "path/filepath" "strings" ) var configPath string var config = map[string]string{} func authHandler(w http.ResponseWriter, r *http.Request) { pw, err := getConfig(r.URL.Path) if err != nil || pw == "" { //http.Error(w, "no authentication config foun...
package controllers import ( "os" "path/filepath" . "mick/models" "github.com/jinzhu/gorm" ) func CheckImageFile(db *gorm.DB) { d, err := os.Open("./images/") CheckErr(err) defer d.Close() files, err := d.Readdir(-1) CheckErr(err) var photo Photo for _, file := range files { if file.Mode().IsRegular(...
package job_build import ( "github.com/yangqinjiang/mycrontab/worker/common" ) //推送任务执行结果 事件的管理者 type JobResultPusher interface { PushResult(jobResult *common.JobExecuteResult) }
package ads import ( "encoding/json" "fmt" "log" "regexp" "sync" "time" ) var portOpen bool type Connection struct { addr *AmsAddr port int symbolsLoaded bool Symbols map[string]*ADSSymbol datatypes map[string]ADSSymbolUploadDataType handles ...
package main import ( "fmt" ) // 六种特殊情况,左边比右边小,表示的值=右边-左边,也就意味着,遇到这种情况时,减去该数就行 func romanToInt(s string) int { roman := make(map[byte]int) roman['I'] = 1 roman['V'] = 5 roman['X'] = 10 roman['L'] = 50 roman['C'] = 100 roman['D'] = 500 roman['M'] = 1000 var ret int for i := 0; i < len(s)-1; i++ { if ro...
package base import ( "hash/crc32" "hash/crc64" ) var HashTable = map[string]func(Buffer) uint64{ "checksum8": __hashChecksum8, "checksum16": __hashChecksum16, "checksum32": __hashChecksum32, "checksum64": __hashChecksum64, "crc32": __hashCrc32, "crc64": __hashCrc64ISO, "crc64.iso": __hashCrc64IS...
// Copyright 2020 CUE 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 ...
package handler import ( "fmt" "net/http" "tpay_backend/cashier/internal/lang" "tpay_backend/cashier/internal/svc" "tpay_backend/utils" "github.com/gin-gonic/gin" ) func GetCurrentLang(c *gin.Context, svcCtx *svc.ServiceContext) (currentLang string, currentLangList []string) { // 1.程序内的默认语言 currentLang = lan...
package modules import ( "encoding/json" "time" "github.com/fatih/structs" "github.com/sirupsen/logrus" ) // gen:qs type NotificationType struct { ID uint `description:""` CreatedAt time.Time `description:"등록일"` UpdatedAt time.Time `description:"수정일"` Name string ...
package main import ( "flag" "fmt" "io/ioutil" "log" "net/http" "path/filepath" "gopkg.in/yaml.v2" ) type routes struct { Path string URL string } func parseYaml(file string) ([]routes, error) { ymlFile, _ := filepath.Abs(file + ".yml") ymlData, err := ioutil.ReadFile(ymlFile) if err != nil { return...
package main import ( "fmt" ) func d7() { for i := 3; i > 0; i-- { defer func(n int) { fmt.Print(n, " ") }(i) } } // Replace d8 with main to execute the programme func main() { d7() } // Due to the parameter of the anonymous function, each time the anonymous // function is deferred, it gets and therefor...
package module import ( //"loger" ) type SkillInfo struct { ID int `bson:"_id"` Name string `json:"name"` } type SkillInfoLst map[int]*SkillInfo type SkillMgr struct { moduleMgr *ModuleMgr skillLst SkillInfoLst //! 玩家技能信息 } //! 初始化 func (self *SkillMgr) Init(moduleMgr *ModuleMgr) { self.moduleMgr = modul...
package pbengine import ( "io/ioutil" "log" "os" "os/exec" "github.com/vanishs/gwsrpc/swg" "github.com/vanishs/gwsrpc/utils" ) //GenFile GenFile func GenFile(pkgname, filename string) { //copy file err := os.MkdirAll("./gwsrpcpbfile/"+pkgname, 0777) if err != nil { log.Fatalln(err) } //复制原来的文件改名pkgname...
package queue import ( "io" "os" "sync" ) type Queue struct { file *os.File rwMutex sync.RWMutex } type Element struct { size int64 msg uintptr } const ElementMetadataSize = 8 func (q *Queue) Push(bytes []byte) error { size := int64(len(bytes)) data := append(int64ToBytes(size), bytes...) q.rwMutex...
package command import ( Cli "github.com/ajpen/termsnippet/cli" "gopkg.in/urfave/cli.v1" ) func InstallCommand(c cli.Command) { Cli.App.Commands = append(Cli.App.Commands, c) }
package store import ( "time" "github.com/go-ocf/cloud/cloud2cloud-connector/events" "github.com/go-ocf/cloud/cloud2cloud-connector/store" ) type Subscription struct { ID string // Id URL string // href CorrelationID string // uuid Type store.Type ContentType string // ap...
// Copyright 2019-present 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 agr...
// CookieJar - A contestant's algorithm toolbox // Copyright (c) 2013 Peter Szilagyi. All rights reserved. // // CookieJar is dual licensed: use of this source code is governed by a BSD // license that can be found in the LICENSE file. Alternatively, the CookieJar // toolbox may be used in accordance with the terms and...
package utils import ( "os" "path/filepath" "strings" terrascanUtils "github.com/accurics/terrascan/pkg/utils" ) // FindAllSubDirectories finds all the sub directories in a path and filters would any directories specified in dirFilter func FindAllSubDirectories(basePath string, dirFilter []string) ([]string, err...
package parked_domain import ( "fmt" "time" "strings" "encoding/hex" "crypto/sha256" "github.com/google/uuid" ) var ( // define array condition(s) for parked domains ParkedDomainConditions = []func(body string) bool { GoDaddyDomainParked, } ) // function used to check god...
// +build !race package dsstore import ( "context" "testing" "time" "github.com/square/p2/pkg/replication" "github.com/square/p2/pkg/util" . "github.com/anthonybishopric/gotcha" ds_fields "github.com/square/p2/pkg/ds/fields" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/manifest" pc_fields ...
package scroll_test import ( "fmt" "github.com/fatlotus/scroll" "golang.org/x/net/context" ) // Define what a mutation looks like. type Mutation interface { Update(b *Backend) } // Define the types of mutations to store in the log. type AddItem string type RemoveItem string // Make sure duplicate operations are...
package server import ( "encoding/json" "github.com/golang/glog" "io/ioutil" "log" "net/http" ) type ConfigFilePagesData struct { Dns_proxy int `json:"dns_proxy"` Redirect int `json:"redirect"` Subcompany string `json:"subcompany"` CompanyName string `json:"companyName"` } type reqConfigFilePagesNew struct ...
package userinterface import ( ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" ) // ProgressGraph is loading graph of searching of image type ProgressGraph struct { *widgets.Gauge } // SetPercent updates the percentage func (graph *ProgressGraph) SetPercent(percent int) { graph...
package engine import "net/http" // ResponseWriter ... type ResponseWriter interface { responseWriterBase // get the http.Pusher for server push Pusher() http.Pusher } func (w *responseWriter) Pusher() (pusher http.Pusher) { if pusher, ok := w.ResponseWriter.(http.Pusher); ok { return pusher } return nil }
package methodtest func delOneFromArray(slice []int, n int) []int { length := len(slice) result := []int{} for i := 0; i < length; i++ { if n != slice[i] { result = append(result, slice[i]) } } return result }
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obta...
package main import ( "flag" "omokServer" ) type hostConf struct { maxGameCount int startTcpPort int RedisAddress string RedisPoolSize int RedisReqTaskChanCapacity int omokConf omokServer.OmokConf } //-c_maxGameCount=100 -c_startTcpPort=11021 -c_network=tcp4 -c_ipAddress=127.0.0.1 func createHostConf() hos...
package nebulatest import ( "fmt" "strings" "github.com/vesoft-inc/nebula-go/graph" ) type Differ interface { Diff(result string) Error() error } type DifferError struct { err error } func (d *DifferError) Error() error { return d.err } func NewDiffer(resp *graph.ExecutionResponse, dType string, order bool...
package command import ( "flag" "fmt" "sort" "rsc.io/getopt" ) // Help is a "help" cli command and "-h" type Help struct { *command } // NewHelp creates an instance of Generate func NewHelp(pool Pooler, name string) *Help { return &Help{newCommand(pool, name)} } // Run implements Commander func (c *Help) Run...
package descriptor import ( "google.golang.org/grpc" "testing" ) func Test_descriptor_empty_package(t *testing.T) { desc, err := NewDescriptor("../testdata/protobuf/service/service.pb") if err != nil { t.Fatal(err) } sds := ServiceDescs(desc) service := "Service" if s := sds[0].ServiceName; s != service {...
package main import ( "bytes" "errors" "io" "mime/multipart" "net/http" "net/http/httptest" "os" "testing" "time" ) func TestMainFunc(t *testing.T) { defer func() { if r := recover(); r != nil { t.Fatalf("Main panicked ??") } }() go main() time.Sleep(1 * time.Second) } func TestModifyAPI(t *test...
package sync import ( "time" "github.com/cpusoft/goutil/belogs" "github.com/cpusoft/goutil/xormdb" "xorm.io/xorm" ) func delMftDb(session *xorm.Session, filePathPrefix string) (err error) { start := time.Now() belogs.Debug("delMftDb():will delete lab_rpki_mft_*** by filePathPrefix :", filePathPrefix) // get ...
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V. // // 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 // // Un...
package cache import ( "fmt" "time" "project/common/global" "project/utils" "project/utils/config" "github.com/go-redis/redis/v7" ) // GetUserCache 获取用户缓存 func GetUserCache(keys *[]string, userId int) (cacheMap map[string]*redis.StringCmd) { cacheMap = make(map[string]*redis.StringCmd, len(*keys)) pipe := g...
package main import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "gorm_project/modules/relation_tables" ) func main() { connStr := "root:Kaka@2019@/gorm_project?charset=utf8&parseTime=True&loc=Local" db, err := gorm.Open("mysql", connStr) if err != nil { panic(err) } defer db...
package utils import ( "net/http" ) func createCookie(name, value, domain string) *http.Cookie { var age int if value == "" { age = -1 } else { age = 99999 } return &http.Cookie{ Name: name, Value: value, Domain: domain, Path: "/", MaxAge: age, // HttpOnly: true, } } func SaveCookie(w ht...
package validator import ( "context" "github.com/go-playground/validator/v10" "github.com/qiniu/qmgo/operator" "github.com/stretchr/testify/require" "go.mongodb.org/mongo-driver/bson" "testing" ) // User contains user information type User struct { FirstName string `bson:"fname"` LastName strin...
package scheduler import ( "container/heap" "time" "types" "github.com/golang/glog" ) var ( usersPriorityQ types.PriorityQueue usersPresent map[string]bool //userPresent[Uid] == true means that the Uid has been in usersPriorityQ. usersActiveQ chan string usersPodsQ map[string]chan types.Pod highPrio...