text stringlengths 11 4.05M |
|---|
package model
type Order struct {
UserId int64 `json:"user_id"`
OrderGoods []CartGoods `json:"goods"`
TotalPrice float64 `json:"total_price"`
Consignee string `json:"consignee"`
Mobile int64 `json:"mobile"`
Province string `json:"province"`
City string `json:"city... |
package url
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFnPort(t *testing.T) {
f := &fnPort{}
input := "https://subdomain.example.com:8080/path?q=hello world#fragment with space"
v, err := f.Eval(input)
assert.Nil(t, err)
assert.Equal(t, "8080", v)
}
|
package connection
import (
jsoniter "github.com/json-iterator/go"
)
var json = jsoniter.ConfigFastest
|
package mailchimp_test
import (
"context"
"net/url"
"os"
"testing"
"github.com/spotlightpa/almanack/internal/mailchimp"
)
func TestV3(t *testing.T) {
apiKey := os.Getenv("ALMANACK_MC_TEST_API_KEY")
listID := os.Getenv("ALMANACK_MC_TEST_LISTID")
if apiKey == "" || listID == "" {
t.Skip("Missing MailChimp E... |
package server
import (
"fmt"
"log"
"net/http"
"runtime/debug"
"text/template"
"github.com/Gigamons/common/logger"
"github.com/gorilla/mux"
)
func errHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err !... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
package sync2
import (
"context"
"time"
"storj.io/common/time2"
)
// Sleep implements sleeping with cancellation.
func Sleep(ctx context.Context, duration time.Duration) bool {
return time2.Sleep(ctx, duration)
}
|
package database
import (
"log"
"math/rand"
"strconv"
utils "banners.utils"
_ "github.com/denisenkom/go-mssqldb"
"github.com/jmoiron/sqlx"
)
func Seed() {
db, err := sqlx.Open("sqlserver", ConnectionString)
if err != nil {
log.Fatal(err)
} else {
InitializeTables(*db)
}
defer db.Close()
}
func Initi... |
package generator
import (
"fmt"
"os"
"time"
"github.com/RomanosTrechlis/blog-generator/config"
"github.com/beevik/etree"
)
// rssGenerator object
type rssGenerator struct {
posts []*post
destination string
siteInfo *config.SiteInformation
}
const rssDateFormat = "02 Jan 2006 15:04 -0700"
// Gener... |
package receiver
import (
"encoding/json"
"fmt"
"io"
"net"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/mariusler/filesender/config"
"github.com/mariusler/filesender/messages"
"github.com/mariusler/filesender/progressBar"
"github.com/mariusler/filesender/utility"
)
// Receiver calles when... |
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package ownership provides utilities to run ownership API related tests.
package ownership
import (
"chromiumos/policy/chromium/policy/enterprise_management_proto"
lm "... |
package examples
import "context"
/*
* 支持自定义请求路径,每一个自定义路径都将进行匹配。
*/
// @HttpGet("/user")
// @HttpGet("/user/more")
// @HttpPost("/user")
// @HttpPost("/user/info")
func User5() {}
/*
* 路径模糊匹配也是支持的。被匹配上的参数,将存放在 context 中等待被获取。
* 该方法不会匹配 /user/
*
* 需要注意的是:如果有确定的路径被注册,将优先使用确定的路径。
* 例如:还有一个方法 UserAdmin,路径 `/user/... |
package filesystem
import (
"io/ioutil"
"os"
"reflect"
"github.com/juntaki/transparent"
"github.com/juntaki/transparent/simple"
"github.com/pkg/errors"
)
// simpleStorage store file at directory, filename is key
type simpleStorage struct {
directory string
}
// NewSimpleStorage returns SimpleStorage
// Simpl... |
package model
import (
"github.com/jinzhu/gorm"
)
type Author struct{
gorm.Model
Id string
Name string
Introduce string
Love int
View int
}
|
package main
import "C"
//export _TestPlugin_Test_GoPlugin
func _TestPlugin_Test_GoPlugin() {
p.Test()
}
//export _Type
func _Type() uint16 {
return uint16(example_plugin)
}
func main() {}
|
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package feedback
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/apps"
"chromiumos/tast/local/chrome"
"chromiumos... |
package logs
import "testing"
func testConsole(bl *BeeLogger) {
bl.Emergency("emergency")
bl.Alert("alter")
bl.Critical("critical")
bl.Error("error")
bl.Warn("warning")
bl.Notice("notice")
bl.Info("informational")
bl.Debug("debug")
}
func TestConsole(t *testing.T) {
log1 := NewLogger(10000)
log1.EnableFunc... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package main
return
|
/*
*Author: Eddie_Ivan
*Blog: http://nemesisly.xyz
*Github: https://github.com/eddieivan01
*
*爬虫代理IP池
*抓取
* http://www.xicidaili.com
* http://www.66ip.cn
* https://list.proxylistplus.com
*三家代理IP,存入本地Sqlite3数据库中,并在本地开启Http Server监听,提供json API服务
*
*程序架构:
*+ 判断本地是否已存在数据库
* + =>True: 返回数据库句柄,pass
* + =>False: 建立... |
package gosys
import (
"testing"
"fmt"
)
//str
func Test_GetneiIp_str(t *testing.T) {
a:=NewAddr(4440)
a.IntranetAddr()
fmt.Println(a.GetIPstr())
}
func Test_GetwaiIp_str(t *testing.T) {
a:=NewAddr(4441)
a.ExternalAddr()
fmt.Println(a.GetIPstr())
}
func Test_Getlocal_str(t *testing.T) {
a:= NewAddr(4002)
... |
// Copyright 2016 The Lucas Alves Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"encoding/json"
"github.com/luk4z7/pagarme-go/auth"
"github.com/luk4z7/pagarme-go/lib/recipient"
"net/url"
"os"
)
var recip... |
package orders
import (
"app/utils"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"unsafe"
)
var URL = utils.GetStateStoreUrl()
func GetHandler(w http.ResponseWriter, r *http.Request) {
url := URL + "/order"
resp, e := http.Get(url)
if resp != nil {
defer resp.Body.Close()
}
if e != nil {
fmt... |
package user
import (
"log"
"net/http"
"github.com/lazhari/web-jwt/models"
"github.com/lazhari/web-jwt/utils"
"golang.org/x/crypto/bcrypt"
)
type userService struct {
authRepo Repository
}
// NewAuthService creates a new auth service
func NewAuthService(userRepo Repository) Service {
return &userService{
u... |
package preprocess
import (
"testing"
"github.com/jagandecapri/vision/tree"
"github.com/stretchr/testify/assert"
)
func TestNormalize(t *testing.T) {
points := []tree.Point{{Id: 1, Vec_map: map[string]float64{
"first": 5,
"second": 10,
}},
{Id: 2, Vec_map: map[string]float64{
"first": 2,
"second": 6,
}... |
package broker
import (
"context"
"github.com/LiveRamp/gazette/v2/pkg/allocator"
pb "github.com/LiveRamp/gazette/v2/pkg/protocol"
"github.com/coreos/etcd/clientv3"
"golang.org/x/net/trace"
)
// Service is the top-level runtime concern of a Gazette Broker process. It
// drives local journal handling in response ... |
package go_image
import (
"fmt"
"testing"
)
//将某一图片文件进行缩放后存入另外的文件中
func TestImage(t *testing.T) {
//打印当前文件夹位置
fmt.Printf("本文件文件夹位置:%s\n", CurDir())
//图像位置
filename := "./testdata/gopher.png"
//宽度,高度
width := 500
height := 800
//保存位置
save1 := "./testdata/gopher500.jpg"
save2 := "./testdata/gopher500_800... |
/*
* @lc app=leetcode.cn id=124 lang=golang
*
* [124] 二叉树中的最大路径和
*/
// @lc code=start
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func maxPathSum(root *TreeNode) int {
if root == nil {
return 0
}
var max = new(int)
... |
package main
import (
"context"
"encoding/json"
"fmt"
"runtime"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func Handler(_ context.Context, r events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
data, _ := json.Marshal(map[string]interface{}{
"message": ... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package inputs
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/bundles/cros/inputs/fixture"
"chromiumos/tast/local/bundles/cros/inputs/pre"
... |
// Package recode rewrites json-interface objects ( with golang upper case keys )
// to Json dictionaries ( and lowercase keys. )
package recode
import "strings"
type jsonSlice []interface{}
type jsonMap map[string]interface{}
func Dict(src jsonMap) jsonMap {
dst := map[string]interface{}{}
for k, v := range src {... |
package ircmsg
import (
"testing"
)
func TestParseMessage(t *testing.T) {
msg_string := ":kyle!~kyle@localhost PRIVMSG #tenyks :tenyks: messages are awesome"
msg := ParseMessage(msg_string)
if msg == nil {
t.Error("Expected", Message{}, "got", msg)
}
if msg.Command != "PRIVMSG" {
t.Error("Expected", Messag... |
package model
import (
"crypto/rand"
"encoding/base64"
"sync"
"time"
)
// News type
type News struct {
ID string
Title string
Image string
Detail string
CreatedAt time.Time
UpdatedAt time.Time
}
var (
newsStorage []News
mutexNews sync.RWMutex
)
func generateID() string {
buf := make... |
package main
import (
"fmt"
)
type gopher struct{
name string
age int
isAdult bool
}
func (g gopher) jump() string {
if g.age < 64 {
return g.name + " can jump HIGH"
}
return g.name + " can still jump"
}
// This will pass it in as a copy
// func validateAge(g gopher) {
// g.isAdult = g.age >= 21
... |
package main
import "Craftorio/game"
func main() {
game := game.New()
game.Init()
}
|
package main
//1450. 在既定时间做作业的学生人数
//给你两个整数数组 startTime(开始时间)和 endTime(结束时间),并指定一个整数 queryTime 作为查询时间。
//
//已知,第 i 名学生在 startTime[i] 时开始写作业并于 endTime[i] 时完成作业。
//
//请返回在查询时间 queryTime 时正在做作业的学生人数。形式上,返回能够使 queryTime 处于区间 [startTime[i], endTime[i]](含)的学生人数。
//
//
//
//示例 1:
//
//输入:startTime = [1,2,3], endTime = [3,2,7... |
package Pigeon
import "github.com/gorilla/websocket"
type MessagesRepo struct {
messages []*Message
}
type WebSocketsRepo struct {
connections []*websocket.Conn
}
var MessagesRepository = MessagesRepo{}
var WebSocketsRepository = WebSocketsRepo{}
func (r *MessagesRepo) Add(m *Message) {
if r.messages ... |
package standard
import (
. "github.com/ionous/sashimi/script"
)
//
func init() {
AddScript(func(s *Script) {
// FIX: the player should really be a global variable; not an actor instance.
// ( or, possibly a game object type of which there is one, with a relation of an actor. )
s.The("actor",
Called("playe... |
package googlecloud
import (
"context"
"fmt"
"net"
"strconv"
"sync"
"testing"
"time"
vkit "cloud.google.com/go/logging/apiv2"
"github.com/golang/protobuf/ptypes"
tspb "github.com/golang/protobuf/ptypes/timestamp"
"github.com/observiq/stanza/entry"
"github.com/observiq/stanza/operator/buffer"
"github.com/... |
package manager
import (
"github.com/liasece/micchaos/ccmd"
"github.com/liasece/micchaos/mongodb"
"github.com/liasece/micchaos/playermodule/boxes"
"github.com/liasece/micserver/log"
"github.com/liasece/micserver/module"
"github.com/liasece/micserver/roc"
"go.mongodb.org/mongo-driver/bson"
)
type PlayerDocManag... |
package main
type task struct {
ID int `json:"ID"`
Name string `json:"Name"`
Content string `json:"Content"`
}
var tasks = allTasks{
{
ID: 1,
Name: "Test Task",
Content: "Some first content for test",
},
}
type allTasks []task
|
package multierror_test
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/socialpoint-labs/bsk/multierror"
)
func TestAppend(t *testing.T) {
t.Parallel()
t.Run("it returns nil if no errors", func(t *testing.T) {
assert.Nil(t, multierror.Append(multierror.Append()))
assert.Nil(t... |
package lc
import "math"
// Time: O(n*m)
// Benchmark: 4ms 6mb | 99%
func coinChange(coins []int, amount int) int {
min := func(x, y int) int {
if x < y {
return x
}
return y
}
sums := make([]int, amount+1)
for i := 1; i <= amount; i++ {
sums[i] = math.MaxInt32
for j := 0; j < len(coins); j++ {
... |
package strategy02
import (
"finantial/ema"
"finantial/rsi"
"fmt"
"log"
. "markets/exchange"
"markets/generic"
"markets/poloniex"
"time"
tgbotapi "gopkg.in/telegram-bot-api.v4"
)
var UNDEF = int32(-1)
var TRUE = int32(1)
var FALSE = int32(0)
var exchange Exchange = poloniex.Poloniex{}
var bot *tgbotapi.Bot... |
package db
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
)
type Game struct {
ID string `bson:"_id"`
Competition string `bson:"competition"`
Home []string `bson:"... |
package models
import (
"bytes"
"encoding/json"
"strings"
"time"
)
type StringArray []string
func (s *StringArray) FromDB(bts []byte) error {
if len(bts) == 0 {
return nil
}
str := string(bts)
if strings.HasPrefix(str, "{") {
str = str[1:len(str)]
}
if strings.HasSuffix(str, "}") {
str = str[0: le... |
// 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 adding
import (
"github.com/elhamza90/lifelog/internal/domain"
)
// NewActivity validates the activity and calls the repo to store it.
// It does the following checks:
// - Check primitive fields are valid
// - Check Tags exist in DB
func (srv Service) NewActivity(act domain.Activity) (domain.ActivityID, err... |
// 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 scheduler_test
import (
"testing"
"time"
"github.com/waybeams/waybeams/pkg/clock"
"github.com/waybeams/waybeams/pkg/ctrl"
"github.com/waybeams/waybeams/pkg/spec"
"github.com/waybeams/assert"
"github.com/waybeams/waybeams/pkg/env/fake"
"github.com/waybeams/waybeams/pkg/scheduler"
)
func TestSchedule... |
// Package display provides controllers that update the status fields on several resources.
package display
import (
"context"
"fmt"
"strings"
"github.com/rancher/fleet/internal/cmd/controller/summary"
fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
fleetcontrollers "github.com/rancher/fleet/... |
package service
import (
"html/template"
"net/http"
"github.com/NYTimes/gizmo/server"
)
// Demo will serve an HTML page that demonstrates how to use the 'stream'
// endpoint.
func (s *StreamService) Demo(w http.ResponseWriter, r *http.Request) {
vals := struct {
Port int
StreamID int64
}{
s.port,
se... |
package br_test
import (
"testing"
"time"
"github.com/olebedev/when"
"github.com/olebedev/when/rules"
"github.com/olebedev/when/rules/br"
)
func TestPastTime(t *testing.T) {
fixt := []Fixture{
{"meia hora atrás", 0, "meia hora atrás", -(time.Hour / 2)},
{"1 hora atrás", 0, "1 hora atrás", -(time.Hour)},
... |
package text
import "strings"
// ReleaseNotes generates the output mentioned in the expected-output.md
func ReleaseNotes(sections Sections) string {
builder := strings.Builder{}
// Extra lines at the start to make sure formatting starts correctly
builder.WriteString("\n\n")
if len(sections.Features) > 0 {
buil... |
package geo
import (
"bytes"
"fmt"
"io"
"math"
)
// Path represents a set of points to be thought of as a polyline.
type Path struct {
points []Point
}
func NewPath() *Path {
p := &Path{}
p.points = make([]Point, 0, 1000)
return p
}
// SetPoints allows you to set the complete pointset yourself.
// Note tha... |
// support {} pattern like
// - /api/user/{userid}/info
// - /api/user/user-{userid}/info
// not support
// - /api/user/{userid}-user/info
package main
import (
"fmt"
)
const (
patternStart = '{'
patternEnd = '}'
separator = '/'
)
func main() {
t := &tree{}
t.Insert("/api/user", func() {
fmt.Println("cert... |
package main
func main() {
tt := new(MyCircularDeque).Constructor(3)
tt.InsertFront(1)
tt.InsertFront(2)
tt.InsertLast(3)
}
type DoubleListNode struct {
pre *DoubleListNode
next *DoubleListNode
val int
}
type MyCircularDeque struct {
size int
k int
head *DoubleListNode
tail *DoubleListNode
}
/** I... |
package neo4j
import (
"encoding/json"
"fmt"
"github.com/go-ginger/helpers"
"github.com/go-ginger/models"
"github.com/neo4j/neo4j-go-driver/neo4j"
"math"
"strings"
)
func (handler *DbHandler) countDocuments(query string, params map[string]interface{},
done chan bool, count *uint64) {
session, err := handler.... |
// Copyright 2018 The gVisor 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 agree... |
package server
import (
"net/http"
"strconv"
"github.com/go-chi/chi"
"github.com/pkg/errors"
"nidavellir/services/store"
)
type IAccountStore interface {
GetAccount(name string) (*store.Account, error)
AddAccount(account *store.Account) (*store.Account, error)
UpdateAccount(account *store.Account) (*store.A... |
package test
import (
"testing"
"dwc.com/lumiere/utils"
)
func Test_GeneratorGeneratesCodeOfLength(t *testing.T) {
expectedLength := 10
generator := utils.CodeGenerator{}
code, err := generator.Generate(expectedLength)
if err != nil {
t.Errorf("Did not expect error: %v", err)
}
if len(code) != expectedLen... |
//
// Illustration of the behavior of appengine/search with stemming in queries :
// stemming seems to be ignored by "goapp serve" on localhost,
// but works well in prod at http://gae-go-stemming.appspot.com/ .
//
// Official doc is https://cloud.google.com/appengine/docs/go/search/query_strings#Go_Stemming
//
packa... |
package jumphelper
import (
"fmt"
"strconv"
)
// ServerOption is a server option
type ServerOption func(*Server) error
//SetServerAddressBookPath sets the host of the Server client's SAM bridge
func SetServerAddressBookPath(s string) func(*Server) error {
return func(c *Server) error {
c.addressBookPath = s
r... |
package main
/**
BMI계산기
키, 몸무게를 입력받아 체질량 지수를 계산하는 프로그램을 작성하라
bmi = (weight / (height * height))
bmi값이 18.5~25 사이로 나타나면 정상적인 몸무게라고 출력하고
그렇지 않는 경우는 과체중이나 저체중으로 나타낸다음
의사와 상의하라는 문구도 출력해보자
*/
import (
"fmt"
"bufio"
"os"
"strconv"
)
const lowerBound = 18.5
const higherBound = 25
func inFloat(txt string) float64 {
... |
package main
import (
"testing"
)
const testData = "2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2"
func TestTask1(t *testing.T) {
rootNode := getRootNode(testData)
expected := 138
actual := getMetadataSum(rootNode)
if actual != expected {
t.Error("Expected ", expected, ", got ", actual)
}
}
func TestTask2(t *testin... |
// Copyright 2017 The Kubernetes Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... |
package gb32100
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseCode(t *testing.T) {
u, err := ParseCode("91350100M000100Y43")
assert.NoError(t, err)
assert.Equal(t, &Code{
RegAdminCode: "9",
OrgTypeCode: "1",
DivisionCode: "350100",
OrgCode: "M000100Y4",
Sum: "3... |
package handlers
import (
"fmt"
"strconv"
"strings"
"d7y.io/dragonfly/v2/manager/service"
"github.com/gin-gonic/gin"
)
type Handlers struct {
Service service.REST
}
func New(service service.REST) *Handlers {
return &Handlers{Service: service}
}
func (h *Handlers) setPaginationDefault(page, perPage *int) {
... |
// SPDX-License-Identifier: MIT
//go:build ignore
// +build ignore
package main
import (
"io/ioutil"
"os"
"github.com/caixw/apidoc/v7/core"
"github.com/caixw/apidoc/v7/internal/ast/asttest"
"github.com/caixw/apidoc/v7/internal/xmlenc"
)
func main() {
data, err := xmlenc.Encode("\t", asttest.Get(), core.XMLNa... |
package clusterregistration
//go:generate mockgen --build_flags=--mod=mod -destination=../../mocks/service_account_cache_mock.go -package=mocks github.com/rancher/wrangler/pkg/generated/controllers/core/v1 ServiceAccountCache
//go:generate mockgen --build_flags=--mod=mod -destination=../../mocks/secret_cache_mock.go -... |
package controller
import (
"fmt"
"github.com/go-lib-utils-master/time"
"io"
"log"
"mime/multipart"
"net/http"
"os"
"strconv"
"strings"
"text/template"
time2 "time"
"web/Cinema/modle"
"web/Cinema/utils"
)
const PATH = "D:\\gogo\\src\\web\\Cinema\\view\\static\\img\\"
func UpLoadImg(f multipart.File, h *... |
package main
import "fmt"
func sendx(ch chan int) {
i := 0
for {
i++
ch <- i
}
}
func recvx(ch chan int) {
value := <- ch
fmt.Println(value)
value = <- ch
fmt.Println(value)
close(ch)
}
func main() {
var ch = make(chan int, 4)
go recvx(ch)
sendx(ch)
}
|
package limiter
import (
"time"
"github.com/gin-gonic/gin"
"github.com/juju/ratelimit"
)
type LimitInterface interface {
Key(c *gin.Context) string
GetBucket(key string) (*ratelimit.Bucket, bool)
AddBucket(rules ...BucketRule) LimitInterface
}
type Limiter struct {
limiterBuckets map[string]*ratelimit.Bucke... |
package main
func (a *App) initializeRoutes() {
// endpoints
a.Router.HandleFunc("/reviews/status", a.getStatus).Methods("GET")
a.Router.HandleFunc("/reviews", a.getAllMyReviews).Methods("GET")
a.Router.HandleFunc("/reviews", a.createReview).Methods("POST")
a.Router.HandleFunc("/reviews/{reviewId}", a.getReview)... |
/*
* Licensed to Echogogo under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Echogogo licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except ... |
package main
import (
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
"log"
)
func GetAllProcessingHashes() []string {
processingHashSearchKey := fmt.Sprintf("ProcessingHash:%s:%s", "*", "*")
processingHashes := RedisSearchKeys(processingHashSearchKey)
return processingHashes
}
func GetAllProcessingItems(_... |
package controllers
import (
"context"
"encoding/json"
"fmt"
"math"
"net/url"
"os"
"regexp"
"strconv"
"strings"
"time"
"github.com/MakeNowJust/heredoc"
"github.com/go-logr/logr"
getter "github.com/hashicorp/go-getter"
tfv1alpha2 "github.com/isaaguilar/terraform-operator/pkg/apis/tf/v1alpha2"
"github.co... |
package main
import (
"fmt"
"os"
"strings"
)
var directories []string = []string {
"/home/continuum",
"/storage",
"/storage01/replication",
"/storage02/replication",
"/storage03/replication",
"/storage04/replication",
"/storage05/replication",
"/storage06/replication",
"/storage07/replication",
"/storag... |
package enums
//MsgTypes he~he~
type MsgTypes uint16
|
package main
import (
"github.com/gorilla/mux"
"io"
"log"
"net/http"
)
func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {
// 一个非常简单的健康检查实现:如果此 HTTP 接口调用成功,则表示应用健康
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
// 后续我们还可以通过执行 PING 指令反馈 DB、缓存状态,并将它们的健康检查结果放到响应中
i... |
// Copyright 2017 The Bazel Authors. 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 appl... |
package xhtml5_test
import (
. "github.com/bytesparadise/libasciidoc/testsupport"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("unordered lists", func() {
It("simple unordered list with no title", func() {
source := `* item 1
* item 2
* item 3`
expected := `<div class="ulist">... |
package cmd
import (
"fmt"
"regexp"
"strings"
)
// formatHelp formats the help text for Cmd or Group.
func formatHelp(usage, summary, details string, defs []*definitionList) string {
columns := terminalColumns()
sections := []string{}
sections = append(sections, wrapParagraphs(usage, columns))
if summary != ""... |
package runner
import (
"strings"
"testing"
)
func TestConvertEnvMapToList(t *testing.T) {
t.Run("should convert map to list of key=val", func(t *testing.T) {
env := make(map[string]string, 1)
env["ONE"] = "1"
envList := convertEnvMapToList(env)
exp := "ONE=1"
if envList[0] != exp {
t.Errorf("failed t... |
package cmd
import (
"fmt"
"github.com/fsnotify/fsnotify"
"github.com/jweny/pocassist/api/routers"
conf2 "github.com/jweny/pocassist/pkg/conf"
"github.com/jweny/pocassist/pkg/db"
"github.com/jweny/pocassist/pkg/logging"
"github.com/jweny/pocassist/pkg/util"
"github.com/jweny/pocassist/poc/rule"
"github.com/sp... |
package cmd
import (
"testing"
"net/http/httptest"
"net/http"
"io/ioutil"
"github.com/HotelsDotCom/flyte/flytepath"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/HotelsDotCom/flyte/httputil"
"fmt"
)
func TestUploadDs_ShouldUploadDsFromFile(t *testing.T) {
//given
re... |
package gb11714
func Prev(s string) (string, error) {
n, err := dec(s[0:ContentLen])
return build(n, -1), err
}
func Next(s string) (string, error) {
n, err := dec(s[0:ContentLen])
return build(n, +1), err
}
func build(n int, d int) string {
v := n
for {
v += d
// GB 32100-2015
switch (v % 36) - 10 + 'A'... |
//go:build e2e
package cloudnativeproxy
import (
"context"
"path"
"testing"
"github.com/Dynatrace/dynatrace-operator/src/api/v1beta1"
"github.com/Dynatrace/dynatrace-operator/src/kubeobjects"
"github.com/Dynatrace/dynatrace-operator/test/dynakube"
"github.com/Dynatrace/dynatrace-operator/test/kubeobjects/daem... |
package array
import (
"testing"
"github.com/stretchr/testify/assert"
)
var d = &Delete{}
func TestStaticDelete(t *testing.T) {
expectedResult := []string{"Cat", "Dog", "Snake"}
final, err := d.Eval(expectedResult, 2)
assert.Nil(t, err)
assert.Equal(t, []string{"Cat", "Dog"}, final)
}
|
// 微信支付参数服务列表
// 1. 新增公众号支付开发参数
// 2. 获取公众号支付开发参数
// 3. 上传证书 证书包括apiclient_key.pem和apiclient_cert.pem
package controllers
import (
"encoding/json"
"github.com/1046102779/common/consts"
. "github.com/1046102779/official_account/logger"
"github.com/1046102779/official_account/models"
"github.com/astaxie/beego"
"g... |
package heap
import (
"fmt"
)
func ExampleHeap() {
h := &Heap{}
for _, v := range []int{8, 19, 12, 23, 78} {
h.Add(v)
}
for v := range h.Traverse() {
fmt.Printf(" %d", v)
}
fmt.Println()
h.Remove(8)
for v := range h.Traverse() {
fmt.Printf(" %d", v)
}
fmt.Println()
h.Add(8)
for v := range h.Trav... |
package bkz
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
)
type Book struct {
Title string
Author string
ISBN string
Genre string
Id string
}
// Creates an account and adds it to the Database
func CreateBook(book *Book) bool {
session, err := mgo.Dial("127.0.0.1:27017/")
if err != nil {
... |
package endpoint
import (
"fmt"
)
type Endpoint interface {
Upload(destFolder, endpointUsername, endpointPassword, endpointURL string) error
}
func New(endpointType string) (endpoint Endpoint, err error) {
switch endpointType {
case "git":
endpoint = newGitEndpoint()
default:
err = fmt.Errorf("no endpoint i... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"sync"
"github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
"time"
)
type DbConf struct {
User string `json:"user"`
PassWord string `json:"passWord"`
Host string `json:"host"`
Name string `json:"name"`
}
type ... |
package main
import (
"fmt"
"github.com/duego/mongotool/storage"
"labix.org/v2/mgo"
"net/url"
"os"
"strings"
)
// mongoSession gives a session or dies trying.
func mongoSession(addr string) *mgo.Session {
fmt.Fprintln(os.Stderr, "Connecting to", addr)
s, err := mgo.Dial(addr + "?connect=direct")
if err != ni... |
package main
//989. 数组形式的整数加法
//对于非负整数X而言,X的数组形式是每位数字按从左到右的顺序形成的数组。例如,如果X = 1231,那么其数组形式为[1,2,3,1]。
//
//给定非负整数 X 的数组形式A,返回整数X+K的数组形式。
//
//
//
//示例 1:
//
//输入:A = [1,2,0,0], K = 34
//输出:[1,2,3,4]
//解释:1200 + 34 = 1234
//示例 2:
//
//输入:A = [2,7,4], K = 181
//输出:[4,5,5]
//解释:274 + 181 = 455
//示例 3:
//
//输入:A = [2,1,5], ... |
package mapping
import (
"github.com/omniscale/imposm3/element"
"github.com/omniscale/imposm3/geom"
)
func init() {
RegisterFieldTypes(
FieldType{
Name: "echo_hello_world",
GoType: "string",
Func: getField_Echo_parameters,
MakeFunc: nil,
},
)
}
func getField_Echo_parameters(val string... |
package math
// todo 实现
|
package main
//Invalid
// Chekcs if every case inside switch has a return of type func f return type as f itself does not have a return statement
func f () int {
var a int = 10;
switch a {
case 1 : { }
default : { }
}
} |
package cwsharp
import (
"unicode"
"bufio"
"fmt"
"io"
)
type bufReader struct {
offset int
buf []rune
src *bufio.Reader
}
func (b *bufReader) init(src io.Reader) {
b.src = bufio.NewReader(src)
b.offset = 0
b.fill()
}
func NewReader(src io.Reader) Reader {
b := &bufReader{}
b.init(src)
return b
}
f... |
// Copyright (C) 2017 Michał Matczuk
// Use of this source code is governed by an AGPL-style
// license that can be found in the LICENSE file.
package server
import (
"reflect"
"testing"
)
func TestNewAuth(t *testing.T) {
tests := []struct {
actual string
expected *Auth
}{
{"", nil},
{"token", &Auth{To... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.