text stringlengths 11 4.05M |
|---|
// Package threedsecure provides the /3d_secure APIs
package threedsecure
import (
"net/http"
stripe "github.com/stripe/stripe-go"
)
// Client is used to invoke /3d_secure APIs.
type Client struct {
B stripe.Backend
Key string
}
// New POSTs new 3D Secure auths.
// For more details see https://stripe.com/docs... |
package pgnet
import (
"fmt"
"paguma/pgiface"
"paguma/utils"
"strconv"
)
/*
消息处理模块的实现
*/
type MsgHandler struct {
// 存放每一个MsgID所对应的处理方法
Apis map[uint32]pgiface.IRouter
// 业务工作Worker池的数量
WorkerPoolSize uint32
// 负责Worker取任务的消息队列
TaskQueue []chan pgiface.IRequest
}
// NewMsgHandle 创建MsgHandle的方法
func NewMsg... |
package main
import "fmt"
func main() {
for i := 1; i <= 10; i++ {
if i%2 == 0 {
fmt.Println(i, "even")
} else {
fmt.Println(i, "odd")
}
}
// Other uses with if statement
// if el, ok := elements["Li"]; ok {
// fmt.Println(el["name"], el["state"])
// }
}
|
// 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 main
import "fmt"
type heap struct {
H []int
V int
}// your type here
// insert adds element e to the heap
func (h *heap) insert(e int) {
h.H[h.V] = e;
h.bubble_up(h.V);
h.V++;
}
func (h *heap) bubble_down(e int) {
next := 2*e + 1;
if h.V <= next {
return;
}
if h.V == next + 1 {
if(h.H[e] < h.H... |
/*
Copyright 2021 The Skaffold 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, sof... |
// Package tvmaze is an HTTP Client for the tvmaze API.
package tvmaze
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strings"
"time"
cache "github.com/robfig/go-cache"
)
// Client is a tvmaze client.
type Client struct {
Debug bool
BaseURI string
Region s... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
)
// Log handler
func logRequest(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s %s\n", r.RemoteAddr, r.Method, r.URL)
handler.ServeHTTP(w, r)
})
... |
import "container/heap"
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func mergeKLists(lists []*ListNode) *ListNode {
if lists == nil || len(lists) == 0 {
return nil
}
n := len(lists)
for n > 1 {
mid := (n + 1) / 2
for i := 0; i < n/2; i++ ... |
package Router
import (
"log"
"net/http"
//this is our user defined handler function to handle the routes
"test3/packages/Handler"
"github.com/gorilla/mux"
)
//this function will return the router of the gorrila mux
func StartServer() *mux.Router {
//declaring the gorilla mux to make use of our routes
r := ... |
//
// Copyright (c) SAS Institute 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 agre... |
package parser
const defaultRequestTimeout = 10
// NewRequestItem will construct a new Request item with defaults
func NewRequestItem() RequestItem {
defaultClientOptions := Options{Timeout: defaultRequestTimeout}
return RequestItem{Options: defaultClientOptions}
}
// RequestItem defines the structure of a request... |
package client
import (
"context"
"sync"
"time"
bouncemailcounter "github.com/Tungnt24/bounce-mail-counter/bounce_mail_counter"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var client_instance... |
/**
* Copyright 2020 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... |
package ravendb
var _ IContent = &IndexQueryContent{}
type IndexQueryContent struct {
_conventions *DocumentConventions
_query *IndexQuery
}
func NewIndexQueryContent(conventions *DocumentConventions, query *IndexQuery) *IndexQueryContent {
return &IndexQueryContent{
_conventions: conventions,
_query: ... |
package permissions
import "net/http"
type permissionRequest struct {
PermissionName string `json:"permission_name"`
}
func (body *permissionRequest) Bind(r http.Request) error {
return nil
}
func (rs Resource) handleCreatePermission(rw http.ResponseWriter, r *http.Request) {
}
func (rs Resource) handleGetPermi... |
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT License was not distributed with this
// file, you can obtain one at https://opensource.org/licenses/MIT.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
package chain
import (
"bytes"
"encoding/binary"
"fmt"
"git... |
package sflogger
import (
"errors"
"fmt"
"github.com/containous/traefik/v2/pkg/middlewares/accesslog"
"github.com/containous/traefik/v2/pkg/types"
"github.com/sirupsen/logrus"
"io"
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"
)
type logData struct {... |
package scumbag
import (
"database/sql"
"regexp"
"strings"
"time"
irc "github.com/fluffle/goirc/client"
log "github.com/sirupsen/logrus"
)
const (
searchLimit = 5
urlSep = " | "
urlHelp = cmdPrefix + "url <username> or /<search>/"
)
var (
urlRegexp = regexp.MustCompile(`((ftp|git|http|https):\/\/(\w... |
// Package uasurfer provides fast and reliable abstraction
// of HTTP User-Agent strings. The philosophy is to identify
// technologies that holds >1% market share, and to avoid
// expending resources and accuracy on guessing at esoteric UA
// strings.
package uasurfer
import (
"fmt"
"strings"
"github.com/nigeltia... |
package main
import (
"testing"
)
func TestSplitMetadataEmpty(t *testing.T) {
_, _, _, err := splitMetadata(nil)
if err == nil {
t.Error("expected error, not none")
}
_, _, _, err = splitMetadata([]byte(""))
if err == nil {
t.Error("expected error, got none")
}
}
func TestSplitMetadata(t *testing.T) {
da... |
package scan
// Type represents an ECMAScript token type
type Type int
// Definition of tokens constants
const (
tokEndOfFile Type = iota
tokSyntaxError
tokHashbang
tokNoSubstitutionTemplateLiteral
tokNumericLiteral
tokStringLiteral
// Punctuation
tokAmpersand
tokAmpersandAmpersand
tokAsterisk
tokAsteri... |
package main
import "flag"
import "fmt"
func main() {
wordPtr := flag.String("word", "foo", "a string")
numbPtr := flag.Int("numb", 42, "an int")
boolPtr := flag.Bool("fork", false, "a bool")
var svar string
flag.StringVar(&svar, "svar", "bar", "a string var")
flag.Parse()
fmt.Println("word:", *wordPtr)
... |
/*
Copyright 2018 Blindside Networks
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, soft... |
package api
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
"time"
)
// LogEntry represents a sloppy log entry.
type LogEntry struct {
Project *string `json:"project,omitempty"`
Service *string `json:"service,omitempty"`
App *string `json:"app,omitempty"`
CreatedAt *Timestamp `js... |
package main
import (
"fmt"
"net"
"time"
"encoding/gob"
)
//
type Mensaje struct {
ID int
Cont int
}
func procesado(dato chan Mensaje, cerrar chan bool, aux chan Mensaje) {
activos := [5]bool{true, true, true, true, true}
procesos := [5]int{0, 0, 0, 0, 0}
for {
select {
case <-cerrar:
terminado := ... |
package updater
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"sync"
"time"
"github.com/renproject/darknode/addr"
"github.com/renproject/darknode/jsonrpc"
"github.com/renproject/lightnode/http"
"github.com/renproject/lightnode/store"
"github.com/renproject/phi"
"github.com/sirupsen/logrus"
)
// An... |
//
// Copyright (c) SAS Institute 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 agre... |
// Copyright 2016 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.
// Test STW latency and mark throughput on large, heterogeneous heaps.
package main
import (
"flag"
"fmt"
"os"
"runtime"
"sync/atomic"
"time"
"github.c... |
package sliceutil
func Clone[T any](s []T) []T {
if s == nil {
return nil
}
c := make([]T, len(s))
copy(c, s)
return c
}
|
package handlers
import (
"encoding/json"
"github.com/balalay12/intern-test/golang/rest-service/database"
"github.com/gorilla/mux"
"io/ioutil"
"net/http"
"strconv"
)
func GetUsers(w http.ResponseWriter, r *http.Request) {
users := database.List()
js, err := json.Marshal(users)
if err != nil {
http.Error(w... |
package k8s
import (
"context"
"encoding/json"
"fmt"
"strings"
platformK8s "github.com/dolittle/platform-api/pkg/platform/k8s"
"github.com/dolittle/platform-api/pkg/platform/microservice/m3connector"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
meta... |
package dao
import (
"app/model"
"github.com/pkg/errors"
)
type User struct {
Id int64
Name string
}
func (User) TableName() string {
return "user"
}
func (u *User) GetOne(id int) error {
db, err := model.GetDB()
if err != nil {
return errors.Wrap(err, "get db error")
}
if err := db.First(u, id).Error;... |
package myrpc
import (
"context"
"encoding/json"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
)
// MethodName is a key for map of methods in a service
type MethodName string
// MethodHandler is a abstract handler of a method
type MethodHandler func(ctx contex... |
package main
import (
"github.com/jfyne/live"
"net/http"
//"fmt"
"context"
"bytes"
"io"
//"log"
"html/template"
//"sync"
"net/url"
//"time"
//"go.mongodb.org/mongo-driver/mongo"
//"go.mongodb.org/mongo-driver/mongo/options"
//"os"
//"github.com/gin-contrib/sessions"
//"go.mongodb.org/mo... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package ui
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strconv"
"time"
"chromiumos/tast/errors"
"chromium... |
package stats
import (
"errors"
"github.com/NodeFactoryIo/vedran/internal/models"
"github.com/NodeFactoryIo/vedran/internal/repositories"
mocks "github.com/NodeFactoryIo/vedran/mocks/repositories"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func Test_CalculateNodeStatisticsFromLastPayout(t *testing... |
package store
import (
"gorm.io/gorm/clause"
)
type Permission struct {
ChannelTwitchId string `gorm:"primaryKey"`
TwitchID string `gorm:"primaryKey"`
Editor bool `gorm:"default:false"`
Prediction bool `gorm:"default:false"`
}
func (db *Database) GetChannelUserPermissions(userID string,... |
// Package xmppaddress contains constants and structs
// to support XEP-0033 - Extended Stanza Addressing
package xmppaddress
import (
"encoding/xml"
"github.com/rez-go/xmpplib/xmppcore"
)
const (
NS = "http://jabber.org/protocol/address"
AddressesElementName = NS + " addresses"
)
type Address... |
package mesos
import (
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
"net/url"
"sort"
"strings"
"time"
"github.com/nemosupremo/vault-gatekeeper/scheduler"
"github.com/mesos/mesos-go/api/v0/upid"
"github.com/samuel/go-zookeeper/zk"
"github.com/sirupsen/logrus"
)
type defaultLogger struct{}
func (d de... |
package main
import (
"fmt"
)
type coringas []string
func main() {
names := coringas{"R>T", "A>L", "P>O", "O>R", "G>A", "T>U", "U>G"}
cleanNames := clear(names)
fmt.Println(cleanNames)
fmt.Println(whatever(cleanNames))
}
func clean(a []byte) (b []byte) {
return []byte{a[0], a[2]}
}
func clear(a []string) ... |
// Copyright 2022 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
package render
import (
"log"
"sort"
"sync"
"time"
"github.com/shimmerglass/rgbx/device"
"github.com/shimmerglass/rgbx/render/effect"
"github.com/shimmerglass/rgbx/rgbx"
)
type channel struct {
priority int
endAt time.Time
duration time.Duration
effect effect.Effect
}
type Compositor struct {
lock ... |
package common
import (
"errors"
)
var (
ErrNotEnough = errors.New("服务不足份!")
ErrBought = errors.New("服务已被购买!")
ErrExpire = errors.New("服务已过期!")
ErrOffline = errors.New("服务已下线!")
ErrNotAllowed = errors.New("不能进行此操作!")
ErrOrderWrong = errors.New("订单错误!")
ErrOrderType = errors.New("订单类... |
package main
import (
"fmt"
"math"
)
const (
limit = 0.001
)
func Sqrt(x float64) float64 {
// z := 1.0
// for n := 0; n < 10; n++ {
// z = z - (z*z-x)/(2*z)
// }
// return z
z := 1.0
z2 := float64(0)
for (z-z2) < -limit || limit < (z-z2) {
z2 = z
z = z - (z*z-x)/(2*z)
fmt.Println(z, z2)
}
retur... |
/*
Ex 5
Implement a doubly linked list that supports insert and delete.
Author: Xiaoyan ZHANG
*/
package main
import(
"fmt"
)
type list struct {
head *node //head node of the list
tail *node //tail node of the list
len int //number of elements in the list
}
type node struct { //node type that is stored in th... |
// Package asstags
package asstags
|
package main
import (
"context"
"encoding/hex"
"fmt"
"github.com/libp2p/go-reuseport"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"net"
"runtime"
"strconv"
"strings"
)
import _ "github.com/libp2p/go-reuseport"
import _ "github.com/go-sql-driver/mysql"
var number = 0
var ... |
package parsers
import (
"bufio"
"github.com/ruxton/term"
"os"
)
func ParseSeratoTracklist(bufReader *bufio.Reader) {
term.OutputError("Serato tracklist parsing unsupported")
os.Exit(2)
}
|
package main
import (
"context"
"fmt"
"github.com/chidakiyo/benkyo/go-db-ent/ent"
"github.com/chidakiyo/benkyo/go-db-ent/ent/user"
"log"
"time"
_ "github.com/lib/pq"
)
func main() {
ctx := context.Background()
datasource := fmt.Sprintf("host=%s port=%s user=%s dbname=%s sslmode=disable password=%s", "", "... |
package main
import (
"html/template"
"net/http"
"github.com/tomatorpg/tomatorpg/assets"
)
var tpls map[string]*template.Template
func init() {
var err error
var tplBin []byte
tpls = make(map[string]*template.Template)
files, err := assets.FileSystem().ReadDir("/html")
if err != nil {
logger.Fatalf("erro... |
package store
import (
"encoding/json"
"github.com/coreos/bbolt"
"github.com/mrjones/oauth"
)
// Store for everything
type Store interface {
SaveMember(member *Member) error
GetMember(ID string) (*Member, error)
}
// Member represents Trello user
type Member struct {
ID string
AccessToken oauth.Acce... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package typec
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"path/filepath"
"regexp"
"strings"
"time"
"chromiumos/tast/common/servo"
"chromiumos/tast/ctxut... |
package eventstore
import (
"math"
"reflect"
"testing"
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/repository"
)
func testSetColumns(columns Columns) func(factory *SearchQueryBuilder) *SearchQueryBuilder {
return func(factory *SearchQueryBuilder) *SearchQueryBuilder {... |
package LeetCode
import (
"fmt"
)
func Code79() {
board := [][]byte{
{'A', 'B', 'C', 'E'},
{'S', 'F', 'C', 'S'},
{'A', 'D', 'E', 'E'},
}
fmt.Println(exist(board, "ABCCED"))
}
/**
给定一个二维网格和一个单词,找出该单词是否存在于网格中。
单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。
示例:
board =
[
['A','B'... |
// Copyright 2014 Dirk Jablonowski. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package analogin
import (
"github.com/dirkjabl/bricker"
"github.com/dirkjabl/bricker/device"
)
// SetVoltageCallbackThreshold creates the subscriber to se... |
package models
type User struct {
Model
Name string `json:"name"`
Score int `json:"score"`
}
func (user User) GetData() interface{} {
data := make(map[string]interface{})
data["name"] = user.Name
data["id"] = user.ID
data["score"] = user.Score
// Get # of wins and losses
var wins, losses int
DB.M... |
package main
//1139. 最大的以 1 为边界的正方形
//给你一个由若干 0 和 1 组成的二维网格 grid,请你找出边界全部由 1 组成的最大 正方形 子网格,并返回该子网格中的元素数量。如果不存在,则返回 0。
//
//
//
//示例 1:
//
//输入:grid = [[1,1,1],[1,0,1],[1,1,1]]
//输出:9
//示例 2:
//
//输入:grid = [[1,1,0,0]]
//输出:1
//
//
//提示:
//
//1 <= grid.length <= 100
//1 <= grid[0].length <= 100
//grid[i][j] 为 0 或 1
fun... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package firmware
import (
"context"
"fmt"
"strconv"
"time"
"chromiumos/tast/common/servo"
"chromiumos/tast/errors"
"chromiumos/tast/remote/firmware"
"chromiumos/tas... |
package main
import (
"bytes"
"fmt"
"io"
"log"
"os"
"path/filepath"
"reflect"
"sort"
"time"
"github.com/ravendb/ravendb-go-client/examples/northwind"
"github.com/kylelemons/godebug/pretty"
ravendb "github.com/ravendb/ravendb-go-client"
)
// "Demo" is a Northwind sample database
// You can browse its con... |
package main
import "astuart.co/go-iracing/cmd/ir/cmd"
func main() {
cmd.Execute()
}
|
package metrics_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/socialpoint-labs/bsk/metrics"
)
func TestNewTaggedMetrics(t *testing.T) {
recorder := metrics.NewRecorder()
m := metrics.NewTaggedMetrics(
recorder,
metrics.NewTag("foo", "bar"),
)
m.Counter("test", metrics.NewTag(... |
package slog
import (
"go.uber.org/zap/zapcore"
)
const (
LogTagFieldName = `tag`
)
type Conf struct {
Debug bool //是否启用调试
Level zapcore.Level //日志级别
Encoding string //编码格式,目前支持json/console,默认console
WriteToConsole bool //输出到控制台
WriteToLogFile bo... |
package v1
import (
"net/http"
"github.com/cynt4k/wygops/cmd/config"
"github.com/cynt4k/wygops/internal/repository"
"github.com/cynt4k/wygops/internal/router/middlewares"
"github.com/cynt4k/wygops/internal/services/ldap"
"github.com/cynt4k/wygops/internal/services/wireguard"
"github.com/labstack/echo/v4"
"git... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package cleanupfolder provides funcs to cleanup folders in ChromeOS.
package cleanupfolder
import (
"io/ioutil"
"os"
"path/filepath"
"chromiumos/tast/errors"
)
// R... |
package dog
import (
"testing"
)
func BenchmarkTodogYears(b *testing.B) {
for i := 0; i < b.N; i++ {
//fmt.Println(ToDogYears(10)) cool one to try and see different output
ToDogYears(10)
}
}
|
/*
* Copyright 2023 Gravitational, 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 ag... |
package main
import (
"fmt"
"math/rand"
"time"
"strings"
"os"
)
func main() {
//print out greeting
fmt.Println("Welcome to Hangman!")
fmt.Println("Type 'start' to begin.")
//get user input for game start confirmation
var input string
fmt.Scanf("%s", &input)
//check if the user actually wants to s... |
package repository
import (
"strings"
"github.com/chidam1994/happyfox/models"
"github.com/google/uuid"
"github.com/pkg/errors"
)
type InMemRepo struct {
contactsMap map[uuid.UUID]*models.Contact
}
func NewInMemRepo() *InMemRepo {
return &InMemRepo{
contactsMap: make(map[uuid.UUID]*models.Contact, 5),
}
}
... |
package entities
type ErrResourceTemporarilyNotAvailable struct {
ResourceID string
}
func (e ErrResourceTemporarilyNotAvailable) Error() string {
return "resource temporarily unavailable, resource-id : " + e.ResourceID
}
type ErrInsufficientResource struct {
ResourceID string
}
func (e ErrInsufficientResource) ... |
package qdb
import (
"net/http"
"errors"
"appengine"
"appengine/datastore"
)
type Stazione struct {
StazioneId int
Nome string
Url string
Inquinanti string
}
type Misura struct {
DataMisura string
Inquinante string
StazioneId int
Valore float64
}
type MisureRe... |
package mocks
import (
"context"
"github.com/cherry-game/cherry/handler"
"github.com/cherry-game/cherry/interfaces"
"github.com/cherry-game/cherry/logger"
"github.com/cherry-game/cherry/net/message"
"github.com/golang/protobuf/proto"
)
func NewTestHandler() *TestHandler {
return &TestHandler{}
}
type TestHand... |
package repository
type Repository interface {
// チャンネル更新用のロック
ChannelLock()
ChannelUnlock()
SeenChannelRepository
MessageRepository
}
|
package http
import (
"errors"
"sync"
"github.com/brewlin/net-protocol/pkg/buffer"
"github.com/brewlin/net-protocol/pkg/waiter"
tcpip "github.com/brewlin/net-protocol/protocol"
)
type ServerSocket struct {
e tcpip.Endpoint
addr tcpip.FullAddress
waitEntry waiter.Entry
notifyC chan struct{}
queue ... |
package model
import (
"encoding/json"
es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
"time"
"github.com/caos/logging"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/org/model"
"github.c... |
package api
import (
"encoding/json"
"fmt"
"net/http"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface"
awssecret "github.com/CityOfNewYork/prisma-cloud-remediation/... |
// ChangeContent project doc.go
/*
ChangeContent document
*/
package main
|
package zen
import (
"fmt"
"testing"
)
func Test_assert(t *testing.T) {
type args struct {
c bool
msg string
}
tests := []struct {
name string
args args
}{
{
"true",
args{
true,
"nil",
},
},
{
"false",
args{
false,
"panic",
},
},
}
for _, tt := range tests {... |
package main
import (
"fmt"
)
const (
x = 24
y int = 25
)
func main() {
fmt.Println(x, y)
}
|
// Package namegen generates randomized comet names
package namegen
import (
"fmt"
"math/rand"
"time"
)
const nameFormat string = "%s%s%s"
// GenerateName returns a random name in form <adj><adj><noun>
func GenerateName() string {
name := fmt.Sprintf(nameFormat,
getRandomAdjective(),
getRandomAdjective(),
... |
package regctl
import (
"context"
regv1 "github.com/tmax-cloud/registry-operator/api/v1"
"github.com/tmax-cloud/registry-operator/internal/schemes"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
)
var log ... |
package handler
import (
"fmt"
"jotham/helper"
"jotham/utils"
"log"
"strconv"
"github.com/gofiber/fiber/v2"
)
func SaveHandler(c *fiber.Ctx) error {
file, err := c.FormFile("myFile")
if err == nil {
err = c.SaveFile(file, fmt.Sprintf("./uploads/%s", file.Filename))
if err != nil {
fmt.Println(err)
... |
package handler
import (
"errors"
"fmt"
"net/http"
"github.com/uw-thalesians/perceptia-servers/gateway/gateway/utility"
)
var ErrPerceptiaApiVersionNotSet = errors.New("perceptia API version not set in request")
var ErrPerceptiaApiVersionNotValidSemVer = errors.New("perceptia API version not a valid sem ver")
... |
package setting
import (
"fmt"
"os"
"sync"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
"github.com/thetogi/YReserve2/model"
)
var watchOnce sync.Once
var mutexConfigListener sync.Mutex
var mapConfigListener = map[IConfigChangeListener]struct{}{}
type IConfigChangeListener interface {
OnConfigChan... |
package dbconfig
import (
"fmt"
"github.com/go-jet/jet/v2/tests/internal/utils/repo"
)
// Postgres test database connection parameters
const (
PgHost = "localhost"
PgPort = 5432
PgUser = "jet"
PgPassword = "jet"
PgDBName = "jetdb"
)
// PostgresConnectString is PostgreSQL test database connection... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
type NoBC struct{
Status string
Key string
Cert string
}
func main(){
postForm()
return
parsejs()
}
func postForm(){
var NoBCPubKey string=`-----BEGIN EC Public KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE+wmZKMQrSnzF0XjCycAjaDo5... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
// Copyright © 2020 Weald Technology Trading
// 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 a... |
// Copyright 2015 The Prometheus 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... |
// Copyright (c) 2020 Tailscale Inc & 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 deephash
import (
"archive/tar"
"bufio"
"bytes"
"crypto/sha256"
"fmt"
"math"
"reflect"
"runtime"
"testing"
"go4.org/mem"
"inet.... |
package main
import (
"github.com/tdakkota/drone-vk/plugin"
"github.com/urfave/cli"
"log"
"os"
)
func pluginFlags() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "token",
Usage: "VK token",
EnvVar: "VK_TOKEN,TOKEN,PLUGIN_TOKEN",
},
cli.IntFlag{
Name: "peer_id",
Usage: "User/Cha... |
package main
import "fmt"
/*첫 번째 수를 뺀 결과로 키 조회 하면 됨 */
var numsMap = make(map[int]int)
func main(){
target := 9
nums := []int{2, 7, 11, 15}
//키ㅣ와 값을 바꿔 딕셔너리로 저장
for i, num := range nums{
numsMap[num] = i
}
// 타켓에서 첫 번째 수를 뺸 결과로 키 조회 ex: 2 - 9 => 7
for i, num := range nums{
if j, ok := numsMap[target - ... |
package notification
import (
"net/url"
"strings"
)
const (
//HeaderNameTarget header name for message targe
HeaderNameTarget = "target"
//HeaderNameBatch header name for notification batch id
HeaderNameBatch = "batch"
//HeaderNameMessage header name for mesage id
HeaderNameMessage = "mesasge"
//HeaderNameTo... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package main
import "fmt"
func main() {
i := 0
for i < 10 {
fmt.Println(i)
i++
}
// infinite loop
//b := 0
//for {
// fmt.Println(b)
// i++
//}
}
|
package function
import (
"github.com/hecatoncheir/Storage"
"testing"
)
// ---------------------------------------------------------------------------------------------------------------------
func TestPriceCanBeReadByID(t *testing.T) {
IDOfTestedPrice := "0x12"
executor := Executor{Store: MockStore{}}
priceFr... |
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/Riften/libp2p-playground/host"
)
func InitRouter(n *host.Node) *gin.Engine {
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(outPutInfo)
apiPeer := r.Group("/peer")
{
apiPeer.GET("/info", n.ApiPeerInfo)
apiPeer.POST("/connect"... |
package mb_rtu_06h_decoder_resp
import (
"net/source/userapi"
"net/source/proto/trans/interfaces"
"sync"
"net/source/proto/binfiles"
"net/source/proto/constant/modbus"
"net/source/proto/pools"
"net/source/utils/bytes"
"testModbus/utils"
"net/source/proto/trans/errcode"
"fmt"
"time"
)
type modbus_rtu_06_dec... |
// Package tld provides tools for validating top level domain names.
// It comes with a predefined list however it can be updated at runtime
// by running tld.Update(url) where url points to a text file containing a list
// of acceptable TLDs.
package tld
import (
"bufio"
"bytes"
"io"
"net/http"
)
// IANA is the ... |
package main
//680. 验证回文字符串 Ⅱ
//给定一个非空字符串 s,最多删除一个字符。判断是否能成为回文字符串。
//示例 1:
//
//输入: "aba"
//输出: True
//示例 2:
//
//输入: "abca"
//输出: True
//解释: 你可以删除c字符。
//注意:
//
//字符串只包含从 a-z 的小写字母。字符串的最大长度是50000。
func validPalindrome(s string) bool {
var check func(s string, l, r, k int) bool
check = func(s string, l, r, k int) bo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.