text stringlengths 11 4.05M |
|---|
package raft
const (
HeartBeatRequest = iota
HeartBeatResponse
VoteRequest
VoteResponse
ClientRequst
ClientResponse
NodeInfoRequest
NodeInfoResponse
)
const (
UnknowType = 01
UsrClient = 02
RaftNode = 04
)
type Header struct {
Length uint32
Type uint32
}
|
// 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... |
// 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 (
"expvar"
"log"
"runtime"
"strings"
"sync"
"time"
"opentsp.org/contrib/collect-netscaler/nitro"
"opentsp.org/interna... |
/*
Given a string, return a "rotated left 2" version where the first 2 chars are moved to the end. The string length will be at least 2.
*/
package main
import (
"fmt"
)
func left2(s string) string {
if len(s) < 2 { return s }
return s[2:] + s[:2]
}
func main(){
var status int = 0
if left2("There") == "ereTh" {... |
package main
import "fmt"
import "math"
const constante string = "gopher"
func main(){
fmt.Println(constante);
const n = 500
const d = 3e20 / n
fmt.Println(d)
fmt.Println(int64(n))
fmt.Println(math.Sin(n))
}
|
/*
Copyright 2022 The Flux 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, softwar... |
package dushengchen
/**
Submission:
https://leetcode.com/submissions/detail/740152233/
Runtime: 40 ms, faster than 11.76% of Go online submissions for Binary Tree Maximum Path Sum.
Memory Usage: 7.9 MB, less than 36.63% of Go online submissions for Binary Tree Maximum Path Sum.
*/
func maxPathSum(root *TreeNode) i... |
package client
import (
apischema "github.com/giantswarm/api-schema"
)
// UpdatePassword updates the password for the given user to newPass.
// oldPass must contain the current password, otherwise an error is thrown.
func (client *Client) UpdatePassword(userID, oldPass, newPass string) error {
payload := map[string... |
package spells
import (
"os"
"fmt"
"log"
"path"
"sync"
"io/ioutil"
"database/sql"
"gopkg.in/kyokomi/emoji.v1"
"github.com/deepdeeppink/tgbot/db"
"github.com/deepdeeppink/tgbot/mux"
"github.com/deepdeeppink/tgbot/cfg"
"github.com/deepdeeppink/tgbot/errs"
"github.com/deepdeeppink/tgbot/state"
"github.com/d... |
package oauthcli
import (
"context"
"fmt"
"os"
"golang.org/x/oauth2"
"golang.org/x/oauth2/github"
)
// Setup return an oauth2Config configured to talk
// to github, you need environment variables set
// for your id and secret
func Setup() *oauth2.Config {
return &oauth2.Config{
ClientID: os.Getenv("GITHU... |
package bgp
type BGPRPC struct {
Information struct {
Peers []BGPPeer `xml:"bgp-peer"`
} `xml:"bgp-information"`
}
type BGPPeer struct {
IP string `xml:"peer-address"`
ASN string `xml:"peer-as"`
State string `xml:"peer-state"`
Group string `xml:"peer-group"`
Descripti... |
package common
import "time"
type Adapter interface {
Initialize(Configuration) // Initialize the adapter
List(string) []*Task // Return the adapter Task list to print the scrum
Move(Task, string) error // Move the task into the list that have the name ...
NextScrum() ... |
package cmds
import (
"io"
"gx/ipfs/Qmf7G7FikwUsm48Jm4Yw4VBGNZuyRaAMzpWDJcW8V71uV2/go-ipfs-cmdkit"
)
// ResponseEmitter encodes and sends the command code's output to the client.
// It is all a command can write to.
type ResponseEmitter interface {
// closes http conn or channel
io.Closer
// SetLength sets the... |
// Copyright (c) 2020 twihike. All rights reserved.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.
package structconv
import (
"reflect"
"testing"
)
func TestDecodeStringMap(t *testing.T) {
type testNestedStringMap1 struct {
N1 int
}
type testNestedStringMap2... |
/*
On a crime scene, there are many pieces of evidence that point to a particular person having the murder weapon and motive to kill poor old Tom (although not poor at all).
Create a function that takes phrases/words as clues and forms a sentence formatted to have the murder's name, verb, "Tom as", Reason.
Sn Weapon ... |
package printer
import (
"fmt"
"io"
"strings"
)
// SwiftPrinter implement the Printer interface for Swift programs
type SwiftPrinter struct {
Printer
level int
sameline bool
w io.Writer
}
func (p *SwiftPrinter) Reset() {
p.level = 0
p.sameline = false
}
func (p *SwiftPrinter) PushContext(c Conte... |
package event
import (
"log"
)
type Router struct {
handlers []Handler
}
func NewEventRouter(handlers []Handler) *Router {
return &Router{handlers: handlers}
}
func (er *Router) Route(event Event) {
anyHandler := false
for _, h := range er.handlers {
if h.Handle(event) {
anyHandler = true
}
}
if !any... |
// Package run provides an easy way to execute external commands. It's not a
// big package (less than 100 lines of code), but comes handy when one is using
// an external command inside a Go program. Because it gets stdin and returns
// stdout and stderr in []byte.
//
// stdout, stderr, err := Run("hello", "tr... |
package command
import (
"fmt"
"termsnippet/util"
"github.com/ajpen/termsnippet/core"
"github.com/atotto/clipboard"
"gopkg.in/urfave/cli.v1"
)
func init() {
InstallCommand(newSnippetCommand())
}
func newSnippetCommand() cli.Command {
cmd := cli.Command{
Name: "new",
Description: "Create a new cod... |
package logic
import (
"context"
"golang.org/x/crypto/bcrypt"
"software/car_port/model"
"software/car_port/pb_gen"
"software/common"
)
type UserLogic struct {
ctx context.Context
}
func NewUserLogic(ctx context.Context) (*UserLogic, common.BgErr) {
if err := common.AuthPermission(ctx, common.PermissionAdmin);... |
/*
* @lc app=leetcode.cn id=1688 lang=golang
*
* [1688] 比赛中的配对次数
*/
// @lc code=start
package main
func numberOfMatches(n int) int {
if n < 2 {
return 0
} else {
return n/2 + numberOfMatches((n+1)/2)
}
}
// func main() {
// fmt.Println(numberOfMatches(14))
// }
// @lc code=end
|
package main
import (
"flag"
"net/http"
"sub_account_service/number_server/config"
"sub_account_service/number_server/models"
"sub_account_service/number_server/routers/query"
)
func main() {
flag.Parse()
models.Setup()
router := query.InitRouter()
err := http.ListenAndServe(config.Opts().Query_Server_H... |
package model
import (
"log"
)
type User struct {
BaseModel
Name string `form:"name" gorm:"unique;not null" binding:"required"`
Email string `form:"email" binding:"email" gorm:"not null" binding:"required"`
Password string `form:"password" gorm:"not null" binding:"required"`
}
func init() {
}
func (use... |
package company
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/rezwanul-haque/ID-Service/src/domain/companies"
"github.com/rezwanul-haque/ID-Service/src/services"
"github.com/rezwanul-haque/ID-Service/src/utils/consts"
"github.com/rezwanul-haque/ID-Service/src/utils/errors"
"github.com/rezwa... |
package example
import (
"fmt"
"github.com/xfstart07/gosms/luosimao"
)
func main() {
service := luosimao.New("apikey")
result, err := service.Send("you mobile", "你的验证码: 1231")
if err != nil {
fmt.Println("err")
}
fmt.Println(result.Code)
fmt.Println(result.Message)
}
|
package main
import (
"fmt"
"regexp"
)
var (
LinkPattern = `(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?`
text = `https://crawler.club是爬虫的主页哈哈`
)
func main() {
r := regexp.MustCompile(LinkPattern)
fmt.Println(r.FindAllString(text, -1))
}
|
// +build windows
package nio
import "syscall"
type Handle = syscall.Handle
|
// Copyright (c) 2020 Hirotsuna Mizuno. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
package speedio_test
import (
"io/ioutil"
"testing"
"time"
"github.com/tunabay/go-speedio"
)
//
func TestMeterWriter_test1(t *testing.T) {
t.Parallel(... |
/*
* JALANKAN PERINTAH GO BUILD DI FOLDER INI UNTUK MENGCOMPILE PROGRAM
*/
package main
import (
"fmt"
"contoh_mvc/controllers"
"net/http"
)
func main() {
var SiswaController controllers.SiswaController = controllers.NewSiswaController();
// ROUTE
// route
http.HandleFunc("/siswa", SiswaController... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
const (
ascii_offset byte = 48
)
func checkErr(err error) {
if err != nil {
log.Fatalf("Error: %v", err)
}
}
func main() {
f, err := os.Open("input.txt")
checkErr(err)
defer f.Close()
scanner := bufio.NewScanner(f)
sum := 0
for scanner.Scan()... |
package main
import (
"fmt"
"log"
"net/http"
"strconv"
"sync"
)
var counter int
var mutex = &sync.Mutex{}
func incrementCount(w http.ResponseWriter,r *http.Request){
mutex.Lock()
defer mutex.Unlock()
counter++
fmt.Fprintf(w, strconv.Itoa(counter))
}
func main() {
http.Handle("/", http.FileServer(http.Di... |
package saml
import (
"encoding/xml"
"testing"
"time"
"github.com/pkg/errors"
"github.com/sergi/go-diff/diffmatchpatch"
"github.com/stretchr/testify/assert"
)
var testSP = &ServiceProvider{
PrivkeyPEM: `-----BEGIN PRIVATE KEY-----
MIIJKwIBAAKCAgEA8eAiAD/qbOh+PBCOYWFjuVbweHUAb/958G0hF+3ciWCqBDzO
YUO8Gij+S9YBSZ... |
package main
import (
"fmt"
"runtime"
"time"
"github.com/jchiu0/experimental/wstring"
)
func main() {
s := wstring.NewWString()
s.Set([]byte("helloworld")) // This is a copy. No worries about double freeing.
data := s.Get()
fmt.Printf("[%s]\n", string(data))
fmt.Printf("Length = %d\n", s.Size())
// s is n... |
package common
import "encoding/json"
func MarshalBind(src, dsc interface{}) error {
data, err := json.Marshal(src)
if err != nil {
return err
}
return json.Unmarshal(data, dsc)
}
|
package unionfind
// Quick Union
// 元素 0 1 2 3 4 5 6 7 8 9
// -------------------
// parent 0 1 2 3 4 5 6 7 8 9
// parent[i]:元素i的父亲元素
type UnionFind2 struct {
parent []int
count int // 元素个数
}
func NewUnionFind2(n int) *UnionFind2 {
uf := new(UnionFind2)
uf.count = n
uf.parent = make([]int, n)
for i := 0... |
package geekdo
// CollectionItems is the root node of a collection request.
type CollectionItems struct {
TotalItems int `xml:"totalitems,attr"`
TermsOfUse string `xml:"termsofuse,attr"`
PubDate string `xml:"pubdate,attr"`
Items []CollectionItem `xml:"item"`
}
// Collectio... |
package mock
import (
"context"
"time"
"github.com/odpf/optimus/core/progress"
"github.com/odpf/optimus/models"
"github.com/stretchr/testify/mock"
)
type Scheduler struct {
mock.Mock
}
func (ms *Scheduler) VerifyJob(ctx context.Context, namespace models.NamespaceSpec, job models.JobSpec) error {
args := ms.... |
package storage
// AccessTokenService provides access to AccessToken objects.
type AccessTokenService interface {
Get(token string) (*AccessToken, error)
Put(token string, at AccessToken) error
}
|
package main
import "fmt"
func main() {
var x = 4
var p *int
p = &x
fmt.Println(p)
fnNew()
}
func fnNew() {
p := new(int)
fmt.Println("Value:", *p) // Value: 0 - значение по умолчанию
*p = 8 // изменяем значение
fmt.Println("Value:", *p) // Value: 8
newChange()
}
func changeValue(x *int) ... |
package models
type VirtualizationInfo struct {
System string
Role string
}
|
package api
import "testing"
func TestDefMatch(t *testing.T) {
s1 := DefMatch("")
if s1 != ".*" {
t.Error("Expected \".*\" got ", s1)
}
s2 := DefMatch("abc")
if s2 != "abc" {
t.Error("Expected \"abc\" got ", s2)
}
}
|
package catp
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00600102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catp.006.001.02 Document"`
Message *ATMInquiryRequestV02 `xml:"ATMNqryReq"`
}
func (d *Document00600102) AddMessage() *... |
package cache
import (
"encoding/json"
"time"
"gopkg.in/redis.v3"
)
const redisStoreName = "Redis Store"
// NewRedisStore creates a new redis store using the given client
func NewRedisStore(client *redis.Client) Store {
return &redisstore{
client: client,
config: StoreConfig{StoreName: redisStoreName},
}
}... |
package main
import (
"bufio"
"fmt"
"io"
"os"
"path/filepath"
"strconv"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
"golang.org/x/net/context"
)
func dumpContainer(cli *client.Client, container types.Container, baseLogsDir stri... |
package timer
import (
"context"
"errors"
"fmt"
"os"
"runtime"
"sync"
"testing"
"time"
)
func TestMain(m *testing.M) {
defaultWheel = newWheel(context.Background(), time.Millisecond, 1000)
// call flag.Parse() here if TestMain uses flags
os.Exit(m.Run())
}
func TestAfterFunc(t *testing.T) {
i := 10
c :... |
package main
import (
f "fmt"
log "github.com/Sirupsen/logrus"
"github.com/etree"
"os"
"os/exec"
)
// CephDriver is the Driver of Ceph
type CephDriver struct {
DevDescriptor string
MountPoint string
PoolName float64
ImgName float64
GBSize int
NewGBSize int
XmlName ... |
package x
// GENERATED BY XO. DO NOT EDIT.
import (
"errors"
"strings"
//"time"
"ms/sun/shared/helper"
"strconv"
"github.com/jmoiron/sqlx"
)
// (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// ProfileMentioned represents a row from 'sun.pr... |
// redis project main.go
package main
import (
"errors"
"fmt"
"net"
"strconv"
"sync/atomic"
"time"
log "github.com/cihub/seelog"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"redis/common"
"redis/config"
"github.com/go-redis/redis"
pb "redis/message"
)
var... |
package gcp
import (
"context"
"fmt"
"io/ioutil"
"os"
cloudbuild "cloud.google.com/go/cloudbuild/apiv1"
"cloud.google.com/go/storage"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
)
// GCPCredentialsEnvName contains name of the environment variable used
// to specify the path to file with C... |
// 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 native
import (
"fmt"
"log"
"os"
"testing"
)
var (
uri, username, password string
)
func init() {
uri = os.Getenv("ORCLURI")
username = os.Getenv("ORCLUSER")
password = os.Getenv("ORCLPWD")
if uri == "" || username == "" || password == "" {
log.Panic("The following env variables must be set: ORCLU... |
package main
import (
"reflect"
"testing"
)
func Test_fetchLongestStablePrices(t *testing.T) {
type args struct {
data []int
x int
}
tests := []struct {
name string
args args
want []int
}{
{
name: "Test data 1",
args: args{
[]int{2,4,3,6,6,3},
0,
},
want: []int{6,6},
},
{
... |
package time
import (
"sync"
"time"
)
type SharedTime struct {
sync.RWMutex
time time.Time
}
func (s *SharedTime) Before(other time.Time) bool {
s.RLock()
defer s.RUnlock()
return s.time.Before(other)
}
func (s *SharedTime) After(other time.Time) bool {
s.RLock()
defer s.RUnlock()
return !s.time.Before(... |
// Copyright (C) 2019 Cisco Systems Inc.
// Copyright (C) 2016-2017 Nippon Telegraph and Telephone 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.... |
package sv
import (
"reflect"
"testing"
"github.com/Masterminds/semver/v3"
)
func TestSemVerCommitsProcessorImpl_NextVersion(t *testing.T) {
tests := []struct {
name string
ignoreUnknown bool
version *semver.Version
commits []GitCommitLog
want *semver.Version
wantUpdated... |
package main
import "fmt"
func main() {
var n int
fmt.Scanf("%d", &n)
for i := 0; i < n-1; i++ {
fmt.Print("Ho ")
}
fmt.Println("Ho!")
}
|
package interfaces
import (
"github.com/golangid/candi/codebase/factory/types"
"github.com/labstack/echo"
"google.golang.org/grpc"
)
// RESTHandler delivery factory for REST handler
type RESTHandler interface {
Mount(group *echo.Group)
}
// GRPCHandler delivery factory for GRPC handler
type GRPCHandler interface... |
// Package wordwrap provide a utility to wrap text on word boundaries.
package wordwrap
import (
"bufio"
"io"
"strings"
"unicode"
)
// Scanner wraps UTF-8 encoded text at word boundaries when lines exceed a limit
// number of characters. Newlines are preserved, including consecutive and
// trailing newlines, thou... |
package Problem0155
// MinStack 是可以返回最小值的栈
type MinStack struct {
stack []item
}
type item struct {
min, x int
}
// Constructor 构造 MinStack
func Constructor() MinStack {
return MinStack{}
}
// Push 存入数据
func (s *MinStack) Push(x int) {
min := x
if len(s.stack) > 0 && s.GetMin() < x {
min = s.GetMin()
}
s.st... |
package range_sum_bst
type Tree interface {
RangeSumBST(int, int) int
}
type tree struct {
head TreeNode
}
func (t *tree) RangeSumBST(L int, R int) int {
if t.head == nil {
return 0
}
var result int
if t.head.GetValue() < L {
result += NewTree(t.head.GetRight()).RangeSumBST(L, R)
}
if t.head.GetValue() ... |
package main
import (
"math"
"github.com/fogleman/ln/ln"
)
func main() {
cube("cube")
hole(xxyy, "hole")
sphere("sphere", false)
sphere("outline-sphere", true)
cylinder("cylinder", false)
cylinder("outline-cylinder", true)
}
func cube(out string) {
// create a scene and add a single cube
scene := ln.Scene... |
package main
import (
"fmt"
"io/fs"
"os"
"path/filepath"
)
const specPathBase = `/Users/jameslucktaylor/git/github.com/TykTechnologies/ara/k8s/deployments/home/go`
func main() {
sfs := SpecFS{base: specPathBase}
if err := StatHomeNS(sfs); err != nil {
fmt.Fprintf(os.Stderr, "could not stat file: %v\n", err)
... |
package bot
import (
"time"
"sync"
"log"
)
type Context struct {
//state for handler to inspect
Message *Message
CurrentResponse *Response
Inline *Inline
//telegram account info
BotAccount *BotAccount
//next handler to handle
NextHandler Handler
//inner state to choose handler
respons... |
/*--------------------------------------------------------------
* package: 初始化服务
* time: 2018/04/17
*-------------------------------------------------------------*/
package api
import (
"encoding/json"
"github.com/golang/glog"
"strconv"
"sub_account_service/blockchain_server/arguments"
c "sub_account_servic... |
// Package privacy provides functions for removing private information
// from data of different types.
package privacy
import (
"github.com/golang/protobuf/proto"
"gopkg.in/sorcix/irc.v2"
pb "github.com/robustirc/robustirc/internal/proto"
"github.com/robustirc/robustirc/internal/robust"
)
func FilterSnapshot(sn... |
package calc
import "math"
// QuadRoot calculates the real roots of a quadratic equation.
// See https://en.wikipedia.org/wiki/Quadratic_formula.
func QuadRoot(a float64, b float64, c float64) []float64 {
roots := make([]float64, 0, 2)
// Calculate the discriminant.
disc := b*b - 4.0*a*c
if disc < 0.0 {
return... |
package main
import (
"fmt"
"sync"
"time"
)
var cabs = 2
var wg1 sync.WaitGroup
func main() {
m := &sync.Mutex{}
names := []string{"Ravi", "Raj", "Dev", "Vipin", "Ankit"}
for _, name := range names {
wg1.Add(1)
go cab(name, m)
}
wg1.Wait()
}
func cab(name string, m *sync.Mutex) {
m.Lock()
if cabs >=... |
package afdb
import (
"database/sql"
_ "github.com/lib/pq"
"log"
"fmt"
"strings"
"strconv"
)
type Db struct {
Connection *sql.DB
}
type Player struct {
UserName string
UserId int64
Count int
Money float64
}
type Game struct {
Holder string
HolderId int64
Comment string
}
func (th *Db) Close... |
package ir
// IntPredicate represents a predicate for comparing integers.
type IntPredicate int
const (
IntEQ IntPredicate = iota // equal
IntNE // not equal
IntUGT // unsigned greater than
IntUGE // unsigned greater than or equal to
IntULT ... |
package leetcode
import "testing"
func TestSumRootToLeaf(t *testing.T) {
q1 := &TreeNode{
Val: 1,
Left: &TreeNode{
Val: 0,
Left: &TreeNode{
Val: 0,
},
Right: &TreeNode{
Val: 1,
},
},
Right: &TreeNode{
Val: 1,
Left: &TreeNode{
Val: 0,
},
Right: &TreeNode{
Val: 1,
... |
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package requests
import (
"reflect"
"testing"
)
func TestNewGitClient(t *testing.T) {
tests := []struct {
name string
want GitClient
}{
// TODO: Add test cases.
... |
package httpapi
import (
"context"
"crypto/tls"
"net/http"
"github.com/serverless/event-gateway/internal/sync"
"go.uber.org/zap"
)
// ServerConfig contains information for an HTTP listener to interact with its environment.
type ServerConfig struct {
Log *zap.Logger
TLSCrt *string
TLSKey ... |
package main
import "fmt"
func recurse(n int) int{
if n == 0{
return 0
}
return n + recurse(n-1)
}
func main(){
fmt.Println(recurse(3))
fmt.Println(recurse(10))
fmt.Println(recurse(8))
}
|
package main
import "fmt"
func main() {
var a[2]string
a[0] = "Hello"
a[1] = "World"
fmt.Println(a[0], a[1])
fmt.Println(a)
// Hello World
// [Hello World]
}
/*
数组
类型 [n]T 是一个有 n 个类型为 T 的值的数组
表达式
var a[10] int
定义变量 a 是一个有十个整数的数组。
数组的长度是其类型的一部分, 因此数组不能改变大小。
这... |
// +build !integration
package disgord
import (
"io/ioutil"
"testing"
"github.com/andersfylling/disgord/internal/util"
)
func TestStateMarshalling(t *testing.T) {
data, err := ioutil.ReadFile("testdata/voice/state1.json")
check(err, t)
state := VoiceState{}
err = util.Unmarshal(data, &state)
check(err, t)
... |
package testing
import (
"github.com/devspace-cloud/devspace/pkg/devspace/build"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest"
"github.com/devspace-cloud/devspace/pkg/util/log"
"github.com/devspace-cloud/devspace/pkg/util/randutil"
)
// FakeController is the fake build controller
type F... |
// 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 activitystream
import (
"strconv"
"time"
)
// MakeTimestamp returns the given time as unix milliseconds
func MakeTimestamp(t time.Time) int64 {
return t.UnixNano() / int64(time.Millisecond)
}
// CreateTokens generates and returns previous and next token from an array of activities and pagination informati... |
package main
//给定一个字符串 s 和一个整数 k,你需要对从字符串开头算起的每隔 2k 个字符的前 k 个字符进行反转。
//
//如果剩余字符少于 k 个,则将剩余字符全部反转。
//如果剩余字符小于 2k 但大于或等于 k 个,则反转前 k 个字符,其余字符保持原样。
func main() {
}
func reverseStr(s string, k int) string {
if k == 1 || len(s) <= 1 {
return s
}
in := []byte(s)
cnt := len(in) / (2 * k)
for i := 0; i < len(in)/(2... |
package common
//常用方法
import (
"crypto/md5"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"io"
"regexp"
"strings"
mr "math/rand"
"path/filepath"
"os"
"bufio"
"fmt"
)
//md5方法
func GetMd5String(s string) string {
h := md5.New()
h.Write([]byte(s))
return hex.EncodeToString(h.Sum(nil))
}
//Guid方法
func Get... |
package main
import "fmt"
var s string
func main() {
s="G"
fmt.Println(s)
f1()
}
func f1() {
s="O"
fmt.Println(s)
f2()
}
func f2() {
fmt.Println(s)
} |
package configure
import (
"fmt"
log "github.com/mailgun/gotools-log"
"github.com/mailgun/vulcan"
"github.com/mailgun/vulcan/endpoint"
"github.com/mailgun/vulcan/loadbalance/roundrobin"
"github.com/mailgun/vulcan/location/httploc"
"github.com/mailgun/vulcan/route/pathroute"
. "github.com/mailgun/vulcand/adapte... |
package pxf
import (
"errors"
"github.com/greenplum-db/gp-common-go-libs/operating"
"os"
)
type CliInputs struct {
Gphome string
PxfConf string
Cmd Command
}
type EnvVar string
const (
Gphome EnvVar = "GPHOME"
PxfConf EnvVar = "PXF_CONF"
)
type Command string
const (
Init Command = "init"
Start C... |
package server
import (
"context"
"flag"
"io/ioutil"
"net"
"os"
"testing"
"time"
"github.com/stretchr/testify/require"
"go.opencensus.io/examples/exporter"
"go.uber.org/zap"
api "github.com/alexeyqian/proglog/api/v1"
"github.com/alexeyqian/proglog/internal/auth"
configx "github.com/alexeyqian/proglog/in... |
package main
import (
"fmt"
"golang.org/x/text/unicode/norm"
)
func main() {
fmt.Println("à" == "à")
// Output: false
fmt.Println("\u00E0 == \u0061\u0300")
fmt.Println("\u00E0" == "\u0061\u0300")
norm1 := norm.NFD.String("\u00E0")
norm2 := norm.NFD.String("\u0061\u0300")
fmt.Println(norm1 == norm2)
// O... |
package main
import "fmt"
type Property struct {
value int
}
// 设置属性的值
func (p *Property) SetValue(v int) {
p.value = v
}
func (p *Property) getValue() int {
return p.value
}
func main() {
//p := &Property{}
p := new(Property)
p.SetValue(1001)
fmt.Println(p.getValue())
}
|
package users
import (
"encoding/json"
"net/http"
"cinemo.com/shoping-cart/framework/web/httpresponse"
"cinemo.com/shoping-cart/internal/errorcode"
"cinemo.com/shoping-cart/pkg/auth"
)
// LoginHandlers handles login functionality
func LoginHandlers(service Service) func(http.ResponseWriter, *http.Request) {
re... |
package flash
// 0_TreeNode
type TreeNode struct {
Id string
Label string
Children []TreeNode
}
func (t *TreeNode) Push(nodes []TreeNode) {
var tns []TreeNode
for i, e := range nodes {
if i == 0 {
tns = append(t.Children, e)
continue
}
tns = append(tns, e)
}
t.Children = tns
}
func Find... |
package main
import (
"fmt"
"github.com/hwdef/go-algorithm/sort/QuickSort"
)
func main() {
var a = []int{6, 5, 3, 1, 8, 7, 2, 4}
//fmt.Println(BucketSort.BucketSort(a))
//a = []int{6, 5, 3, 1, 8, 7, 2, 4}
//fmt.Println(SelectionSort.SelectionSort(a))
//a = []int{6, 5, 3, 1, 8, 7, 2, 4}
//fmt.Println(Insertio... |
// This file was generated for SObject FeedAttachment, API Version v43.0 at 2018-07-30 03:48:11.864160076 -0400 EDT m=+58.208950665
package sobjects
import (
"fmt"
"strings"
)
type FeedAttachment struct {
BaseSObject
FeedEntityId string `force:",omitempty"`
Id string `force:",omitempty"`
IsDeleted ... |
package service
import (
"2019_2_IBAT/pkg/app/auth/session"
"2019_2_IBAT/pkg/app/notifs/notifsproto"
"2019_2_IBAT/pkg/app/recommends/recomsproto"
. "2019_2_IBAT/pkg/pkg/models"
"context"
"fmt"
"log"
"github.com/google/uuid"
)
type Service struct {
NotifChan chan NotifStruct
ConnectsPool WsConnects
Auth... |
package requests
type KeyStruct struct {
Key string `json:"key"`
}
// type GetBookByISBN struct {
// Publisher []string `json:"publishers"`
// Title string `json:"title"`
// NumberOfPages uint `json:"number_of_pages"`
// PublishDate string `json:"publish_date"`
// AuthorId ... |
package test
import (
"fmt"
"testing"
"ppgo"
)
func TestConfig(t *testing.T) {
ppgo.API_ROOT = "/Users/wangpp/Code/github/go/src/ppgo-sample";
//初始化配置文件
ppgo.NewConfig("Config", "conf")
fmt.Println(ppgo.Config.GetString("system.port"));
}
|
package client
type WrappableError interface {
error
Unwrap() error
}
type CertificateReadError struct {
Err error
}
func (e *CertificateReadError) Error() string {
return "cannot read certificate"
}
func (e *CertificateReadError) Unwrap() error {
return e.Err
}
type CertificateDecodeError struct{}
func (e *... |
package class
import (
"github.com/zxh0/jvm.go/jvmgo/jutil"
)
func (self *Obj) IsArray() bool {
return self.class.IsArray()
}
func (self *Obj) IsPrimitiveArray() bool {
return self.class.IsPrimitiveArray()
}
func (self *Obj) Refs() []*Obj {
return self.fields.([]*Obj)
}
func (self *Obj) Booleans() []int8 {
ret... |
package main
import "fmt"
type unexpectedResponseErr struct {
statusCode int
body string
}
func (e *unexpectedResponseErr) Error() string {
return fmt.Sprintf("error: unexpected response: %v %v", e.statusCode, e.body)
}
type invalidKeyTypeErr struct {
key string
val interface{}
}
func (e *invalidKeyType... |
package main
import (
"fmt"
tools "../tools"
)
func main() {
fmt.Println(tools.Add(10, 100))
} |
package downloader
import (
"io"
"log"
"net/http"
"os"
"sync"
)
type job struct {
url string
filename string
}
type Downloader struct {
threadNum int
jobs chan *job
waitGroup sync.WaitGroup
}
func New(threadNum int) *Downloader {
downloader := &Downloader{threadNum, make(chan *job, 0), sync.Wai... |
// test-for project doc.go
/*
test-for document
*/
package main
|
package bulletproofs
import "incognito-chain/common"
type BulletproofsLogger struct {
Log common.Logger
}
func (logger *BulletproofsLogger) Init(inst common.Logger) {
logger.Log = inst
}
// Global instant to use
var Logger = BulletproofsLogger{}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.