text
stringlengths
11
4.05M
package controllers var ( // Common errors SUCCESS = &Errno{Code: 200, Message: "成功"} InternalServerError = &Errno{Code: 10001, Message: "内部服务错误"} ErrBind = &Errno{Code: 10002, Message: "参数错误"} ErrDatabase = &Errno{Code: 20001, Message: "数据库错误"} ErrToken = &Errno{Code: 20002, ...
// Copyright (c) 2020 Blockwatch Data Inc. // Author: alex@blockwatch.cc package micheline import ( logpkg "github.com/echa/log" ) var log logpkg.Logger = logpkg.Log func init() { DisableLog() } func DisableLog() { log = logpkg.Disabled } func UseLogger(logger logpkg.Logger) { log = logger } type logClosure ...
package gjwt import "testing" type fixture struct { token string valid bool } var ( fixtures = []fixture{ { token: "eyJhbGciOiJSUzI1NiIsImtpZCI6IjUyNDNiNDI5ZGUxOGY0NTY4NTYwOTMwNDY3NDBlMDU2NjRjNDI5OTYifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhdF9oYXNoIjoiVzlfazV6R2ZlVDBPdWZ3M2JLSG1WZyIsImF1ZCI6Ij...
package hooks import ( "fmt" "os" "path/filepath" "github.com/sirupsen/logrus" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/manifest" "github.com/square/p2/pkg/pods" "github.com/square/p2/pkg/runit" "github.com/square/p2/pkg/util" ) // Populates the given directory with executor scripts for ...
package main import "fmt" func main() { x := []int{ 1, 0, } moveZeroes(x) fmt.Println(x) } func moveZeroes(nums []int) { for left, right := 0, 0; left < len(nums) && right < len(nums); right++ { if nums[right] != 0 { nums[left], nums[right] = nums[right], nums[left] left++ } } }
package main import "fmt" type MemoryUserStore struct { store Users } type Users map[string]User func NewMemoryUserStore() *MemoryUserStore { return &MemoryUserStore{Users{}} } func (u *MemoryUserStore) InsertUser(user User) { u.store[user.Username] = user fmt.Println(u.store) } func (u *MemoryUserStore) GetU...
package tls import ( "github.com/pkg/errors" "github.com/openshift/installer/pkg/asset" ) // KeyPairInterface contains a private key and a public key. type KeyPairInterface interface { // Private returns the private key. Private() []byte // Public returns the public key. Public() []byte } // KeyPair contains ...
package main import ( "fmt" . "leetcode" ) //定义一个函数,输入一个链表的头节点,反转该链表并输出反转后链表的头节点。 // 示例: // 输入: 1->2->3->4->5->NULL // 输出: 5->4->3->2->1->NULL func main() { fmt.Println(reverseList(NewListNode(1, 2, 3, 4, 5))) } func reverseList(head *ListNode) *ListNode { if head == nil || head.Next == nil { return head } ...
package aggregates import ( "github.com/tmtx/res-sys/pkg/bus" "github.com/tmtx/res-sys/pkg/event" "github.com/tmtx/res-sys/pkg/validator" ) type Space struct { Base Id int `json:"id"` } func (ag *Space) GetTargetEvents() []bus.MessageKey { return []bus.MessageKey{} } func (ag *Space) ApplyEvent(e event.Event)...
package intercom import ( "io/ioutil" "testing" ) func TestConversationFind(t *testing.T) { http := TestConversationHTTPClient{t: t, expectedURI: "/conversations/147", fixtureFilename: "fixtures/conversation.json"} api := ConversationAPI{httpClient: &http} convo, _ := api.find("147") if convo.ID != "147" { t....
package main import ( "fmt" "os" "time" "github.com/casainurbania/playground/task" "github.com/gomodule/redigo/redis" "github.com/casainurbania/playground/cmd" "github.com/casainurbania/playground/conn" ) var r redis.Conn func init() { var err error r, err = redis.Dial("tcp", "127.0.0.1:6379") if err != ...
/* * Copyright © 2018-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://...
package controller import ( "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/argoproj/argo/errors" "github.com/argoproj/argo/persist/sqldb/mocks" wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" "githu...
package mediator import ( "log" ) // Mediator provides type Mediator interface { Notify(id rune, amount int) } type mediator struct { colleagueA Account colleagueB Account } // Notify processes an operation from the mediator (implement Mediator interface) func (m *mediator) Notify(id rune, amount int) { if m.c...
package redis import () const ( ResultUsed = 0 ResultFree = 1 ) type Result struct { Data interface{} Cmd *Command Err error } func (r *Result) release() { }
// Copyright 2019 Kuei-chun Chen. All rights reserved. package mdb import ( "bufio" "encoding/json" "errors" "fmt" "io/ioutil" "os" "path/filepath" "strings" "github.com/simagix/gox" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" ) // Explain stores explain object info type Explai...
// Copyright 2016 Matthew Endsley // All rights reserved // // Redistribution and use in source and binary forms, with or without // modification, are permitted providing that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions ...
// Copyright 2010 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 main import ( "bufio" "github.com/knieriem/peg" "os" "runtime" ) func main() { runtime.GOMAXPROCS(2) t := peg.New(true, true) /*package peg ...
// 模拟读取、解析、写入log的过程 package main import ( "fmt" "strings" "time" ) type Reader interface { Read(rc chan string) } type Writer interface { Write(wc chan string) } type ReadFromFile struct { path string } type WriteToInfluxDB struct { dbsource string } type LogProcess struct { rc chan string wc chan ...
package mysqldb import ( "database/sql" "fmt" "sync" ) type Mysqldb struct { db *sql.DB } var mysqlObject *Mysqldb var once sync.Once func GetInstance() *Mysqldb { once.Do(func() { mysqlObject = &Mysqldb{} }) return mysqlObject } func (mdb *Mysqldb) OpenMysqlDateBase() *sql.DB { var err error mdb.db, er...
package main import ( "os" "github.com/therecipe/qt/widgets" ) func main() { widgets.NewQApplication(len(os.Args), os.Args) var ( window = widgets.NewQMainWindow(nil, 0) vbox = widgets.NewQVBoxLayout2(nil) button = widgets.NewQPushButton2("click me!", nil) ) vbox.AddWidget(button, 0, 0...
package es import ( "context" "errors" "github.com/cshum/gopkg/dev" "github.com/cshum/gopkg/paginator" "github.com/olivere/elastic" ) var DebugMode = false type Middleware func(s *Search) type QueryHandler func(ctx context.Context, q *elastic.BoolQuery) error type FunctionScoreHandler func(ctx context.Context,...
package main import "fmt" func main() { var average = calculateAverage(1, 1, 2, 4, 5, 6, 7) var message = fmt.Sprintf("Average : %.2f ", average) fmt.Printf(message) } func calculateAverage(number ...int) float64 { var total int = 0 for _, n := range number { total += n fmt.Println(total) } var avg = f...
package main import ( "fmt" "os" "runtime" "strconv" "time" micro "github.com/micro/go-micro" pb "github.com/rpcx-ecosystem/rpcx-benchmark/go-micro/pb" "golang.org/x/net/context" ) var ( host string delay int ) type Hello struct{} func (t *Hello) Say(ctx context.Context, args *pb.BenchmarkMessage, reply...
package discord import ( "fmt" "regexp" "time" "github.com/bwmarrin/discordgo" "github.com/mitchellh/mapstructure" ) var warnMatch = regexp.MustCompile(`warn <@!?\d+> (.+)`) type empty struct{} type warning struct { Mod string //ID Text string Date int64 Guild string //ID } func (b *Bot) warnCmd(user...
package protocols_test import ( "net/http" "reflect" "testing" . "github.com/smartystreets/goconvey/convey" "github.com/stellar/gateway/protocols" callback "github.com/stellar/gateway/protocols/bridge" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestProtocols(t *testing....
package services //TeamService define the team management operations type TeamService interface { Add(team *Team) (Team, error) Get(id string) (Team, error) Put(team *Team) (Team, error) Delete(id string) error GetAll() ([]Team, error) } //MatchService define the match management operations type MatchService int...
package raft import ( "bytes" "encoding/gob" "labrpc" "math/rand" "sync" "time" ) // import "bytes" // import "encoding/gob" // // as each Raft peer becomes aware that successive log entries are // committed, the peer should send an ApplyMsg to the service (or // tester) on the same server, via the applyCh pas...
package main import ( "os" "fmt" "bufio" ) func main() { input_filepath := "03_input.txt" count := make(map[string]int) if len(os.Args) > 1 { input_filepath = os.Args[1] } input_file, err := os.Open(input_filepath) if err != nil { fmt.Printf("Error! %s\n", err) } input := bufio.NewScanne...
package main import ( "fmt" "io/ioutil" "log" "gopkg.in/yaml.v3" ) // User struct represents one user record in the file type User struct { Name string Occupation string } func main() { yfile, err := ioutil.ReadFile("villains.yaml") if err != nil { log.Fata...
package main import ( "bufio" cryptorand "crypto/rand" "flag" "fmt" "io" "math/rand" . "os" "os/signal" "syscall" ) func readInput(f *File, c chan []byte) { reader := bufio.NewReader(f) for { line, err := reader.ReadBytes('\n') if err != nil { if err == io.EOF { break } else { panic(err...
package donothing import ( "bytes" "testing" "github.com/stretchr/testify/assert" ) // DefaultCLI.Usage should return the usage string. func TestDefaultCLI_Usage(t *testing.T) { t.Parallel() assert := assert.New(t) pcd := NewProcedure() pcd.Short("Procedure's short description") type testCase struct { De...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02500104 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.025.001.04 Document"` Message *SecuritiesSettlementTransactionConfirmationV04 `xml:"Sctie...
package main import ( "container/list" "log" ) /* Checks if a Field on the Map can be accessed by the Player. If a Field is accessible or the Player is in Ghost-Mode, the Old-Position gets updated and true gets returned. */ func (b *Bomberman) isFieldAccessible(x int, y int) bool { isAccessNull := true isAccessOn...
package controllers import ( "os" "strconv" "time" "github.com/astaxie/beego" ) type UserController struct { beego.Controller } func (c *UserController) Get() { userID := c.Input().Get("userID") sleepTime, _ := strconv.Atoi(os.Args[1]) if sleepTime > 0 { time.Sleep(time.Duration(sleepTime) * time.Millisec...
package sqlite_test import ( "context" "fmt" "testing" "regexp" "github.com/stretchr/testify/assert" sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1" "github.com/hezbymuhammad/payment-gateway/domain" transactionRepo "github.com/hezbymuhammad/payment-gateway/transaction/repository/...
package spider import ( "fmt" "github.com/gocolly/colly" "github.com/sanguohot/zxcs-go-spider/etc" "github.com/sanguohot/zxcs-go-spider/pkg/common/client" selfErr "github.com/sanguohot/zxcs-go-spider/pkg/common/err" "github.com/sanguohot/zxcs-go-spider/pkg/common/file" "github.com/sanguohot/zxcs-go-spider/pkg/c...
package main import ( "fmt" "reflect" "strconv" ) // This example shows the basic usage of the package: Create an encoder, // transmit some values, receive them with a decoder. func main() { csv := map[string]string{"Name": "ethan", "Age": "30", "Test": "true"} type man struct { Name string Age int Test ...
package main import ( "fmt" "net/http" "io/ioutil" "os" "" //"net/url" ) type Result struct { Url string star float64 } func main() { crawl("http://jobtalk.jp/company/index_1.html") } /** * 実際にクロールする関数 */ func crawl(url string){ response, err := http.Get(url) if err...
package drainer import ( "context" ) // EnsureDeleted is a no-op, because the lifecycle resource only has to act on // create and update events in order to drain guest cluster nodes. func (r *Resource) EnsureDeleted(ctx context.Context, obj interface{}) error { return nil }
package gender // NOTE This should obviously not be assumed this is an exhaustive list. var gender = map[string]string{ "female": "♀", "male": "♂", "hermaphrodite": "⚦", "trans": "⚧", // or ⚦ or ⚥ or ⚨ "inter": "⚩", }
package defaults import ( "fmt" "os" "github.com/apparentlymart/go-cidr/cidr" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/openstack" ) const ( // DefaultCloudName is the default name of the cloud in clouds.yaml file. DefaultCloudName = "openstack" // DualStackVIPsPor...
package atlas import ( "errors" "fmt" ) var ( errCommonServerError = "an unexpected server error has occurred" errCommonUnauthorized = "failed to authenticate with MongoDB Cloud API" errCommonForbidden = "Please check your Atlas API Whitelist entries to " + "ensure that requests from this IP address are allo...
package model import ( "fmt" "gorm.io/gorm" "time" ) const MerchantBankCardTableName = "merchant_bank_card" type MerchantBankCard struct { Id int64 `gorm:"id"` MerchantId int64 `gorm:"merchant_id"` // 商户id CreateTime int64 `gorm:"create_time"` // 创建时间 BankName string `gorm:"bank_name"` /...
package base import "rtda" // Branch 指令跳转方法 // 获取当前线程的程序计数器 // 设置下一条指令的地址 基地址+offset func Branch(frame *rtda.Frame, offset int) { pc := frame.Thread().PC() nextPC := pc + offset frame.SetNextPC(nextPC) }
// Copyright 2018 The eballscan Authors // This file is part of the eballscan. // // The eballscan is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your optio...
package foundation import ( "fmt" "strings" ) func Assert(b bool, a ...interface{}) { if !b { Panic(a...) } } func Panic(a ...interface{}) { if !IsProd() { formats := make([]string, len(a)+1) panic(fmt.Errorf(strings.Join(formats, "%v "), a...)) } } func Panicf(format string, a ...interface{}) { if !Is...
package main import ( "fmt" ) func main() { var t int fmt.Scan(&t) for ;t>0;t-- { var n int fmt.Scan(&n) even := 0 odd := 0 off := 0 for i:=0; i<n; i++ { var e int fmt.Scan(&e) if e%2 == 0 { even++ if i%2 == 1 { off++ } } else { odd++ if i%2 == 0 { off++ } } } if...
package manifests import ( "fmt" "os" "path/filepath" "strings" "github.com/coreos/stream-metadata-go/arch" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1" "github.com/openshi...
package annotated import hsm "github.com/hhkbp2/go-hsm" func NewWorld() *AnnotatedHSM { top := hsm.NewTop() initial := hsm.NewInitial(top, StateS0ID) s0 := NewS0State(top) s1 := NewS1State(s0) NewS11State(s1) s2 := NewS2State(s0) s21 := NewS21State(s2) NewS211State(s21) sm := NewAnnotatedHSM(top, initial) s...
// Copyright © 2019 IBM Corporation and others. // // 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 la...
package handlers import ( "fmt" "net/http" "strings" "time" "github.com/dgrijalva/jwt-go" "golang.org/x/oauth2" "golang.org/x/oauth2/google" api_oauth2 "google.golang.org/api/oauth2/v2" "github.com/root-gg/plik/server/common" "github.com/root-gg/plik/server/context" ) var googleEndpointContextKey = "goog...
package codec import ( "fmt" "github.com/popodidi/log" ) type simpleCodec struct{} func (c *simpleCodec) Encode(entry *log.Entry) []byte { content := entry.Log if entry.Level <= log.Error { content = fmt.Sprintf("%s: %s", entry.DebugInfo, entry.Log) } return []byte(content) }
package 链表 // ----------------------------- 迭代解法 ----------------------------- func swapPairs(head *ListNode) *ListNode { oddList, evenList := getOddAndEvenList(head) return crossMerge(evenList, oddList) } func getOddAndEvenList(list *ListNode) (*ListNode, *ListNode) { oddDummyHead, EvenDummyHead := &ListNode{}, &...
package main import ( "context" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" "path/filepath" "time" "github.com/mmcdole/gofeed" "github.com/pquerna/cachecontrol/cacheobject" ) // TODO if a feed is fetched, it shouldn't need to be loaded type cacheItem struct { Name string UUID ...
package crypto import ( "crypto/rand" "testing" pb "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto/pb" "gx/ipfs/QmW7VUmSvhvSGbYbdsh7uRjhGmsYkc9fL8aJ5CorxxrU5N/go-crypto/ed25519" ) func TestBasicSignAndVerify(t *testing.T) { priv, pub, err := GenerateEd25519Key(rand.Reader) if err != n...
package problem0300 import "testing" func TestLIS(t *testing.T) { //t.Log(lengthOfLIS([]int{10, 9, 2, 5, 3, 7, 101, 18})) t.Log(lengthOfLIS([]int{0, 1, 0, 3, 2, 3})) t.Log(lengthOfLISII([]int{0, 1, 0, 3, 2, 3})) //t.Log(lengthOfLIS([]int{7, 7, 7, 7, 7})) }
package utils import ( "crypto/aes" "crypto/cipher" "crypto/rand" "crypto/sha256" "encoding/hex" "fmt" "io" ) const salt = "61606982" type AESCrypt struct { SecretKey string } func NewAesCrypt(key string) *AESCrypt { // Sha256 hash the key h := sha256.New() h.Write([]byte(key)) return &AESCrypt{SecretKe...
package seeder import ( "ImaginatoGolangTestTask/shared/utils" _const "ImaginatoGolangTestTask/shared/utils/const" ) func (s Seed) AdminSeed() { adminData := []map[string]interface{}{ { "Name": "super admin", "Email": "superadmin@gmail.com", "Password": utils.HashedPassword("123...
// Copyright 2016 Claudemiro Alves Feitosa Neto. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package ipe import "net/http" type applicationContext struct { DB db } // url params type params map[string]string func (p params) Get(key s...
// Package http provides the HTTP server for accessing the distributed key-value store. // It also provides the endpoint for other nodes to join an existing cluster. package http import ( "bytes" "fmt" "net" "net/http" "strings" log "github.com/sirupsen/logrus" "github.com/gogo/protobuf/proto" "github.com/ra...
package test import ( "database/sql" "fmt" "log" "os" "strconv" "testing" "time" "github.com/cucumber/godog" _ "github.com/lib/pq" "github.com/spirifoxy/accountclient/pkg/accounts" "github.com/stretchr/testify/assert" ) var f *clientFeature type clientFeature struct { c *accounts.Client dsn string d...
package main import ( "Lect12/str" "fmt" ) func PrintEmployee(empl str.Employee) { fmt.Println("Name:", empl.FirstName) fmt.Println("Lastname:", empl.LastName) fmt.Println("Age:", empl.Age) } func main() { empl := str.Employee{ FirstName: "Bob", LastName: "Snow", Age: 27, } PrintEmployee(empl) ...
package gonba import ( "fmt" "time" ) const endpointScheduleV2 = "scoreboard/%s/games.json" const scheduleV2DateFormat = "20060102" func (c *Client) GetScheduleV2(date time.Time) (ScheduleV2, int) { var schedule scheduleResponseV2 params := map[string]string{"version": "2"} dateString := date.Format(scheduleV2D...
package main import ( "bufio" "fmt" "log" "os" "strings" ) func main() { file, err := os.Open("input.txt") if err != nil { log.Fatal(err) } defer file.Close() s := bufio.NewScanner(file) alphabet := "abcdefghijklmnopqrstuvwxyz" characters := make([]int, 26) var duplicates, triplets int for s.Scan() {...
package main import ( "fmt" "os" ) const ( watchPath = "./test.txt" //hudredMB = 100000000 //oneMB = 1000000 fiftyKB = 50000 ) func main() { f, _ := os.OpenFile(watchPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) //f, _ := os.OpenFile("./log.txt", os.O_APPEND, os.ModeAppend) f.Write(make([]byte, fiftyKB))...
package yo // more idents than expressions in declaration func yoyo(){ var i,j,k = 1,2 }
package ghosts import "testing" func TestPhantom(t *testing.T) { result := new(Phantom) expectedName := "Phantom" expectedEvidence := [3]string{"Freezing", "EMF 5", "Orbs"} t.Run("Phantom.Name()", func(t *testing.T) { if result.Name() != expectedName { t.Errorf("Phantom.Name() should equal %v, but instead ...
package leetcode /*In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the...
/* 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, so...
package main import ( "regexp" "strconv" "github.com/gdamore/tcell" ) type ListItem interface { DrawMessage(s tcell.Screen, y int) String() string } type List struct { List []ListItem ActiveIdx int Offset int Updating bool chord string BackCallback func() ForwardCallback func() T...
package main import ( "context" "fmt" "github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter10/pipeline" ) func main() { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() in, out := pipeline.NewPipeline(ctx, 10, 2) go func() { for i := 0; i < 20; i++ { ...
package db import ( "context" "go-cqrs/model" ) // Repository interface type Repository interface { InsertWoof(ctx context.Context, woof model.Woof) error ListWoofs(ctx context.Context, offset uint64, limit uint64) ([]model.Woof, error) Close() } // This is a straightforward way of achieving inversion of contr...
// 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 utils import ( "github.com/kuznetsovin/go.geojson" "github.com/stretchr/testify/assert" "testing" "time" ) func TestBrokerMsg_FromBytes(t *testing.T) { msg := []byte(`{"client":445,"packet_id":22989,"navigation_unix_time":1573116514,"received_unix_time":1573116516,"latitude":55.697471661422746,"longitude...
package ghclient import ( "fmt" "os" "path/filepath" "strings" "github.com/pkg/errors" "github.com/spf13/afero" desfacer "gopkg.in/jfontan/go-billy-desfacer.v0" git "gopkg.in/src-d/go-git.v4" gitcache "gopkg.in/src-d/go-git.v4/plumbing/cache" gitfs "gopkg.in/src-d/go-git.v4/storage/filesystem" ) // RepoFin...
package slack import ( "net/http" "reflect" "testing" ) type userGroupsHandler struct { gotParams map[string]string response string } func newUserGroupsHandler() *userGroupsHandler { return &userGroupsHandler{ gotParams: make(map[string]string), response: `{ "ok": true, "usergroup": { "id"...
// Copyright 2021 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...
/* Copyright (c) 2016 Jason Ish * 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 conditions...
package main import ( "bytes" "encoding/json" "errors" "fmt" "gopkg.in/redis.v3" "os" ) var ( // This creates the connection to the redis client RClient *redis.Client = readConfig() ) func createBlankRCfg() (rClient *redis.Client) { blankCfg := redis.Options{} rClient = redis.NewClient(&blankCfg) return r...
package handler import ( "api-server/utils" "encoding/json" "github.com/golang/glog" "github.com/gomodule/redigo/redis" "net/http" ) /* http://192.168.2.153:5678/ConfigFile/ConfigJM?version=66 */ type ResponseConfigJM struct { Success string `json:"success"` Code int `json:"code"` Data in...
package main import ( "bytes" "fmt" "os" "os/exec" "path" "path/filepath" "strings" ) const ( assetDir = "./assets/images" staticDir = "./static/images" ) // TODO: read from config file var widths = []int{ 650, 500, 400, } var quality = map[string]int { ".jpg" : 70, ".png" : 90, ".webp" : 40, ...
package middlewares import ( "encoding/base64" "encoding/json" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/defaults" "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" "github...
package main import ( "math/rand" "strings" "testing" ) func TestGenerateString(t *testing.T) { t.Run("should generate the correct length", func(t *testing.T) { length := rand.Intn(10) a := GenerateString(length, "abcde") if len(a) != length { t.Errorf("GenerateString() returned the wrong length %d inst...
package main import gc "github.com/rthornton128/goncurses" func (v *View) NormalCommand(ch gc.Key) { switch ch { case gc.KEY_RIGHT, 'l', gc.KEY_UP, 'k', gc.KEY_DOWN, 'j', '\n', gc.KEY_LEFT, 'h', DELETE_KEY: v.CursorMove(ch) case CTRS_KEY: v.Save() case 'q': close(quit) case 'i': v.mode = Insert v.sta...
/** * Copyright 2019 Comcast Cable Communications Management, 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 requir...
// Copyright 2023 Google LLC. 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 applica...
package proxy import ( corev1 "k8s.io/api/core/v1" ) // NoopQuerier returns an instance of noopQuerier. It's used for upstream where // we don't have any cluster proxy configuration. func NoopQuerier() Querier { return &noopQuerier{} } // Querier is an interface that wraps the QueryProxyConfig method. // // QueryP...
package solver import ( "fmt" "math/rand" ) func pupuRand(shuffleCount int) []int { nbMove := shuffleCount pupu := finalGrid var iz int for i, v := range pupu { if 0 == v { iz = i } } for nbMove > 0 { randDir := rand.Intn(4) if randDir == 0 { if iz/size+1 != size { tmp := pupu[iz] pupu[...
package auth0 import ( "testing" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func TestAccResourceServer(t *testing.T) { resource.Test(t, resource.TestCase{ Providers: map[string]terraform.ResourceProvider{ "auth0": Provider(), }, Steps: []resource.TestS...
package buffer import ( // "fmt" "sync" ) // Ephemeral stays in the volatile storage // later could make a decision on using sync.Map vs map with locks // ref: https://medium.com/@deckarep/the-new-kid-in-town-gos-sync-map-de24a6bf7c2c type PageTable struct { index map[uint32]int _lock sync.RWMutex } func (pt *Pa...
package alarms import ( "code.google.com/p/gompd/mpd" "database/sql" "encoding/json" "github.com/frio/restful" ) var ( Resource *restful.Resource Collection *restful.Collection ) type Alarm struct { Room string Host string IsSounding bool } func post(encoded json.Decoder) (interface{}, error)...
package main import ( "go-server/src/handlers" "log" "net/http" ) func main() { http.HandleFunc("/", getSpotifyAuth) log.Fatal(http.ListenAndServe(":8081", nil)) }
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-07-24 14:34 * Description: *****************************************************************/ package xthrift import "github.com/apache/thrift/lib/go/...
package template import ( "math/rand" "regexp" "strconv" "time" ) // TrimSpace 去除首位空格 func TrimSpace(params string) string { var rep, err = regexp.Compile(`(^\s*)|(\s*$)`) if err != nil { return "" } return rep.ReplaceAllString(params, "") } // GetRandNum 获取随机数(字符串) // length: 随机数长度 // return: string - 随机...
package main import "fmt" func IterativeFactorial(nb int) int { if nb < 0 || nb > 12 { // если исходное значение - отрицательное или охереть какое больлшое return 0 //то функция выводит 0 } else if nb == 0 { //если же исходное значение равно 0 return 1 //то функция выводит 0 } c := nb /...
package fourchan // Struct to hold catalog information from a JSON Unmarshal. type PageInfo struct { Page int `json:"page"` Threads []PostData `json:"threads"` }
package mysqldb import ( . "logicdata/parser" ) var ( userTables = map[string]TblField{ "main_ranking": TblField{ FieldList: []Field{ Field{"id", "BIGINT(20) UNSIGNED", false, false}, Field{"score", "BIGINT(20) UNSIGNED", false, false}, Field{"name", "VARCHAR(32)", false, false}, Field{"userdat...
package common import ( "context" "fmt" "os" "path/filepath" "sort" "strconv" "strings" "time" "github.com/spf13/cobra" "github.com/werf/logboek" "github.com/werf/logboek/pkg/level" "github.com/werf/logboek/pkg/style" "github.com/werf/logboek/pkg/types" "github.com/werf/werf/pkg/build" "github.com/we...
package omp // OMPv4 . type OMPv4 struct { }