text stringlengths 11 4.05M |
|---|
package models
type Responce struct {
JsonRPC string `json: "jsonrpc"`
ID string `json: "id"`
Result map[string]interface{} `json: "result"`
}
|
package virtualmachinevolume
import (
"context"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
hc "kubevirt-image-service/pkg/apis/hypercloud/v1alpha1"
"kubevirt-image-service/pkg/util"
)
// # pvc pvc phase volume condition volume s... |
package config
type Config struct {
Version int
Buttons []struct {
Label string
Id string
}
}
|
/*
* Copyright 2021 American Express
*
* 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... |
// Copyright 2018 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 w... |
package birdwatcher
// Http Birdwatcher Client
import (
"encoding/json"
"io/ioutil"
"net/http"
)
type ClientResponse map[string]interface{}
type Client struct {
Api string
}
func NewClient(api string) *Client {
client := &Client{
Api: api,
}
return client
}
// Make API request, parse response and return ... |
package pools
import (
"context"
"fmt"
"github.com/exoscale/egoscale"
"github.com/janoszen/exoscale-account-wiper/plugin"
"log"
"sync"
"time"
)
type Plugin struct {
}
func (p *Plugin) GetKey() string {
return "pools"
}
func (p *Plugin) GetParameters() map[string]string {
return make(map[string]string)
}
f... |
/*
Copyright 2021 The KodeRover 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, s... |
package trains
import (
"strconv"
"time"
)
//Train 对应trains表
type Train struct {
ID string
}
//TrainStaion 对应train_station表,车次经过的某个站点
type TrainStaion struct {
StationNo uint `gorm:"column:station_no"`
StationName string `gorm:"column:station_name"`
ArriveTime string `gorm:"column:arr... |
// Package postgres implements the Driver interface.
package postgres
import (
"database/sql"
"fmt"
"strconv"
"strings"
"github.com/db-journey/migrate/v2/direction"
"github.com/db-journey/migrate/v2/driver"
"github.com/db-journey/migrate/v2/file"
"github.com/lib/pq"
)
var fileTemplate = []byte(``) // TODO
/... |
// Copyright © 2019 Michael. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package fetch
import (
"container/list"
"fmt"
"sort"
"strconv"
"strings"
"sync"
"sync/atomic"
"skygo/runbook"
"skygo/runbook/xsync"
"skygo/utils/log"
)
... |
package jobs
import (
"crypto/md5"
"fmt"
"github.com/m7shapan/my-http/models"
"github.com/m7shapan/my-http/repositories"
)
type hashingJob struct {
responseRepository repositories.ResponseRepository
url string
}
func NewHashingJob(r repositories.ResponseRepository, url string) *hashingJob {
re... |
package main
import "fmt"
func main() {
s := []int{4, 3, 6, -7, 2, 8}
for i := 0; i < len(s)/2; i++ {
help := s[i]
s[i] = s[len(s)-i-1]
s[len(s)-i-1] = help
}
fmt.Print(s)
}
|
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package repository
import (
"context"
"fmt"
"time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
... |
package main
import ( "reflect" "testing")
func Test_Graph(t *testing.T) {
a := &Node{Name: "Kruthika's abode"}
b := &Node{Name: "Brian's apartment"}
c := &Node{Name: "Greg's casa"}
d := &Node{Name: "Wesley's condo"}
g := Graph{}
g.AddEdge(a, b, 1)
g.AddEdge(a, c, 2)
g.AddEdge(b, d, 9)
g.AddEdge(c, b, 10)
... |
package main
import (
"fmt"
)
func main() {
n:=0
ans:=0
fmt.Scan(&n)
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {
x:=0
fmt.Scan(&x)
ans = ans + x
}
}
fmt.Printf("%d\n",ans)
} |
package main
import "fmt"
func main() {
x := []int{2, 3, 4, 5}
fmt.Println(x[1]) // 3
fmt.Println(x[1:]) // [3 4 5]
fmt.Println(x[1:3]) // [3 4]
for i := 0; i < len(x); i++ {
fmt.Println(x[i])
}
}
|
package echologrus
import (
"io"
"time"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/labstack/gommon/log"
"github.com/sirupsen/logrus"
)
// Logger : implement logrus Logger
type Logger struct {
*logrus.Logger
Skipper middleware.Skipper
}
// Level delegate echo.Logger
func (l ... |
package balance
import (
"encoding/hex"
"fmt"
"github.com/alethio/web3-multicall-go/multicall"
"github.com/avast/retry-go"
"golang.org/x/sync/errgroup"
)
type multicallLoader struct {
mc *multicall.Multicall
}
func (loader multicallLoader) fetchRequests(b *Bookkeeper, requests []*Request, results chan *RawResp... |
package addbinary
func addBinary(a string, b string) string {
la := len(a)
lb := len(b)
lmax := max(la, lb)
result := make([]byte, lmax+1) // big enough to hold a flowed answer
carry := off
sum := off
// iterate backwards over the input strings and the result byte slice concurrently
for pos, posA, posB := l... |
package main
import (
"errors"
"fmt"
"net/http"
log "github.com/cihub/seelog"
"github.com/getsentry/raven-go"
"github.com/gin-gonic/gin"
)
func httpServer() {
//gin.SetMode(gin.ReleaseMode)
router := gin.New()
if cfg.DevMode {
log.Info("Use Gin Logger")
router.Use(gin.Logger())
}
if cfg.Sentry != "" &... |
package clients
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
"regexp"
"strings"
"sync"
"videocrawler/common/comm"
"videocrawler/common/util"
"videocrawler/env"
)
type Entry struct {
jar *cookiejar.Jar
domain string
ready chan struct{}
}
type Jars struct {
JarTable map[stri... |
package generator
func GenerateGinFunc() {
} |
package main
import (
"bufio"
"encoding/json"
"io"
//"io/ioutil"
"log"
"net"
"net/http"
"os"
"rihuo-up/util"
"runtime"
"strings"
"time"
//"sync"
)
const (
START = 0
LOGIN_INFO_END = 20 //用户登录信息总行数
URLS_END = 4 ... |
package main
import "fmt"
func main() {
s1 := "abcd"
b1 := []byte(s1)
fmt.Println(b1) // [97 98 99 100]
s2 := "中文"
b2 := []byte(s2)
fmt.Println(b2) // [228 184 173 230 150 135], unicode,每个中文字符会由三个byte组成
r1 := []rune(s1)
fmt.Println(r1) // [97 98 99 100], 每个字一个数值
r2 := []rune(s2)
fmt.Println(r2) // [2001... |
package main
import (
"fmt"
"net"
"net/http"
"os"
"time"
libhoney "github.com/honeycombio/libhoney-go"
"github.com/honeycombio/libhoney-go/transmission"
statsd "gopkg.in/alexcesaro/statsd.v2"
"github.com/facebookgo/inject"
"github.com/facebookgo/startstop"
flag "github.com/jessevdk/go-flags"
"github.com/... |
package main
import "fmt"
var (
a = []int{1, 3, 5, 7, 9}
b = []int{2, 4, 6, 8, 10}
c = []int{}
)
func main() {
realMain(a, b, &c)
fmt.Println(c)
}
func realMain(a, b []int, c *[]int) {
// TODO: код писать здесь
}
|
// This file is part of CycloneDX GoMod
//
// 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 agr... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package video
import (
"bytes"
"context"
"encoding/base64"
"image"
"image/color"
"net/http"
"net/http/httptest"
"os"
"path"
"strings"
"chromiumos/tast/common/med... |
package main
import (
"net/url"
)
type ClusterState struct {
ClusterName string `json:"cluster_name"`
MasterNode string `json:"master_node"`
Nodes map[string]struct {
Name string `json:"name"`
TransportAddress string `json:"transport_address"`
Attributes NodeAttributes `j... |
// Copyright (C) 2018 Satoshi Konno. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
uechosearch is a search utility for Echonet Lite.
NAME
uechosearch
SYNOPSIS
uechosearch [OPTIONS]
DESCRIPTION
uechosearch is a search utility for... |
package models
import (
"io/ioutil"
"os"
"strconv"
"strings"
"testing"
"time"
log "github.com/sirupsen/logrus"
. "github.com/smartystreets/goconvey/convey"
)
func TestRateSchedule(t *testing.T) {
log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)
SetDefaultFailureMode(FailureContinues)
defer SetDefa... |
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// GetConnectionDetailsReader is a Reader for the GetConnectionDetails st... |
package models
import(
"encoding/json"
)
/**
* Type definition for Type16Enum enum
*/
type Type16Enum int
/**
* Value collection for Type16Enum enum
*/
const (
Type16_KSTORAGEARRAY Type16Enum = 1 + iota
Type16_KVOLUME
)
func (r Type16Enum) MarshalJSON() ([]byte, error) {
s :... |
/*
* @lc app=leetcode.cn id=102 lang=golang
*
* [102] 二叉树的层序遍历
*/
package leetcode
// @lc code=start
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
type TreeNode struct {
Val int
Left *TreeNode
R... |
package main
import (
zmq "github.com/pebbe/zmq4"
"log"
"time"
"os"
)
type MessageHandler func(msg Message) Message
var (
context *zmq.Context
handlers map[string] MessageHandler = make(map[string] MessageHandler)
clients map[string] *client = make(map[string] *client)
pub chan []byte = make(chan [... |
package Gas_Station
func canCompleteCircuit(gas []int, cost []int) int {
start, remain, debt := 0, 0, 0
for k, v := range gas {
remain += v - cost[k]
if remain < 0 {
start = k+1
debt += remain
remain = 0
}
}
if remain+debt < 0 {
return -1
}
return start
}
|
package confsvr
import (
"github.com/oceanho/gw"
"github.com/oceanho/gw/contrib/apps/confsvr/api"
"gorm.io/gorm"
)
type App struct {
}
func New() App {
return App{}
}
func (a App) Name() string {
return "gw.confsvr"
}
func (a App) Router() string {
return "confsvr"
}
func (a App) Register(router *gw.RouterG... |
// Tomato static website generator
// Copyright Quentin Ribac, 2018
// Free software license can be found in the LICENSE file.
package main
import (
"fmt"
)
// Author is the type for an author of the website.
type Author struct {
Name string `json: "name"`
Email string `json: "email"`
}
// Helper prints a html ... |
package odoo
import (
"fmt"
)
// SaleOrderLine represents sale.order.line model.
type SaleOrderLine struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AmtInvoiced *Float `xmlrpc:"amt_invoiced,omptempty"`
AmtToInvoice *Float `xmlrpc:"amt_to_invoice,omptempty"... |
package summary_ranges
import (
"fmt"
)
type Range struct {
from *int
cur *int
to *int
}
func (r Range) String() string {
if r.to == nil {
return fmt.Sprintf("%d", *r.from)
}
return fmt.Sprintf("%d->%d", *r.from, *r.to)
}
func summaryRanges(nums []int) []string {
if len(nums) == 0 {
return []string{... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"github.com/golang/glog"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"github.com/openshift/machine-config-operator/pkg/operator"
"github.com/openshift/machine-conf... |
package repository
import (
"context"
"errors"
"github.com/CyganFx/snippetBox-microservice/user_details/pkg/domain"
"github.com/jackc/pgconn"
"github.com/jackc/pgx/v4/pgxpool"
"golang.org/x/crypto/bcrypt"
"strings"
"time"
)
type UserRepository struct {
Pool *pgxpool.Pool
}
func NewUserRepository(Pool *pgxpo... |
package code
import "errors"
// ErrUnusableCode unusable code error.
var ErrUnusableCode = errors.New("unusable code")
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package aws
import (
"context"
"fmt"
"os"
"strings"
"sync"
"testing"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ec2"
ec2Types "github.com/aws/aws-sdk-go-v2/service... |
package sendwithus
import (
"context"
"encoding/json"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestSend(t *testing.T) {
client, err := NewClient(os.Getenv("SENDWITHUS_TEST_API_KEY"), nil)
require.NoError(t, err)
sendPayload := SendPayload{}
sendPayload.Template = os.Getenv("SENDWITHUS_TE... |
/*
// Copyright (c) 2016 Intel Corporation
//
// 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... |
/*
* Wager service APIs
*
* APIs for a wager system
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package wager
type Wager struct {
Id int64 `json:"id"`
TotalWagerValue int32 `json:"total_wager_value"`
Odds int32 `json:"odds"`
SellingPercentage int32 `json... |
// Copyright © 2020 Weald Technology Trading
// 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 a... |
package models
import "time"
type TextMessageModel struct {
ID uint `gorm:"primaryKey" json:"id"`
Title string `json:"title"`
Details string `json:"details" gorm:"type:longtext"`
Type int `gorm:"default:1" json:"type"` // 1=sms; 2=email;
Status int `gorm:"default:1"`
... |
package cert
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"golang.org/x/crypto/argon2"
)
// KDF factors
type Argon2Parameters struct {
version rune
Memory uint32 // KiB
Parallelism uint8
Iterations uint32
salt []byte
}
// Returns a new Argon2Parameters object with curre... |
package main
import (
"fmt"
"io"
"log"
"net"
"github.com/johnantonusmaximus/grpc-golang/bidirectional_stream/bidirectionalpb"
"google.golang.org/grpc"
)
type server struct{}
func (s *server) GreetEveryone(stream bidirectionalpb.GreetService_GreetEveryoneServer) error {
fmt.Printf("GreetEveryone function was ... |
package HttpSender
import (
"bytes"
"io"
"io/ioutil"
"net/http"
)
func check(e error) {
if e != nil {
panic(e)
}
}
// postFromReader takes an io.Reader and issues a POST to a destination server
func postFromReader(URL string, buffer io.Reader, mime string) (string, error) {
r, err := http.Post(URL, mime, bu... |
package leetcode
/*
* @lc app=leetcode id=88 lang=golang
*
* [88] Merge Sorted Array
*/
// @lc code=start
func merge(nums1 []int, m int, nums2 []int, n int) {
im := m - 1
in := n - 1
for i := m + n - 1; i > im; i-- {
if in < 0 {
nums1[i] = nums1[im]
im--
} else if im < 0 {
nums1[i] = nums2[in]
... |
//go:build windows
// +build windows
package wguser
import (
"errors"
"fmt"
"net"
"os"
"testing"
"time"
"golang.org/x/sys/windows/registry"
"golang.zx2c4.com/wireguard/ipc/namedpipe"
)
// isWINE determines if this test is running in WINE.
var isWINE = func() bool {
// Reference: https://forum.winehq.org/vi... |
package webserver
import (
"net/http"
boardModel "github.com/joostvdg/cmg/pkg/model"
"github.com/joostvdg/cmg/pkg/webserver/model"
"github.com/labstack/echo/v4"
)
// GetMapLegend retrieves the map Legend, helps explain codes used within the data returned by the API
func GetMapLegend(c echo.Context) error {
call... |
package wunsch
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCanAlign(t *testing.T) {
assert.Equal(t, int('-'), 45)
assert.Equal(t, CanAlignString("ABCDEF", "ABCDEF"), true)
assert.Equal(t, CanAlignString("ABCDEF", "ABCDEF"), true)
assert.Equal(t, true, CanAlignString("ab--e", "-bcde"))
as... |
/*
Copyright 2021 The Skaffold 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, sof... |
package greedy
/*
Greedy Algorithm : Solution is constructed through a sequence of steps. At each step, choice is made
which is locally optimal. Greedy algorithms are generally used to solve optimization problems. We
always take the next data to be processed depending upon the dataset which we have already processed
a... |
package config
// RedisConfig redis 配置
type RedisConfig interface {
GetEnabled() bool
GetConn() string
GetPassword() string
GetDBNum() int
}
type defaultRedisConfig struct {
Enabled bool `json:"enabled"`
Conn string `json:"conn"`
Password string `json:"password"`
DBNum int `json:"dbNum"`
Timeout... |
package models
import (
"time"
)
// GamePlayer is 게임플레이어 정보
type GamePlayer struct {
State int `json:"state"`
ChairIndex int `json:"chairIndex"`
RoomIndex int `json:"roomIndex"`
Round int `json:"round"`
Card1 int `json:"card1"`
Card2 ... |
package validations
import (
"fmt"
"github.com/lestrrat/go-jsschema"
)
type FormatValidation struct {
Format string
}
func NewFormatValidation(s *schema.Schema) (FormatValidation, error) {
f := string(s.Format)
if f == "" {
return FormatValidation{}, fmt.Errorf("not initialized")
}
return FormatValidation{... |
package model
import (
"errors"
)
var ErrNullField = errors.New("Field value is null")
type User struct {
ID *uint32 `json:"id"`
Email *string `json:"email"`
FirstName *string `json:"first_name"`
LastName *string `json:"last_name"`
Gender *string `json:"gender"`
BirthDate *int64 `json:"birth_d... |
package http
import (
"github.com/go-kratos/kratos/pkg/conf/paladin"
"github.com/go-kratos/kratos/pkg/log"
bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
"github.com/go-kratos/kratos/pkg/net/http/blademaster/binding"
"github.com/go-kratos/kratos/pkg/net/rpc/warden"
"net/http"
"sync"
utilerr "way-jas... |
package drivers
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNormalizeDSN(t *testing.T) {
const (
myDSN = "root@tcp(0.0.0.0:3306)/test?parseTime=true"
pgDSN = "postgres://root:password@0.0.0.0:5432/test"
msDSN = "sqlserver://sa:password@0.0.0.0:5432?database=test"
)
var dir = t.TempD... |
//
// Copyright (c) SAS Institute 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 agre... |
// Copyright 2020 Ye Zi Jie. 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 sweep
import (
"strconv"
)
// Int2 represents a 2 byte integer.
type Int2 [2]byte
// Int4 represents a 4 byte integer.
type Int4 [4]byte
// Int6 represents a 6 byte integer.
type Int6 [6]byte
// NewInt2 returns a new 2 byte integer with the given integer.
func NewInt2(n int) Int2 {
if n < 0 || n > 99 {
... |
// purpose
// to divide and conquer a summing task
package sub2
import (
"fmt"
)
func sum(s []int, c chan int) {
sum := 0
for _, item := range s {
sum += item
}
c <- sum
}
func main() {
p := fmt.Println
s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
c := make(chan int) // make is used for maps, slices and c... |
package api
import (
"boilerplate/pkg/config"
"net/http"
)
type healthCheckResponse struct {
Commit string `json:"commit"`
Healthy bool `json:"healthy"`
}
func healthHandler(w http.ResponseWriter, r *http.Request) {
health := healthCheckResponse{
Commit: config.Commit,
Healthy: true,
}
resultResponse... |
package publisher
import (
"log"
"github.com/thisiserico/golabox/eventbus"
)
type Publisher struct {
bus chan eventbus.Event
}
func NewPublisher(ch chan eventbus.Event) *Publisher {
return &Publisher{
bus: ch,
}
}
func (p *Publisher) Publish(ev eventbus.Event) {
log.Printf("publishing event %s:%s\n", ev.Ev... |
package http
import (
"errors"
error3 "github.com/payfazz/fazzkit/fazzkiterror"
"net/http"
"testing"
)
var error1 = errors.New(`invalid_code`)
var error2 = errors.New(`invalid_code_me`)
func Test_ErrorMapper(t *testing.T) {
translator := NewErrorMapper()
translator.RegisterError(error1, http.StatusUnprocessab... |
package main
import "fmt"
type State interface {
Start()
}
type CommonState struct {
}
func (s *CommonState) Start() {
fmt.Println("common start")
}
type InitState struct {
}
func (s *InitState) Start() {
fmt.Println("init start")
}
func start(state State) {
state.Start()
}
func main() {
i := InitState{}
... |
/*
* Npcf_SMPolicyControl API
*
* Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 1.0.4
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
type AccuUsageReport str... |
package lang
import (
"bitbucket.org/pkg/inflect"
"regexp"
"strings"
)
var Articles = []string{"the", "a", "an", "our", "some"}
var articleBar = strings.Join(Articles, "|")
var articles = regexp.MustCompile(`^((?i)` + articleBar + `)\s`)
const NewLine = "\n"
const Space = " "
func SliceArticle(str string) (artic... |
package main
import (
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var (
// Debugが出力されるLogger
DebugLogger *zap.SugaredLogger
// 通常のLogger
DefaultLogger *zap.SugaredLogger
)
func initLoggers() func() {
consoleEnc := zap.NewDevelopmentEncoderConfig()
core1 := zapcore.NewCore(zapcore.NewConsoleEncoder(c... |
package discover
import (
"math/rand"
"sync"
"time"
"github.com/iotaledger/hive.go/autopeering/peer"
"github.com/iotaledger/hive.go/autopeering/server"
"github.com/iotaledger/hive.go/crypto/identity"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/runtime/timeutil"
)
const (
// PingExp... |
package student
//SplitWhiteSpaces a function that separates the words of a string and puts them in a string array.
func SplitWhiteSpaces(str string) []string {
for str[0] == 9 || str[0] == 32 || str[0] == 10 {
str = str[1:]
}
for str[lenStr2(str)-1] == 9 || str[lenStr2(str)-1] == 32 || str[lenStr2(str)-1] == 10 ... |
package event
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
)
type ApiEventBus interface {
Subscribe(gvr schema.GroupVersionResource, name types.NamespacedName, clusterNames ...string) error
Unsubscribe(gvr schema.GroupVersionResource, name types.NamespacedName, clusterName ..... |
package logstream
import "io"
type LogStream interface {
Publish(channel string, stream io.ReadCloser)
HeartBeat(name string, quit chan int)
}
|
package converter
import (
"strings"
)
// FirehoseConverter KinesisStream AggregatedRecordDatas to FirehosePutDataMap converter
type FirehoseConverter struct {
DeliveryStream string
DefaultStream string
TargetColumn string
RemovePrefix string
AddPrefix string
ReplacePatterns [][2]string
}
// Co... |
// +build ignore
package main
import (
"fmt"
)
func main() {
fmt.Print("火星の表面で、私の体重は")
fmt.Print(149.0 * 0.3783)
fmt.Print("ボンド、年齢は?")
}
|
/*
*
* ____ ______
* / __ \_________ _ ____ __/ ____/_ _____
* / /_/ / ___/ __ \| |/_/ / / / __/ / / / / _ \
* / ____/ / / /_/ /> </ /_/ / /___/ /_/ / __/
* /_/ /_/ \____/_/|_|\__, /_____/\__, /\___/
* /_/ ... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package main
import (
"bytes"
"errors"
"fmt"
"net"
"regexp"
"strconv"
)
var HTTP_END []byte = []byte("\r\n")
var HTTP_SEMICOLON = []byte(": ")
var RSP_MAP = map[int]string{
200: "200 OK",
206: "206 Partial Content",
400: "400 Bad Request",
500: "500 Internal Server Error"}
var REQ_FORMAT string = "%s /%s HT... |
package controller
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/holywolfchan/yuncang/model"
)
type entityController struct {
}
var EntityController = new(entityController)
func (this entityController) GetFactory(c *gin.Context) {
ret, err := model.EntityService.GetFactory()
if err != nil {
fallback... |
package main
import "fmt"
func bestRotation(A []int) int {
N, cnt := len(A), [20010]int{}
for i, v := range A {
r, l := (i-v+N+1)%N, (i-(N-1)+N)%N
cnt[l]++
cnt[r]--
if l >= r {
cnt[0]++
}
}
cur, ans, idx := 0, 0, -1
for i := 0; i < N; i++ {
cur += cnt[i]
if cur > ans {
ans = cur
idx = i
... |
package migrations
import "github.com/jmoiron/sqlx"
func CreateCustomCommandTables(tx *sqlx.Tx) error {
_, err := tx.Exec("CREATE TABLE `custom_commands` (`name` varchar(255) NOT NULL, `proc` varchar(255) NOT NULL, `description` varchar(255) NOT NULL, PRIMARY KEY(`name`,`proc`))")
if err != nil {
return err
}
_... |
package socket
import (
. "Api-go/model"
"encoding/json"
"github.com/gorilla/websocket"
)
func SendMessage(ws *websocket.Conn, userName string, params map[string]string) {
msg := params["msg"]
var message Message
//反序列化
err := json.Unmarshal([]byte(msg), &message)
if err != nil {
err := ws.WriteMessage(webs... |
package rwasm
import (
"os"
"github.com/pkg/errors"
"github.com/suborbital/reactr/rcap"
"github.com/wasmerio/wasmer-go/wasmer"
)
func getStaticFile() *HostFn {
fn := func(args ...wasmer.Value) (interface{}, error) {
namePointer := args[0].I32()
nameeSize := args[1].I32()
ident := args[2].I32()
ret := g... |
package main
var WebserverCertificate = []byte(`-----BEGIN CERTIFICATE-----
MIIDrTCCApWgAwIBAgIURD387nezQwUSYH7yw4x1iL6o0ecwDQYJKoZIhvcNAQEL
BQAwZjELMAkGA1UEBhMCVVMxDzANBgNVBAgMBk9yZWdvbjERMA8GA1UEBwwIUG9y
dGxhbmQxDzANBgNVBAoMBmJzaWRlczEOMAwGA1UECwwFIFVuaXQxEjAQBgNVBAMM
CWxvY2FsaG9zdDAeFw0yMDEwMTUwNDA0MjFaFw0zMDEwMTMw... |
package main
import (
"bufio"
"io/ioutil"
"log"
"os/exec"
"strconv"
"strings"
"github.com/icexin/mini-falcon/common"
)
type UserMetric struct {
script string
}
func NewUserMetric(script string) *UserMetric {
return &UserMetric{
script: script,
}
}
func (u *UserMetric) Metrics() []*common.Metric {
var ... |
package main
import (
"fmt"
)
func main() {
fmt.Println("Welcome to function")
port := 3000
_, err := startWebServer(port, 2)
fmt.Println(err)
}
func startWebServer(port int, numberOfRetries int) (int, error) {
fmt.Println("Starting webserver...")
fmt.Println("Server Started", port)
fmt.Println("Retries", n... |
package sshd
import (
"errors"
"fmt"
"net"
"sync"
"github.com/armon/go-radix"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
)
type SSHServer struct {
config *ssh.ServerConfig
l *logrus.Entry
// Map of user -> authorized keys
trustedKeys map[string]map[string]bool
// List of available comm... |
package main
import "github.com/coreos/go-systemd/sdjournal"
type LogWatcher struct {
journal *sdjournal.Journal
}
|
package main
import (
"github.com/jyggen/advent-of-go/util"
"strconv"
"strings"
)
func normalizeRanges(ipRanges [][]int) [][]int {
newRanges := make([][]int, 0)
for _, ipRange := range ipRanges {
normalized := false
for index, newRange := range newRanges {
// Range is already fully covered by the existi... |
package p2p
import (
"testing"
"time"
"github.com/aergoio/aergo-lib/log"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
func Test_reconnectManager_AddJob(t *testing.T) {
logger := log.NewLogger("test.p2p")
// TODO: is it ok that this global v... |
package middlewares
import "github.com/gin-gonic/gin"
// BasicAuth returns a Gin BasicAuth Account.
func BasicAuth() gin.HandlerFunc {
return gin.BasicAuth(gin.Accounts{
"rogeruiz": "test",
})
}
|
package main
import (
"fmt"
"os"
"sort"
"github.com/spf13/pflag"
)
var (
countByBytes = pflag.BoolP("bytes", "c", false, "count by bytes")
countByChars = pflag.BoolP("chars", "m", false, "count by chars")
countByWords = pflag.BoolP("words", "w", false, "count by words")
countByLines = pflag.BoolP("lines", "l... |
package main
//Invalid
//Checks if init has no return value
func init () int {
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.