text stringlengths 11 4.05M |
|---|
package main
import (
"encoding/json"
"fmt"
"github.com/slofurno/ws"
"time"
)
func getCurrentTime() int64 {
nanos := time.Now().UnixNano()
return nanos / 1000000
}
type GithubUserResponse struct {
Login string `json:"login"`
Url string `json:"url"`
Name string `json:"name"`
Id uint64 `json:"id"`
}
t... |
/*
Package voxels implements DVID support for data using voxels as elements.
A number of data types will embed this package and customize it using the
"NumChannels" and "BytesPerVoxel" fields.
*/
package voxels
import (
"encoding/gob"
"fmt"
"image"
"log"
"net/http"
"strings"
"sync"
"time"
"github.com/jane... |
package model
import (
"context"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"time"
)
var MyDB *sqlx.DB
func intDB() error {
MyDB = sqlx.MustOpen("mysql","root:root@tcp(localhost:3306)/test?parseTime=True&loc=Local&multiStatements=true&charset=utf8mb4")
ctx,cancel := context.WithTimeout(conte... |
// Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//go:build !cgo
package manual
// Provides versions of New and Free when cgo is not available (e.g. cross
// compilation).
// New allocate... |
package knownhosts
import (
"bufio"
"bytes"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"errors"
"fmt"
"io"
"net"
"regexp"
"strings"
"golang.org/x/crypto/ssh"
)
type KnownHosts []*Line
func Unmarshal(in io.Reader) (*KnownHosts, error) {
var k KnownHosts
s := bufio.NewScanner(in)
var errs []string
... |
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or //
// its subsidiaries. ... |
// 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... |
package main
import (
"fmt"
"github.com/exproletariy/pip-services3-containers-examples/app-container-example-go/containers"
"path"
"sync"
)
func main() {
shutdown := make(chan bool, 1)
defer close(shutdown)
var wg sync.WaitGroup
wg.Add(2)
fmt.Println("To shutdown the service press eny key...")
go func(si... |
package verbosity
import (
"fmt"
"log"
"os"
"path"
"runtime"
"github.com/TwinProduction/go-color"
)
var (
logToFile log.Logger
verbose = false
saveLog = false
logFilePath string
)
// Set verbosity level and log file
func SetupLog(VerbosityActive bool, logPath string) {
verbose = VerbosityActive... |
package binance
import (
"errors"
"testing"
"github.com/stretchr/testify/suite"
)
type websocketServiceTestSuite struct {
baseTestSuite
origWsServe func(*WsConfig, WsHandler, ErrHandler) (chan struct{}, chan struct{}, error)
serveCount int
}
func TestWebsocketService(t *testing.T) {
suite.Run(t, new(websock... |
// Copyright 2023 Google LLC. All Rights Reserved.
//
// 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 applica... |
package plugin
import (
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
"github.com/gogo/protobuf/vanity"
)
type plugin struct {
*generator.Generator
generator.PluginImports
regexPkg generator.Single
fmtPkg generator.Single
protoPkg generator.Single
preprocessorPkg generator.Singl... |
package router
import (
"github.com/yaice-rx/yaice/network"
"google.golang.org/protobuf/proto"
)
type IRouter interface {
AddRouter(msgObj proto.Message, handler func(conn network.IConn, content []byte))
RegisterMQ(msgQueueName string, handler func(content []byte))
ExecRouterFunc(conn network.IConn, message netw... |
package proxy_test
import (
"context"
"io"
"testing"
"github.com/mjpitz/highlander-proxy/internal/proxy"
"github.com/stretchr/testify/require"
)
func TestPipe(t *testing.T) {
message := "Hello World!"
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
readerA, writerA := io.Pipe()
readerB,... |
package main
func main() {
}
// TODO 未完成
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
var calcMid = func(nums []int) float64 {
len := len(nums)
if len == 1 {
return float64(nums[0])
}
if len%2 == 0 {
mid := len / 2
return (float64(nums[mid]) + float64(nums[mid-1])) / 2
} else ... |
package repositories
import (
"database/sql/driver"
"errors"
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/stretchr/testify/assert"
"github.com/ariel17/railgun/api/entities"
"github.com/ariel17/railgun/api/repositories/database"
)
var (
columnsByID = []string{"user_id", "url", "code", "verified"}
... |
package problem0022
func generateParenthesis(n int) []string {
res := make([]string, n*n)
bytes := make([]byte, n*2)
dfs(n, n, 0, bytes, &res)
return res
}
func dfs(left, right, idx int, bytes []byte, res *[]string) {
if left == 0 && right == 0 {
*res = append(*res, string(bytes))
return
}
if left > 0 {
... |
import "strings"
func lengthOfLastWord(s string) int {
words := removeEmpty(strings.Split(s, " "))
if len(words) > 0 {
return len(words[len(words) - 1])
}
return 0
}
func removeEmpty(arr []string) []string {
var newArr []string
for i := 0; i < len(arr); i++ {
if len(arr[i]) > 0 {
newArr = append(newArr, ... |
/*
Copyright 2020 Daniel Avrukin
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, software
dis... |
package main
import (
"fmt"
"net/http"
"net/http/httptest"
)
const (
checkMark = "\u2713"
ballotX = "\u2717"
)
//feed模拟期望接收的XML文档
var feed = `<?xml version="1.0" encoding="UTF-8"?>
<rss>
<channel>
<title>Going Go Programming</title>
<description>Golang : https://github.com/goinggo</description>
<link>htt... |
package main
import (
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)
/*
# in debian
sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev
*/
func main() {
app := app.New()
w := app.NewWindow("Hello")
w.SetTitle("my first demo")
w.SetContent(widget.NewHBox(
widget.NewVBox(
widget.NewLabel("Hello Fyne!"),
... |
//go:generate protoc -I ./proto --go_out=plugins=grpc:./proto ./proto/products.proto
package main
import (
"context"
"net"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
pb "github.com/prologic/youfoodz_challenge/products/proto"
log "github.com/sirupsen/logrus"
)
const (
bind = ":8000"
)
type... |
package main
import (
"fmt"
)
func add(x float64, y float64) float64 {
return x + y
}
func multiple(a, b string) (string, string) {
return a, b
}
func main() {
// var num1 float64 = 5.5
// var num2 float64 = 9.9
s1, s2 := "Hey", "bitch"
// fmt.Println(add(num1, num2))
fmt.Println(multiple(s1, s2))
}
|
// Copyright 2015 The StudyGolang Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// http://studygolang.com
// Author:polaris polaris@studygolang.com
package filter
import (
"model"
"net/http"
"service"
"config"
"logger"
"uti... |
package encryption
type Service interface {
PasswordMatchHex(guessedPassword, hexSalt, hexHashedPassword string) (bool, error)
CreatePassword(raw_pass string) (Password, error)
}
|
// Copyright 2021 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
// This file was generated for SObject AuthSession, API Version v43.0 at 2018-07-30 03:47:19.012514934 -0400 EDT m=+5.355322319
package sobjects
import (
"fmt"
"strings"
)
type AuthSession struct {
BaseSObject
CreatedDate string `force:",omitempty"`
Id string `force:",omitempty"`
IsC... |
// Copyright 2015 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 dump_test
import (
"testing"
"github.com/Kretech/xgo/dump"
"github.com/Kretech/xgo/encoding"
)
func TestIsScalar(t *testing.T) {
mustbe := map[interface{}]bool{
3: true,
true: true,
0.43: true,
complex(2, 3): true,
"hi": true... |
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package commands
import (
"encoding/json"
"fmt"
"strings"
"testing"
"github.com/scaleway/scaleway-cli/pkg/api"
. "github.com/smartystreets/goconvey/con... |
package geoelevations
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path"
"strings"
)
func reloadJsonUrls(destinationFilename string) error {
srtmData, err := LoadSrtmData()
if err != nil {
return err
}
srtmDataJson, err := json.MarshalIndent(srtmData, "", "\t")
if err != nil {
return err
}... |
package mr
//
// RPC definitions.
//
//
// example to show how to declare the arguments
// and reply for an RPC.
//
type ExampleArgs struct {
X int
}
type ExampleReply struct {
Y int
}
// Add your RPC definitions here.
// 注册
type RegisterReq struct {
}
type RegisterRes struct {
WorkerID uint64
}
// 获取任务
type ... |
package websocket_service
import (
"sync"
"github.com/gorilla/websocket"
"github.com/golang/protobuf/proto"
"log"
"ms/sun_old/config"
"ms/sun/shared/helper"
"ms/sun/shared/x"
)
const PB_CommandReceivedToServer = "PB_CommandReceivedToServer"
const PB_CommandReceivedToClient = "PB_CommandReceivedToClient"
typ... |
package bitbucket
// ListProjects returns a list of all projects on the Bitbucket server
func (b *BitbucketClient) ListProjects() ([]BBProject, error) {
if b.IsBBCloud {
return b.listProjectsBBCloud()
}
return b.listProjectsBBServer()
}
|
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2019
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package sensordb
import (
"time"
// Frameworks
gopi "github.com/djthorpe/gopi"
)
/////////////////////////... |
/**
* constants
* @author liuzhen
* @Description
* @version 1.0.0 2021/1/28 16:56
*/
package constants
const (
Admin = "admin"
UserNameKey = "username"
SessionIdKey = "sessionId"
BuildFlowTypeCustomer = "customer"
BuildFlowTypeIncrementVersio... |
package main
import (
"gopkg.in/qml.v1"
//"time"
//"fmt"
)
type Theme struct {
Name string
FontFamily string
MainColor string
Opacity float64
FontColorPrimary string
FontColorAccent string
AccentItalics bool
HoverColor string
TitleImage string
NewIdentityIcon string
AddDeviceIcon string
Res... |
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0.
package log
import (
"strings"
"go.uber.org/zap/zapcore"
)
var _ zapcore.Core = (*FilterCore)(nil)
// FilterCore is a zapcore.Core implementation, it filters log by path-qualified
// package name.
type FilterCore struct {
zapcore.Core
filters []string
... |
package main
import "fmt"
type person struct {
name string
age int
}
func main() {
p1 := &person{"James", 27}
fmt.Println(p1)
fmt.Printf("%T \n", p1)
fmt.Println(p1.name)
fmt.Println(p1.age)
}
// &{James 27}
// *main.person
// James
// 27
|
package config
import (
"errors"
"net"
"os"
"path/filepath"
"strconv"
"time"
"github.com/GlitchyGlitch/typinger/crypto"
)
var ErrInvalidStatic = errors.New("invalid static path configuration")
func EnvDBURL() string {
url := os.Getenv("DATABASE_URL")
return url
}
func EnvHost() string {
host := os.Getenv... |
package config
import (
"fmt"
"io"
"text/template"
"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"
rootcmd "github.com/instructure-bridge/muss/cmd"
"github.com/instructure-bridge/muss/config"
)
var format = "{{ yaml . }}"
func newShowCommand(cfg *config.ProjectConfig) *cobra.Command {
var cmd = &cobra.Com... |
package handlers
import (
"html"
"io"
"net/http"
"strconv"
"github.com/jackc/pgx"
)
type yakstakRow struct {
id int64
publicID string
name string
}
type YakstakIndex struct {
DB *pgx.ConnPool
}
func (action *YakstakIndex) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var yakstakRows []ya... |
package mocks
import "io"
var _ io.WriteCloser = &DiscardCloser{}
type DiscardCloser struct {
io.Writer
}
func (d *DiscardCloser) Close() error {
return nil
}
func NewDiscardCloser() *DiscardCloser {
return &DiscardCloser{io.Discard}
}
|
// Copyright 2021 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 db_query_loan
import (
"bankBigData/BankServerJournal/entity"
table2 "bankBigData/BankServerJournal/table"
"bankBigData/_public/table"
"gitee.com/johng/gf/g"
)
func GetKeys(keyStr g.Slice) (g.List, error) {
db := g.DB(table.CDbName)
sql := db.Table(table.CTableColumnConfig).Fields("`id`,`column`,`text`"... |
package config
import (
"github.com/asaskevich/govalidator"
"regexp"
)
type RuleSpec struct {
Name string `mapstructure:"name"`
ServiceName string `mapstructure:"service"`
Schema string `default:"http" mapstructure:"schema"`
PathPrefix string ... |
// array_test.go
package arrays
import (
"fmt"
"os"
"testing"
)
func TestMain(m *testing.M) {
SetArrayStartIndexToOne()
fmt.Println("Launching test suite with startOfArrayIndex=", startOfArrayIndex)
retCode := m.Run()
os.Exit(retCode)
}
func failOnNil(t *testing.T, err error, msg string) {
if err == nil {
... |
package main
func main() {
cards := readDeck("test.deck")
// cards.print()
cards.shuffle2(2)
cards.print()
// hand, remainingDeck := deal(cards, 5)
// cards = remainingDeck
// hand.print()
// cards.print()
// if err := cards.saveDeck("test.deck"); err != nil {
// fmt.Println(err)
// os.Exit(1)
// } else ... |
package main
import "fmt"
func main() {
var name = "truong"
var age int32 = 22
const isHandsome = true
// shortHand
sex, subject := "Male", "Go"
size := 20.55
fmt.Println(name, age, isHandsome)
fmt.Printf("%T\n", isHandsome)
fmt.Println(sex, subject)
fmt.Printf("%T\n", size)
}
// bool
// Numeric Types
//... |
package terminal
import (
"bufio"
"fmt"
"io"
"os"
"strings"
"github.com/docker/docker/pkg/term"
)
//go:generate counterfeiter -o mocks/fake_term.go . Term
type Term interface {
SaveState(fd uintptr) (*term.State, error)
RestoreTerminal(fd uintptr, state *term.State) error
DisableEcho(fd uintptr, state *term... |
// C. Успеть все
// https://codeforces.com/contest/1031/problem/C
// tags: greedy
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type scanner struct {
s *bufio.Scanner
}
func initScanner(filename string) scanner {
//f, _ := os.Open(filename)
f := os.Stdin
return scanner{s: bufio.NewSca... |
// Copyright ©2015 The gonum 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 distmv
import (
"math"
"testing"
)
type prober interface {
Prob(x []float64) float64
LogProb(x []float64) float64
}
type probCase struct {
d... |
package models
import (
"monitor/data"
"monitor/responses"
"sync"
"time"
)
var (
once sync.Once
modelInstance MonitorServiceIf
)
// GetQB86APIModel return interface models
func GetMonitorModel() MonitorServiceIf {
once.Do(func() {
onceInitMonitorModel()
})
return modelInstance
}
type MonitorServ... |
package master
import (
"server/libs/log"
"server/share"
"sync"
)
var (
applock sync.RWMutex
mustapps = map[string]string{}
)
func Ready(app *app) {
applock.Lock()
defer applock.Unlock()
out, err := share.CreateReadyMsg(app.id)
if err != nil {
log.LogFatalf(err)
}
ismustapp := false
for _, v := rang... |
package search
import (
"fmt"
"github.com/myProj/scaner/new/include/logggerScan"
"github.com/myProj/scaner/new/include/textSearchAndExtract/extract"
"github.com/tealeg/xlsx"
"log"
"math"
"runtime/debug"
"strings"
"reflect"
)
func recovery(st chan map[string]int,filename string) {
if r := recover(); r != nil... |
package sms
import (
"bufio"
"bytes"
"github.com/sujit-baniya/smpp/coding/semioctet"
"io"
"time"
)
type Time struct{ time.Time }
func (t *Time) ReadFrom(r io.Reader) (n int64, err error) {
data := make([]byte, 7)
if _, err = r.Read(data); err != nil {
return
}
blocks := semioctet.DecodeSemi(data)
t.Time ... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/5/29 4:46 下午
# @File : linked_list_cycle.go
# @Description :
给定一个链表,判断链表中是否有环。
如果链表中有某个节点,
可以通过连续跟踪 next 指针再次到达,则链表中存在环。
为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。
如果 pos 是 -1,则在该链表中没有环。注意:pos 不作为参数进行传递,仅仅是为了标识链表的实际情况。
# @Attention :
*/
package v2
fun... |
package main
import (
//gsv ".."
cryptoRand "crypto/rand"
"flag"
"fmt"
gsv "simonwaldherr.de/go/GolangSortingVisualization"
"strings"
"time"
)
func randomArray(n int, max int) []int {
var i int
var number float64
arr := make([]int, n)
for i = 0; i < n; i++ {
b := make([]byte, 1)
cryptoRand.Read(b)
n... |
package gol
type Cell struct {
alive bool
}
func NewCell(alive bool) *Cell {
return &Cell{alive}
}
func (c *Cell) Next(count int) *Cell {
return NewCell(count == 3 || (c.alive && count == 2))
}
func (c *Cell) Value() int {
if (c.alive) {
return 1
} else {
return 0
}
}
func (c *Cell) IsAlive() b... |
package common
type BgErr struct {
ErrNo int32
ErrMsg string
}
func (e BgErr) Error() string {
return e.ErrMsg
}
func (e BgErr) Is(err BgErr) bool {
return e.ErrNo == err.ErrNo
}
func (e BgErr) ErrNoMsg() (int32, string) {
return e.ErrNo, e.ErrMsg
}
var (
Success = BgErr{0, ""}
BindErr = BgErr{... |
package main
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"sync"
_ "github.com/go-sql-driver/mysql" // mysql
"github.com/sasha-s/go-deadlock"
)
// Element has the data for a created element
type Element struct {
Color string `json:"color"`
Comment string `json:"comment"`
CreatedOn int `... |
/*
Description
Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two cards with the same pip. During a round, each player chooses one card to compare with others. The pl... |
/* Copyright (c) 2016 Jason Ish
* 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, this list of conditions... |
package base
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
"oneday-infrastructure/internal/pkg/authenticate/domain"
"oneday-infrastructure/tools"
)
type LoginUserDO struct {
gorm.Model
//TODO unique_index
Username string `gorm:"type:varchar(100);unique_index;not null"`
Passw... |
/**
* @license
* Copyright 2018 Telefónica Investigación y Desarrollo, S.A.U
*
* 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
*
* Unles... |
//go:build mage
package main
import (
"github.com/magefile/mage/sh"
)
var Default = Build
func Build() error {
return sh.Run("go", "build", "-o", "bin/kit", "./cmd/kit")
}
|
package bclient
import (
"context"
"math/big"
"github.com/bonedaddy/go-defi/sushiswap"
"github.com/bonedaddy/go-defi/testenv"
"github.com/bonedaddy/go-defi/uniswap"
"github.com/bonedaddy/go-defi/utils"
"github.com/ethereum/go-ethereum/ethclient"
)
// BClient wraps ethclient and provides helper functions for c... |
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
"time"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
_ "github.com/go-sql-driver/mysql"
)
type Task struct {
Id int `json:"id"`
Name string `json:"name"`
Status bool `json:"status"`
Order int `json:... |
// Copyright 2017 Walter Schulze
//
// 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... |
// 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 main
import (
"reflect"
"fmt"
)
func main() {
langs := [4]string{
"go",
"python",
"php",
"javascript",
}
slice := langs[0:4]
fmt.Println(reflect.TypeOf(langs))
fmt.Println(reflect.TypeOf(slice))//slice本身不存值
fmt.Println(langs[3])
slice[3] = "C++" //array的值不可修改,但可透過修改slice來改變array的值
fmt.Prin... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-17 09:32
# @File : lt_76_Minimum_Window_Substring.go
# @Description :
# @Attention :
*/
package slide_window
import "math"
func minWindow(s string, t string) string {
// windows 滑动窗口
have := make([]int, 128)
// 目标次数
need := make([]int, 128)
for _,... |
package logger
import (
"fmt"
"log"
"log/syslog"
"path/filepath"
"runtime"
"strings"
"time"
)
// Conf structure for syslog options
// Indentity is the syslog tag
type SyslogConfig struct {
Enabled bool
Identity string
}
// Conf structure for stdout logging
type StdlogConfig struct {
Enabled bool
}
// Gen... |
package polygon
import (
"github.com/JesseleDuran/secure-graph-worker/inmem/crime/cell"
"github.com/golang/geo/s2"
)
// Polygon Represents a projection of coordinates to a set of points on a sphere.
// it should be noted that a point on the sphere is a vector in the
// three-dimensional plane.
type Polygon struct ... |
//二叉树
package btree
import "fmt"
type BTree struct {
Data interface{}
LeftChild *BTree
RightChild *BTree
}
func New() *BTree {
return &BTree{}
}
//将数组放到二叉树中
func ArrayToBTree(arr []int, start, end int) *BTree {
var root *BTree
if end >= start {
root = New()
mid := (start + end + 1) / 2
root.Data ... |
package middleware
import (
"github.com/best-expendables/httpclient/net/profile"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNetworkProfiler(t *testing.T) {
a := assert.New(t)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.R... |
// Copyright 2019 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 serverpb
const (
Swagger = `
{
"swagger": "2.0",
"info": {
"title": "server.proto",
"version": "version not set"
},
"tags": [
{
"name": "ServerService"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/addServer": {
... |
package main
import (
"bytes"
"crypto/md5"
"encoding/json"
"fmt"
"github.com/urfave/cli"
"io/ioutil"
"net"
"os"
)
// Checks if the files have the same hash in order to determine if they are the same
func checkIT(c *cli.Context) {
same, err := check(c.Args()[0])
if err != nil {
panic(err)
}
if same {
... |
package social
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/loginradius/lr-cli/api"
"github.com/loginradius/lr-cli/prompt"
"github.com/spf13/cobra"
)
var temp string
var Url string
func NewsocialCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "social",
Short: "get social providers"... |
// 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 collect
import (
"opentsp.org/contrib/collect-netscaler/nitro"
"opentsp.org/internal/tsdb"
)
func init() {
registerStatFunc("Interface", ... |
package badwords
import (
"bufio"
"fmt"
"os"
"sort"
"strings"
"io"
"io/ioutil"
)
type wordMap struct {
lenMap map[int]int
lenSlice []int
words map[string]string
}
type wordTree struct {
wordMaxLen int
trees map[string]*wordMap
file string
}
func (t *wordTree) add(word string) {
wSlice := st... |
package ast
// LeftJoin represents an inner join table relation in the SQL query.
type LeftJoin struct {
Table *Table
Left *Field
Right *Field
}
func (j *LeftJoin) SetTable(table *Table) {
j.Table = table
}
func (j *LeftJoin) GetTable() *Table {
return j.Table
}
func (j *LeftJoin) BuildQuery() string {
retur... |
package css
type Id string
func (id Id) Selector() string {
return "#" + string(id)
}
func (id Id) WithPseudoClass(pseudoClass PseudoClass) SelectorWithPseudoClass {
return SelectorWithPseudoClass{Element: id, PseudoClass: pseudoClass}
}
func (id Id) Style(properties ...Property) RuleSet {
return For(id).Set(pro... |
package elevator
import (
"math"
)
type ControlSystem struct {
Elevators []*Elevator
NumberOfElevators int
NumberOfFloors int
}
type ControlSystemStatus []*Elevator
func(css *ControlSystemStatus)Len() int {
return len(*css)
}
func(css *ControlSystemStatus)GetStatusAtIndex(index int) *Elevator {
cp... |
package main
import (
"fmt"
"github.com/GoesToEleven/go-programming/code_samples/010-ninja-level-thirteen/01/starting-code/dog"
)
type canine struct{
name string
age int
}
func main() {
fido := canine{
name: "fido",
age: dog.Years(7),
}
fmt.Println(fido.age)
} |
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.4.1.dev1
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
package swagger
// 201 created object
type PostFleetsFleetIdWingsWingIdSquadsCreated struct {
// The squad_id of the newly created squad
Sq... |
package validation
import (
"fmt"
"net"
"net/url"
"os"
"regexp"
"sort"
"strconv"
"strings"
dockerref "github.com/containers/image/docker/reference"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apim... |
package keystores
import (
"log"
"os"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
Helpers "github.com/kaikoh95/web3go/src/helpers"
)
func InitKeyStore(folder string) *keystore.KeyStore {
return keystore.NewKeyStore(folder, keystore.StandardScryptN, keystore.St... |
package local
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/10gen/realm-cli/internal/cloud/realm"
u "github.com/10gen/realm-cli/internal/utils/test"
"github.com/10gen/realm-cli/internal/utils/test/assert"
)
func TestNewApp(t *testing.T) {
t.Run("new app should create... |
package main
import (
"os"
)
func main() {
_, err := os.Open("no-file.txt")
if err != nil {
panic(err)
}
}
/*
Package log implements a simple logging package ...
writes to standard error and prints the date and time of each logged message ...
the Fatal functions call os.Exit(1) after writing the log message... |
package node
import (
"context"
"crypto/rand"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"github.com/Secured-Finance/dione/blockchain/database/memory"
"github.com/Secured-Finance/dione/blockchain/database/lmdb"
"github.com/Secured-Finance/dione/blockchain/database"
"github.com/Secu... |
// +k8s:deepcopy-gen=package
// +groupName=pxc.percona.com
package v1alpha1
|
package aoc2015
import (
"testing"
aoc "github.com/janreggie/aoc/internal"
"github.com/stretchr/testify/assert"
)
func TestDay16(t *testing.T) {
assert := assert.New(t)
testCases := []aoc.TestCase{
{Details: "Y2015D16 my test case",
Input: day16myInput,
Result1: "40",
Result2: "241"},
}
for _, tt... |
package entity
type Plant struct {
Name string `json:"title"`
Description string `json:"description"`
Price float64 `json:"price"`
Avatar string `json:"avatar"`
}
|
package cfrida
func Frida_bus_is_detached(obj uintptr)bool{
r,_,_:=frida_bus_is_detached.Call(obj)
return r!=0
}
func Frida_bus_attach_sync(obj uintptr,cancellable uintptr)(bool,error){
gerr:=MakeGError()
r,_,_:=frida_bus_attach_sync.Call(obj,cancellable,gerr.Input())
return r!=0,gerr.ToError()
}
func Frida_bu... |
package multiaddr
import (
"encoding/binary"
"testing"
)
func checkVarint(t *testing.T, x int) {
buf := make([]byte, binary.MaxVarintLen64)
expected := binary.PutUvarint(buf, uint64(x))
size := VarintSize(x)
if size != expected {
t.Fatalf("expected varintsize of %d to be %d, got %d", x, expected, size)
}
}
... |
package main
import "fmt"
func medias(numeros ...float64) float64 {
total := 0.0
for _, numero := range numeros {
total += numero
}
return total / float64(len(numeros))
}
func main() {
fmt.Printf("Média: %.2f\n", medias(7.7, 8.1, 5.9, 9.9))
}
|
package compute
// ImageType represents a type of Image.
type ImageType int
const (
// ImageTypeUnknown represents an unknown image type.
ImageTypeUnknown ImageType = iota
// ImageTypeOS represents an OS (built-in) image.
ImageTypeOS
// ImageTypeCustomer represents a customer image.
ImageTypeCustomer
)
// Im... |
// Copyright 2016 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package main
import (
"strings"
"testing"
"github.com/issue9/assert"
"github.com/tanxiaolong/apidoc/input"
"github.com/tanxiaolong/apidoc/output"
"github.com/tanxi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.