text stringlengths 11 4.05M |
|---|
package processors
import (
"context"
sdk "github.com/identityOrg/oidcsdk"
"github.com/identityOrg/oidcsdk/impl/sdkerror"
)
type DefaultTokenRevocationProcessor struct {
TokenStore sdk.ITokenStore
AccessTokenStrategy sdk.IAccessTokenStrategy
RefreshTokenStrategy sdk.IRefreshTokenStrategy
}
func NewD... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-06-15 11:00
# @File : _17_Letter_Combinations_of_a_Phone_Number.go
# @Description : 手机键盘功能,排列组合问题,FIFO | MAP 能解决
# @Attention : 排列组合问题,都可以是直接用for循环遍历匹配
*/
package main
func letterCombinations(digits string) []string {
num2letters := map[rune][]string{
'2'... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//565. Array Nesting
//A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] ... |
package widget
import (
"fyne.io/fyne"
"fyne.io/fyne/canvas"
"image/color"
)
type Pomodoro fyne.CanvasObject
func NewPomodoro(size int, color color.Color) Pomodoro {
pomodoro := canvas.NewRectangle(color)
pomodoro.SetMinSize(fyne.Size{Width: 2, Height: size})
return pomodoro
}
|
package main
import (
"archive/zip"
"encoding/json"
"flag"
"github.com/Sirupsen/logrus"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
)
var filesList []string
var log = logrus.New()
// zipDir takes source directory pathname and archive it into target .zip file
func zipDir(source, target string) ... |
package api
import (
"net/http"
"github.com/PhongVX/taskmanagement/internal/pkg/http/middleware"
"github.com/PhongVX/taskmanagement/internal/pkg/http/router"
"github.com/PhongVX/taskmanagement/internal/pkg/log"
"github.com/gorilla/mux"
)
func NewRouter() (http.Handler, error) {
r := mux.NewRouter()
taskHandl... |
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
"sync"
"github.com/PuerkitoBio/goquery"
"github.com/nektro/go-util/types"
"github.com/nektro/go-util/util"
"github.com/nektro/go-util/vflag"
"github.com/schollz/progressbar/v3"
)
var (
sites []string
e... |
package src
type Directives struct {
Compiler *Compiler
Consumer *ParseConsumer
SymTable *SymTable
NewTokens []*Token
}
func ProcessDirectives(compiler *Compiler, tokens []*Token) []*Token {
reporter := NewReporter(compiler.File.Filename, compiler.File.Source)
consumer := NewParseConsumer(tokens, reporter, c... |
package tripapi
import (
)
const drugCache = "alldrugs"
func GetDrug(name string) *Drug {
checkCaches()
// Check if this is actually really cheap
dgs := cache[drugCache]
v, simple := dgs[name]
if simple {
return &v
} else {
for _, v := range cache[drugCache] {
for alias := range v.Aliases {
if v.Ali... |
package main
import (
"log"
"strconv"
"encoding/json"
"time"
"net/http"
"io/ioutil"
"fmt"
"github.com/jinzhu/now"
"os"
// "github.com/agonopol/readability"
"github.com/advancedlogic/GoOse"
"strings"
"runtime"
)
type Story struct {
Created_at time.Time `json:"created_at"`
T... |
package main
func intersect(nums1 []int, nums2 []int) []int {
mymap := make(map[int]int)
res := []int{}
for _,v := range nums1{
if _,ok := mymap[v]; ok{
mymap[v]++
}else{
mymap[v] = 1
}
}
for _,v := range nums2{
if value,ok := mymap[v]; ok && value>0{
res = append(res,v)
mymap[v]--
}
}
r... |
// Copyright (c) 2018 Dean Jackson <deanishe@deanishe.net>
// MIT Licence applies http://opensource.org/licenses/MIT
package env // import "go.deanishe.net/env"
import (
"fmt"
"os"
"strconv"
"time"
)
var (
// System retrieves values from the system environment.
System Env = systemEnv{}
// Default Reader, whic... |
package controllers
import (
"context"
"errors"
"fmt"
"github.com/alioygur/is"
passwordauth "github.com/anshap1719/authentication/controllers/gen/password_auth"
"github.com/anshap1719/authentication/database"
"github.com/anshap1719/authentication/models"
"github.com/anshap1719/authentication/utils/auth"
. "gi... |
// Licensed to SolID under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. SolID licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compli... |
package main
import (
"log"
"os"
"encoding/csv"
"strconv"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
func main() {
errl := log.New(os.Stderr, "ERROR: ", 0)
warnl := log.New(os.Stderr, "WARNING: ", 0)
bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_TOKEN"))
if err != nil {
errl.Panic(err)
}
u ... |
// DO NOT EDIT, generated by goctl
package types
type ExpandReq struct {
Key string `form:"key"`
}
type ExpandResp struct {
Url string `json:"url"`
}
type ShortenReq struct {
Url string `form:"url"`
}
type ShortenResp struct {
ShortUrl string `json:"shortUrl"`
}
|
package fs
import (
"context"
"os"
"path/filepath"
"strings"
"github.com/sirupsen/logrus"
"github.com/yunify/qscamel/constants"
"github.com/yunify/qscamel/model"
"github.com/yunify/qscamel/utils"
)
// List implement source.List
// errors in List may be ignored (depend on isIgnoredErr()), to avoid infinite b... |
package configurator
import (
"encoding/json"
"errors"
)
var (
m = make(map[string]Builder)
ErrNotFound = errors.New("configureurator: not found")
defaultScheme = "localcfg"
)
func Register(b Builder) {
m[b.Scheme()] = b
}
func Get(scheme string) (Builder, bool) {
if b, ok := ... |
package ast
import (
"bufio"
"fmt"
"strings"
blk "github.com/DynamoGraph/block"
slog "github.com/DynamoGraph/syslog"
"github.com/DynamoGraph/types"
//"github.com/DynamoGraph/db"
"github.com/DynamoGraph/ds"
)
const (
logid = "exprFunc"
fatal = true
)
type inEQ uint8
const (
eq inEQ = iota
le
lt
ge
gt... |
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
//
// 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 ... |
package differential
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/url"
"github.com/keelerm84/go-conduit/conduit"
)
type commentsResult struct {
Results map[string][]Comment `json:"result"`
}
type CommentsQuery struct {
Conduit conduit.Connection `json:"__conduit__"`
Ids []string `json:... |
package explain
import (
"os"
"testing"
)
func loadCRD(t *testing.T) []byte {
crd, err := os.ReadFile("../../data/data/install.openshift.io_installconfigs.yaml")
if err != nil {
t.Fatalf("failed to load CRD: %v", err)
}
return crd
}
|
package model
import "net"
//HostProc //proc.ProcAll
type HostProc interface {
Init()
Update()
}
//HostResponse describe hots informations
type HostResponse struct {
Name string `json:"Name,omitempty"`
Interfaces map[string]HostInterfaceResponse `json:"Interfaces,omitempty"`
Proc... |
// Package config parses JSON configuration files and exports the Config struct
// for server-side use and the ClientConfig struct, for JSON stringification and
// passing to the client,
package config
import (
"encoding/json"
"github.com/Soreil/mnemonics"
"github.com/bakape/meguca/util"
"io/ioutil"
"path/filepa... |
package ijvmasm
import (
"fmt"
"github.com/sirupsen/logrus"
"strconv"
"strings"
)
func (asm *Assembler) executeMacro(method *Method, line string) {
if strings.HasPrefix(line, "#print") {
param := strings.TrimSpace(strings.TrimPrefix(line, "#print"))
if param == "" {
asm.Errorf("#print called without argum... |
package main
import (
"fmt"
"io"
)
func getPlay(nth string) (string, error) {
var p string
var err error
for {
fmt.Printf("Enter %s play\n", nth)
_, err = fmt.Scan(&p)
if err == io.EOF {
break
}
if err != nil {
err = fmt.Errorf("play read error: %w", err)
break
}
if p != "r" && p != "p" &... |
package sdk
import (
"context"
"net/http"
rm "github.com/brigadecore/brigade/sdk/v3/internal/restmachinery"
"github.com/brigadecore/brigade/sdk/v3/restmachinery"
)
// SubstrateWorkerCount represents a count of Workers currently executing on
// the substrate.
type SubstrateWorkerCount struct {
// Count is the ca... |
package admin
import (
"github.com/go-xe2/xthrift/builder/test/build/go/com/mnyun/reg/types"
)
type RegSvc interface {
// 修改
UpdateResult(regId int32, parId int32, name string) bool
// 乡镇列表
GetTownList(countyId int32) []*types.RegItem
// 州市列表
GetCityList(provinceId int32) []*types.RegItem
// 地区目录树
GetRegTree... |
package setup
import (
"fmt"
"io/ioutil"
"log"
"os"
"sort"
"strings"
"github.com/FINTLabs/fint-consumer/common/config"
"github.com/FINTLabs/fint-consumer/common/github"
"github.com/FINTLabs/fint-consumer/common/types"
"github.com/FINTLabs/fint-consumer/common/utils"
"github.com/FINTLabs/fint-... |
package xeno
//go:generate mockgen -source=game.go -destination=./game_mock.go -package xeno
import (
"fmt"
"log"
"math/rand"
)
var (
CardTypes = []string{
"", //
"少年(革命)", // 1
"兵士(捜査)", // 2
"占師(透視)", // 3
"乙女(守護)", // 4
"死神(疫病)", // 5
"貴族(対決)", // 6
"賢者(選択)", // 7... |
/*
There is a strange printer with the following two special properties:
The printer can only print a sequence of the same character each time.
At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters.
Given a string s, return the minimum... |
// Copyright 2015 The Chromium 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 isolatedclient
import (
"errors"
"flag"
"net/http/httptest"
"os"
"github.com/luci/luci-go/client/internal/lhttp"
"github.com/luci/luci-go/... |
package param_verify
import (
"github.com/zhuiyi1997/go-gin-api/app/model"
"gopkg.in/go-playground/validator.v9"
_ "log"
"regexp"
"time"
)
// 验证手机号
func CheckPhone(fl validator.FieldLevel) bool {
val := fl.Field().String()
if match, _ := regexp.MatchString(`^1[2-9]\d{9}$`,val);match{
return true;
}
return ... |
package main
import (
"errors"
)
func fatorial(number int) (result int, err error) {
result = 1
if number < 0 {
return 0, errors.New("Number may be higher zero")
}
for number > 1 {
result *= number
number--
}
return
}
func fatorial_rec(number int) (result int, err error) {
result = 1
if number < 0 {
... |
package main
import (
"docker/route"
"net/http"
)
type aa interface {
}
func main() {
route.Route()
http.ListenAndServe("0.0.0.0:1001", nil)
}
|
package goclock_test
import (
"testing"
"time"
clock "github.com/bearchit/goclock"
"github.com/stretchr/testify/assert"
)
func TestClock_Now(t *testing.T) {
a := time.Now().Round(time.Second)
b := clock.New().Now().Round(time.Second)
assert.Equal(t, a, b)
}
func TestMock_Now(t *testing.T) {
c := clock.NewMo... |
package main
import (
"fmt"
// "sort"
)
// 31. 下一个排列
// 实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。
// 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。
// 必须原地修改,只允许使用额外常数空间。
// 以下是一些例子,输入位于左侧列,其相应输出位于右侧列。
// 1,2,3 → 1,3,2
// 3,2,1 → 1,2,3
// 1,1,5 → 1,5,1
// https://leetcode-cn.com/problems/next-permutation/
func main() {
num... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
import (
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/aks-engine/pkg/api/common"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network"
"github.com/Azure/go-autorest/auto... |
package api
import (
model "github.com/EgorKekor/chat_backend/models"
"github.com/valyala/fasthttp"
"net/http"
)
func ReadMessages(ctx *fasthttp.RequestCtx) {
ctx.Response.Header.Set("Access-Control-Allow-Origin", "http://localhost:8080")
ctx.Response.Header.Set("Access-Control-Allow-Credentials", "true")
ctx.R... |
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2018
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package sensors
import (
"fmt"
"time"
// Frameworks
"github.com/djthorpe/gopi"
)
//////////////////////... |
package fracker
import (
"github.com/coreos/go-etcd/etcd"
)
type Client interface {
Get(key string) (Node, error)
}
func NewClient(hosts []string) Client {
return &etcdClient{etcd.NewClient(hosts)}
}
type etcdClient struct {
*etcd.Client
}
func (self *etcdClient) Get(key string) (Node, error) {
var err error
... |
package main
func findSecondMinimumValue(root *TreeNode) int {
return find(root, root.Val)
}
func find(root *TreeNode, val int) int {
if root == nil {
return -1
}
// 此时root.Val就是要求的值,因为另外一个节点的值和根节点相同
if root.Val > val {
return root.Val
}
l := find(root.Left, val)
r := find(root.Right, val)
if l == -1 {
... |
package model
import (
"github.com/gohail/mafiosi/metadata/res"
"github.com/gorilla/websocket"
)
type Player struct {
Conn *websocket.Conn
PlayerId int
Name string
Role string
IsAlive bool
}
func NewPlayer(c *websocket.Conn, id int, name string, role string) *Player {
return &Player{
Conn: ... |
// Go Programming
// Go programs are read top to bottom,left to right
package main // "package declaration".
import "fmt" // fmt package (shorthand for format) implements formatting for input and output
func main() {
language := 8
fmt.Printf("Language %d: I am Go Programming. What's for supper?", language)
}
|
package credential
import (
"fmt"
"strings"
"sync"
"time"
"github.com/appootb/substratum/errors"
"google.golang.org/grpc/codes"
)
type clientSeedInfo struct {
PrivateKey []byte
NotBefore time.Time
NotAfter time.Time
LockMessage string
}
type ClientSeed struct {
sync.Map
}
func (s *ClientSeed) Add(... |
package repositories
import (
"context"
"database/sql"
"errors"
"payment/internal/config"
"payment/internal/database"
erraccount "payment/internal/domains/payment/errors"
"payment/internal/dto"
"payment/internal/models"
logger "payment/pkg/log"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)
//AccountRepo... |
package main
import (
"fmt"
"database/sql"
_ "github.com/lib/pq"
)
const (
host = "localhost"
port = 5432
user = "postgres"
password = "test123"
dbname = "postgres"
)
func main() {
dbinfo := fmt.Sprintf("host=%s port=%d user=%s "+
"password=%s dbname=%s sslmode=disable", ho... |
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2018
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package mihome
import (
"fmt"
"strings"
// Frameworks
gopi "github.com/djthorpe/gopi"
sensors "github.c... |
/*
Copyright 2019 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agree... |
package store
import (
"errors"
"time"
"fmt"
"os"
"strings"
sql "github.com/jmoiron/sqlx"
"github.com/mcculleydj/currency-trader/exchange/pkg/common"
)
var db *sql.DB
// DBConnect provides an interface to Postgres
func DBConnect() (err error) {
uri := fmt.Sprintf(
"postgres://%s:%s@%s:%s/archive?sslmode... |
package services
// Service is a generalized definition for a web application service
type Service interface {
// TODO
}
|
package friend
import (
"github.com/stretchr/testify/assert"
"spapp/src/commands/user"
helper "spapp/src/common/helpers"
friendmodels "spapp/src/models/apimodels/friend"
usermodels "spapp/src/models/apimodels/user"
"strconv"
"testing"
"fmt"
)
func Test_BlockUser_Ok_1(t *testing.T){
// Config
initConfig()
... |
package easypost
// CarbonOffset objects contain carbon offset details for a rate.
type CarbonOffset struct {
Object string `json:"object,omitempty"`
Currency string `json:"currency,omitempty"`
Grams int64 `json:"grams,omitempty"`
Price string `json:"price,omitempty"`
}
|
//
// Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org>
//
// 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 requir... |
// 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... |
package kuu
import (
"encoding/json"
"io/ioutil"
"os"
)
var (
pairs map[string]interface{}
inst *Config
)
func parseKuuJSON() {
filePath := os.Getenv("CONFIG_FILE")
if IsBlank(filePath) {
filePath = "kuu.json"
}
pairs = make(map[string]interface{})
if _, err := os.Stat(filePath); os.IsNotExist(err) {
... |
package tests
import (
"fmt"
"testing"
"app/src/models"
)
func init() {
fmt.Println("Configuring test enviroment!")
models.DatabaseHost = "localhost:27017"
}
func TestAddCompany(t *testing.T) {
testCompany := models.Company{}
testCompany.Name = "Company teste"
testCompany.AddressZip = "12345"
testCompany.... |
package main
import (
"log"
"net/http"
"insta_graph/handler"
"github.com/joho/godotenv"
)
func init() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, err := r.Cookie("authtoken")
if ... |
package engine
import (
"net"
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
func TestAdding(t *testing.T) {
srcIP, dstIP := net.ParseIP("192.168.86.158"), net.ParseIP("192.168.86.191")
// Let's move quickly in the tests.
const evaluationTime = time.Millisecond
tes... |
package fileutils
import (
"os"
)
// Exists check if a given file exists
func Exists(filepath string) (bool, error) {
var err error
ok := true
if f, openError := os.Open(filepath); openError != nil {
_ = f.Close()
// Return an error only if it is not a "not exist" error
if os.IsNotExist(openError) {
ok ... |
package main
import (
"fmt"
"sync"
"os"
"crypto/sha256"
"io"
"time"
"log"
)
type hasherWorkerResult struct {
Hash string
Info fileInfo
}
type ReadOperationType uint8
const (
READ_FIRST ReadOperationType = iota
READ_LAST = iota + 1
READ_WHOLE = iota + 1
)
type hasher... |
package auth
import (
"github.com/chfanghr/hydric/core/auth/models"
"github.com/chfanghr/hydric/core/shared"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"net/http"
"strconv"
)
func (s *Service) MakeIsAuthMiddleware() func(ctx *gin.Context) {
return func(c *gin.Context) {
uidRaw := c.GetHeader("X-User... |
// 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 (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/totalsynthesis/autoromance/lib/userservice"
)
// extract_messaging_client prepares the context with the messaging client from the user,
// so that component/message has access.
func extract_messaging_client(c *... |
//go:build integration
// +build integration
// nolint:errcheck
package main
import (
"github.com/signaux-faibles/libwekan"
"github.com/stretchr/testify/assert"
"testing"
)
func TestWekan_ManageBoardsMembers_withoutBoard(t *testing.T) {
// WHEN
wekan := restoreMongoDumpInDatabase(mongodb, "", t, "")
ass := as... |
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"
"github.com/mcandre/stank"
)
var flagSh = flag.Bool("sh", false, "Limit results to specifically bare POSIX sh scripts")
var flagAlt = flag.Bool("alt", false, "Limit results to specifically alternative, non-POSIX lowlevel shell scrip... |
package gojson
import "strings"
func empty(s string) bool {
return len(s) == 0
}
func startsWithUpper(s string) bool {
if len(s) == 0 {
return false
}
char := s[0:1]
return char == strings.ToUpper(char)
}
func contains(elems []string, search string) bool {
if (elems == nil) || (len(elems) == 0) {
return f... |
package leetcode
import "sort"
type SortRunes []rune
func (s SortRunes) Less(i, j int) bool {
return s[i] < s[j]
}
func (s SortRunes) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s SortRunes) Len() int {
return len(s)
}
func numSpecialEquivGroups(A []string) int {
m := make(map[string]struct{})
for _, s ... |
package selectionsort
// Sort an array of numbers
func Sort(numbers []int) []int {
for i := 0; i < len(numbers); i++ {
sweep(numbers, i)
}
return numbers
}
func sweep(numbers []int, currentIndex int) {
smallestIndex := currentIndex
for i := currentIndex + 1; i < len(numbers); i++ {
if numbers[i] < numbers[... |
package main
import (
"fmt"
"github.com/Cloud-Foundations/Dominator/lib/log"
"github.com/Cloud-Foundations/Dominator/lib/srpc"
"github.com/Cloud-Foundations/Dominator/proto/dominator"
)
func configureSubsSubcommand(args []string, logger log.DebugLogger) error {
if err := configureSubs(getClient()); err != nil {... |
package stringindex
import (
"math"
"sort"
"strings"
)
const (
substringPenaltyScale = 3
)
// Match stores the confidence that a result with the id is a match.
type Match struct {
ID int
Confidence float64
}
// Index is a simple search index.
// It does not store values, only the value's ID provided b... |
package resolver
import (
"cloudfreexiao/ant-graphql/backend-go/graphql/model"
)
type addrResolver struct {
addr *model.Address
}
func (r *addrResolver) IP() *string {
return &r.addr.IP
}
func (r *addrResolver) Mask() *string {
return &r.addr.Mask
}
|
package heap
import (
"bytes"
"fmt"
)
func New(n int, isTopMin bool) *Heap {
data := make([]int, n+1)
return &Heap{data, 0, n, isTopMin}
}
func NewWithData(data []int, isTopMin bool) *Heap {
n := len(data)
h := &Heap{data, n - 1, n - 1, isTopMin}
for i := n / 2; i > 0; i-- {
h.heapify(i)
}
return h
}
typ... |
package main
import (
"flag"
"fmt"
"log"
"net"
"net/rpc"
"time"
"github.com/c12o16h1/shender/pkg/models"
)
const (
WORKER_LIFE_TIME = 30 * time.Second
ERR_INVALID_PORT = models.Error("Invalid port")
)
func main() {
port := flag.Int("port", 0, "this binary port")
flag.Parse()
if *port == 0 {
log.Fatal... |
package problem0496
func nextGreaterElement(nums1 []int, nums2 []int) []int {
stack := []int{}
dict := map[int]int{}
for _, num2 := range nums2 {
for len(stack) > 0 && stack[len(stack)-1] < num2 {
dict[stack[len(stack)-1]] = num2
stack = stack[:len(stack)-1]
}
stack = append(stack, num2)
}
result := [... |
package controllers
import (
"businessense/models"
u "businessense/utils"
"fmt"
"net/http"
"strconv"
"github.com/gorilla/mux"
)
//GetSolutionsForIssue HandlerFunc
var GetSolutionsForIssue = func(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
id, _ := strconv.Atoi(params["id"])
fmt.Println("... |
package osbuild2
import (
"encoding/json"
"testing"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/stretchr/testify/assert"
)
func TestNewGrub2InstStage(t *testing.T) {
options := Grub2InstStageOptions{
Filename: "img.raw",
Platform: "i386-pc",
Location: 2048,
Core: CoreMkImage{
Ty... |
package tpl
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"path"
"text/template"
"github.com/pilgreen/loopit/tpl/strings"
"github.com/pilgreen/loopit/tpl/collections"
"github.com/pilgreen/loopit/tpl/partial"
"github.com/pilgreen/loopit/tpl/scratch"
)
/**
* Simple error checker
*/
func check(e ... |
package main
//heads up, go does not have a while loop
import (
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
)
//basic for loop
// for loop without any parameter runs like while (true) or while (1) , that is forever
//check git commits to see wassup
type SitemapIndex1 struct {
Locations []Location1 `xml:"sitema... |
package main
import "fmt"
func main(){
add := func(x int,y int) int{
return x+y
}
fmt.Println(add(1,1))
}
|
package main
import "fmt"
const spanish = "Spanish"
const french = "French"
const englishPrefixHello = "Hello, "
const spanishPrefixHello = "Hola, "
const frenchPrefixHello = "Bonjour, "
func Hello(name string, langage string) string {
if name == "" {
name = "World"
}
return greetingPrefix(langage) + name
}
... |
package model
// ReadChannel will emit the records that are read from topics
type ReadChannel struct {
Messages chan<- Record
}
|
package mssql
import _ "github.com/denisenkom/go-mssqldb" // Import the mssql driver.
|
package health_test
import (
"crypto/md5"
"errors"
"fmt"
"strings"
"testing"
"github.com/jsteenb2/health/internal/health"
)
func TestService(t *testing.T) {
validateID := func(t *testing.T, endpoint string, got string) {
t.Helper()
// validates that IDs' area created in this fashion
// test driven here... |
package spider
import (
"context"
"io"
"net/http"
"net/url"
"sync"
"time"
"go.uber.org/zap"
"github.com/Willyham/gospider/spider/internal/concurrency"
"github.com/Willyham/gospider/spider/internal/parser"
"github.com/Willyham/gospider/spider/reporter"
"github.com/temoto/robotstxt"
)
const (
workerPollIn... |
package loader
import (
"io/ioutil"
"os"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/util"
"github.com/devspace-cloud/devspace/pkg/devspace/deploy/deployer/kubectl/walk"
"github.com/pkg/errors"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest"
yaml "gopkg.in/yaml.v2... |
// +build integration
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
)
const testDataDir = "testdata"
func TestMain(m *testing.M) {
if err := exec.Command("go", "build").Run(); err != nil {
fmt.Printf("failed to build tool: %+v\n", err)
os.Exit(1)
}
os.Exit(m.... |
// +build linux
package fsutil
import (
"encoding/hex"
"hash"
"io"
"os"
"path/filepath"
"strconv"
"sync"
"syscall"
"time"
"github.com/pkg/errors"
"github.com/stevvooe/continuity/sysx"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
)
type writeToFunc func(context.Context, string, io.WriteCloser) err... |
package beacon
import (
"bytes"
"context"
"crypto/sha512"
"errors"
"fmt"
"math"
"strings"
"sync"
"time"
"github.com/benbjohnson/clock"
"github.com/drand/drand/log"
proto "github.com/drand/drand/protobuf/drand"
"github.com/drand/kyber/share"
"github.com/drand/kyber/sign"
"google.golang.org/grpc/peer"
... |
package yolosvc
import (
"context"
"berty.tech/yolo/v2/go/pkg/yolopb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (svc *service) DevDumpObjects(ctx context.Context, req *yolopb.DevDumpObjects_Request) (*yolopb.DevDumpObjects_Response, error) {
if req == nil {
req = &yolopb.DevDumpObj... |
package 链表
func removeElements(head *ListNode, val int) *ListNode {
return deleteNode(head,val)
}
func deleteNode(head *ListNode, val int) *ListNode {
dummyHead := &ListNode{Next: head}
cur := dummyHead
for cur.Next != nil {
if cur.Next.Val == val {
cur.Next = cur.Next.Next
} else {
cur = cur.Next
}... |
package mssql
import (
"fmt"
"github.com/jinzhu/gorm"
)
var (
GetDbConnection databaseConnectionInterface = &databaseCon{}
)
type databaseConnectionInterface interface {
GetDbConnection() *gorm.DB
}
type databaseCon struct {
}
func (dbCon *databaseCon) GetDbConnection() *gorm.DB {
db, err := gorm.Open("mssq... |
package main
import (
"fmt"
"time"
)
func Numbers(chnlNums chan int) {
for i := 0; i < 50; i++ {
chnlNums <- i
}
time.Sleep(10 * time.Second)
chnlNums <- 9999
close(chnlNums)
}
func main() {
chnlNums := make(chan int)
go Numbers(chnlNums)
for val := range chnlNums {
fmt.Println("Recieved from channel... |
package rna
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
// DiffConfig is a model of config file for Diff function.
type DiffConfig struct {
ConfigFile string
ProjectPath string `json:"projectPath"`
Groups []Group `json:"groups"`
Comparisons []Comparison `j... |
package blocks
type Header struct {
Version int64
PrevBlockId string
PayloadDigest string
Transactions string
}
|
package main
import (
"flag"
"os"
log "github.com/sirupsen/logrus"
"cozysystems.net/projects/CloudNative/repos/docker-gateway-project/config"
"cozysystems.net/projects/CloudNative/repos/docker-gateway-project/client"
"cozysystems.net/projects/CloudNative/repos/docker-gateway-project/process"
"io/ioutil"
"githu... |
package controllers
import (
"lili_style_test/src/models"
"lili_style_test/src/utils"
)
func GetCommitData(userdata []string) models.Commit {
answer := userdata[60:70]
// はいで加点を整形
yesAdd := answer[3:5]
yesAdd = append(yesAdd,answer[0])
// いいえで加点を整形
noAdd1 := answer[1:3]
noAdd2 := answer[5:10]
noAdd := appen... |
package main
import (
"fmt"
"strconv"
)
func getMaskedFloatingAddress(mask string, intValue int) string {
base2 := strconv.FormatInt(int64(intValue), 2)
paddedBase2Value := fmt.Sprintf("%036s", base2)
result := []rune(paddedBase2Value)
for i := 0; i < len(mask); i++ {
char := string(mask[i])
switch string(... |
package main
import (
"encoding/json"
"flag"
"log"
"net/http"
)
var portFlag = flag.String("p", ":4673", "Service port")
func main() {
flag.Parse()
http.HandleFunc("/", home)
log.Fatal(http.ListenAndServe(*portFlag, nil))
}
func home(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", ... |
package actions
import (
"context"
"time"
"github.com/pkg/errors"
"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
"github.com/batchcorp/plumber/backends"
"github.com/batchcorp/plumber/options"
"github.com/batchcorp/plumber/prometheus"
"github.com/batchcorp/plumber/server/types"
"github.com/batc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.