text
stringlengths
11
4.05M
package cli import ( "encoding/json" "fmt" "github.com/kohirens/stdlib" "io/fs" "os" "path/filepath" "strings" "text/template" "text/template/parse" ) const ( TmplManifest = "template.json" ) // GenerateATemplateManifest Make a JSON file with your templates placeholders. func GenerateATemplateManifest(tmpl...
package clusters import ( envoy_cluster "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" "github.com/kumahq/kuma/pkg/xds/envoy/endpoints/v3" ) type DnsClusterConfigurer struct { Name string Address string Port uint32 } var _ ClusterConfigurer = &DnsClusterConfigurer{} func (e *DnsCluster...
//nolint:gocritic package lgtm import ( "bytes" "fmt" "regexp" "strconv" "strings" "text/template" "time" "github.com/sirupsen/logrus" "github.com/ti-community-infra/tichi/internal/pkg/ownersclient" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/test-infra/prow/config" "k8s.io/test-infra/prow/github" "k8s.i...
package main import ( "net/http" "time" "github.com/PhongVX/taskmanagement/internal/app/api" "github.com/PhongVX/taskmanagement/internal/pkg/log" ) func main() { log.Infof("Initializing HTTP routing...") r, err := api.NewRouter() if err != nil { log.Panicf("Failed to init routing, error %v", err) } log.In...
package httphandlers import ( "encoding/json" "fmt" "net/http" ) type User struct { Name string } type UserService interface { Register(user User) (id string, err error) } type UserServer struct { service UserService } func NewUserServer(s UserService) *UserServer { return &UserServer{service: s} } func (s...
package sdkconnector import ( "fmt" "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" "github.com/hyperledger/fabric-sdk-go/pkg/common/errors/retry" "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" ) //JoinChannel joins given organization's peers to channel func JoinChannel(setup *OrgSetup, channelName ...
package main import "fmt" type Person struct { name string sex byte age int } type Student struct { Person id int addr string } func (tmp *Person) PrintlnInfo() { fmt.Printf("name=%s,sex=%c,age=%d\n", tmp.name, tmp.sex, tmp.age) } func (tmp *Student) PrintlnInfo() { fmt.Println("Student: tmp = ", tmp) ...
/* 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 controllers import ( "devbook-api/src/authentication" "devbook-api/src/database" "devbook-api/src/models" "devbook-api/src/repositories" "devbook-api/src/responses" "encoding/json" "errors" "io/ioutil" "net/http" "github.com/gorilla/mux" ) func CreatePost(w http.ResponseWriter, r *http.Request) { ...
package controllers import ( "admigo/common" "admigo/model/users" "encoding/json" "github.com/julienschmidt/httprouter" "net/http" "time" ) const ( UUID_COOKI string = "uuidcookie" ) // POST /signup // Create an user account func SignupAccount(w http.ResponseWriter, request *http.Request, ps httprouter.Params...
package namegen import ( "compress/gzip" "crypto/rand" "encoding/json" "fmt" "log" "math/big" "os" "strings" ) const ( legalDNSChars = "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ) // NameGenerator describes an object capable of generating new environment names type NameGenerator inter...
package switcher import ( //"crypto/md5" //"crypto/rand" //"database/sql" "os" "strconv" "time" //"encoding/base64" //"encoding/hex" //"encoding/json" //"fmt" //"io" //"io/ioutil" "log" //"net/http" //"path" //sw "sqliteToMysql/switcher" "strings" //xupload "xinlanAdminTest/xinlanUpload" //"github....
package iset const ( NOP byte = 0x00 // Loads value from DS address into register // EX: if DS[0x01] is int32 and op used is int8 the value is casted LOAD byte = iota // load #1, 0x01 FREE byte = iota // load #1 // String to numbers STRI8 byte = iota // stri8 #1, #2 STRI16 byte = iota STRI32 byte = i...
package combat import ( "fmt" "log" "time" "github.com/I82Much/rogue/event" "github.com/I82Much/rogue/math" "github.com/I82Much/rogue/player" "github.com/I82Much/rogue/stats" termbox "github.com/nsf/termbox-go" ) const ( PlayerDied = "PLAYER_DIED" AllMonstersDied = "MONSTERS_VANQUISHED" ) type State ...
package main // ResourceType resource type ResourceType struct { ID string `json:"id"` Name string `json:"name"` Active bool `json:"active"` PrivateName string `json:"privateName"` } // ResourceTypePrivateData type ResourceTypePrivateData struct { ResourceTypeID string `json:"resource_type...
package gofinancial import ( "encoding/json" "fmt" "io" "math" "os" "path" "time" "github.com/go-echarts/go-echarts/v2/charts" "github.com/go-echarts/go-echarts/v2/opts" "github.com/razorpay/go-financial/enums/interesttype" ) // Amortization struct holds the configuration and financial details. type Amorti...
// Copyright 2019 John Papandriopoulos. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. // Zydis is a Go wrapper for the fast and lightweight Zydis x86/x86-64 // disassembler library, found at http://zydis.re/. This package provides // bind...
/* * 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 server import ( "net/http" "github.com/qnib/metahub/pkg/daemon" ) func getBaseHandler(service daemon.Service) http.Handler { //storageService := env.Storage() return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { }) }
package serviced import ( "encoding/json" "fmt" "io/ioutil" "os" "path/filepath" log "github.com/sirupsen/logrus" ) func unmarshal(filename string, v interface{}) (err error) { jsonBytes, err := ioutil.ReadFile(filename) if err == nil { err = json.Unmarshal(jsonBytes, v) } return } func marshal(filename...
package models_test import ( "fmt" "github.com/APTrust/exchange/constants" "github.com/APTrust/exchange/models" "github.com/APTrust/exchange/util" "github.com/APTrust/exchange/util/testutil" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "math/rand" "testi...
package tarot import ( "fmt" "sort" ) type Player struct { Id int CardsRemaining map[Card]bool } type PlayerJson struct { AllCards []Card `json:"cards"` Heart []int `json:"0"` Club []int `json:"1"` Diamond []int `json:"2"` Spade []int `json:"3"` Trump []int `json:"4"` Excuse...
/* * 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 main import ( "fmt" "net" "os" "os/exec" "strconv" "time" ) var laddr *net.UDPAddr var current_count byte = 0 var message_size int = 1 var alive_timeout_seconds int = 3 func main() { // check for correct parameters on the command line if len(os.Args) != 2 { fmt.Println("Usage: go run safe_...
package main func detectCycle(head *ListNode) *ListNode { // a为链表头到成环点的长度,c为环的长度。可以知道,a+nc是链表头到城环点的距离。又 // f = 2s // f = s + nc 快指针比慢指针多走n圈 // 所以f = 2nc ,s = nc // 所以在相交点的时候,只要再走a距离就到成环点了 fast := head slow := head for { if fast == nil || slow == nil || fast.Next == nil { return nil } fast = fast.Next....
package localnet import ( "net" "strings" "sort" "time" "fmt" ) var ( localIP string broadcastIP string IPList [] string IPTimestamps map[string]time.Time ) func Init(){ IP() BroadcastIP() IPList = make([]string,0,20) IPTimestamps = make(map[string]time.Time) } func IP() (string, error) { if localIP ...
package 数组 func minCount(coinPiles []int) int { minTimesOfTakingAwayAllCoins := 0 for _, coins := range coinPiles { minTimesOfTakingAwayAllCoins += getMinTimesOfTakingAway(coins) } return minTimesOfTakingAwayAllCoins } func getMinTimesOfTakingAway(coins int) int { return (coins + 1) / 2 } /* 题目链接:https://le...
package utils import ( "math/rand" "time" ) var CaptchaTool = &CaptchaUtil{} type CaptchaUtil struct{} var captchaCodeStr="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" func (*CaptchaUtil)Generate(len int32) string{ code:=[]byte{} rand.Seed(time.Now().Unix()) for i:=int32(1);i<=len ;i++ { ...
package main import ( "fmt" ) func main() { matrix := [][]string{ []string{"Tony", "Hawk", "Skate"}, []string{"Bob", "Dylan", "Guitar"}, []string{"Freddie", "Mercury", "Sing"}, } for _, v := range matrix { fmt.Println() for _, i := range v { fmt.Printf("%s\t\t\t", i) } } }
package main import ( "reflect" "errors" "fmt" ) type CellHint interface { SetDefaults(cell *ModbusCell) Validete(cell *ModbusCell) error } type HoldingCellHint struct{} type InputCellHint struct{} type CoilCellHint struct{} type DiscreteInputCellHint struct{} func validateComon(cell *ModbusCell) error { if c...
package authorization import ( "budget-calendar/database" "github.com/gin-gonic/gin" ) func ValidSession(db *database.DB) gin.HandlerFunc { return func(c *gin.Context) { session, err := db.SessionStore.Get(c.Request, "session") if err != nil { c.AbortWithStatusJSON(500, "The server was unable to retrieve th...
package main import ( "fmt" "time" ) // UN CANAL ES UN espacio de memoria para dialogo entre rutinas func main() { canal1 := make(chan time.Duration) go bucle(canal1) fmt.Println("llegue hasta aca") // para poner a alguien a la espera de que la rutina ha terminado //espera a que canal1 tenga valor (parece pro...
package controllers import ( "fmt" "github.com/astaxie/beego" ) // BaseController 结构体 type BaseController struct { beego.Controller } func (c *BaseController) Prepare() { phone := c.GetSession("phone") password := c.GetSession("password") if phone != nil && password != nil && phone == c.Ctx.GetCookie("phone")...
package nifi import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) // Provider returns a terraform.ResourceProvider. func Provider() terraform.ResourceProvider { return &schema.Provider{ Schema: map[string]*schema.Schema{ "host": &schema.Schema{ Type: ...
// Copyright 2020 The Reed Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. package types import ( "bytes" "github.com/reed/common/byteutil/byteconv" "github.com/reed/crypto" ) type UTXO struct { ID Hash ...
/* Copyright 2019 The Kubernetes 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, ...
// Copyright (C) 2018 Storj Labs, Inc. // See LICENSE for copying information. package redis import ( "time" "github.com/go-redis/redis" ) // Client defines the interface for communicating with a Storj redis instance type Client interface { Get(key string) ([]byte, error) Set(key string, value []byte, ttl time....
package webhooks import ( "fmt" "net/http" ) func HandleSettleDebt(w http.ResponseWriter, r *http.Request) { payments := split.RemoveDebt(lastSpeaker) if len(payments) > 0 { msg := fmt.Sprintf("Okay! Here's the list of payments you must perform\n") for _, p := range payments { msg += fmt.Sprintf("* %d to ...
package channelserver import ( "encoding/hex" "fmt" "io" "net" "sync" "github.com/Andoryuuta/Erupe/common/stringstack" "github.com/Andoryuuta/Erupe/common/stringsupport" "github.com/Andoryuuta/Erupe/network" "github.com/Andoryuuta/Erupe/network/clientctx" "github.com/Andoryuuta/Erupe/network/mhfpacket" "gi...
/* Utilizando o exercício anterior, remova uma entrada do map e demonstre o map inteiro utilizando range. */ package main import ( "fmt" ) func main() { dadosPessoais := map[string][]string{ "João_Bruno": []string{ "Programar", "Jogar Video Game", }, "Maria_Fátima": []string{ "Reclamar da vida", ...
// vim: ts=4 sts=4 sw=4 package executor import ( "sync" ) ////////////// // Executor // ////////////// type QuitChan chan bool type Runer interface { Run(QuitChan) } type Executor struct { quitChan QuitChan waitGroup *sync.WaitGroup } func New() *Executor { return &Executor{make(QuitChan), new(sync.WaitGrou...
// Licensed to SolID under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. SolID licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compli...
/* Package retoil provides simple functionality for restarting toilers (i.e., workers). A toiler that has a Toil() method, that does work, blocks (i.e., doesn't return) until the work is done, and panic()s if there is a problem it cannot or doesn't want to deal with. Usage To use, create one or more types that imple...
package main import "fmt" func main() { a := 2.5 fmt.Println(myPow(a, 16)) } func myPow(x float64, n int) float64 { if n == 0 { return 1 } if n < 0 { n = -n x = 1 / x } res := 0.0 if n%2 == 0 { temp := myPow(x, n/2) fmt.Println(temp) res = temp * temp } else { temp := myPow(x, n/2) fmt.Print...
package param import ( "fmt" "github.com/wlMalk/gapi/constants" "github.com/wlMalk/gapi/validation" ) type Params struct { params map[string]*Param containsFiles bool containsBodyParams bool isLocked bool } func NewParams() *Params { return &Params{ params: map[string]*Param{}, ...
package github import ( "fmt" "testing" ) func CreateTestPRManager() PRManager { c := testCmd{} pm := defaultPRManager{cmd: &c} return &pm } type testCmd struct {} func (c *testCmd) run(args []string) (string, string, error) { // checkPRExists func: run([]string{"pr","view", baseBranch, "--json", // "state,...
package src import "crypto/sha256" //decrypt datakey (using kms) and emails (using datakey) //returns hash of email. does it need to be sha 256? prob not. func HashEmailForTimingLogs(email string) []byte { h:= sha256.New() h.Write([]byte(email)) return h.Sum(nil) }
package tenantfetcher type EventsType int const ( CreatedEventsType EventsType = iota DeletedEventsType UpdatedEventsType ) type TenantEventsResponse []byte
package weather_provider import ( "encoding/json" "fmt" "interface-testing/api/clients/restclient" "interface-testing/api/domain/weather_domain" "io/ioutil" "log" "net/http" ) const ( weatherUrl = "https://api.darksky.net/forecast/%s/%v,%v" ) type weatherProvider struct {} type weatherServiceInterface interf...
package semt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document01500105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.015.001.05 Document"` Message *IntraPositionMovementConfirmationV05 `xml:"IntraPosMvmntConf"` } fu...
package main import ( "flag" "net/http" "os" "strings" "github.com/huaweicloud/cloudeye-exporter/collector" "github.com/huaweicloud/cloudeye-exporter/logs" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) var ( clientConfig = flag.String("config", ...
package vastflow import ( "errors" "fmt" "github.com/jack0liu/logs" "reflect" "time" ) var ( ErrorRetry = errors.New("river retries to run") ErrorCanceled = errors.New("river canceled to run") ErrorBasinCanceled = errors.New("basin canceled to run") ErrorContinue = errors.New("river needs t...
package main import ( "encoding/json" "fmt" "html/template" "os" "strconv" ) type Hello struct { Name string Age int } func main() { //fmt.Println(os.Args) var resMap map[string]interface{} json.Unmarshal([]byte(os.Args[1]), &resMap) age, _ := strconv.Atoi(resMap["age"].([]interface{})[0].(string)) hell...
package restmachinery // OutboundRequest models of an outbound API call. type OutboundRequest struct { // Method specifies the HTTP method to be used. Method string // Path specifies a path (relative to the root of the API) to be used. Path string // QueryParams optionally specifies any URL query parameters to be...
package study import ( "database/sql" "fmt" _ "github.com/alexbrainman/odbc" "github.com/axgle/mahonia" "runtime" "time" "encoding/json" ) type PacsInfo struct { PID string `json:"pid"` NC string `json:"name"` SX string `json:"sex"` BR time.Time `json:"birthday"` Modality string `jso...
package solution // TreeNode tree node type TreeNode struct { Val int Left *TreeNode Right *TreeNode } // 這是個模擬,因為問題沒有寫到建立樹的性質。 // HINT: 建立樹不是從頭開始 func buildTree(values ...int) *TreeNode { head := &TreeNode{} currentNode := head for i, v := range values { if i == 0{ head.Val = v head.L...
package config import "os" func Domain() string { return getEnv("GLSAMAKER_DOMAIN", "localhost") } func PostgresUser() string { return getEnv("GLSAMAKER_POSTGRES_USER", "root") } func PostgresPass() string { return getEnv("GLSAMAKER_POSTGRES_PASS", "root") } func PostgresDb() string { return getEnv("GLSAMAKE...
package main import ( "flag" "fmt" "image" "image/color" "image/jpeg" "math" "os" "golang.org/x/image/tiff" _ "golang.org/x/image/tiff" "gonum.org/v1/gonum/mat" ) var input, output string func init() { flag.StringVar(&input, "input", "", "input file") flag.StringVar(&output, "output"...
package v1 import ( "context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) // AddRequested is invoked when the invoker requests to add an activity. func (h Handle) AddRequested( _ context.Context, _ string, _ string, _ string, ) (e error) { e = status.Error(codes.Unimplemented, "Out of sc...
// time: O(1), space: O(1) func reverseBits(num uint32) uint32 { cur := num res := uint32(0) for i := 0; i < 32; i++ { if cur & 1 == 1 { res++ } cur = cur >> 1 if i < 32 - 1 { res = res << 1 } } return res }
package leagueranker import ( "bufio" "log" "strings" "testing" ) var addCases = []struct { description string in string want string }{ { "No space between team and score", `Lions3, Snakes 3`, `invalid line format`, }, { "No commas between team scores", `Lions 3 Snakes 1`, "inval...
/* Copyright 2019 The Crossplane Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package main import ( "container/list" "fmt" ) type Item interface{} type TreeNode struct { Val int Left *TreeNode Right *TreeNode } type Tree struct { root *TreeNode } func (bst *Tree) Insert(key int) { n := &TreeNode{key, nil, nil} if bst.root == nil { bst.root = n } else { insertNode(bst.root, n...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //240. Search a 2D Matrix II //Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: //I...
package spider import ( "net/url" "testing" "time" "github.com/Willyham/gospider/spider/internal/concurrency" "github.com/Willyham/gospider/spider/mocks" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) var willydURL, _ = url.Parse("http://willdemaine.co.uk") var willydRobots, _ = url...
package tvdbapi import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "net/url" "time" ) type searchData struct { Series []Series `json:"data"` } type SearchQuery struct { Name string ImdbId string Zap2itId string AcceptLanguage string } type AiredTime struct { time.Time }...
package utils import ( "ginDemo/models" "github.com/dgrijalva/jwt-go" "time" ) var jwtSecret = []byte(Settings.Server.JWTSecret) type Claims struct { UserID uint64 Username string jwt.StandardClaims } func GenerateToken(user models.Author) (string, error) { now := time.Now() claims := Claims{ user.ID, ...
package models import "time" type EnergyResource struct { EnergyResourceAttributeId int `json:"energyResourceAttributeId,omitempty" db:"EnergyResourceAttributeId"` EnergyResourceAttributeName string `json:"energyResourceAttributeName" db:"EnergyResourceAttributeName"` GUSResourceId int `j...
// Copyright © 2021 Banzai Cloud // // 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 ...
/** * Author: hashcode55 (Mehul Ahuja) * Created: 11.05.2017 **/ package main // Remove local imports import ( "flag" "github.com/HashCode55/GPython" ) func main() { boolPtr := flag.Bool("log", true, "Set it to true to log the details.") flag.Parse() gpython.ParseEngine("hello = 3 * 6 - ( 5 / 2 )", *b...
package main import ( "flag" "fmt" "github.com/golang/glog" "strings" "sync" "time" mvutil "podmove/util" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kclient "k8s.io/client-go/kubernetes" "k8s.io/client-go/pkg/api/v1" ) //global variables var ( masterUrl string kubeConfig string ...
package main import ( "flag" "fmt" "go/ast" "go/parser" "go/token" "log" "os" "path/filepath" "strings" ) var ( debug *bool providerPath *string ) type schemaCheck func(string) schemaWalker type schemaWalker func(ast.Node) ast.Visitor func (fn schemaWalker) Visit(node ast.Node) ast.Visitor { ret...
package main import "net" type listener struct { newConns chan *net.Conn addr *net.TCPAddr }
package tool import "time" // BeginningOfHour 获取 t 这个时间点所在小时的开始时间. // // 返回的 time.Time 和传入的参数 t 的 *time.Location 一致! func BeginningOfHour(t time.Time, locationOffsetSeconds int) time.Time { const secondsPerHour = 60 * 60 x := t.Unix() x += int64(locationOffsetSeconds) x = (x / secondsPerHour) * secondsPerHour x ...
package mock import ( "math/big" "sync" "github.com/qlcchain/go-qlc/common" "github.com/qlcchain/go-qlc/common/merkle" "github.com/qlcchain/go-qlc/common/types" ) var povCoinbaseOnce sync.Once var povCoinbaseAcc *types.Account func GeneratePovCoinbase() *types.Account { if povCoinbaseAcc == nil { povCoinbas...
package main import ( "bufio" "bytes" "fmt" "io" "log" "net" "os" "os/signal" "strings" "time" "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" "github.com/hashicorp/memberlist" "github.com/swiftkick-io/xbinary" ) // Raft support // - Setup Memberlist // - If the cluster does not alr...
package main import ( "crypto/tls" "encoding/json" "flag" "fmt" "log" "net/http" "net/http/httputil" "net/url" "os" "path/filepath" "strings" ) var configFile = flag.String("conf", "config.json", "configuration file") var httpAddress = flag.String("http", ":80", "http address") var httpsAddress = flag.Stri...
package main import( _ "github.com/denisenkom/go-mssqldb" "dataFromDB" ) //Server=120.196.136.235;database=mclCoverSystem_Web_BAGX;User Id=sa;Password=maxt8899MAX func main(){ dbConn := Database.dbConn{ server: "120.196.136.235", user: "sa", password: "maxt8899MAXT", database: "m...
package graphql import ( "context" "sync" ) func (r subscriptionResolver) MessageAdded(ctx context.Context, id string) (<-chan Message, error) { ls := r.ls.addListener(ctx, id) // Not sure if I need to lock here, better safe then sorry. r.ls.mtx.Lock() ls.mc = make(chan Message, 1) r.ls.mtx.Unlock() return l...
package main import ( "log" "net/http" "os" "github.com/go-http/wechat_work" "github.com/tencentyun/scf-go-lib/cloudfunction" ) func main() { client := wechat.NewAgentClientFromEnv() client.SendTextToUsers("中华英豪", "fengjianbo") message := wechat.NewNewsMessage() message.Append("标题标题3", "http://b22aiodu.co...
package renter import ( "context" "fmt" "sync" "time" "gitlab.com/NebulousLabs/Sia/build" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/modules" "gitlab.com/NebulousLabs/errors" ) const ( // projectDownloadByRootPerformanceDecay defines the amount of decay that is // applied to the exp...
package sync import ( "context" "github.com/kumahq/kuma/pkg/core/dns/lookup" core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" "github.com/kumahq/kuma/pkg/core/resources/manager" core_model "github.com/kumahq/kuma/pkg/core/resources/model" core_store "github.com/kumahq/kuma/pkg/core/resources/stor...
/* Cryptocurrencies often have a lot of decimals. For example, the popular cryptocurrency Ethereum has 18 decimals. When dealing with money, precision is important, you don't want to lose money because a number is losing precision. However, with JavaScript, normal numbers only can go up to 9007199254740991. To deal w...
package queue // IntQueue only process integers. type IntQueue interface { // Insert an element into the queue. // Return true if the operation is successful. EnQueue(x int) bool // Delete an element from the queue. // Return true if the operation is successful. DeQueue() bool // Get the front item from the q...
// A native Pulumi package for creating and managing Amazon Web Services (AWS) resources. package aws
// +build !debug package main import ( "github.com/blevesearch/bleve/index/store" ) func printOtherHeader(s store.KVStore) { } func printOther(s store.KVStore) { }
package test import ( "testing" "github.com/alionurgeven/IBAN/pkg/ibanvalidator" "github.com/stretchr/testify/assert" ) func TestValidIBANs(t *testing.T) { IBAN := "AE070331234567890123456" assert.True(t, ibanvalidator.Validate(IBAN)) IBAN = "GB82 WEST 1234 5698 7654 32" assert.True(t, ibanvalidator.Valida...
// Copyright 2020 Google 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
// Copyright (C) 2019 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...
/* Copyright SecureKey Technologies Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package operationparser import ( "encoding/json" "errors" "fmt" "github.com/trustbloc/sidetree-core-go/pkg/api/operation" "github.com/trustbloc/sidetree-core-go/pkg/docutil" "github.com/trustbloc/sidetree-core...
package components import ( "github.com/fananchong/go-xserver/common" "github.com/fananchong/go-xserver/internal/components/gateway" "github.com/fananchong/gotcp" ) // Gateway : 网关服务器 type Gateway struct { ctx *common.Context } // NewGateway : 构造函数 func NewGateway(ctx *common.Context) *Gateway { gw := &Gateway{...
package testdata type SelectExistsWithWhereBlockQuery struct { Exists bool `rel:"test_user:u"` Where struct { Email string `sql:"u.email,@lower"` } }
// SPDX-FileCopyrightText: (c) 2018 Daniel Czerwonk // // SPDX-License-Identifier: MIT package server import ( "context" "fmt" "testing" bnet "github.com/bio-routing/bio-rd/net" "github.com/bio-routing/bio-rd/route" "github.com/czerwonk/bioject/pkg/api" "github.com/czerwonk/bioject/pkg/database" pb "github.c...
package flags import ( "errors" "fmt" "github.com/spf13/cobra" "os" "strings" ) // ApplyExtraFlags args parses the flags for a certain command from the environment variables func ApplyExtraFlags(cobraCmd *cobra.Command) ([]string, error) { envName := strings.ToUpper(strings.Replace(cobraCmd.CommandPath(), " ", ...
package modulecreate import ( "github.com/gobuffalo/packr/v2" "github.com/tendermint/starport/starport/pkg/cosmosver" ) // these needs to be created in the compiler time, otherwise packr2 won't be // able to find boxes. var templates = map[cosmosver.MajorVersion]*packr.Box{ cosmosver.Launchpad: packr.New("module/c...
package main import ( "log" "runtime" "github.com/go-gl/gl/v4.1-core/gl" "github.com/go-gl/glfw/v3.2/glfw" "./controller" "math/rand" ) const ( width = 500 height = 500 ) func main() { runtime.LockOSThread() window := initGlfw() defer glfw.Terminate() initOpenGL() rand.Seed(123456) con := control...
/* Copyright 2017 The Kubernetes 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, ...
package main import ( "bufio" "fmt" "os" ) // định nghĩa hàm func main () { fmt.Println("mời bạn nhập tên: "); var reader *bufio.Reader = bufio.NewReader(os.Stdin) name, _ := reader.ReadString('\n') fmt.Println("xin chào: -> " + name) }
package main import ( "github.com/hydra13142/webui" "net/http" "time" ) func main() { w := &webui.Window{ Width: 200, Height: 50, Sub: []webui.Object{ &webui.Timer{Common: webui.Common{Id: "clock", Do: func(c *webui.Context) { c.Ans["text"] = time.Now().Format("2006/01/02 15:04:05.00 -0700") }}, ...
package model import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestDatabase_QueryFileById(t *testing.T) { database := PrepareTestDatabase() // Query exists row. file, err := database.QueryFileById(1) assert.NoError(t, err) t.Log(file) } func TestDatabase_QueryFileByUk(t *testing.T) { ...