text stringlengths 11 4.05M |
|---|
package google
import (
"strings"
"github.com/davecgh/go-spew/spew"
log "github.com/sirupsen/logrus"
)
func mergeOutput(input []inputObject, output []responsePair) []responsePair {
inputCount := len(input)
outputCount := len(output)
if inputCount == 0 || outputCount == 0 {
return output
}
if inputCount >... |
package day5
import (
"fmt"
"io/ioutil"
"os"
"strings"
)
//DayFiveOne Day five task one
func DayFiveOne() {
amountOfRows := createNumberArray(0, 127)
amountOfColumns := createNumberArray(0, 7)
highestSeatId := 0
input, err := ioutil.ReadFile("./5/input.txt")
if err != nil {
fmt.Println(err)
os.Exit(1)
... |
package controllers
import (
"crud/models"
"strconv"
"strings"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
)
type InsereController struct {
beego.Controller
}
func (c *InsereController) Get() {
c.TplName = "insere.tpl"
}
func (c *InsereController) Post() {
c.TplName = "insere.tpl"
codigo := ... |
package cmd
import (
"context"
"github.com/kumahq/kuma/pkg/core"
)
type RunCmdOpts struct {
SetupSignalHandler func() context.Context
}
var DefaultRunCmdOpts = RunCmdOpts{
SetupSignalHandler: core.SetupSignalHandler,
}
|
package meta
type LicenseType uint8
const (
Unlicensed LicenseType = iota
Proprietary
Custom
GPLv3
GPLv2
LGPLv3
LGPLv2_1
AGPLv3_0
Apache2_0
MPL_2_0
PublicDomain
)
|
package ipfix
import (
"bytes"
"encoding/binary"
"encoding/json"
"fmt"
"ipfix-gen/util"
"net"
"reflect"
"testing"
"time"
)
func TestCheckE(t *testing.T) {
fmt.Println(0x80)
fmt.Println(1 << 7)
fmt.Println(0x00 == uint8(0))
fmt.Println(reflect.TypeOf(0x00).Size(), reflect.TypeOf(uint8(0)).Size())
fmt.Pri... |
package response
//BusRoute to hold response from rest api
type BusRoute struct {
Description string `json:"Description"`
ProviderID string `json:"ProviderID"`
Route string `json:"Route"`
}
|
package main
import (
"encoding/json"
"fmt"
"time"
"github.com/evanxg852000/eserveless/internal/core"
"github.com/evanxg852000/eserveless/internal/database"
"github.com/evanxg852000/eserveless/internal/helpers"
"github.com/gofiber/fiber"
"github.com/sirupsen/logrus"
)
// ProjectController provides all proje... |
package gormv2
import (
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"os"
"time"
)
var (
db *gorm.DB
)
// InitMysql [账号]:[密码]@tcp([地址]:[端口]) db.table([库名].[表名])
func InitMysql(dbUrl string) {
url := fmt.Sprintf("%v/?charset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=True&loc=L... |
// Copyright 2017 Canonical Ltd.
//
// 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 ... |
package runner
import (
"errors"
"github.com/gofrs/uuid"
"github.com/hitman99/peppercd/internal/redis"
log "github.com/sirupsen/logrus"
v1batch "k8s.io/api/batch/v1"
v1meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
"time"
)
type Interface interface {... |
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package logutil
import (
"encoding/hex"
"encoding/json"
"fmt"
"strings"
"github.com/google/uuid"
"github.com/pingcap/errors"
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/kvproto/pkg/import_sstpb"
"github.com/pingcap/kvproto/pkg... |
// symlink.
package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
testroot, err := ioutil.TempDir("", "test_symlink")
if err != nil {
panic(err)
}
defer os.RemoveAll(testroot)
dir, err := ioutil.TempDir(testroot, "test_symlink")
if err != nil {
panic(err)
}
sym := dir + ".link"
err = os.Symli... |
package models
import (
"testing"
)
func Test_common(t *testing.T) {
mi := MongoInfo{"127.0.0.1:27017", 5, 1000}
err := newMongodb(mi)
if err != nil {
println(err.Error())
t.Fail()
}
}
|
package main
import (
"fmt"
cd "go.jlucktay.dev/golang-workbench/custom-domain/one"
)
func main() {
fmt.Println(cd.HelloCustomDomain())
}
|
package dao
import (
"errors"
"github.com/golang/glog"
"qipai/model"
)
var Room roomDao
type roomDao struct {
}
func (roomDao) Get(roomId uint) (room model.Room, err error) {
if ret := Db().First(&room, roomId); ret.Error != nil || ret.RecordNotFound() {
err = errors.New("该房间不存在")
return
}
return
}
func ... |
package problem0057
import "testing"
func TestSolve(t *testing.T) {
t.Log(insert([][]int{[]int{1, 3}, []int{6, 9}}, []int{2, 5}))
t.Log(insert([][]int{[]int{1, 2}, []int{3, 5}, []int{6, 7}, []int{8, 10}, []int{12, 16}}, []int{4, 8}))
t.Log(insert([][]int{[]int{1, 5}}, []int{2, 3}))
t.Log(insert([][]int{[]int{1, 5... |
package adminController
import (
"github.com/krix38/gophotogallery/web/controller/adminController/handlers"
"github.com/krix38/gophotogallery/external/github.com/gorilla/context"
"github.com/krix38/gophotogallery/properties"
"net/http"
"log"
)
func StartAdminController() {
http.HandleFunc(properties.UrlAdminLo... |
/*
命題
「パトカー」+「タクシー」の文字を先頭から交互に連結して文字列「パタトクカシーー」を得よ。
*/
package main
import (
"strings"
"fmt"
)
func main(){
str1 := "パトカー"
str2 := "タクシー"
slice1 := strings.Split(str1, "")
slice2 := strings.Split(str2, "")
var combineStr string
for i := range slice1 {
combineStr += slice1[i]
combineStr += slice2[i]
}... |
--- vendor/github.com/modern-go/reflect2/unsafe_link.go.orig 2022-04-16 22:01:31 UTC
+++ vendor/github.com/modern-go/reflect2/unsafe_link.go
@@ -19,19 +19,13 @@ func typedslicecopy(elemType unsafe.Pointer, dst, src
//go:linkname mapassign reflect.mapassign
//go:noescape
-func mapassign(rtype unsafe.Pointer, m unsa... |
package rtrserver
import (
"bytes"
"encoding/binary"
"errors"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/jsonutil"
)
func ParseToRouterKey(buf *bytes.Reader, protocolVersion uint8) (rtrPduModel RtrPduModel, err error) {
/*
ProtocolVersion uint8 `json:"protocolVersion"`
PduType ... |
package mysqldb
import (
"context"
"time"
)
// AnalysisStatus 分析状态
type AnalysisStatus int32
const (
// AnalysisStatusPending 待决
AnalysisStatusPending AnalysisStatus = 0
// AnalysisStatusInProgress 进行中
AnalysisStatusInProgress AnalysisStatus = 1
// AnalysisStatusCompeleted 完成
AnalysisStatusCompeleted Analysi... |
// Copyright 2021 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... |
// Copyright © 2018 Sunface <CTO@188.com>
//
// 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 ... |
package rehearse
import (
"fmt"
"path/filepath"
"sort"
"strconv"
"testing"
"github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
pjapi "k8s.io/test-infra/prow/apis/prowjobs/v1"
"k8s.io/test-infra/prow/client/clientset/versioned/fake"
prowconfig "k8s.io/test-infra/prow/config"
"k8s.io/apimachinery/pkg/api/eq... |
package external
import (
"bytes"
"encoding/json"
"errors"
wrap "github.com/pkg/errors"
"net/http"
"os"
)
type Client struct {
*http.Client
}
func (c *Client) Request(r *PlnRequest) (*http.Response, error) {
reqBytes := new(bytes.Buffer)
err := json.NewEncoder(reqBytes).Encode(r)
if err != nil {
errInva... |
func findMinDifference(timePoints []string) int {
m:=make([]int,1440)
for _,v:=range timePoints{
s:=strings.Split(v,":")
a,_:=strconv.Atoi(s[0])
b,_:=strconv.Atoi(s[1])
m[a*60+b]++
if m[a*60+b]>1{
return 0
}
}
a,b:=0,0
for _,v:=range m{
... |
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.,
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obt... |
package vault
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/cinus-ue/securekit/common/bytesutil"
"github.com/cinus-ue/securekit/common/fileutil"
"github.com/cinus-ue/securekit/common/pathutil"
"github.com/cinus-ue/securekit/common/strutil"
"github.com/cinus-ue/securekit/int... |
package Router
import(
"fmt"
"html/template"
"net/http"
"strings"
"strconv"
_ "github.com/go-sql-driver/mysql"
"database/sql"
"os"
"io"
"io/ioutil"
)
var (
cur_username string
cur_password string
)
var html = `
<!DOCTYPE html>
<html lang="zh-ch">
<head>
<meta charset="utf-8">
<title>主页</title>
... |
package server
import (
"encoding/json"
"fmt"
"chatserver/pkg/domain"
"chatserver/pkg/usecase"
"github.com/tokopedia/tdk/go/app/http"
"github.com/tokopedia/tdk/go/log"
)
type HttpService struct {
}
func NewHttpServer() HttpService {
return HttpService{}
}
func (s HttpService) RegisterHandler(r *http.Router... |
package main
import (
"fmt"
"reflect"
)
type Person struct {
name string
age int
}
func (p Person) SayBye() string {
return p.name
}
func (p Person) SayHello() (string, string) {
return "Hello", "world"
}
func (p Person) Say(word string) (string, string) {
return word, "ok"
}
type SayInterface interface {... |
package main
import "fmt"
func main() {
// 타입有
const age int = 10
const name string = "sky"
fmt.Println("타입有 : ", age, name)
/* 컴파일 에러
const score int // 대입값이 없으면 상수로 사용 불가
age = 20 // 타입이 없다면 const를 붙여줘야 한다.
name = "Hippo" // 타입이 없다면 const를 붙여줘야 한다.
*/
//타입無
const height = 190 // 타입이 없어도 ... |
package main
import (
"fmt"
"strconv"
"strings"
)
// Find the two values that sum to 2020, multiply them and return the result
const targetSum = 2020
func main() {
data := strings.Split(input, "\n")
fmt.Println("Ans 1:", sum(data))
fmt.Println("Ans 2:", sum3(data))
}
func sum(data []string) int {
// O(n^2) b... |
package main
import (
"fmt"
"github.com/gorilla/mux"
"net/http"
"os"
. "reunion/announcement"
"reunion/announcement/rss"
"reunion/announcement/specy"
"reunion/authentication"
. "reunion/compression"
"reunion/configuration"
"reunion/home"
"reunion/minify"
"reunion/websocket"
)
func main() {
configuration... |
// SPDX-FileCopyrightText: (c) 2018 Daniel Czerwonk
//
// SPDX-License-Identifier: MIT
package config
import (
"fmt"
"io"
"gopkg.in/yaml.v2"
)
// Config respresents the server configuration
type Config struct {
// Our ASN
LocalAS uint32 `yaml:"local_as"`
// RouterID is the BGP router identifier of our server... |
package main
import "github.com/study-golang/resmgr/deferusage"
func main() {
//df.TryDefer()
deferusage.WriteFile("abc.txt")
}
|
package main
import (
"fmt"
"container/heap"
)
// 使用最大最小堆实现,维护两个堆,一个大根堆,一个小根堆,并且两个堆元素个数差不超过1
// 这样大根堆存储前半部分有序数据,小根堆存储后半部分有序数据
// 然后根据两个堆大小判断把来的数据放在哪个堆里 AddNum(num int)
// 若两个堆元素个数相等,取两个堆顶元素平均数即为中位数
// 否则谁的元素多取谁的堆顶元素为中位数 FindMedian()
type intHeap []int
func (h intHeap) Len() int { return len(h) } // 绑定len方法,返回长度
fu... |
package filter
import (
"fmt"
"testing"
)
func PrintList(msg string, r, s []uint64) {
fmt.Print(msg)
for _, ele := range r {
fmt.Print(ele, ",")
}
fmt.Println()
for _, ele := range s {
fmt.Print(ele, ",")
}
fmt.Println()
}
// 基本功能测试
func TestBasic(t *testing.T) {
tool := Init("127.0.0.1:6379", 100000, ... |
package destiny
type ItemData struct {
ItemHash float64
ItemName string
ItemDescription string
Icon string
SecondaryIcon string
DisplaySource string
ActionName string
HasAction bool
DeleteOnAction bool
TierTypeName string
Ti... |
/*
A Tour of Go Exercise: Web Crawler
Go语言之旅 - 网络爬虫
https://tour.golang.org/concurrency/10
*/
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
}
// 使用sync.Mutex对数... |
package osbuild2
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewTimezoneStage(t *testing.T) {
expectedStage := &Stage{
Type: "org.osbuild.timezone",
Options: &TimezoneStageOptions{},
}
actualStage := NewTimezoneStage(&TimezoneStageOptions{})
assert.Equal(t, expectedStage, actualSt... |
package cmd
import "testing"
func TestCheckURL(t *testing.T) {
tt := []struct {
name string
originalURL string
expectedURL string
expectedToFail bool
}{
{
name: "base URL",
originalURL: "google.com",
expectedURL: "https://google.com/api/commands",
expectedToFail... |
package auth
import (
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "auth",
Short: "Authenticate with the Pathbird API",
Long: "Authenticate with the Pathbird API.",
}
|
package main
import "fmt"
func main() {
char := "false11111"
var result bool
switch char {
case "true", "yes", "1":
result = true
case "false", "no", "0":
result = false
default:
fmt.Println("error")
}
fmt.Println(result)
}
|
/*
* @lc app=leetcode.cn id=64 lang=golang
*
* [64] 最小路径和
*/
package main
import (
"fmt"
)
/*
DFS
var dx []int = []int{0, 1}
var dy []int = []int{1, 0}
func dfs(grid [][]int, x, y, sum int, minSum *int) {
rows, cols := len(grid), len(grid[0])
if x == rows-1 && y == cols-1 {
if sum < *minSum {
*minSum = s... |
package routes
import (
"net/http"
"grhamm.com/todo/handler"
)
func RegisterRoute() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/", handler.Health)
mux.HandleFunc("/todo/get", handler.GetTodo)
mux.HandleFunc("/todo/post", handler.InsertTodo)
mux.HandleFunc("/todo/set-finished", handler.SetTodoFi... |
package network
import (
"crypto/tls"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
"time"
)
// IRequest :
type IRequest interface {
Execute(Method string, URL string, Headers map[string][]string, Payload string) (int, string, error)
}
// Request :
type Request struct{}
// Execute :
func (r Request) Exec... |
package xxhash
/*
#include "c-trunk/xxhash.h"
*/
import "C"
import (
"hash"
"unsafe"
)
type xxHash32 struct {
seed uint32
sum uint32
state unsafe.Pointer
}
// Size returns the number of bytes Sum will return.
func (xx *xxHash32) Size() int {
return 4
}
// BlockSize returns the hash's underlying block size... |
package bot
import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/wneessen/sotbot/database"
"github.com/wneessen/sotbot/random"
"github.com/wneessen/sotbot/response"
"github.com/wneessen/sotbot/user"
"time"
)
func (b *Bot) CheckSotAuth() {
l := log.WithFields(log.Fields{
"action": "bot.CheckSotAuth",
... |
package main
import (
"crypto/sha256"
"fmt"
"strings"
)
func main() {
var a API
a.LocalKey = true
a.GenerateAPIKey()
k := a.GetAPIKey()
prefix := strings.Split(k, ".")[0]
h := sha256.Sum256([]byte(k))
s := fmt.Sprintf("%x", h)
query := "INSERT INTO api (active, name, create_date, last_update, api_key, a... |
package htmlp
import (
"bytes"
"io"
"log"
"regexp"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
var bannedMap = map[atom.Atom]bool{
atom.Svg: true,
atom.Img: true,
atom.Style: true,
atom.Script: true,
}
var whiteSpaces = regexp.MustCompile(`\s+`)
func Parse(htm string) string {... |
package rabbit_streams
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/rabbitmq/rabbitmq-stream-go-client/pkg/amqp"
"github.com/rabbitmq/rabbitmq-stream-go-client/pkg/stream"
"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
"github.com/batchcorp/plumber-schemas/build/go/protos/records"... |
// Copyright 2020 Google Inc. 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 applicable... |
package responses
type PasswordChangeResponse struct {
Changed string `json:"changed" mapstructure:"changed"`
}
|
package doc
import (
"fmt"
_ "github.com/russross/blackfriday"
"io/ioutil"
"os"
"strings"
"testing"
)
func readDir(path string) {
dir, _ := ioutil.ReadDir(path)
for _, info := range dir {
fmt.Println(info.Name())
}
}
func getAllFileDic(path string) (result map[string]os.File) {
dir, _ := ioutil.ReadDir... |
package main
import (
"sync/atomic"
"fmt"
)
func main() {
//AddInt32 atomically adds delta to *addr and returns the new value.
var i int32 = 1
atomic.AddInt32(&i,1)
fmt.Println("i=i+1=",i)
atomic.AddInt32(&i,-1)
fmt.Println("i=i-1=",i)
//CompareAndSwapInt32 executes the compare-and-swap operation for an int3... |
package wooter
import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"code.cloudfoundry.org/windows2016fs/layer"
"code.cloudfoundry.org/windows2016fs/writer"
"github.com/Microsoft/hcsshim"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
const VolumesDir string = "volumes"
const DiffsDir string = "... |
package main
import (
"fmt"
)
func main() {
var arr = [5]int{1, 2, 3, 4, 5}
modifyArr(arr)
fmt.Println(arr)
}
func modifyArr(a [5]int) {
a[1] = 20
}
|
package data
import (
pb "github.com/bgokden/veri/veriservice"
)
// Delete delete data to internal kv store
func (dt *Data) Delete(datum *pb.Datum) error {
return dt.DeleteBDMap(datum)
}
|
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"net/url"
"os"
"regexp"
"strings"
"time"
"github.com/nlopes/slack"
)
var custom CustomResponses = nil
var config Config
type Config struct {
MtgApiEndpoint string `json:"mtg_api_endpoint"`
CustomResponseFile strin... |
package main
import (
"crypto/md5"
"database/sql"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"os/user"
"path/filepath"
"runtime"
"syscall"
// "time"
"github.com/cznic/ql"
"github.com/dchest/uniuri"
"github.com/fsnotify/fsnotify"
"github.com/op/go-logging" // more complete package to log to different out... |
package lcd
import (
"github.com/gorilla/mux"
"github.com/irisnet/irishub/client/context"
"github.com/irisnet/irishub/codec"
)
// RegisterRoutes - Central function to define routes that get registered by the main application
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
r.Handl... |
// Package isgd provides wrapper for url shortener services provided by `is.gd`
package isgd
import (
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"net/url"
)
// Shorten calls to shortener services with data provided and returns string
// containing shortened url and error (if any)
func Shorten(longUrl s... |
package distutil
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
// WasmExecJsPath find wasm_exec.js in the local Go distribution and return it's path.
// Return error if not found.
func WasmExecJsPath() (string, error) {
b, err := exec.Command("go", "env", "GOROOT").CombinedOutput()
if err != nil {... |
package requests
import (
"errors"
"fmt"
"log"
"net"
"net/http"
"net/http/httptest"
"runtime"
"strings"
"testing"
"time"
"github.com/alessiosavi/Requests/datastructure"
)
// Remove comment for set the log at debug level
var req Request // = InitDebugRequest()
func TestCreateHeaderList(t *testing.T) {
t.... |
package main
import "testing"
func TestGetNtpTime(t *testing.T) {
ntpServer := "0.beevik-ntp.pool.ntp.org"
if len(ntpServer) < 1 {
t.Fatalf("Name NTP server is empty")
}
_, e := GetNtpTime(ntpServer)
if e != nil {
t.Fatalf("bad return value for ntp server %s", ntpServer)
}
}
|
package controller
import (
"encoding/json"
"fmt"
"net/http"
"github.com/ksw95/GoIndustrialProject/API/models"
"github.com/labstack/echo"
"golang.org/x/crypto/bcrypt"
)
func (dbHandler *DBHandler) InsertUserCond(c echo.Context) error {
userC := models.UserCond{}
err := json.NewDecoder(c.Request().Body... |
package problem0079
import "testing"
func TestWordSearch(t *testing.T) {
/*board := [][]byte{
[]byte{'A', 'B', 'C', 'E'},
[]byte{'S', 'F', 'C', 'S'},
[]byte{'A', 'D', 'E', 'E'},
}
t.Log(exist(board, "ABC"))
t.Log(exist(board, "ASAD"))
t.Log(exist(board, "FCS"))
t.Log(exist(board, "ABES"))
*/
//t.Log(exi... |
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, ... |
package main
import (
"fmt"
"fiber-gorm-books/book"
"fiber-gorm-books/database"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html"
)
func main() {
// Initialize standard Go html template engine
engine := html.New("./views", ".html")
app := fiber.New(fiber.Config{
Views: engine,
})
initDa... |
package queries
import (
"context"
"github.com/graphql-go/graphql"
"go.mongodb.org/mongo-driver/bson"
database "graphql-mongo/data"
"graphql-mongo/types"
"os"
)
type todoStruct struct {
NAME string `json:"name"`
DESCRIPTION string `json:"description"`
}
var GetNotTodos = &graphql.Field{
Type: ... |
/*
Given an image, output the [width in pixels of a full vertical section]1 (if one exists). If no vertical section exists, output 0.
Input may be provided as a local file or a nested array. If you choose to take input as a nested array, white pixels should be represented by a truthy value while non-white pixels shou... |
package controller
import (
"github.com/gin-gonic/gin"
"net/http"
"qipai/enum"
"qipai/game"
"qipai/middleware"
"qipai/model"
"qipai/srv"
"qipai/utils"
)
func user(){
r := R.Group("/users")
r.POST("/login", userLoginFunc)
ar := r.Group("")
ar.Use(middleware.JWTAuth())
ar.POST("/notice", postNoticeFunc)
a... |
/*
Crie e utilize uma função anônima.
*/
package main
import (
"fmt"
)
func main() {
slice := []int{100, 200}
func(sliceDeInteiros ...int) {
resultadoSoma := 0
for _, valor := range sliceDeInteiros {
resultadoSoma += valor
}
fmt.Println("A soma dos elementos da slice é:", resultadoSoma)
}(slice...)
... |
package main
func countPrimes(n int) int {
return len(primeGenerator(n - 1)) // 因为题目要求的是 [1,n)的素数个数,所以这里要 -1
}
// 返回[1,n]的质数
// 最容易想到的素数筛 (没有优化)
func primeGenerator(n int) []int {
isNotPrime := make([]bool, n+1)
ans := []int{}
for i := 2; i <= n; i++ {
if isNotPrime[i] == true {
continue
}
ans = append(... |
// Copyright 2020 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package module
import (
"context"
"fmt"
"net/http"
"github.com/clivern/walrus/core/driver"
"github.com/clivern/walrus/core/model"
"github.com/clivern/walrus/core/s... |
// Copyright (c) 2014 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package bdb
import (
"fmt"
"time"
"github.com/btcsuite/btcwallet/walletdb"
)
const (
dbType = "bdb"
)
// parseArgs parses the arguments from the walletdb Open/Create ... |
package main
import (
"time"
"fmt"
)
func server1(ch chan string) {
//time.Sleep(time.Millisecond * 7000)
ch <- "from server 1"
}
func server2(ch chan string) {
//time.Sleep(time.Millisecond * 3000)
ch <- "from server 2"
}
func main(){
time.Sleep(time.Second)
output1 := make(chan ... |
package c29_break_sha1_length_extension
import (
"bytes"
"math/rand"
"testing"
"github.com/vodafon/cryptopals/set4/c28_sha1_key_mac"
)
func TestExploit(t *testing.T) {
inp := []byte("comment1=cooking%20MCs;userdata=foo;comment2=%20like%20a%20pound%20of%20bacon")
key := make([]byte, 10+rand.Intn(40))
rand.Read... |
package main
import "fmt"
func main() {
TestBubbleSort()
}
func TestBubbleSort() {
a := [...]int{9,8,7,4,5,2,1,3}
bubbleSort(a[:])
fmt.Println(a)
}
func bubbleSort(a []int) {
for i := 0; i < len(a); i++ {
//每次冒泡排序固定最右端的数
for j := 1;j < len(a) - i; j++ {
if a[j] < a[j - 1] {
a[j], a[j - 1] = a[j - ... |
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2017
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package bme280
import (
"fmt"
)
////////////////////////////////////////////////////////////////////////... |
package handlers
import (
"fmt"
"net/url"
"regexp"
"strings"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/valyala/fasthttp"
"github.com/authelia/authelia/v4/internal/authentication"
"github.com/authelia/authelia/v4/internal/... |
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obta... |
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/JustinSo1/TVShowFinder/internal"
"github.com/JustinSo1/TVShowFinder/pkg/userinterface"
ui "github.com/gizak/termui/v3"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Missing parameter, provide file name!")
return
}
data, err... |
package chartjs
var List = map[string]string{
"chartjs": `{{define "chartjs"}}
{{if ne .Title ""}}
<p class="text-center">
<strong>{{langHtml .Title}}</strong>
</p>
{{end}}
<div class="chart">
<canvas id="{{.ID}}" style="height: {{.Height}}px;"></canvas>
</div>
... |
package main
func main() {
game := Game{100, 0, ""}
game.playGame()
}
|
// Copyright Jetstack Ltd. See LICENSE for details.
package kubernetes
import (
"testing"
"github.com/golang/mock/gomock"
vault "github.com/hashicorp/vault/api"
)
type tokenCreateRequestMatcher struct {
ID string
name string
}
func (tcrm *tokenCreateRequestMatcher) String() string {
return "matcher"
}
func... |
/*
Doordog helps you watch your doors.
When somebody entries your room, you will be alerted by a beeping buzzer and a blinking led.
*/
package main
import (
"log"
"net/http"
"net/url"
"time"
"github.com/shanghuiyang/face-recognizer/face"
"github.com/shanghuiyang/go-speech/oauth"
"github.com/shanghuiyang/rpi-d... |
package main
import (
"bytes"
"encoding/json"
"strconv"
"github.com/hyperledger/fabric-chaincode-go/shim"
sc "github.com/hyperledger/fabric-protos-go/peer"
)
type SmartContract struct {
}
func (s *SmartContract) Init(stub shim.ChaincodeStubInterface) sc.Response {
return shim.Success(nil)
}
func (s *SmartCont... |
package apierrtest
import (
"bytes"
"encoding/json"
"fmt"
"io"
"github.com/optiopay/x/apierr"
)
// alias that provides pretty printing
type APIValidationErrors []error
func (errs APIValidationErrors) String() string {
var b bytes.Buffer
for _, e := range errs {
fmt.Fprintf(&b, "%+v\n", e)
}
return b.Stri... |
package checker
import (
"fmt"
"strings"
)
const (
commentPrefix = " BBG-TRANSLATION-CHECKER-NOTES\n\t\t\t"
)
type (
File struct {
Filename string
Error error
Translations Translations
rows Translations
replacements Translations
}
Translation struct {
Comment string `xml:",comm... |
package lib
import (
"fmt"
"github.com/yamamoto-febc/jobq"
)
var SakuraCloudDefaultZones = []string{"tk1v", "is1a", "is1b", "tk1a"}
type Option struct {
AccessToken string
AccessTokenSecret string
Zones []string
TraceMode bool
ForceMode bool
JobQueueOption *jobq.Option
}
... |
package main
import "os"
import "flag"
import "time"
import "strings"
import "runtime"
import "net/http"
import "runtime/pprof"
import _ "net/http/pprof"
import "github.com/bnclabs/golog"
import "github.com/bnclabs/gostore/bogn"
import "github.com/bnclabs/gostore/bubt"
import "github.com/bnclabs/gostore/llrb"
var va... |
package request
const AlipaySystemOauthTokenMethod = "alipay.system.oauth.token"
type AlipaySystemOauthTokenRequest struct {
RefreshToken string `json:"refresh_token"`
}
|
package main
import (
"fmt"
"strconv"
"strings"
)
func main() {
cipher := "11211111911310110810910097107108115111112119113101106107971101021101061021041149710511411497"
finalStr := ""
inc := 0
num := 0
if len(cipher) >= 3 {
inc = 3
temp := cipher[0:3]
num1, _ := strconv.Atoi(temp)
num = num1
//fi... |
package textextract
import (
"regexp"
"strings"
)
const (
BLOCKSWIDTH = 3
/* 当待抽取的网页正文中遇到成块的新闻标题未剔除时,只要增大此阈值即可。*/
/* 阈值增大,准确率提升,召回率下降;值变小,噪声会大,但可以保证抽到只有一句话的正文 */
THRESHOLD = 86
)
type ExtractServer struct {
source string
threshold int
}
type blockInfo struct {
indexs []int
maxIndex int
threshold i... |
package backends
import (
"errors"
"fmt"
"log"
"time"
"github.com/dchest/passwordreset"
"github.com/wealthworks/csmtp"
"github.com/liut/staffio/pkg/common"
"github.com/liut/staffio/pkg/models"
"github.com/liut/staffio/pkg/settings"
)
var (
ErrInvalidResetToken = errors.New("invalid reset token or not foun... |
// 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 main
import (
"strings"
"golang.org/x/tour/wc"
//"fmt"
)
func WordCount(s string) map[string]int {
strs := strings.Fields(s)
var wc = make(map[string]int)
for _, str := range strs {
if _, ok := wc[str]; ok {
wc[str]++
} else {
wc[str] = 1
}
}
return wc
}
func main() {
// s := "this is a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.