text stringlengths 11 4.05M |
|---|
package repository
import (
"fmt"
"github.com/GoGroup/Movie-and-events/event"
"github.com/GoGroup/Movie-and-events/model"
"github.com/jinzhu/gorm"
)
// EventGormRepo implements the event.EventRepository interface
type EventGormRepo struct {
conn *gorm.DB
}
// NewEventGormRepo will create a new object of Event... |
package cli
import (
"fmt"
"strings"
"time"
"github.com/tomocy/go-todo"
"github.com/tomocy/go-todo/usecase"
"github.com/urfave/cli"
)
func (a *app) getTasks(ctx *cli.Context) error {
u := usecase.NewGetTasks(a.taskRepo(), a.sessionRepo())
tasks, err := u.Do()
if err != nil {
return err
}
if len(tasks)... |
package main
func main() {
var (
sign = make(chan int)
done = make(chan struct{})
)
go do(sign, done)
go command(sign)
println("go...")
<-done
println("done")
}
func do(s <-chan int, d chan<- struct{}) {
//select {
//case <-s:
// println("get sign and do --->")
//}
//defer close(d)
for i := range s ... |
/*
It is well-known that there are one-to-one correspondences between pairs of integers and the positive integers. Your task is to write code defining such a correspondence (by defining a pair of functions/programs that are inverses of each other) in your programming language of choice, plus a correctness check (see b... |
package quantum
import "math"
// CCNot performs a Toffoli gate.
func CCNot(c Computer, control1, control2, target int) {
// https://quantum.country/qcvc
H(c, target)
c.CNot(control2, target)
InvT(c, target)
c.CNot(control1, target)
T(c, target)
c.CNot(control2, target)
InvT(c, target)
c.CNot(control1, target... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//413. Arithmetic Slices
//A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two co... |
package main
import (
"testing"
"github.com/abhinav/git-pr/cli/clitest"
"github.com/abhinav/git-pr/editor"
"github.com/abhinav/git-pr/editor/editortest"
"github.com/abhinav/git-pr/gateway/gatewaytest"
"github.com/abhinav/git-pr/ptr"
"github.com/abhinav/git-pr/repo"
"github.com/abhinav/git-pr/service"
"github... |
package mqops
import (
"encoding/json"
"github.com/matscus/Hamster/Guns/busM5/errors"
)
type getDepositInfoJSON struct {
Data struct {
SystemCode string `json:"systemCode"`
ContractID string `json:"contractId"`
} `json:"data"`
}
func init() {
GetDepositInfo()
}
//GetDepositInfo - init script struct
func ... |
package dochead
import (
"net/http"
)
type ApiDefinition struct {
Resources []ApiResource
}
type ApiResource struct {
Name string
Method string
URI string
Description string
Parameters []Parameter
Body Body
Return Return
Examples []Example
}
type Parameter struct {
Name ... |
package repository
import (
"database/sql"
"fmt"
"github.com/DATA-DOG/go-sqlmock"
"github.com/beevik/guid"
"github.com/jinzhu/gorm"
"github.com/radyatamaa/loyalti-go-echo/src/domain/model"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"testing"
... |
package qx
// BooleanField either represents a boolean column or a literal bool value.
type BooleanField struct {
// BooleanField will be one of the following:
// 1) Literal bool value
// Examples of literal bool values:
// | query | args |
// |-------|------|
// | ? | true |
value *bool
// 2) Boolean co... |
package database
var connection string
func init() {
connection = "MySQL"
}
func GetDatabase() string {
return connection
}
|
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"strconv"
"strings"
"time"
fuzz "github.com/google/gofuzz"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/ghttp"
"git... |
/*
You goal is to implement the operation of XOR (carryless) multiplication, defined below, in as few bytes as possible.
If we think of bitwise XOR (^) as binary addition without carrying
101 5
^ 1001 9
----
1100 12
5^9=12
we can perform XOR multiplication @ by doing binary long-multiplication but do... |
package outbox
import (
"context"
"database/sql"
"encoding/json"
"errors"
"log"
"time"
"github.com/jmoiron/sqlx"
"github.com/quintans/faults"
"github.com/quintans/go-clean-ddd/lib/transaction"
"github.com/quintans/toolkit/latch"
)
var errLocking = errors.New("failed to get advisory lock")
type Publisher i... |
package main
import "fmt"
type Profile struct {
Nama string
Umur int
Alamat string
Pekerjaan string
Agama string
}
func main () {
profile := Profile{
Nama: "Andre",
Umur: 28,
Alamat: "Kebagusan",
Pekerjaan: "Tidak ada",
Agama: "Kristen",
}
fmt.Println(profile)
}
|
package room
import (
"testing"
// "strings"
)
func TestMarkDownText(t *testing.T) {
md := MarkDownText{}
if 0 != md.Version{
t.Fatal("when init , version is 0")
}
md.Init("你好!!!hello world!")
if md.GetMarkDownText().Version != 0{
t.Fatal("init text, version is 0.")
}
... |
package game_map
import (
"fmt"
"github.com/steelx/go-rpg-cgm/combat"
"github.com/steelx/go-rpg-cgm/world"
"reflect"
)
type CEUseItem struct {
Scene *CombatState
Character *Character
Targets []*combat.Actor
ItemDef world.Item
owner *combat.Actor
name string
countDown float64
... |
package 待分类
import "fmt"
func main() {
var s string
s = "abc"
/*
1.原始类型
1.分类
1.数值型
2.字符串(从技术实现细节上来说也是引用型)
3.布尔型
2.Note
1.值传递
2.引用类型
1.分类
1.切片
2.映射
3.通道
4.接口
5.函数
2.Note
1.引用传递
1.本质也是值传递 ~ 标头值: 引用类型变量称为标头值(包含用于管理底层数据结构的特定字段)
eg.切片
... |
package main
import "fmt"
func main() {
//二维数组声明
/* 0 0 0 0 0 0
0 0 1 0 0 0
0 2 0 3 0 0
0 0 0 0 0 0 */
// arr [4]是列,[6]是行
var arr [4][6]int
arr[1][2] = 1
arr[2][1] = 2
arr[2][3] = 3
// 二维数组的遍历
for i := 0; i < 4; i++ {
for j := 0; j < 6; j++ {
fmt.Print(arr[i][j]) // print 不换行的输出每行元素
... |
package vaccines
import (
"errors"
"strings"
)
const (
// AstraZeneca is the name of the astrazeneca vaccine
AstraZeneca = "astra"
// JohnsonAndJohnson is the name for the JohnsonAndJohnson vaccine
JohnsonAndJohnson = "johnson"
// Pfizer is the name for the biontech/pfizer vaccine
Pfizer = "pfizer"
// Bionte... |
package main
import (
"context"
"github.com/saracen/fastzip"
"io"
"log"
"os"
"path"
"path/filepath"
"regexp"
"strings"
)
type Repackager struct {
BuildDir string
ContainsLvoFiles bool
ContainsDeliFiles bool
ContainsSideloaderFiles bool
RequiresH3VRUtilities bool
}
func (rp... |
/*
Package users returns non logged and non deleted users of an account and saves an user
with it's user roles and user tags.
*/
package users
import (
"github.com/MerinEREN/iiPackages/api"
userLogged "github.com/MerinEREN/iiPackages/api/user"
"github.com/MerinEREN/iiPackages/datastore/user"
"github.com/MerinEREN/... |
package video_stream
import (
"os/exec"
"log"
"bytes"
"fmt"
config "../config"
)
func GeneratorRoutine(quit chan bool){
c := exec.Command(config.PYTHON, config.VID_GENERATOR_PY)
var out bytes.Buffer
var stderr bytes.Buffer
c.Stdout = &out
c.Stderr = &stderr
err ... |
package main
import "fmt"
func main() {
raw := `
manam oon yare shirin
manam oon yare khosh
`
fmt.Println(raw)
} |
package main
import (
"fmt"
"math/rand"
"time"
)
const testTimes int64 = 10000
const firstZodiac string = "虎"
const secondZodiac string = "牛"
const thirdZodiac string = "龍"
func main() {
zodiacs := [12]string{"鼠", "牛", "虎", "兔", "龍", "蛇", "馬", "羊", "猴", "雞", "狗", "豬"}
ballZodicas := make(map[int]string)
for i... |
package parser
const digits = "0123456789"
func lexNumber(l *StatefulRubyLexer) stateFn {
l.acceptRun(digits)
if l.accept(".") {
if l.accept(digits) {
l.acceptRun(digits)
l.emit(tokenTypeFloat)
return lexAnything
} else {
l.backup()
l.emit(tokenTypeInteger)
return lexAnything
}
}
l.emit(t... |
package hub
import (
"context"
"encoding/json"
"strings"
"sync"
"time"
"github.com/gorilla/websocket"
"github.com/lillilli/logger"
)
const (
// Time allowed to read a message from the peer.
readWait = 60 * time.Second
// Time allowed to write a message to the peer.
writeWait = 10 * time.Second
// Time ... |
package socketmode
import (
"log"
"os"
"reflect"
"runtime"
"testing"
"github.com/slack-go/slack"
"github.com/slack-go/slack/slackevents"
)
func init_SocketmodeHandler() *SocketmodeHandler {
eventMap := make(map[EventType][]SocketmodeHandlerFunc)
interactioneventMap := make(map[slack.InteractionType][]Socket... |
package LeetCode
func PeakIndexInMountainArray(A []int) int {
for i,v := range A {
if i > 0 && v < A[i-1] {
return i-1
}
}
return 0
} |
package main
import (
"context"
"errors"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/k-komarov/pas... |
/*
* 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://... |
../_bindata_test.go |
package main
import (
"fmt"
"time"
)
func buildSleepMap(events []event) map[int]map[int]int {
sleepPerMinutePerGuard := map[int]map[int]int{}
sleepStart := time.Now()
for _, event := range events {
switch event.action {
case sleep:
sleepStart = event.date
case wake:
for minute := sleepStart.Minute();... |
package cmd
import (
"fmt"
"os"
"text/template"
"github.com/ContinuousSecurityTooling/clairctl/clair"
"github.com/spf13/cobra"
)
const healthTplt = `
Clair: {{if .}}✔{{else}}✘{{end}}
`
type health struct {
Clair interface{} `json:"clair"`
}
var healthCmd = &cobra.Command{
Use: "health",
Short: "Get Healt... |
package utils
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
)
type metricsMapForType map[string]string
type metricsType map[string]interface{}
type metricsMapType map[string]metricsType
// type agentDetails map[string]string
// type agentDetailsMap map[string]agentDetails
func PollMetrics(agents agent... |
// Copyright 2017 The go-darwin 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 hdiutil
import (
"fmt"
"strconv"
"strings"
)
// Usage: hdiutil <verb> <options>
// <verb> is one of the following:
// help ... |
package sink
import (
"github.com/Mvilstrup/mosquito/communication/errors"
"github.com/Mvilstrup/mosquito/communication/messages"
zmq "github.com/alecthomas/gozmq"
)
type Sink struct {
context *zmq.Context // Context
receiver *zmq.Socket // Socket for clients & sinks
}
func New(endpoint string) (*Sink, erro... |
package storage
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/hspazio/mint/configurations"
)
// Note is initialized using Name and Path of the file
type Note struct {
Name string
Path string
}
// Store contains the applications's data
type Store struct {
Config configurat... |
package server
import (
"fmt"
"github.com/gorilla/mux"
"github.com/patrickmn/go-cache"
"github.com/sandro-h/prom_rest_exporter/scrape"
"github.com/sandro-h/prom_rest_exporter/spec"
log "github.com/sirupsen/logrus"
"net/http"
"time"
)
type MetricServer struct {
Endpoint *spec.EndpointSpec
Defa... |
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in wr... |
package impl
import (
"bitbucket.org/waas_pro/api/views"
"github.com/jinzhu/gorm"
"time"
)
func GenerateReport(db *gorm.DB) ([]views.ReportRes, error) {
var err error
var res []views.ReportRes
after := time.Now().AddDate(0, 0, -1)
db.Debug().Table("transactions").Select("users.uid, users.username, wallets.wall... |
func decrypt_go( inp string ) string {
final := make( [ ]rune, 12 )
d := "\x0b\x0f\x03\x05\x1c\x1b\x14\x01\x1d\x1b\x1a"
if len( inp ) != 4 {
return ""
} // End if
var cnt int = -1
for i, l := range d {
if i % len( inp ) == 0 {
cnt++
} // End if
final[ i ] = rune( inp[ cnt ] ) ^ l
} // End for... |
package main
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
)
var allGraphs = make(map[int]map[string][]string)
var minLength = 1
var maxLength = 8
type MostConnected struct {
Word string `json:"word"`
Connections int `json:... |
/*
* This file is part of impacca. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
* Licensed under the MIT license, which can be found at https://choosealicense.com/licenses/mit.
*/
package publish
import (
"fmt"
"os"
"strings"
"github.com/Masterminds/semver"
"github.com/ShogunPanda/impacca/utils"
... |
package utils
import (
"crypto/sha256"
"fmt"
"github.com/pkg/errors"
)
// Sha256 receives arbitrary data and computes its sha256
func Sha256(o interface{}) ([]byte, error) {
hash := sha256.New()
if _, err := hash.Write([]byte(fmt.Sprintf("%+v", o))); err != nil {
return nil, errors.WithStack(err)
}
return h... |
package main
import (
"crypto/sha256"
"crypto/sha512"
"flag"
"fmt"
"os"
)
var n = flag.Bool("n", false, "use sha512")
func main() {
fmt.Fprintf(os.Stdout, "%x\n", sha256.Sum256([]byte(os.Args[1])))
if *n {
fmt.Fprintf(os.Stdout, "%x\n", sha512.Sum512([]byte(os.Args[1])))
}
}
|
package cmd
import (
"fmt"
"github.com/oberd/ecsy/ecs"
"github.com/spf13/cobra"
)
// describeCmd represents the logs command
var describeCmd = &cobra.Command{
Use: "describe [cluster] [service]",
Short: "Show current task configuration for service",
Long: `Show current task configuration for service`,
Run:... |
package friend
import (
"fmt"
"spapp/src/common/constants"
"spapp/src/models/apimodels"
helper "spapp/src/common/helpers"
friendmodels "spapp/src/models/apimodels/friend"
"spapp/src/models/domain"
"spapp/src/persistence"
)
func MakeFriendCommand (input friendmodels.MakeFriendInput) friendmodels.MakeFriendOu... |
package datastore
import (
"errors"
"github.com/direktiv/direktiv/pkg/refactor/core"
"github.com/direktiv/direktiv/pkg/refactor/events"
"github.com/direktiv/direktiv/pkg/refactor/logengine"
"github.com/direktiv/direktiv/pkg/refactor/mirror"
)
// Direktiv application data (namespaces, annotations, mirrors, etc..... |
package drop
import (
"encoding/json"
"fmt"
"github.com/boltdb/bolt"
"github.com/fxnn/deadbox/model"
)
const responseBucketName = "request"
const requestBucketName = "request"
func assertWorkerExists(tx *bolt.Tx, workerId model.WorkerId) error {
b := tx.Bucket([]byte(workerBucketName))
if b == nil {
return ... |
package keycloak
import "fmt"
type LdapHardcodedRoleMapper struct {
Id string
Name string
RealmId string
LdapUserFederationId string
Role string
}
func convertFromLdapHardcodedRoleMapperToComponent(ldapMapper *LdapHardcodedRoleMapper) *component {
... |
package application
import (
"context"
"os"
"testing"
"cloud.google.com/go/datastore"
"github.com/juntaki/fix"
"github.com/juntaki/techbook-qrcode/src/infra"
"github.com/juntaki/techbook-qrcode/src/lib/qrcode"
"google.golang.org/appengine/aetest"
)
var qrCodeServiceServer *QRCodeServiceServer
var ctx context... |
// Package scenariolib handles everything need to execute a scenario and send all
// information to the usage analytics endpoint
package scenariolib
import (
"errors"
"math/rand"
"github.com/k0kubun/pp"
)
// ============== SEARCH AND CLICK EVENT ======================
// ==========================================... |
package main
import "fmt"
import "mypackage"
func main() {
fmt.Println("main")
mypackage.Test()
}
|
package ros
import (
"time"
)
// Duration is ros duration primitive that defines a period of time.
type Duration struct {
temporal
}
// NewDuration creates a new instance of ros duration from seconds and nanoseconds.
func NewDuration(sec uint32, nsec uint32) Duration {
sec, nsec = normalizeTemporal(int64(sec), in... |
// mysql.go
// author:昌维 [github.com/cw1997]
// date:2017-05-08 01:36:41
package db
import (
"database/sql"
// "fmt"
"log"
"strconv"
"time"
_ "github.com/go-sql-driver/mysql"
"config"
)
var (
db *sql.DB
)
type DatabaseConfig struct {
ip string
port string
username string
password ... |
package Controllers
import (
"net/http"
"../Models"
"github.com/gin-gonic/gin"
"fmt"
)
// Index
func Index(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{
"title": "YEET", "okay": "okay",
})
}
// list all todos
func GetTodos(c *gin.Context) {
var todo []Models.To... |
package main
type Link struct {
Value byte // '' for epsilon link
NextState *State
}
type State struct {
Id int
Out1 *Link
Out2 *Link
IsFinal bool
}
type StateFrag struct {
StartState *State
FinalState *State
}
func compile(regex string) *StateFrag {
/* compile regex to nfa
regex in the ... |
package config
import (
"encoding/json"
"io/ioutil"
"os"
)
//Config is a whole config
type Config struct {
Entries []Entry `json:"entries"`
}
//Entry is one entry of a config
type Entry struct {
Loc Location `json:"location"`
TimeOffsetMinutes int `json:"offsetMinutes"`
Target st... |
package converterService
import (
"github.com/button-tech/BNBTextWallet/helpers"
"github.com/button-tech/BNBTextWallet/services/courseService"
)
type SendData struct {
Amount float64
AmountUSD float64
ToNickName string
IdentifierTo string
ToAddress string
}
// todo: amount to fixed загуглить ско... |
package http
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"github.com/cloudfly/ecenter/pkg/sender"
)
func init() {
sender.Register(Name, New)
}
// 发送器名称
const (
Name = "http"
)
// Sender represents a email sender
type Sender struct {
url string
}
// New create new sender
func New(setting... |
// Copyright © 2017 Aeneas Rekkas <aeneas+oss@aeneas.io>
//
// 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 appl... |
package pserver
import (
"bytes"
"fmt"
"net"
"github.com/hxangel/bot/libs/websock"
)
var (
Server *PServer
)
type Client struct {
data []byte
conn net.Conn
}
type PServer struct {
listener net.Listener
clients map[string]*Client
qmsg chan *Client
qclose chan *Client
err error
}
func (client... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"os/user"
"path/filepath"
"time"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/calendar/v3"
"github.com/ajesler/playbulb-candle"
)
func BookEve... |
package vgrand
import (
"math/rand"
"sort"
)
// WeightElement 权重元素
type WeightElement struct {
weightSum int64
content interface{}
}
// WeightArray 权重元素数组
type WeightArray []*WeightElement
func (w WeightArray) Len() int {
return len(w)
}
func (w WeightArray) Swap(i, j int) {
w[i], w[j] = w[j], w[i]
}
func... |
package main
import "fmt"
func main() {
// 声明一个map对象,key和value都是string类型
var myMap1 map[string]string
if myMap1 == nil {
fmt.Println("myMap1是一个空map")
}
// 第一种声明方式,使用map前,需要先分配数据空间
myMap1 = make(map[string]string, 10)
myMap1["one"] = "java"
myMap1["two"] = "c++"
myMap1["three"] = "python"
fmt.Println(m... |
package querytool
import (
"time"
"strings"
"strconv"
)
// gets the integer value for the current time for each index in the cron object to compare to the given value in the cron string
func getCronVal(index int) int {
val := 0
layOut := "2006-01-02 15:04:05"
currentTime := time.Now()
timeStampString := curre... |
// Copyright 2020 Torben Schinke
//
// 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... |
package builtin
import (
"context"
"fmt"
"reflect"
"strings"
"github.com/openllb/hlb/codegen"
"github.com/openllb/hlb/diagnostic"
"github.com/openllb/hlb/parser"
"github.com/openllb/hlb/pkg/filebuffer"
"github.com/pkg/errors"
)
var (
Module *parser.Module
FileBuffer *filebuffer.FileBuffer
Callables = m... |
package types
type RPCRequestBody struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params []interface{} `json:"params"`
ID int `json:"id"`
}
func NewRPCRequestBody(method string) *RPCRequestBody {
i := make([]interface{}, 0)
return &RPCRequestBody{
Jsonrpc:... |
package server
import (
"io/ioutil"
"log"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/janivihervas/authproxy/upstream"
)
func TestRunHTTP(t *testing.T) {
go func() {
err := RunHTTP("30000", upstream.Echo{}, log.New(ioutil.Discard, "", log.LstdFlags))
if err != nil {
panic(err... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//22. Generate Parentheses
//Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
//For example, giv... |
package seev
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document03500105 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.035.001.05 Document"`
Message *CorporateActionMovementPreliminaryAdviceV05 `xml:"CorpActnMvm... |
/*
Copyright (c) 2015, Dave Cheney <dave@cheney.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions an... |
package main
import (
"fmt"
"log"
"net"
"os"
"time"
"github.com/dymm/orchestrators/grpc-consul/pkg/messaging/process"
resolver "github.com/nicholasjackson/grpc-consul-resolver"
"google.golang.org/grpc"
)
var infoLogger *log.Logger
func main() {
infoLogger = log.New(os.Stdout, "", log.Ldate... |
package digo
import (
"fmt"
"reflect"
"testing"
)
func TestDiGoImpl_SingletonFunc(t *testing.T) {
type fields struct {
DiGoStub stub
binding map[Type]interface{}
store map[Type]reflect.Value
share map[Type]bool
startBuilding map[Type]struct{}
finishBuilt map[Type]struct{}
... |
package kubectl
import (
"fmt"
"k8s.io/apimachinery/pkg/util/wait"
"net"
"net/http"
"os/exec"
"strings"
"time"
"github.com/devspace-cloud/devspace/pkg/devspace/kubectl/portforward"
"github.com/devspace-cloud/devspace/pkg/util/log"
"github.com/devspace-cloud/devspace/pkg/util/message"
"github.com/devspace-c... |
package pprofutils
import (
"fmt"
"io"
"strconv"
"strings"
"time"
"github.com/google/pprof/profile"
)
func Text2PPROF(text io.Reader, pprof io.Writer) error {
var (
functionID = uint64(1)
locationID = uint64(1)
p = &profile.Profile{
TimeNanos: time.Now().UnixNano(),
SampleType: []*profile... |
package axone
type TicketStatus string
const (
TICKET_STATUS_NEW TicketStatus = "NEW" //after creation
TICKET_STATUS_OPEN TicketStatus = "OPEN" //has been evaluated and is assigned
TICKET_STATUS_PENDING TicketStatus = "PENDING" //need more informations from end user
TICKET_STATUS_SOLVED TicketStatu... |
// This file was generated for SObject DataAssessmentFieldMetric, API Version v43.0 at 2018-07-30 03:47:22.864692461 -0400 EDT m=+9.207644397
package sobjects
import (
"fmt"
"strings"
)
type DataAssessmentFieldMetric struct {
BaseSObject
CreatedById string `force:",omitempty"`
CreatedDate ... |
package service
import (
"github.com/msvetkov/notes-app/pkg/domain"
"github.com/msvetkov/notes-app/pkg/repository"
)
type NotesService struct {
repo repository.Note
}
func NewNotesService(repo repository.Note) *NotesService {
return &NotesService{repo: repo}
}
func (s NotesService) Create(note domain.Note) (int... |
package docs
import (
"net/http"
"strings"
)
// TDocHandler defines the type of the documentation handler structure
type TDocHandler struct {
}
// NewDocHandler initializes a documentation handler with the given params
func NewDocHandler() *TDocHandler {
return &TDocHandler{}
}
// Get gets the entire dummy list
... |
package qx
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"fmt"
"math/rand"
"strconv"
"strings"
"time"
)
// TODO: rewrite this documentation
// FormatPreprocessor operates similar to fmt.Sprintf except it only recognizes ? question
// mark as a format specifier. It replaces each ? in the format... |
package mhfpacket
import (
"errors"
"github.com/Andoryuuta/Erupe/network"
"github.com/Andoryuuta/Erupe/network/clientctx"
"github.com/Andoryuuta/byteframe"
)
// TerminalLogEntry represents an entry in the MSG_SYS_TERMINAL_LOG packet.
type TerminalLogEntry struct {
// Unknown fields
U0, U1, U2, U3, U4, U5, U6, ... |
package main
import "fmt"
//给定一个 没有重复 数字的序列,返回其所有可能的全排列。
//
//示例:
//
//输入: [1,2,3]
//输出:
//[
//[1,2,3],
//[1,3,2],
//[2,1,3],
//[2,3,1],
//[3,1,2],
//[3,2,1]
//]
func main() {
fmt.Println(permute([]int{3, 2, 1}))
}
//回溯法
func permute(nums []int) [][]int {
var res [][]int
if len(nums) == 0 {
return res
}
dfs(... |
package pool
import (
"sort"
"testing"
"time"
"github.com/google/go-cmp/cmp"
)
//nolint:gocognit //it is hard so...
func TestPool_AddingOnRunningServer(t *testing.T) {
t.Run("A simple information", func(t *testing.T) {
ch := make(chan struct{ ID string })
p := New(1)
add(t, p, func(taskID string) error {... |
package sudoku
import (
"testing"
)
//TODO: test a few more puzzles to make sure I'm exercising it correctly.
func TestXWingRow(t *testing.T) {
options := solveTechniqueTestHelperOptions{
targetCells: []CellRef{{1, 4}, {1, 7}, {8, 4}},
pointerCells: []CellRef{{0, 4}, {0, 7}, {7, 4}, {7, 7}},
targetNums: I... |
package auth
import (
"sync"
)
type hintedTokenCache struct {
entries map[string]authResponse
mutex sync.RWMutex
}
func (c *hintedTokenCache) Get(hint string) (token string) {
c.mutex.RLock()
if entry, cached := c.entries[hint]; cached {
token = entry.Token
}
c.mutex.RUnlock()
return
}
func (c *hintedT... |
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"image"
"image/gif"
"image/jpeg"
"image/png"
"io"
"log"
"strings"
"cloud.google.com/go/storage"
"github.com/btoll/rest-go/app"
"github.com/goadesign/goa"
"google.golang.org/appengine"
"google.golang.org/appengine/file"
)
// ImageCo... |
package hue
type tokenResponse []struct {
Success struct {
Username string `json:"username"`
} `json:"success"`
} |
package model
import (
"cloudfreexiao/ant-graphql/backend-go/lib/network"
)
type Iface struct {
Name string `json:"name"`
Mac string `json:"mac"`
Addrv4 []*Address `json:"addrv4"`
Addrv6 []*Address `json:"addrv6"`
MTU int `json:"mtu"`
RxByte uint64 `json:"rxbyte"`
TxByte uint64 ... |
package main // 包,表明代码所在的模块(包)
import (
"fmt"
"os"
) // 引入代码依赖
// 功能实现
func main() {
//fmt.Println(os.Args)
if len(os.Args) > 1 {
fmt.Println("hello World", os.Args[1])
} else {
fmt.Print("1. fmt.Print:我加了换行符\n")
fmt.Println("2. fmt.Println:我会自动换行")
fmt.Print("3. fmt.Print:我不会换行 ")
fmt.Println("4. fmt... |
package util
import (
"bytes"
"encoding/json"
"github.com/bearname/videohost/internal/common/dto"
log "github.com/sirupsen/logrus"
"io"
"net/http"
)
type Token struct {
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
}
func NewToken(accessToken string, refreshToken string) ... |
package bill
import (
"errors"
"fmt"
"math"
"os"
"strconv"
"time"
)
type Bill struct {
ID string `json:"id"`
SubscriberNumber string `json:"subscriber"`
Month string `json:"month"` // only after it has ended (not current month)
Year string `json:"year"`
Calls ... |
package main
import (
"github.com/funkygao/gobench/util"
"regexp"
"strings"
"testing"
)
func main() {
b := testing.Benchmark(BenchmarkStringConstains)
util.ShowBenchResult("strings.Contains", b)
b = testing.Benchmark(BenchmarkStringConcat)
util.ShowBenchResult("builtin string +", b)
b = testing.Benchmark(Ben... |
package mocking
//DoStuffer 는 간단한 인터페이스이다.
type DoStuffer interface {
DoStuff(input string) error
}
|
package validMountainArray
//one
func validMountainArray(A []int) bool {
if len(A) < 3 {
return false
}
up := true
for index := 1; index < len(A); index++ {
if A[index-1] == A[index] {
return false
}
if up {
if A[index-1] > A[index] {
if index == 1 {
return false
}
up = false
} e... |
// Copyright 2020 Thomas.Hoehenleitner [at] seerose.net
// Use of this source code is governed by a license that can be found in the LICENSE file.
// Package args implements the commandline interface and calls the appropriate commands.
// Its function Handler is called in package main as entry point.
package args
imp... |
package main
import (
"fmt"
"github.com/Sataapon/order_brushing/shop"
)
func main() {
run()
}
func run() {
path := "dataset/order_brush_order.csv"
mapping := shop.New(path)
_ = mapping
fmt.Println("complete")
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.