text stringlengths 11 4.05M |
|---|
package main
import (
"bufio"
"github.com/ziutek/mymysql/autorc"
"io"
"log"
"net"
"os"
"strconv"
"strings"
"time"
)
// Message format (lines ended by CR or CRLF):
// FROM - symbol of source (<=16B)
// PHONE1[=DSTID1] PHONE2[=DSTID2] ... - list of phone numbers and dstIds
// Lin... |
package metrics
import (
"os"
"time"
)
type JSONData = map[string]interface{}
type KernelInfo struct {
rebootRequired bool
release string
}
type CVEInfo struct {
id string
packageName string
severity string
notFixedYet bool
fixState string
title string
summar... |
package app
// Lifecycle support a bunch of APIs required for lifecycle
// Certain initialization order will be automatically calculated according to the dependency injection.
// Don't use circle dependency, otherwise it will cause unexpected behavior.
type Lifecycle interface {
PrepareInitialization() error
Initial... |
package main
import "fmt"
var z = 40
func main() {
foo()
}
func foo() {
fmt.Println(z)
}
|
package main
import (
"context"
"database/sql"
"fmt"
"log"
"math/rand"
"time"
"github.com/Rican7/retry"
"github.com/Rican7/retry/backoff"
"github.com/Rican7/retry/jitter"
"github.com/Rican7/retry/strategy"
)
func insert(ctx context.Context, db *sql.DB, runnerId string) {
d := time.Now().Add(60 * time.Seco... |
package bmcrypto
import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"testing"
)
// Mock reader so we deterministic signature
type dummyReader struct{}
var (
signMessage = []byte("b2d31086f098254d32314438a863e61e")
)
func (d *dummyReader) Read(b []byte) (n int, err error) {
for i := range b {
b[i] = 1
... |
package auth
import (
"github.com/atymkiv/echo_frame_learning/blog/model"
"github.com/labstack/echo"
"github.com/ribice/gorsk/pkg/utl/model"
"net/http"
)
var (
ErrInvalidCredentials = echo.NewHTTPError(http.StatusUnauthorized, "Username or password does not exist")
)
// New creates new iam service
func New(udb ... |
package dice
import (
"fmt"
"github.com/theshadow/dice/formula"
"strings"
"testing"
)
func TestDropExtension_New(t *testing.T) {
cases := []struct {
name string
which string
results Results
roll formula.Roll
expected string
}{
{
name: "Drop lowest without duplicates",
which: ... |
package main
import (
"fmt"
"log"
)
type (
myError struct {
Code int
}
)
func (e *myError) Error() string {
return fmt.Sprintf("Error code: %v", e.Code)
}
func sandbox(protected func()) {
defer func() {
if x := recover(); x != nil {
switch x.(type) {
case string:
log.Printf("[sandbox] end for a ... |
package domain
import (
"testing"
"github.com/DATA-DOG/go-sqlmock"
)
func Test_BookRepository_Create(t *testing.T) {
db, mock, err := sqlmock.New()
if err != nil {
t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
}
defer db.Close()
bookRepository := NewBookRepository... |
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
/*
* @lc app=leetcode.cn id=1413 lang=golang
*
* [1413] 逐步求和得到正数的最小值
*/
// @lc code=start
package main
func minStartValue(nums []int) int {
minSum := 0
sum := 0
for i := 0; i < len(nums); i++ {
sum += nums[i]
if sum < minSum {
minSum = sum
}
}
if minSum > 0 {
return 1
} else {
return 1 - minSum... |
package random
import "math/rand"
const (
numberBytes = "0123456789"
)
// Number generates random numbers.
func Number(n int) string {
b := make([]byte, n)
l := len(numberBytes)
for i := range b {
b[i] = numberBytes[rand.Intn(l)]
}
return string(b)
}
|
package proto
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseTopic(t *testing.T) {
input := [][]byte{
[]byte("/"),
[]byte("a/b"),
[]byte("a/b/"),
[]byte("/a/b"),
[]byte("a/b/c"),
[]byte("/a/b/c"),
[]byte("/asdf/bse/dewer"),
[]byte("/a"),
[]byte("/a//b"),
[]byte("/+/b/c... |
package model
import (
"fmt"
"github.com/zhenghaoz/gorse/base"
"github.com/zhenghaoz/gorse/core"
"github.com/zhenghaoz/gorse/floats"
"math"
)
type _BiasUpdateCache struct {
cache map[int]float64
}
func _NewBiasUpdateCache() *_BiasUpdateCache {
cache := new(_BiasUpdateCache)
cache.cache = make(map[int]float64... |
package main
// 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。
// 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
// 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径?
func uniquePathsWithObstacles(obstacleGrid [][]int) int {
maxX := len(obstacleGrid)
maxY := len(obstacleGrid[0])
status := make([][]int, maxX)
for i := range sta... |
package main
import "fmt"
type Minutes int
type Hours int
type Weight float64
type Title string
type Answer bool
func main() {
minutes := Minutes(37)
hours := Hours(2)
weight := Weight(945.7)
name := Title("The Matrix")
answer := Answer(true)
fmt.Println(minutes, hours, weight, name, answer)
minutes += 3
fmt... |
package main
//heads up, go does not have a while loop
import (
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
)
//What is unmarshalling and marshalling?
/*In computer science, unmarshalling or unmarshaling refers to the process of transforming a representation of an object that was used for storage or transmission... |
package memsearch
import (
"testing"
"github.com/manishrjain/gocrud/testx"
)
func initialize() *MemSearch {
ms := new(MemSearch)
ms.Init()
testx.AddDocs(ms)
return ms
}
func TestNewAndFilter(t *testing.T) {
testx.RunAndFilter(ms, t)
}
var soln = [...]string{
"m81",
"ngc 3370",
"galaxy ngc 1512",
"ngc 1... |
package service
import (
"context"
"github.com/go-ocf/cloud/grpc-gateway/pb"
)
func (r *RequestHandler) GetClientConfiguration(context.Context, *pb.ClientConfigurationRequest) (*pb.ClientConfigurationResponse, error) {
return &r.clientConfiguration, nil
}
|
package b2
import (
"context"
"net/http"
)
const (
createBucketURL = "b2api/v2/b2_create_bucket"
listBucketsURL = "b2api/v2/b2_list_buckets"
)
// Bucket is used to represent a B2 Bucket
type Bucket struct {
AccountID string `json:"accountId"`
ID string `json:"buc... |
package main
import "fmt"
var a int
func main() {
var mp = map[int](func() int){
1: func() int { return 10 },
2: func() int { return 20 },
3: func() int { return 30 },
}
fmt.Printf("%v", mp)
}
|
package main
import "log"
func main() {
amar, ranjan, deepak, satyam := Customer{}, Customer{}, Customer{}, Customer{}
govind, abhay, anuj, sunny := Student{}, Student{}, Student{}, Student{}
/*customerList := []StudentAndCustomer{amar,ranjan,deepak,satyam}
studentList := []StudentAndCustomer{govind,abhay,anuj,su... |
package chapter1
// 声明存储结构
var store = make([]string, 0)
// 索引数据
func Index(data string) {
store = append(store, data)
}
// 检索数据
func Search(query string) string {
for _, name := range store {
if name == query {
return name
}
}
return ""
} |
package lolbas
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
log "github.com/sirupsen/logrus"
"github.com/sudneo/gtfodora/pkg/binary"
cloner "github.com/sudneo/gtfodora/pkg/repo_utils"
"gopkg.in/yaml.v2"
)
const (
repoURL string = "https://github.com/LOLBAS-Project/LOLBAS"
)
type lolbasbin str... |
/*
* 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 main
import (
"github.com/ShogunPanda/tempera"
"github.com/spf13/cobra"
"github.com/ShogunPanda/impacca/command... |
package committer
import (
"fmt"
"regexp"
)
// PatternMatch checks whether the given msg follows proper style or out
// the pattern is defined under getPattern and
// built in regexp.MatchString check the format of commit message
// if it fails, it let users know which rules they have to follow
func PatternMatch(m ... |
package http
import (
"../g"
"net/http"
"strings"
)
func configReloadRoutes(){
http.HandleFunc("/config/reload", func(w http.ResponseWriter, r *http.Request){
if strings.HasPrefix(r.RemoteAddr, "127.0.0.1"){
err := g.ParseConfig(g.ConfigFile)
AutoRender(w, g.Config(), err)
}else {
w.Write([]byte("no... |
// Refactor a ledger printer.
package ledger
import (
"errors"
"fmt"
"sort"
"strings"
)
const testVersion = 4
type Entry struct {
Date string // "Y-m-date"
Description string
Change int // in cents
}
var currencyMap = map[string]string{
"EUR": "€", "USD": "$",
}
var localeMap = map[string]stru... |
package main
import (
"encoding/json"
"fmt"
"regexp"
"strconv"
"strings"
)
// Message which can be send to Google Chat
// More info at https://developers.google.com/hangouts/chat/reference/message-formats/cards
type Message struct {
Text string `json:"text,omitempty"`
Cards []Card `json:"cards"`
}
// Card pr... |
// FindbinFolder
package DaeseongLib
import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"sync"
"time"
)
var (
directories = make(map[string]bool)
)
func IsBinDir(path string) bool {
fileStat, err := os.Stat(path)
if err != nil {
return false
}
return fileStat.IsDir()
}
func getRootDrives() (drives [... |
package main
import (
"errors"
"net"
"os"
"os/signal"
"syscall"
"github.com/ermanimer/grpc-example/chat/server"
proto "github.com/ermanimer/grpc-example/proto/message"
logger "github.com/ermanimer/slog"
"google.golang.org/grpc"
)
const (
address = "0.0.0.0:9000"
)
func main() {
l := logger.NewLogger(os.S... |
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int, level int) {
if t.Left != nil {Walk(t.Left, ch, level + 1)}
ch <- t.Value
if t.Right != nil {Walk(t.Right, ch, level + 1)}
if level =... |
package apis
import (
"project/app/admin/models/bo"
"project/app/admin/models/dto"
"project/app/admin/service"
"project/common/api"
"project/utils"
"project/utils/app"
"github.com/gin-gonic/gin"
)
var r = new(service.Role)
// SelectRolesHandler 多条件查询角色
// @Summary 多条件查询角色
// @Description Author:Ymq 2021/01/2... |
package assgn3Models
//TripPostReq to accept input request for POST operation
type TripPostReq struct {
StartLocationID string `json:"starting_from_location_id"`
DestLocationID []string `json:"location_ids"`
}
//CountID structure to keep the track of "_id"
type CountID struct {
ID string `bson:"_id"`
Seq int ... |
// BSD 3-Clause License
//
// Copyright (c) 2020, Kingsgroup
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, thi... |
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package repository
import (
"context"
"net/url"
"strconv"
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/diegobernardes/flare"
)
... |
package catalogsource
import (
"context"
"reflect"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/version... |
package main
import "github.com/Caik/go-stream-broadcast/internal/reader"
func main() {
reader.Serve()
}
|
package start
import (
c "github.com/zond/godip/variants/classical/common"
dip "github.com/zond/godip/common"
"github.com/zond/godip/graph"
)
func SCs() (result map[dip.Province]dip.Nation) {
result = map[dip.Province]dip.Nation{}
g := Graph()
for _, prov := range g.Provinces() {
if nat := g.SC(prov); nat != ... |
package main
import "fmt"
func main() {
i:=1; j:=0;
fmt.Println("Хуваахын өмнө...");
i = i / j; /* 0-д хуваах алдаа */
fmt.Println("Дараа нь")
} |
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package app
// [START sample]
import (
"net/http"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
)... |
package ircserver
import (
"sort"
"strings"
"gopkg.in/sorcix/irc.v2"
)
func init() {
Commands["NAMES"] = &ircCommand{
Func: (*IRCServer).cmdNames,
}
}
func (i *IRCServer) cmdNames(s *Session, reply *Replyctx, msg *irc.Message) {
if len(msg.Params) > 0 {
channelname := msg.Params[0]
if c, ok := i.channel... |
package main
import (
"fmt"
// "net/url"
"github.com/kavenegar/kavenegar-go"
)
func main() {
api := kavenegar.New(" your apikey ")
//Verify.VerifyLookup
receptor := ""
template := ""
token := ""
params := &kavenegar.VerifyLookupParam{
// Type: kavenegar.Type_VerifyLookup_Sms
}
if res, err := api.Verify... |
/*
There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.
When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlock... |
package fluent
import (
"fmt"
"log"
"strings"
"sync"
)
const (
whereClause = "WHERE"
andClause = "AND"
orClause = "OR"
isNullClause = "IS NULL"
isNotNullClause = "IS NOT NULL"
selectStatement = "SELECT %s FROM %s"
insertStatement = "INSERT INTO %s (%s) VALUES (%s) R... |
// Longest Common Substring
// Dynamic Programming
//
// Time complexity: O(len(s1) * len(s2))
// Space complexity: O(len(s1) * len(s2))
//
// References:
// https://www.geeksforgeeks.org/longest-common-substring/
// https://github.com/mission-peace/interview/blob/master/src/com/interview/dynamic/LongestCommonSubstring... |
package alchemyapi
import (
"encoding/json"
"net/http"
"net/http/httptest"
"net/url"
"testing"
)
func TestNewAnalyzer(t *testing.T) {
key := "foooooooooooooooooooooooooooooooooooobar"
keyInvalid := key + "!"
_, err := NewAnalyzer(key)
if err != nil {
t.Error("should not be error")
}
_, err = NewAnalyzer... |
package postal
import (
"log"
"math"
"strings"
"time"
"github.com/cloudfoundry-incubator/notifications/cf"
"github.com/cloudfoundry-incubator/notifications/gobble"
"github.com/cloudfoundry-incubator/notifications/mail"
"github.com/cloudfoundry-incubator/notifications/metrics"
"gith... |
package isakura
import (
"fmt"
"net/http"
"net/url"
"time"
"io"
"io/ioutil"
"encoding/json"
"path/filepath"
"os"
"sync"
"regexp"
"log"
"strings"
uuid "github.com/satori/go.uuid"
)
var saveMutex sync.Mutex
func (isakura *Isakura) refresh() error {
return fmt.Errorf("Unsupported")
}
func... |
// Copyright 2014 The Sporting Exchange Limited. All rights reserved.
// Use of this source code is governed by a free license that can be
// found in the LICENSE file.
package tsdb
import (
"bytes"
"fmt"
"log"
"strconv"
"time"
)
const maxLineLength = 1023 // limit in net.opentsdb.tsd.PipelineFactory
func (p *... |
package main
import (
"fmt"
)
type User interface {
PrintNama()
PrintDetails()
}
type Person struct{
Nama string
Asal string
Email string
}
func (p *Person) PrintNama(){
fmt.Printf("Nama :%s", p.Nama)
}
func (p *Person) PrintDetails(){
fmt.Printf("Asal : %s, Email : %s", p.Asal, p.Email)
}
type Admin struct... |
package main
import (
"fmt"
"sync"
"sync/atomic"
"time"
)
var (
// shutdown is a flag to alert running goroutines to shutdown
shutdown int64
// wg is used to wait for the program to finish
wg sync.WaitGroup
)
func main() {
//Add a count of two , one for each goroutine.
wg.Add(2)
//Create two goroutines
g... |
package main
import "github.com/urfave/cli"
// These are the core settings and requirements for the plugin to run
// Config is configuration settings by user
type Config struct {
User string
Key string
Server string
AppID string
File string
Src string
Channel string
Publish string
}
// form... |
package bindata
import (
"bytes"
"errors"
"net/http"
"os"
"path/filepath"
"strings"
"time"
)
var (
errIsDirectory = errors.New("is a directory")
errIsFile = errors.New("is a file")
)
// dir is an in-memory implementation of vfs.FileSystem
type dir struct {
name string
files map[string]*file
dirs m... |
package errutil
import (
"errors"
"fmt"
"testing"
)
func recovered(f func()) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("%v", r)
}
}()
f()
return
}
func TestFirst(t *testing.T) {
err1 := errors.New("first error")
err2 := errors.New("second error")
var tests = []str... |
package random
import (
"math/rand"
"time"
)
var r *rand.Rand
func init() {
r = rand.New(rand.NewSource(time.Now().UnixNano()))
}
func Generate(strlen int) string {
const chars = "abcdefghijklmnopqrstuvwxyz0123456789"
result := ""
for i:=0; i<strlen; i++ {
index:=r.Intn(len(chars))
result += cha... |
package codec
import (
"fmt"
"os"
"time"
)
type Message struct {
data []byte
counter uint64
}
func (m *Message) Data() []byte {
return m.data
}
func MakeMsg(f *os.File, size uint64) (Message, error) {
data := make([]byte, size)
m := Message{data, 0}
_, e := f.Read(data)
return m,... |
package servers
import (
"github.com/s-matyukevich/centurylink_sdk/base"
"github.com/s-matyukevich/centurylink_sdk/models"
"time"
)
type GetServerRes struct {
Connection base.Connection
Id string
Name string
Description string
GroupId string
IsTemplate bool
LocationId string
OsType ... |
package controller
import (
"gopetstore/src/config"
"gopetstore/src/domain"
"gopetstore/src/service"
"gopetstore/src/util"
"log"
"net/http"
"path/filepath"
"strconv"
)
const (
viewOrderFile = "viewOrder.html"
initOrderFile = "initOrder.html"
confirmOrderFile = "confirmOrder.html"
shipFormFile = ... |
package types
type Film struct {
ID int `json:"id"`
Name string `json:"name"`
Year int `json:"year"`
AddedAt string `json:"added_at"`
Genres []Genre `json:"genres, omitempty"`
}
type PostFilm struct {
*Film
Genres []int `json:"genres"`
}
type GetFilmParams struct {
Limit int `query:"limit"`
O... |
package device
//go:generate go run gen/gen_streams.go
// #cgo CFLAGS: -g -Wall
// #cgo LDFLAGS: -lSoapySDR
// #include <stdlib.h>
// #include <stddef.h>
// #include <SoapySDR/Device.h>
// #include <SoapySDR/Formats.h>
// #include <SoapySDR/Types.h>
import "C"
import (
"errors"
"github.com/pothosware/go-soapy-sdr/p... |
// This file should be auto generated
package selectionsort
import (
"testing"
"github.com/seifer/go-dsa/sort/internal/testutil"
)
func TestInts(t *testing.T) {
input := testutil.InputInts()
Ints(input)
if !testutil.IsSortedInts(input) {
t.Fail()
}
}
|
package main
import (
"crypto/ecdsa"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
//"github.com/ethereum/go-ethereum/common"
"encoding/hex"
"github.com/sanguohot/medichain/util"
)
func main() {
privateKeyStr := "7aaf3e2786ff4b38f4aceb6f86ff4a367020637... |
package models
import ()
type Lyric struct {
Id int
Artist *Artist
Track *Track
Content string
}
|
package main
import (
"encoding/binary"
"encoding/json"
"github.com/boltdb/bolt"
"log"
)
type Queue struct {
DB *bolt.DB
}
var QUEUE = []byte("QUEUE")
//Open the Queue DB and make sure a bucket exists for Tasks.
func OpenQueue() Queue {
db, err := bolt.Open("queued.db", 0600, nil)
if err != nil {
log.Fatal... |
package types
type PersonList []*Person
type PersonToBool func(*Person) bool
func (al PersonList)Filter(f PersonToBool) PersonList {
var ret PersonList
for _, a := range al {
if f(a) {
ret = append(ret, a)
}
}
return ret
}
|
package main
import (
"fmt"
)
func searchMatrix(matrix [][]int, target int) bool {
m := len(matrix)
if m == 0 {
return false
}
n := len(matrix[0])
if n == 0 {
return false
}
// 从左下角开始搜索
i := m - 1
j := 0
for i >= 0 && j < n {
if matrix[i][j] < target {
j++
} else if matrix[i][j] > target {
... |
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/kataras/iris"
"github.com/kataras/iris/config"
"github.com/kataras/iris/websocket"
)
type clientPage struct {
Title string
Host string
}
type Message struct {
Message string `json:"message"`
User string `json:"user"`
}
type Resource struct... |
package engine
import (
chess "github.com/Yoshi-Exeler/chesslib"
opening "github.com/Yoshi-Exeler/chesslib/opening"
)
type byMVVLVA struct {
Nodes []*Node
Worker *Worker
TPV *chess.Move
Depth int
DepthRemaining int
Alpha int16
Beta int16
Max ... |
package router
import (
"testing"
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/stretchr/testify/mock"
)
func TestPoolRouterActor_Receive_AddRoute(t *testing.T) {
state := new(testRouterState)
a := poolRouterActor{state: state}
p1 := actor.NewLocalPID("p1")
c := new(mockContext)
c.On("Message").R... |
package bt
import (
"bytes"
"context"
"crypto/sha1"
"errors"
"bufio"
"github.com/neoql/btlet/bencode"
"github.com/neoql/btlet/tools"
)
// FetchMetadata fetch metadata from host.
func FetchMetadata(ctx context.Context, infoHash string, host string) (RawMeta, error) {
// connect to peer
var reserved uint64
S... |
package models
import (
"encoding/json"
"io/ioutil"
"testing"
)
func BenchmarkCreateSubmission(b *testing.B) {
data, _ := ioutil.ReadFile("./tests/submission.json")
submissionExampleJson := string(data)
for i := 0; i < b.N; i++ {
sub := Submission{}
json.Unmarshal([]byte(submissionExampleJson), &sub)
}
}
|
package main
import "fmt"
func main() {
//khai bao array
var myArray [4]int
fmt.Println(myArray) // [0 0 0 0]
// phần tử mảng chưa đc gán giá trị sẽ đc gán mặc định 0
myArray[0] = 11
myArray[1] = 23
fmt.Println(myArray) // [11 23 0 0]
//khai báo có khởi tạo giá trị
arrays := [3]int{1, 2, 3}
// var arrays... |
package main
import (
"context"
"fmt"
"net/http"
"os"
"github.com/DataDog/datadog-go/statsd"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/jrxfive/superman-detector/handlers/healthz"
v1 "github.com/jrxfive/superman-detector/handlers/v1"
"github.com... |
// Package calculator provides a library for simple calculations in Go.
package calculator
import (
"errors"
"fmt"
"math"
)
// Add takes two numbers and returns the result of adding them together.
func Add(a, b float64) float64 {
return a + b
}
// Subtract takes two numbers and returns the result of subtracting ... |
package controllers
import (
"fmt"
"math/rand"
"strings"
"time"
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
"github.com/astaxie/beego/config"
)
/*UtilsController 工具类 */
type UtilsController struct {
MainController
}
/*GenValidateCode 生成随机验证码 */
func (c *UtilsController) GenValidateCode(length ... |
package server
// type serverContext struct {
// *sqlx.DB
// }
//
// type server struct {
// context serverContext
// }
//
// func New(dbFile string) (server, error) {
// tdb, err := db.OpenDatabase(dbFile)
// if err != nil {
// return server{}, err
// }
// return server{serverContext{tdb}}, nil
// }
//
// fun... |
package gbm
import (
"bytes"
"encoding/json"
"os"
)
const BUFSIZE = 1024
type GbLeaf struct {
Split *int `json:"split"`
SplitCondition *float64 `json:"split_condition"`
Yes *int `json:"yes"`
No *int `json:"no"`
Missing *int `json:"missing"`
Leaf ... |
package utils
import (
"bytes"
"encoding/binary"
"fmt"
"sort"
)
/*
creating a tablet for insertion
for example, considering device: root.sg1.d1
timestamps, m1, m2, m3
1, 125.3, True, text1
2, 111.6, False, text2
3, 688.6, True, text3
Notice: The tabl... |
package nfs
import (
"context"
"fmt"
nfsstoragev1alpha1 "github.com/johandry/nfs-operator/api/v1alpha1"
"github.com/johandry/nfs-operator/resources"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg... |
package groupsimilar
import (
"fmt"
"hash"
"unicode/utf8"
)
var (
splits = []rune{',', '.', '!', ' ', ','}
)
type StringVector struct {
hashfn hash.Hash64
}
func NewStringVector(fn hash.Hash64) *StringVector {
stringVector := new(StringVector)
stringVector.hashfn = fn
return stringVector
}
func toRunes(gro... |
package mock
import (
"github.com/10gen/realm-cli/internal/telemetry"
)
// TelemetryService is a mocked telemetry service
type TelemetryService struct {
telemetry.Service
TrackEventFn func(eventType telemetry.EventType, data ...telemetry.EventData)
CloseFn func()
}
// TrackEvent calls the mocked TrackEvent ... |
package replay
import (
"bytes"
"io"
"io/ioutil"
"net/http"
"net/url"
"runtime"
)
// Filter function is used to determine if a given http.Request should be replayed or not.
type Filter func(*http.Request) bool
// Modifier function is used to modify a given http.Request before replaying it.
type Modifier func(*... |
package config
var constantValue map[string]interface{}
func SetConstantValue(key string, value interface{}) {
if constantValue == nil {
constantValue = make(map[string]interface{})
}
constantValue[key] = value
}
func GetConstantValue(key string) interface{} {
if val, ok := constantValue[key]; ok {
return val... |
package _862_Shortest_Subarray_with_Sum_at_Least_K
type mem struct {
idx int
sum int
}
func shortestSubarray(nums []int, k int) int {
sum := 0
queue := []mem{{idx: -1, sum: sum}}
res := len(nums) + 1
for idx, num := range nums {
sum += num
for len(queue) > 0 && sum-queue[0].sum >= k {
res = min(res, idx-... |
package hikoqiuclient
import (
"eureka/vars"
"fmt"
"time"
"github.com/HikoQiu/go-eureka-client/eureka"
)
// instance 정보에 meta 필드가 없음.
type HikoQiuClient struct {
instanceID string
vo *eureka.InstanceVo
config *eureka.EurekaClientConfig
cli *eureka.Client
api *eureka.EurekaServerAp... |
// This file was generated for SObject ApexTestRunResult, API Version v43.0 at 2018-07-30 03:48:06.346527851 -0400 EDT m=+52.691111397
package sobjects
import (
"fmt"
"strings"
)
type ApexTestRunResult struct {
BaseSObject
AsyncApexJobId string `force:",omitempty"`
ClassesCompleted int `force:",omitempty"`... |
// 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 i... |
package blc
import (
"flag"
"fmt"
"log"
"os"
)
//对blockchain进行命令行管理
//CLI 对象
type CLI struct {
}
//PrintUsage 用法展示
func PrintUsage() {
fmt.Println("Usage:")
//初始化区块链--
fmt.Printf("\tcreateblockchain -address address --create a blockchain\n")
//添加区块
fmt.Printf("\taddblock -data DATA --a... |
package bills
import {
}
// Post represents a Social Media Post type.
type Bill struct {
UUID string `json:"uuid"`
OriginalFileName string `json:"OriginalFileName"`
GeneratedFileName string `json: "GeneratedFileName"`
}
// The init() function is responsible for initializing th... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
var numeri []float64
fmt.Println("inserisci i numeri")
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
input := scanner.Text()
numconv, _ := strconv.ParseFloat(input, 4)
numeri = append(numeri... |
// Copyright 2019 The Android Open Source Project
//
// 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 ... |
package tmpl1
import (
"fmt"
"testing"
)
func TestMySqrt(t *testing.T) {
testMySqrt(t, mySqrt, mySqrt1)
}
func testMySqrt(t *testing.T, fs ...func(int) int) {
tcs := []struct {
input int
expect int
}{
{0, 0},
{1, 1},
{2, 1},
{3, 1},
{4, 2},
{5, 2},
{6, 2},
{7, 2},
{8, 2},
{9, 3},
{655... |
package controller
import (
"github.com/allentom/youcomic-api/auth"
ApiError "github.com/allentom/youcomic-api/error"
"github.com/allentom/youcomic-api/model"
"github.com/allentom/youcomic-api/permission"
"github.com/allentom/youcomic-api/serializer"
"github.com/allentom/youcomic-api/services"
"github.com/allen... |
package main
import (
"log"
"runtime"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/glfw/v3.2/glfw"
"./basic"
"./ball"
"math/rand"
)
const (
width = 500
height = 500
)
type Drawable interface {
Draw()
}
const BallNum = 1
func main() {
runtime.LockOSThread()
window := initGlfw()
defer glfw.T... |
// Copyright (c) 2014 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"errors"
"io"
"io/ioutil"
"log"
"math/rand"
"os"
"os/exec"
"strconv"
"time"
rpc "github.com/conformal/btcrpcclient"
"github.com/conformal/bt... |
package dushengchen
/**
Submission:
https://leetcode.com/submissions/detail/366509188/
*/
func multiply(num1 string, num2 string) string {
a := []rune(num1)
b := []rune(num2)
sum := make([]rune, len(num1)+len(num2))
sum[0] = '0'
for i := 0; i < len(a); i++ {
m := runeToInt(a[len(a)-i-1... |
package sfen
import (
"testing"
"bytes"
"fmt"
)
func TestParsePosition(t *testing.T) {
s, err := ParsePosition("position startpos moves 7g7f 3c3d 6g6f 8c8d 2h6h 8d8e 8h7g 7a6b 5i4h 5c5d 3i3h 5a4b 4h3i 1c1d 1g1f 3a3b 7i7h 6b5c 3i2h 6a5b 6i5h 4b3a 4g4f 2c2d 3g3f 3b2c 5h4g 4a3b 2i3g 2b4d 5g5f 3a2b 6f6e 4d7g+ 7h7g 4... |
// Package none contains generic structures for installer
// configuration and management.
package external
// Name is name for the External platform.
const Name string = "external"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.