text
stringlengths
11
4.05M
package main import ( "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" ) type CustomTableModel struct { core.QAbstractTableModel _ func() `constructor:"init"` m_data [][]float64 m_mapping map[string]*core.QRect m_columnCount int m_rowCount int } func (c *CustomTa...
package upstream_notify import ( "context" "errors" "github.com/tal-tech/go-zero/core/logx" "tpay_backend/model" "tpay_backend/payapi/internal/logic" "tpay_backend/payapi/internal/svc" "tpay_backend/utils" ) type SyncOrder struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewSyn...
package atlas import "testing" type TestParams struct { Files []string Params *GenerateParams } type TestWant struct { NumFiles, NumAtlases int } func TestGenerate(t *testing.T) { OUTPUT_DIR := "./output" BUTTONS := []string{ "./fixtures/button.png", "./fixtures/button_active.png", "./fixtures/button_h...
/* * Copyright 2018- The Pixie 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 ag...
package core import ( "context" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" kubepod "k8s.io/kubernetes/pkg/api/v1/pod" "sigs.k8s.io/controller-runtime/pkg/client" "time" ) const ( GracefulDrainPrefix = "pod-graceful-drain" WaitLabelKey = Graceful...
package main func getKeySize(text string, lGramLength int) int { repeat := make([]int, 0, len(text)) size := len(text) - lGramLength + 1 for i := 0; i < size; i++ { first := text[i : i+lGramLength] for j := i + 1; j < size; j++ { second := text[j : j+lGramLength] if first == second { repeat = append(r...
package driveapicollector import ( "fmt" "github.com/scjalliance/drivestream/resource" drive "google.golang.org/api/drive/v3" ) // MarshalPermission marshals the given permission as a resource. func MarshalPermission(perm *drive.Permission) (resource.Permission, error) { expiration, err := parseRFC3339(perm.Expi...
package graph import ( "os" "testing" "github.com/goava/di/internal/graph/testgraph" ) func TestGraph_CheckCycles(t *testing.T) { for _, graph := range testgraph.GraphSlice { f, err := os.Open("testdata/graph.json") if err != nil { t.Error(err) } defer f.Close() g, err := NewGraphFromJSON(f, graph.N...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "os" "path" "strings" "github.com/sendgrid/rest" ) func main() { // Build the URL const host = "api.sendgrid.com" endpoint := "/v3/api_keys" key := os.Getenv("SENDGRID_API_KEY") // GET params := url.Values{ "limit": {"100...
package handler import ( "log" "net/http" "strconv" "github.com/gin-gonic/gin" "github.com/quickfixgo/enum" "github.com/rudeigerc/broker-gateway/service" "github.com/rudeigerc/broker-gateway/tool" ) func TradeHandler(c *gin.Context) { futuresID := c.Query("futures_id") traderName := c.Query("trader_name") ...
package main import ( sf "github.com/zyedidia/sfml/v2.3/sfml" ) var colision bool = false func Intersects(s1, s2 *sf.Sprite) bool { isColliding, _:= s1.GetGlobalBounds().Intersects(s2.GetGlobalBounds()) return isColliding } func SpawnExplosion(pos sf.Vector2f) { explosion := NewExplosion(po...
package models //1. 目標達成できない時は、とても悔しい 10 //2. 環境のせいで、達成できないことが多い 01 //3. 難題が出てきた時、とっさに「できない」と思う 01 //4. 達成したら、すぐに次の目標を作りたい 10 //5. 目標達成するために、とにかく誰よりも行動する 10 //6. 「できない」ことは断るべきだ 01 //7. 諦めたくなったら、諦めればいい 01 //8. 環境のせいで、達成できないことが多い 01 //9. 報告しづらいことは隠せば問題ない 01 //10.自分なり...
package plugins type Error int func (e Error) Error() string { if s, ok := errors[e]; ok { return s } if e < 100 { return "Unknown transmission error" } else if e < 200 { return "Unknown server error" } else if e < 300 { return "Unknown client error" } else { return "Unknown error" } } var errors =...
package models import ( "encoding/json" "io/ioutil" "testing" ) func BenchmarkCreateRedditor(b *testing.B) { data, _ := ioutil.ReadFile("./tests/redditor.json") redditorExampleJson := string(data) for i := 0; i < b.N; i++ { sub := Redditor{} json.Unmarshal([]byte(redditorExampleJson), &sub) } }
package main import "fmt" func main() { a := 5 b := 5 count := 0 for a != b { count++ if count > b+a { fmt.Println("true") return } a++ b-- } fmt.Println(count) fmt.Println("false") }
package main import ( "errors" "flag" "log" "net" "os" "runtime" "strings" "sync" "syscall" "xip/xip" ) func main() { var wg sync.WaitGroup var blocklistURL = flag.String("blocklistURL", "https://raw.githubusercontent.com/cunnie/sslip.io/main/etc/blocklist.txt", `URL containing a list of "forbidden" names...
/* Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s. If you add periods ('.') between some characters in the local name p...
package ircserver import ( "sort" "strconv" "strings" "time" "gopkg.in/sorcix/irc.v2" ) func init() { Commands["WHOIS"] = &ircCommand{ Func: (*IRCServer).cmdWhois, MinParams: 1, } } func (i *IRCServer) cmdWhois(s *Session, reply *Replyctx, msg *irc.Message) { session, ok := i.nicks[NickToLower(msg....
package main import ( //"math" "fmt" //"io/ioutil" ) type Line struct { x int y int z int } func main() { var n int var x0, y0, x, y int m := map[Line]bool{} fmt.Scan(&n, &x0, &y0) for i:=0; i<n; i++ { fmt.Scan(&x, &y) xd := x0-x yd := y0-y v ...
package api import ( "io" "net/http" ) func serveV1SwaggerJSON(w http.ResponseWriter, r *http.Request) { w.Header().Set("content-type", "application/json") io.WriteString(w, `{ "components": { "responses": { "AssetsDetailedResponse": { "content": { "application/json": ...
package index import ( "github.com/juju/errgo" ) type field_int_neq_t struct { field_with_int_value_t field_t } func (self *field_int_neq_t) Add(id Id, value interface{}) error { var err error = nil if id < 0 { return ErrorUnsaved } conn := self.idx.Conn() defer conn.Close() _, err = conn.Do("ZADD", se...
func findDuplicate(nums []int) int { slow:=0 fast:=0 for ;;{ slow = nums[slow] fast = nums[nums[fast]] if slow == fast{ fmt.Println(slow) fmt.Println(fast) break } } fast = 0 for ;;{ fast = nums[fast] slow = nums[slow] if...
// 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 ecode import ( "fmt" "testing" ) func TestEcode(t *testing.T) { fmt.Println(TokenInvidErr.Message()) }
package kubelet import ( "fmt" "io" log "github.com/sirupsen/logrus" "github.com/argoproj/argo/errors" ) type KubeletExecutor struct { cli *kubeletClient } func NewKubeletExecutor() (*KubeletExecutor, error) { log.Infof("Creating a kubelet executor") cli, err := newKubeletClient() if err != nil { return ...
package postgres import ( "fmt" "go-movie-app/api" "log" "os" "github.com/jinzhu/gorm" "github.com/joho/godotenv" ) type movieRepository struct { db *gorm.DB tableName string } func newPostgresClient() (*gorm.DB, error) { err := godotenv.Load(".env") if err != nil { return nil, err } host := os...
package main import ( "log" "time" "github.com/shanghuiyang/rpi-devices/dev" "github.com/shanghuiyang/rpi-devices/util" ) func main() { oled, err := dev.NewOLED(128, 32) if err != nil { log.Printf("failed to create an oled, error: %v", err) return } util.WaitQuit(oled.Close) for { t := time.Now().For...
/* Package vcs provides controllers to communicate with the package repo registry. */ package vcs
package main import ( "fmt" "test" ) func main() { directions := []string{"S2N", "S2W", "E2W", "E2S", "N2S", "N2E", "W2E", "W2N", "S2E", "E2N", "N2W", "W2S"} //创建12条路 for i := 0; i < len(directions); i++ { new(test.Road).Init(directions[i]) } //打开控制器 new(test.LampController).Init() //避免主goroutine迅速运行完 va...
package design import . "goa.design/goa/v3/dsl" var _ = Service("loan", func() { Description("The loan service makes it possible to view, add or remove loans") HTTP(func() { Path("/loans") }) Method("listLoans", func() { Description("List all stored loans") Result(CollectionOf(Loan), func() { View("tin...
/* Copyright 2017 by GoWeb author: gdccmcm14@live.com. 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...
package main import "fmt" func main() { mapa := make(map[string]int) fmt.Println(mapa) mapa["Juan"] = 32 mapa["Yessica"] = 41 mapa["Darío"] = 32 fmt.Println(mapa) for i, v := range mapa { fmt.Println(i, v) } valueJ, ok := mapa["Juan"] fmt.Println(valueJ, ok) valueM, ok := mapa["Maria"] fmt.Println(v...
package server import ( "net" "sync" "sync/atomic" "errors" "dnsgo/layer" "log" ) var ( ErrClosed = errors.New("closed dns server") ) type DNSServer interface { Serve() error Addr() *net.UDPAddr Shutdown() } type server struct { addr *net.UDPAddr conn *net.UDPConn closeOnce sync.Once closed ...
package errors import ( "fmt" ) // deprecated type PageError struct { Message string } func (p PageError) Error() string { return p.Message } func (p PageError) String() string { return p.Message } func Bomb(format string, a ...interface{}) { panic(PageError{Message: fmt.Sprintf(format, a...)}) } func Danger...
package main import ( "errors" "net/url" "strconv" ) func GetLimitQueryParam(val url.Values) (int, error) { if val.Get("limit") == "" || len(val.Get("limit")) < 1 { return 0, errors.New("no 'limit' query param") } limit, err := strconv.Atoi(val.Get("limit")) if err != nil { return 0, err } return limi...
package user import ( "time" "github.com/dwaynelavon/es-loyalty-program/internal/app/eventsource" "github.com/pkg/errors" ) var ( errInvalidAggregateType = errors.New("aggregate is not of type user.User") UserDeletedEventType = "UserDeleted" UserCreatedEventType = "UserCreated" UserReferr...
// Package transmitter provides functionality for transmitting // arbitrary webhook messages on Discord. // // Existing webhooks are used for messages sent, and if necessary, // new webhooks are created to ensure messages in multiple popular channels // don't cause messages to be registered as new users. package transm...
package main import "fmt" func main() { i, j := 5, 11 k := (i + j) >> 1 fmt.Println(k) } /** 二分查找 */ func findDuplicate(nums []int) int { n := len(nums) l, r := 1, n-1 ans := -1 for l <= r { mid := (l + r) >> 1 cnt := 0 for i := 0; i < n; i++ { if nums[i] <= mid { cnt++ } } if cnt <= mid {...
/* 时间:2017/11/6 功能:golang 各种排序算法 */ package main import "fmt" func main() { a := []int{1, 5, 8, 9, 74, 6, 4, 7, 5} fmt.Println(bubbleSort(a)) } /* #冒泡排序: 重复比较相邻两个元素,顺序错误就叫唤,重复至不在需要叫唤。 冒泡就是说最小或者最大的元素回慢慢浮到数列的顶端 */ func bubbleSort(arr []int) []int { length := len(arr) for i := 0; i < length; i++ { for j :=...
package pow import ( "testing" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/mock" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint...
package problem0160 import "testing" func TestSolve(t *testing.T) { listA := &ListNode{Val: 4} listB := &ListNode{Val: 4} t.Log(getIntersectionNode(listA, listB) == nil) }
package model import ( "Seaman/utils" "time" ) type TplPermResourceT struct { Id int64 `xorm:"pk autoincr BIGINT(20)"` Code string `xorm:"not null comment('资源编号') VARCHAR(16)"` Status int `xorm:"not null default 1 comment('状态(0:无效,1:有效)') INT(11)"` Desp strin...
package yaice import ( "context" "github.com/yaice-rx/yaice/config" "github.com/yaice-rx/yaice/network" "github.com/yaice-rx/yaice/network/kcpNetwork" "github.com/yaice-rx/yaice/network/tcp" "github.com/yaice-rx/yaice/router" "google.golang.org/protobuf/proto" "reflect" ) //服务运行状态 var shutdown = make(chan boo...
package models import uuid "github.com/satori/go.uuid" type Like struct { PostID uuid.UUID `json:"post_id" gorm:"primaryKey"` UserID uuid.UUID `json:"user_id" gorm:"primaryKey"` }
package slaveMapHandler import ( "github.com/stretchr/testify/assert" "master/master" "net/http" "net/http/httptest" "testing" "github.com/gorilla/mux" "time" ) func TestInitiateEmptySlaveMapHandler(t *testing.T) { router := mux.NewRouter() responseRecorder := httptest.NewRecorder() slaveMap := make(map[st...
// Package meta reads and interprets repo metadata (acyl.yml) package meta import ( "context" "fmt" "io" "os" "path" "path/filepath" "strconv" "strings" "time" "github.com/dollarshaveclub/acyl/pkg/eventlogger" nitroerrors "github.com/dollarshaveclub/acyl/pkg/nitro/errors" "github.com/dollarshaveclub/acyl...
package initdb import ( "github.com/jinzhu/gorm" "fmt" _ "github.com/jinzhu/gorm/dialects/mysql" ) var MYSQLORM *gorm.DB func init() { connect, err := gorm.Open("mysql", "root:123456@tcp(localhost:3307)/reader?parseTime=true") if err != nil { fmt.Print(err) panic("connect postgres failed ") } //defer ...
func twoSum(nums []int, target int) []int { m := make(map[int]int) for i := 0; i < len(nums); i++ { idx := target - nums[i] // idx => if idx exists, nums slice has answer if _, ok := m[idx]; ok { return []int{m[idx], i} } // set m[pivot nums value] to nums slice keys // so if m[pivot nums value] exis...
package loader import ( "net/http" "net/http/httptest" "testing" "time" ) const ( testTextFile = "/index.html" testImgFile = "/image.png" ) func TestCompression(t *testing.T) { t.Run("compressed", func(t *testing.T) { req := httptest.NewRequest(http.MethodGet, testTextFile, nil) req.Header.Set("Accept", ...
package sound import ( "errors" "fmt" "github.com/rmcsoft/hasp/events" "github.com/sirupsen/logrus" ) // HotWordDetectedEventData is the HotWordDetectedEvent data type HotWordDetectedEventData struct { AudioData *AudioData } const ( // HotWordDetectedEventName is the event name for keyword detection HotWordD...
package instruction // GitInstructionSet 表示一个 git 指令集 type GitInstructionSet interface { Init() *GitInit Add() *GitAdd Commit() *GitCommit Push() *GitPush Status() *GitStatus } func Default() GitInstructionSet { return &defaultGitInstructionSet{} }
// Copyright (c) 2016-2018, Jan Cajthaml <jan.cajthaml@gmail.com> // // 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 require...
package middlewares import ( "encoding/json" "errors" "fmt" "net/mail" "path" "time" "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" "github.com/authelia/authelia/v4/internal/model" "github.com/authelia/authelia/v4/internal/templates" ) // IdentityVerificationStart the handler for initiating the i...
package gotten_test import ( "bytes" "fmt" "github.com/Hexilee/gotten" "github.com/Hexilee/gotten/headers" "github.com/stretchr/testify/assert" "io" "io/ioutil" "net/http" "strings" "testing" ) func TestFormRequest(t *testing.T) { creator, err := gotten.NewBuilder(). SetBaseUrl("https://mock.io"). SetC...
package main import "fmt" //匿名结构体的使用 type A struct { Name string age int } func (a *A) sayOK() { fmt.Println("A is OK.", a.Name) } func (a *A) hello() { fmt.Println("hello.", a.Name) } type B struct { Name string score float64 } type C struct { //匿名结构体 A //有名结构体 b B Name string } func main() { v...
// Copyright (c) Facebook, Inc. and its affiliates. // All rights reserved. // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. package tailerhandler import ( "github.com/facebookexperimental/GOAR/confighandler" "github.com/facebookexp...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger // 200 ok object type GetUniverseSchematicsSchematicIdOk struct { // Time in seconds to process a run CycleTime int32 `json...
package service import ( "HumoAcademy/models" "HumoAcademy/pkg/repository" ) type MainPage interface { GetAll () (models.MainPageContent, error) AddUserForNews (news models.SubscribedUsers) error } type Courses interface { CreateCourse(courses models.Courses) (int, error) EditCourse(id int, course models.Cour...
package openshift import ( "context" "errors" "fmt" "os" "strings" "sync" semver "github.com/blang/semver/v4" configv1 "github.com/openshift/api/config/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" utilerrors "k8s.io/apimachinery/pkg/util/errors" "sigs.k8s.io/controller-runtime/...
package problem0110 import "testing" func TestSolve(t *testing.T) { root1 := MakeTree([]int{10, 5, -3, 3, 2, 0, 11, 3, -2, 0, 1}) t.Log(isBalanced(root1)) root2 := MakeTree([]int{3, 9, 20, 0, 0, 15, 7}) t.Log(isBalanced(root2)) root3 := MakeTree([]int{1, 2, 2, 3, 3, 0, 0, 4, 4}) t.Log(isBalanced(root3)) } func...
package message import ( "github.com/golang/protobuf/proto" ) type Message interface { Handle() } type MessageManager interface { Produce(msg Message) Consume() (msg Message) } type messageManager struct { messageCh chan Message } func (m *messageManager) Produce(msg Message) { m.messageC...
package caaa import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00500102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.005.001.02 Document"` Message *AcceptorCancellationRequestV02 `xml:"AccptrCxlReq"` } func (d *Document00...
package utils import ( "crypto/md5" "encoding/base64" "github.com/golang/glog" "github.com/mitchellh/mapstructure" "io/ioutil" "net" "os" //"os/exec" //"strings" ) // MergeMap copy keys from a `data` map to a `resultTo` tagged object func MergeMap(data map[string]string, resultTo interface{}) error { if dat...
package main import ( "fmt" ) type TreeNode struct { Data int Left *TreeNode Right *TreeNode } type Stack struct { nodes []*TreeNode count int } func (s *Stack) Push(n *TreeNode) { s.nodes = append(s.nodes[:s.count], n) s.count++ } func (s *Stack) Pop() *TreeNode { if s.count == 0 { return nil } s.c...
package main import ( "testing" ) func TestParseCode(t *testing.T) { opcode, paramsMode := ParseCode(1002) if opcode != 2 { t.Errorf("expected 2, got %v", opcode) } if paramsMode[0] != 0 || paramsMode[1] != 1 || paramsMode[2] != 0 { t.Errorf("expected [0, 1, 0], got %v", paramsMode) } } func TestIntCodeCom...
package slice_utils //Subtract - func Subtract(originalList []interface{}, subtractList []interface{}) []interface{} { result := make([]interface{}, 0) for _, original := range originalList { exists := false for _, subtract := range subtractList { if subtract == original { exists = true } } if !exi...
package 贪心 import "strconv" func maximum69Number(num int) int { // 获得最高位的6,将其改为9,如果没有,就不用更改 numString := strconv.Itoa(num) numBytes := []byte(numString) for i := 0; i <= len(numBytes)-1; i++ { if numBytes[i] == '6' { numBytes[i] = '9' break } } max69Number, _ := strconv.Atoi(string(numBytes)) return ...
package map2 func Append(m1, m2 map[string]interface{}) { for k, v := range m2 { m1[k] = v } }
package metalgo import ( v1 "github.com/metal-stack/masterdata-api/api/rest/v1" "github.com/metal-stack/metal-go/api/client/project" "github.com/metal-stack/metal-go/api/models" ) // ProjectListResponse is the response of a ProjectList action type ProjectListResponse struct { Project []*models.V1ProjectResponse }...
package main import ( "context" "errors" "sync" "testing" "time" "github.com/brigadecore/brigade/sdk/v3" coreTesting "github.com/brigadecore/brigade/sdk/v3/testing" myk8s "github.com/brigadecore/brigade/v2/internal/kubernetes" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io...
package main import ( "fmt" "sync" "time" ) // To wait for multiple goroutines to finish, we can use a wait group. // This is the function we’ll run in every goroutine. func worker(id int, wg *sync.WaitGroup) { defer wg.Done() fmt.Printf("Worker %d starting \n", id) time.Sleep(time.Second) fmt.Printf("Work...
package main import ( "fmt" "sync" "testing" ) var counter = 0 func OnlyInce() { counter++ } func TestOnce(t *testing.T) { once := sync.Once{} group := sync.WaitGroup{} for i := 0; i < 100; i++ { go func() { group.Add(1) once.Do(OnlyInce) group.Done() }() } group.Wait() fmt.Println("Counter...
package main import ( "fmt" ) const FMT = "%T Value = %v\n" // a struct is a collection of fields // a struct is always a type. type Astruct struct { X int Y int } func main() { // literal struct declaration with named variables // v receives type Astruct var v = Astruct{Y: 2} v.X = 7 fmt.Printf(FMT, v, v) ...
// base64 project doc.go /* base64 document */ package main
// +build wireinject // The build tag makes sure the stub is not built in the final build. package di import ( "github.com/google/wire" "github.com/yk2220s/go-grpc-sample/api/application/server" "github.com/yk2220s/go-grpc-sample/api/usecase" ) func InitializeGRPCServer() (*server.GRPCServer, func(), error) { wi...
package api import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) type CloudCIXClient struct { Email, Password, ApiKey, Token, ApiUrl string } func (cixClient CloudCIXClient) GetToken() (string, error) { json_data := map[string]string{"api_key": cixClient.ApiKey, "email": cixClient.Email, "password"...
package main import ( "fmt" merry_go_round "merry-go-round" "sync" ) func main() { i := 0 pool := merry_go_round.NewPool(func() interface{} { rs := i i++ return rs }, 64) result := map[int]int{} muResult := sync.Mutex{} wg := sync.WaitGroup{} shouldBe := 1024 * 64 wg.Add(shouldBe) for i := 0; i < s...
package dao import ( "context" "git.dustess.com/mk-base/mongo-driver/mongo" "git.dustess.com/mk-training/mk-blog-svc/config" ) const collName = "blog" // BlogDao 客数据可连接 type BlogDao struct { dao *mongo.Dao ctx context.Context } // NewBlogDao 创建对象 func NewBlogDao(ctx context.Context) *BlogDao { return &BlogDao...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
package engine_util import "github.com/coocood/badger" type CFItem struct { item *badger.Item prefixLen int } // String returns a string representation of Item func (i *CFItem) String() string { return i.item.String() } func (i *CFItem) Key() []byte { return i.item.Key()[i.prefixLen:] } func (i *CFItem) K...
package headway import ( "fmt" "github.com/pkg/errors" "net/http" ) type Client struct { Host string Secret string Client http.Client } func NewClient(host, secret string) *Client { return &Client{ Secret: secret, Host: host, Client: http.Client{}, } } func (c *Client) Send(current, total float64,...
package lode import ( "context" "errors" "fmt" "github.com/brunoscheufler/lode/parser" "github.com/brunoscheufler/lode/replication" "github.com/jackc/pgx" "github.com/sirupsen/logrus" ) type Configuration struct { // Postgres connection string to use ConnectionString string // Postgres replication slot nam...
/* 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 dht import ( "fmt" "testing" "time" dhtcfg "github.com/libp2p/go-libp2p-kad-dht/internal/config" "github.com/libp2p/go-libp2p-kad-dht/providers" "github.com/libp2p/go-libp2p-kbucket/peerdiversity" record "github.com/libp2p/go-libp2p-record" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/g...
package main import ( "flag" "fmt" "log" "net/http" ) var ( addrFlag = flag.String("addr", ":5555", "server address:port") ) func main() { flag.Parse() http.HandleFunc("/", helloWorld) err := http.ListenAndServe(*addrFlag, nil) if err != nil { log.Fatal(err) } } func helloWorld(w http.ResponseWriter, r ...
package main import ( "fmt" ) const ( url = "https://lpo.dt.navy.mil/data/DM/Environmental_Data_Deep_Moor_2015.txt" ) func main() { fmt.Println(url) }
package router import ( "context" "net/http" ) type handler struct { endpoint Endpoint decodeReq DecodeRequestFunc encodeRes EncodeResponseFunc encodeErr EncodeErrorFunc } func NewHandler(e Endpoint, d DecodeRequestFunc, en EncodeResponseFunc, er EncodeErrorFunc) *handler { h := &handler{ endpoint: e, d...
// fzgo is a simple prototype of integrating dvyukov/go-fuzz into 'go test'. // // See the README at https://github.com/thepudds/fzgo for more details. // // There are three main directories used: // // 1. cacheDir is the location for the instrumented binary, and would typically be something like: // GOPATH/pkg...
package consumer type Limiter func(topic string)
package main import ( "flag" "fmt" "os" "sort" "strings" ) func newSpellCheck(srcpaths []string, ignfile string) (*Spellcheck, error) { toks, err := GoTokens(srcpaths) if err != nil { return nil, err } splitToks := make(map[string]struct{}) for k, _ := range toks { for _, field := range strings.Fields(k...
package main /** 37. 解数独 编写一个程序,通过已填充的空格来解决数独问题。 一个数独的解法需遵循如下规则: - 数字 1-9 在每一行只能出现一次。 - 数字 1-9 在每一列只能出现一次。 - 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。 空白格用 '.' 表示。 ![_1.png](./source/_1.png) 一个数独。 ![_2.png](./source/_2.png) 答案被标成红色。 Note: - 给定的数独序列只包含数字 1-9 和字符 '.' 。 - 你可以假设给定的数独只有唯一解。 - 给定数独永远是 9x9 形式的。 */ /** ... */ fun...
package utils import ( "testing" _ "gin-vue-admin/config" ) func TestSendSMS(t *testing.T) { SendShotMessage("13718320428", "123456") }
package controllers import ( "context" "github.com/superbet-group/code-cadets-2021/homework_4/02_bets_api/internal/api/controllers/models" ) type BetResponse interface { GetBetById(ctx context.Context, id string) (models.BetResponseDto, bool, error) GetBetsByUser(ctx context.Context, userId string) ([]models.BetR...
package mhfpacket import ( "errors" "github.com/Andoryuuta/Erupe/network" "github.com/Andoryuuta/Erupe/network/clientctx" "github.com/Andoryuuta/byteframe" ) // MsgMhfGetEarthValue represents the MSG_MHF_GET_EARTH_VALUE type MsgMhfGetEarthValue struct { AckHandle uint32 Unk0 uint32 Unk1 uint32 ReqT...
package main import "code.google.com/p/go-tour/pic" func Pic(dx, dy int) [][]uint8 { ret := make([][]uint8, dy) for i:=0; i<len(ret); i++ { ret[i] = make([]uint8, dx) } return ret } func main() { pic.Show(Pic) }
package main import ( "fmt" "log" //"sync" "os" "time" "os/exec" "strconv" "bufio" ) var usage = ` Usage: autoscaler [options] <url> Options: -h Custom Web Cluster Address, name1:value1 -r request rate (sent per second) threshold -c cpu usage threshold -t response time (average in one second) threshold ` va...
package tccpoutputs import ( "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/giantswarm/microerror" "github.com/giantswarm/aws-operator/service/controller/legacy/v25/cloudformation" "github.com/giantswarm/aws-operator/service/controller/legacy/v25/controller...
package core type Language uint8 const ( English Language = iota ) func (lang Language) toStopwordsCode() *string { switch lang { case English: code := new(string) *code = "en" return code default: return nil } } func (lang Language) toSnowballCode() *string { switch lang { case English: code := ne...
package logs import "unicode/utf8" // Application identifies the application emitting the given log. func Application(log string) string { for _, char := range log { switch { case char == '❗': return "recommendation" case char == '🔍': return "search" case char == '☀': return "weather" } } retu...
package oidcsdk import "gopkg.in/square/go-jose.v2" type IClient interface { GetID() string GetSecret() string IsPublic() bool GetIDTokenSigningAlg() jose.SignatureAlgorithm GetRedirectURIs() []string GetPostLogoutRedirectURIs() []string GetApprovedScopes() Arguments GetApprovedGrantTypes() Arguments }