text stringlengths 11 4.05M |
|---|
package transport
import (
sa "github.com/atymkiv/sa/model"
)
// Shops feed model response
// swagger:response shopsResp
type swaggShopsResponse struct {
//in:body
Body struct{
Shops []sa.Shop
}
}
// swagger:response addressResp
type swaggAddressResponse struct {
//in:body
Body struct{
City string
Numbe... |
package stories
import (
G "github.com/ionous/sashimi/game"
. "github.com/ionous/sashimi/script"
)
//
func The_Lab(s *Script) {
s.The("story",
Called("testing"),
Has("author", "me"),
Has("headline", "extra extra"),
When("commencing").Always(func(g G.Play) {
g.Say("Welcome to the lab.")
}))
s.The("ro... |
package main
import (
"github.com/gin-gonic/gin"
"gopetstore_v2/src/config"
"gopetstore_v2/src/global"
"gopetstore_v2/src/route"
"gopetstore_v2/src/util"
"html/template"
"log"
"path/filepath"
)
func main() {
r := gin.Default()
setFrontConfig(r)
// 注册路由
route.RegisterRoute(r)
err := r.Run(":" + global.Ser... |
// Copyright 2019 Yunion
//
// 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 writi... |
package session
import (
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
func TestFormatValue(t *testing.T) {
mp := message.NewPrinter(language.Make("en"))
f := 1.2345
assert.Equal(t, "1.234", formatValue(mp, f, 3))
assert.Equal(t, "1.234", formatVal... |
package main
type session struct {
username string
userdn string
password string
}
|
package config
import (
"github.com/wu-xing/wood-serve/common"
"github.com/wu-xing/wood-serve/database"
)
func Migration(db *database.DB) {
var count int
err := common.GetDB().Connection.DB().QueryRow("select count(*) from app_config").Scan(&count)
if err != nil {
panic(err)
}
if count >= 1 {
return
}
... |
package cmd
import (
"fmt"
"log"
"os/exec"
"path"
"strings"
"github.com/BurntSushi/toml"
"github.com/spf13/cobra"
)
// process_yaml_queueCmd respresents the process_yaml_queue command
var process_yaml_queueCmd = &cobra.Command{
Use: "process_yaml_queue",
Short: "Process images specified in toml queue",
L... |
/*
Copyright 2020 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 twitter
import (
"fmt"
"regexp"
"strings"
logger "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"strconv"
"github.com/namsral/flag"
vision "cloud.google.com/go/vision/apiv1"
"github.com/ChimeraCoder/anaconda"
"github.com/amcleodca/pretty-pinboard/pin-enricher/enricher"
"github.com/amcle... |
// Copyright 2019 Yunion
//
// 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 writi... |
package runtime
// Tail calls are handled by a trampoline
type Call struct {
*NilObj
// The function that was invoked
Fn Callable
// The arguments it was invoked in
Args Sequence
// The environment it was invoked in
Env Env
}
func (c *Call) Eval(env Env) (Value, error) {
return c, nil
}
// These should never... |
package main
import (
//"fmt"
//"time"
//"flag"
"strings"
"github.com/SophisticaSean/gitlab-bot/gitlab"
"github.com/davecgh/go-spew/spew"
"github.com/SophisticaSean/gitlab-bot/model"
)
var job_count int
var app_id string
var job_name string
var owner_name string
func main() {
gl := gitlab.New()
name... |
package udwCmd_test
import (
"github.com/tachyon-protocol/udw/udwCmd"
"github.com/tachyon-protocol/udw/udwFile"
"github.com/tachyon-protocol/udw/udwRand"
"github.com/tachyon-protocol/udw/udwTest"
"testing"
)
func TestBashEscape(ot *testing.T) {
udwTest.Equal(len(udwCmd.BashEscape("'")), 6)
udwTest.Equal(len(ud... |
package main
import (
"log"
"strings"
)
/**
给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度。
如果不存在最后一个单词,请返回 0 。
说明:一个单词是指由字母组成,但不包含任何空格的字符串。
示例:
输入: "Hello World"
输出: 5
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/length-of-last-word
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*/
func lengthOfLastWord(s string) int ... |
package main
import (
"encoding/csv"
"fmt"
"log"
"os"
"strings"
"sync"
"time"
"github.com/gocolly/colly"
)
const (
prefix = "https://www.gumtree.pl"
)
func main() {
fName := "cryptocoinmarketcap.csv"
file, err := os.Create(fName)
if err != nil {
log.Fatalf("Cannot create file %q: %s\n", fName, err)
... |
package divine_test
import (
"fmt"
"reflect"
"github.com/onsi/gomega/types"
"github.com/shamus/divine"
)
type (
providerMatcher struct {
executed bool
err error
dependent, required, yielded interface{}
}
)
func Provide(required interface{}) *providerMatcher {... |
package main
import (
"encoding/base64"
"fmt"
)
func main() {
decoded, err := base64.StdEncoding.DecodeString("AAcAAAgA9QEBZAD//w==")
if err != nil {
fmt.Println("decode error:", err)
return
}
fmt.Printf("%#v\n", decoded)
// []byte{0x0, 0x7, 0x0, 0x0, 0x8, 0x0, 0xf5, 0x1, 0x1, 0x64, 0x0, 0xff, 0xff}
}
|
package main
const (
pgConnHost = "localhost"
pgConnPort = 5432
pgConnUser = "mbadmin"
pgConnPassword = "kalra"
pgConnDBName = "message_board"
)
//DBInterface defined what DB module must offer for users
type DBInterface interface {
NewDB() error
InsertNewUser(email, firstname, lastname string) (u... |
package main
import (
"database/sql"
"sync"
)
// Server represents the state of a single server, and is the endpoint for RPC calls.
type Server struct {
sync.Mutex
DB *sql.DB
// the current state: one of "follower", "leader", or "candidate"
State string
// all servers persistent state
CurrentTerm int
Voted... |
package k8s_api_bybass_test
import (
"github.com/kumahq/kuma/test/e2e/k8s_api_bybass"
. "github.com/onsi/ginkgo"
)
var _ = Describe("Test Kubernetes API Bypass", k8s_api_bybass.K8sApiBypass)
|
package utils
import (
"fmt"
"github.com/google/uuid"
)
const (
queryKeyDelim = "#"
)
func NewID() string {
return uuid.New().String()
}
// Forms a new document's "query ID", which is the ID used for "queries", which
// are retrieval operations that retrieve multiple documents by query ID
// prefix.
func DocQue... |
package main
import (
"fmt"
)
func main() {
var s1 interface{} = "123"
var s2 []byte = []byte{'4', '5', '6'}
fmt.Println(fmt.Sprintf("%s%s", s1, s2))
}
|
package altrudos
import (
"database/sql/driver"
"encoding/json"
"errors"
"fmt"
"os"
"reflect"
"strings"
"github.com/lib/pq"
)
var (
ErrInvalidCurrency = errors.New("invalid currency")
)
var ValidCurrencies = map[string]string{
"USD": "USD",
"CAD": "CAD",
"EUR": "EUR",
"GBP": "GBP",
"AUD": "AUD",
}
ty... |
package configs
import (
"fmt"
"time"
"github.com/go-kit/kit/log"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/rulefmt"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/rules"
"github.com/weaveworks/cortex/pkg/util"
)
// An ID is the ID of a s... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekaerr
import (
"sync"
"sync/atomic"
)
//noinspection GoSnakeCaseUsage
const (
// _ERR_NAMESPACE_ARRAY_CACHE describes how many regi... |
package iam_test
import (
"errors"
gcpiam "google.golang.org/api/iam/v1"
"github.com/genevieve/leftovers/gcp/iam"
"github.com/genevieve/leftovers/gcp/iam/fakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("ServiceAccounts", func() {
var (
client *fakes.ServiceAccountsClient
l... |
package utility
import (
"io"
"io/ioutil"
"log"
"mime/multipart"
"os"
jwt "github.com/dgrijalva/jwt-go"
"github.com/labstack/echo"
"golang.org/x/crypto/bcrypt"
)
func HashAndSalt(p []byte) string {
// Use GenerateFromPassword to hash & salt pwd
// MinCost is just an integer constant provided by the bcrypt
... |
package main
import "fmt"
// In Go, when we call a function and pass in a bunch of arguments to that function,
// the language creates copies of the arguments which are then used within said function.
func main6() {
a := 2
addOne(&a)
fmt.Println(a)
// GO BY EXAMPLE
i, j := 42, 2701
p := &i // point to... |
package controller
import (
"errors"
"log"
"net/http"
"regexp"
"strings"
"sync"
"time"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/hashicorp/go-uuid"
"github.com/jinzhu/copier"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/crypto/bcrypt"
"golang.org/x/sync/singleflight"... |
package connector
// import (
// "centerclient"
// "chatclient"
// // "clanclient"
// "common"
// // "csvcfg"
// // "fmt"
// // "herobattleclient"
// "logger"
// // "mailclient"
// // "math/rand"
// "os"
// "proto"
// "rpc"
// "strconv"
// "strings"
// "time"
// )
//单点聊天关闭,暂时不开放了
/*func (self *CNServe... |
package landscaper
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"k8s.io/helm/pkg/repo/repotest"
)
func TestLoadLocalCharts(t *testing.T) {
tmp := filepath.Join(os.TempDir(), "landscaper", "landscapeTest")
defer os.RemoveAll(tmp)
localCharts := NewLocalCharts("testdata/helmho... |
/*
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 osutil
import (
"bufio"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
)
var (
clean = filepath.Clean
Location *time.Location
osutil Settings
)
// Alert alters the user, waiting for input on the standard settings.
func Alert(... |
package internal_test
import (
"crypto/tls"
"errors"
"io"
"net/http"
"reflect"
"testing"
"time"
"github.com/michelin/gochopchop/internal"
)
func TestNewFetcher(t *testing.T) {
t.Parallel()
var tests = map[string]struct {
Insecure bool
Timeout int
ExpectedFetcher internal.NetFetcher
}... |
// 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 hole
import (
"bytes"
"crypto/tls"
"crypto/x509"
"github.com/felixge/tcpkeepalive"
"io/ioutil"
"log"
"net"
"strings"
"sync"
"time"
)
// Client define a client.
type Client struct {
sessions map[string]Session
locker *sync.RWMutex
conn Conn
subAddr string
alive bool
tlsConfig tls... |
package linked_list
//反转链表 双指针迭代
func reverseList(head *ListNode) *ListNode {
//存储前一个节点 head的前节点是nil
var pre *ListNode = nil
//记录当前节点
cur := head
//当前节点不为空
for cur != nil {
//temp保存当前节点的后继节点
temp := cur.Next
//反转 当前节点的下一个节点是它的前一个节点
cur.Next = pre
//temp的前一个节点变为当前节点
pre = cur
//当前节点替换为下一个节点 也就是te... |
package main
import (
"encoding/json"
"errors"
"log"
"net/http"
"github.com/gin-gonic/gin"
"gopkg.in/olahol/melody.v1"
)
var clients = map[string]struct{}{}
var chatHistory []Message
var chatChannel = make(chan Message)
var m *melody.Melody
func RegisterUser(name string) error {
_, ok := clients[name]
if... |
package innerSortImpl
/**
* @author liujun
* @version 1.0
* @date 2021-06-22 00:09
* @author—Email liujunfirst@outlook.com
* @blogURL https://blog.csdn.net/ljfirst
* @description 快速排序——单向快排
*/
type QuickSortSimplex struct {
}
func (s *QuickSortSimplex) SortMethod(array []int) []int {
if array == nil || len(a... |
package rawdatalog
import (
"encoding/json"
"github.com/nats-io/stan.go"
)
type stanLogRepo struct {
sc stan.Conn
}
func NewStanLogRepo(sc stan.Conn) Repo {
return &stanLogRepo{
sc: sc,
}
}
// topic == subject == stream
func (r *stanLogRepo) Write(topic string, moment RawMoment) error {
msg, _ := json.Mars... |
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// license. Its contents can be found at:
// http://creativecommons.org/publicdomain/zero/1.0
package vlc
//#include <stdlib.h>
//#include <vlc/vlc.h>
import "C"
import (
"bytes"
"encoding/binary"
"unsafe"
)
// Generic event type.... |
// Code generated from FaultParser.g4 by ANTLR 4.8. DO NOT EDIT.
package parser // FaultParser
import "github.com/antlr/antlr4/runtime/Go/antlr"
type BaseFaultParserVisitor struct {
*antlr.BaseParseTreeVisitor
}
func (v *BaseFaultParserVisitor) VisitSpec(ctx *SpecContext) interface{} {
return v.VisitChildren(ctx)... |
package wphd
import (
"reflect"
"testing"
)
func TestGetPluginData(t *testing.T) {
var tests = []struct {
in string
expected *Plugin
}{
{`<?php
/**
* Plugin Name
*
* @package PluginPackage
* @author Your Name
* @copyright 2016 Your Name or Company Name
* @license GPL-2.0+
*
* @w... |
package util
// LowerBound restricts value to given lower bound
func LowerBound(value, bound int) int {
if value < bound {
return bound
}
return value
}
// UpperBound restricts value to given upper bound
func UpperBound(value, bound int) int {
if value > bound {
return bound
}
return value
}
|
package posting
import (
"testing"
"github.com/dgraph-io/dgraph/schema"
"github.com/dgraph-io/dgraph/types"
"github.com/stretchr/testify/require"
)
func TestIndexingInt(t *testing.T) {
schema.ParseBytes([]byte("scalar age:int @index"))
a, err := IndexTokens("age", types.Val{types.StringID, []byte("10")})
requ... |
package kuber
import (
"strings"
"github.com/reconquest/karma-go"
"k8s.io/apimachinery/pkg/runtime/schema"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
)
type GroupVersionResourceKind struct {
schema.GroupVersionResource
Kind... |
// Package main ...
package main
import (
"io/ioutil"
"log"
"github.com/go-rod/rod"
)
func main() {
u := "https://avatars.githubusercontent.com/u/33149672"
browser := rod.New().MustConnect()
page := browser.MustPage(u).MustWaitLoad()
b, err := page.GetResource(u)
if err != nil {
log.Fatal(err)
}
if e... |
package mdb
import (
"log"
"os"
"github.com/dgraph-io/badger"
"github.com/pkg/errors"
)
type DB struct {
*badger.DB
}
// New creates a new DB wrapper around LMDB
func New(folder string, cfg *Config) (*DB, error) {
os.MkdirAll(folder, os.ModePerm)
opts := badger.DefaultOptions(folder)
if cfg.Readonly {
lo... |
// controllers/books.go
package controllers
import (
"net/http"
models "Angel/Angel_Service_User/Models"
"github.com/gin-gonic/gin"
)
func Adduser(c *gin.Context) {
// Validate input
var input models.User
if err := c.ShouldBindJSON(&input); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Erro... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"strings"
"time"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
"github.com/atomicjolt/string_utils"
)
// CreateContentMigrationUsers Create a content migration. If th... |
package main
import (
"fmt"
"strings"
)
func main() {
str := "hello world you and me"
result := strings.Fields(str)
fmt.Printf("type is %T,value is %v\n", result, result)
for k, v := range result {
fmt.Printf("inidex=%d,value=%v\n", k, v)
}
}
|
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"github.com/bloveless/tweetgo"
)
type config struct {
OAuthConsumerKey string `json:"oauth_consumer_key"`
OAuthConsumerSecret string `json:"oauth_consumer_secret"`
OAuthAccessToken string `json:"oauth_access_token"`
OAuthAccessToken... |
package greetings
import (
"errors" /*nicewise, Go, doesn't know exceptions; errors go with the normal control flow*/
"fmt"
"math/rand"
"time"
)
/*
Functions with name with uppercase first letter are public functions,
Functions with name with lowercase first letter are packages private methods.
In Go terms, a c... |
package url
import (
"github.com/Dynatrace/dynatrace-operator/src/logger"
)
var (
log = logger.Factory.GetLogger("oneagent-url")
)
const (
VersionLatest = "latest"
)
|
/*
ARMed version 1.0
Author : https://github.com/coderick14
ARMed is a very basic emulator of the ARM instruction set written in Golang
USAGE : ARMed [OPTIONS]... SOURCE_FILE
Example SOURCE_FILE :
ADDI X0, XZR, #3;
BL fact;
B Exit;
fact: SUBI SP, SP, #8;
STUR LR, [SP, #4];
STUR X0, [SP, #0];
SUBIS ... |
package main
import (
"flag"
"fmt"
_ "goray/geometry"
"log"
"net/http"
"strconv"
)
func runRayTracer(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World")
}
/*
* Command line arguments allowed are: -port=xxxx
* Example: go run goray.go -port=9234
*/
func main() {
port := flag.Int("port",... |
package common
const AMQP_URL = "amqp://guest:guest@localhost:5672/"
|
/*
Copyright 2018 The Chronologist 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 rest
import (
"crypto/tls"
"github.com/jrapoport/gothic/store"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"github.com/jrapoport/gothic/models/types/key"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPaginateRequest(t *testing.T) {
req, err ... |
package models
import(
"encoding/json"
)
/**
* Type definition for QosTierEnum enum
*/
type QosTierEnum int
/**
* Value collection for QosTierEnum enum
*/
const (
QosTier_KLOW QosTierEnum = 1 + iota
QosTier_KMEDIUM
QosTier_KHIGH
)
func (r QosTierEnum) MarshalJSON() ([]byte, e... |
package arithmetic
import (
"errors"
)
// solve the postfix input.
func solve(input []interface{}) (interface{}, error) {
st := &stack{}
// read the input. For each token...
for _, t := range input {
// If it is a function, retreive the functions arguments: pop the operand
// stack to get the number of argu... |
package libdemo
func Print() {
//fmt.Println("Hello Static Library2")
}
|
package config
type (
Config struct {
Bot Bot
}
Bot struct {
Token string
Prefix string
}
)
|
package raft
//
// this is an outline of the API that raft must expose to
// the service (or tester). see comments below for
// each of these functions for more details.
//
// rf = Make(...)
// create a new Raft server.
// rf.Start(command interface{}) (index, term, isleader)
// start agreement on a new log entry
... |
package book
var pageImageID uint
//PageImage is used to store an image on a page
type PageImage struct {
ID uint `json:"id"`
Image string `json:"image"`
Width int `json:"width"`
Height int `json:"height"`
}
//GetID gets the ID of the current instance
func (p *PageImage) GetID() uint {
if p.ID <= ... |
package piscine
func ConcatParams(args []string) string {
a := 0
for i := range args {
a = i + 1
}
result := make([]string, a)
for j := 0; j < (a - 1); j++ {
result[1] = result[1] + args[j] + "\n"
}
result[1] = result[1] + args[(a-1)]
return result[1]
}
|
package serializer
import (
"bytes"
"encoding/binary"
"encoding/json"
"fmt"
"sort"
)
// Serializable is something which knows how to serialize/deserialize itself from/into bytes
// while also performing syntactical checks on the written/read data.
type Serializable interface {
json.Marshaler
json.Unmarshaler
... |
package main
import (
"fmt"
)
func main() {
slice := []int{1, 2, 3}
for i := 0; i < len(slice); i++ {
fmt.Println(slice[i])
}
for i, v := range slice {
fmt.Println(i, v)
}
wellKnownPorts := map[string]int{"http": 80, "https": 443}
for k, v := range wellKnownPorts {
// Mandatroy to use the variable h... |
package main
import "fmt"
func main() {
cache := Constructor(2)
fmt.Println(cache.Get(2))
cache.Put(2, 6)
fmt.Println(cache.Get(1))
cache.Put(1, 5)
cache.Put(1, 2)
fmt.Println(cache.Get(1))
fmt.Println(cache.Get(2))
}
type LRUCache struct {
cacheMap map[int]*node
head *node
tail *node
capacity *i... |
package astParser
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"log"
"os"
"path/filepath"
"reflect"
"regexp"
"strings"
"github.com/bykof/go-plantuml/domain"
)
var earlySeenFunctions map[string]domain.Functions
func ParseDirectory(directoryPath string, opts ...ParserOptionFunc) domain.Packages {
option... |
package main
import (
"os"
"github.com/alecthomas/kingpin"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/b-b3rn4rd/gocfn/pkg/writer"
"github.com/sirupsen/logrus"
)
var (
version = "master"
debug = kingpin.Flag("debug", "Enable debug logging.").Short('d').Bool()
logger = logrus.New(... |
package config
import (
"time"
"shared/utility/glog"
"shared/utility/mysql"
"github.com/go-redis/redis/v8"
)
type Config struct {
Service string
ServerName string
GRPCListenPort string
ETCDEndpoints []string
TCPConnKeepAlive time.Duration // tcp连接保持时间
MaxConn int
Redis ... |
package comparisons
import (
"jvm-go/instruction/base"
"jvm-go/runtimedata"
)
// 比较Long变量
type LCMP struct { base.NoOperandsInstruction }
// 将栈顶的两个long变量弹出,进行比较,将比较结果(0、1、-1)推入栈顶
func (self *LCMP) Execute(frame *runtimedata.Frame) {
stack := frame.OperandStack()
v2 := stack.PopLong()
v1 := stack.PopLong()
if v... |
package pipa
import (
"sync"
"time"
)
// InputStream reads messages from the consumer
type InputStream struct {
consumer Consumer
notifier Notifier
}
// NewInputStream wraps a consumer into a message stream
func NewInputStream(consumer Consumer, notifier Notifier) *InputStream {
return &InputStream{consumer: co... |
package sqlite
import (
"database/sql"
"github.com/7phs/coding-challenge-search/db/common"
"github.com/7phs/coding-challenge-search/model"
)
type QueryItemsLoad struct{}
func (o QueryItemsLoad) Query() string {
return `
SELECT
item_name,
lat,
lng,
item_url,
img_urls
FROM
items
`
}
func (o QueryI... |
package apiservice
import (
"log"
"net/http"
"time"
"goji.io/middleware"
)
func (cl *Client) recoverPanic(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
log.Printf("panic recovery: %+v", err)
http.Error(w, http... |
package turingapi
import (
"github.com/gin-gonic/gin"
"spoon/util/turingapi"
"spoon/handler"
)
// 与机器人进行文字聊天
func ChatBot(c *gin.Context) {
text := c.PostForm("text")
err, result := turingapi.ChatRobotWithText(text, nil)
if err != nil {
handler.SendResponse(c, err, nil)
} else {
handler.SendResponse(c, nil... |
package Trapping_Rain_Water
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTrap(t *testing.T) {
ast := assert.New(t)
test1 := []int{0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}
ast.Equal(6, trap(test1))
ast.Equal(6, trap2(test1))
ast.Equal(6, trap3(test1))
}
|
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"github.com/urfave/cli"
"github.com/bitmark-inc/bitmarkd/fault"
)
func runAdd(c *cli.Context) error {
m := c.Ap... |
// Copyright (C) 2017 Google 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 t... |
package LeetCode
func Code23() {
l1 := InitSingleList([]int{-9, 5, 7})
l2 := InitSingleList([]int{2, 4, 6})
l3 := InitSingleList([]int{4, 5, 6})
arr := []*ListNode{l1, l2, l3}
PrintSingleList(mergeKLists(arr))
}
/**
合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。
示例:
输入:
[
1->4->5,
1->3->4,
2->6
]
输出: 1->1->2->3->4-... |
package storage
import (
"errors"
"fmt"
"github.com/futurehomeno/fimpgo"
"github.com/futurehomeno/fimpgo/fimptype/primefimp"
log "github.com/sirupsen/logrus"
"github.com/thingsplex/tpflow"
"github.com/thingsplex/tpflow/registry/model"
)
type VinculumRegistryStore struct {
vApi *primefimp.ApiClient
ms... |
package version
import "github.com/hashicorp/go-version"
func Assert(v, constraint string) (bool, error) {
cv, err := version.NewVersion(v)
if err != nil {
return false, err
}
constraints, err := version.NewConstraint(constraint)
if err != nil {
return false, err
}
return constraints.Check(cv), nil
}
|
package usecase
import (
"github.com/Okaki030/hinagane-scraping/domain/repository"
)
// articleUseCase はスクレイピングプログラムに必要な構造体をまとめた構造体
type articleS3UseCase struct {
articleRepository repository.ArticleS3Repository
memberCountRepository repository.MemberCountS3Repository
wordCountRepository repository.WordCoun... |
package app
// TODO: Decouple this from the application, investigate Traefik's CLI args
import (
"github.com/urfave/cli"
)
func GetOpts() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "run, r",
Usage: "For running a local CI definition",
EnvVar: "DEBUG",
},
cli.StringFlag{
... |
package model
type Wallet struct {
ID uint `gorm: "primaryKey"`
Balance float32 `gorm: "not null,default:'0'"`
}
|
package main
import (
"io/ioutil"
"fmt"
"bufio"
"strings"
"strconv"
)
func main() {
// Read file
fileContent, err := ioutil.ReadFile("input.txt")
if err != nil {
fmt.Print(err)
}
input := string(fileContent)
fmt.Println("Part 1")
fmt.Println(Problem1("0\n3\n0\n1\n-3"), "should be 5")
fmt.Println("the ... |
package rod_test
import (
"fmt"
"time"
"github.com/ysmood/kit"
"github.com/ysmood/rod"
"github.com/ysmood/rod/lib/input"
"github.com/ysmood/rod/lib/launcher"
"github.com/ysmood/rod/lib/proto"
)
// Open wikipedia, search for "idempotent", and print the title of result page
func Example_basic() {
// launch and... |
package main
import (
"log"
"fmt"
)
func (cli *PHBCLI) phbgetBalance(address, nodeID string) {
if !PHBValidateAddress(address) {
log.Panic("ERROR: Address is not valid")
}
bc := PHBNewBlockchain(nodeID)
UTXOSet := PHBUTXOSet{bc}
defer bc.phbdb.Close()
balance := 0
pubKeyHash := PHBBase58Decode([]byte(addr... |
// 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 consent
func ParseConsentVersion(s string) (byte, error) {
if len(s) == 0 {
return 0, ErrUnexpectedEnd
}
// string is base64-encoded and version is encoded in the first 6 bits (i.e. first char in b64 string)
switch s[0] {
case 'B':
return 1, nil
case 'C':
return 2, nil
}
return 0, ErrUnsupported
... |
/*
Copyright 2021 Gravitational, 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 in writing, soft... |
package user
import (
"github.com/gin-gonic/gin"
"fmt"
"github.com/goweb/model"
"github.com/goweb/db"
"net/http"
"github.com/goweb/common"
)
func Save(c *gin.Context) {
name := c.Query("name")
pwd := c.Query("password")
email := c.Query("email")
fmt.Printf("save user %s in controller\n",name)
var u mode... |
// Package game contains data structures and functions which encapsulate the
// complete set of rules of "Tic Tac Toe 2.0".
package game
import (
"errors"
)
const (
RequiredNumberOfPlayers = 3
)
var (
ErrSizeIllegal = errors.New("size illegal")
)
// Move represents a Player's intended action. It contains their ... |
package main
import "fmt"
func main() {
//加一
/**
最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。你可以假设除了整数 0 之外,这个整数不会以零开头。
示例 1:
输入: [1,2,3]
输出: [1,2,4]
解释: 输入数组表示数字 123。
示例 2:
输入: [4,3,2,1]
输出: [4,3,2,2]
解释: 输入数组表示数字 4321。
*/
nums := []int{4, 3, 2, 1}
nums2 := []int{9, 9, 9, 9}
fmt.Println(plusOne(nums))
fmt.Print... |
package post
import (
"io/ioutil"
"log"
"net/http"
"github.com/cc2k19/go-tin/storage"
"github.com/cc2k19/go-tin/web"
)
type controller struct {
repository storage.Repository
credentialsExtractor web.CredentialsExtractor
}
func (c *controller) add(rw http.ResponseWriter, r *http.Request) {
defer r.... |
package main
import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"os"
)
func countFile(filepath string) (*FileStats, error) {
fin := os.Stdin
if filepath != "/dev/stdin" {
inf, err := os.Lstat(filepath)
if err != nil || inf.IsDir() {
return nil, fmt.Errorf("invalid file entry")
}
f, err := os.Open(filepath)
... |
package main
import (
//"bufio"
"fmt"
"os"
// "strings"
)
// a plumbService coordinates communication between a de process, and a deplumber
// process.
//
// (The deplumber process communicates with the p9p plumber and receives messages.
// It decides whether or not to spawn a new window or re-use the existing on... |
package api
import (
"github.com/gin-gonic/gin"
"github.com/oceanho/gw"
"github.com/oceanho/gw/contrib/apps/tester/biz"
"github.com/oceanho/gw/contrib/apps/tester/dto"
)
func CreateMyTester(c *gw.Context) {
obj := &dto.MyTester{}
if c.Bind(obj) != nil {
return
}
err := biz.CreateMyTester(c.Store().GetDbStor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.