text stringlengths 11 4.05M |
|---|
package testbed
import (
"net/http"
"time"
"appengine"
ds "appengine/datastore"
"appengine/memcache"
"github.com/vmihailenco/appengine/context"
"launchpad.net/gocheck"
)
var (
kinds = make([]string, 0)
ctx context.Context
)
func RegisterDsKind(kind string) {
kinds = append(kinds, kind)
}
func FlushDs(c... |
package main
import (
"encoding/json"
"fmt"
"testing"
"github.com/aws/aws-lambda-go/events"
)
func testSum(t *testing.T, a, b, expected int) {
res, err := handler(events.APIGatewayV2HTTPRequest{
Body: fmt.Sprintf(`{"x": %d, "y": %d}`, a, b),
IsBase64Encoded: false,
})
if err != nil {
t.Fatal(... |
package main
import (
"fmt"
"github.com/jrapoport/gothic/cmd/cli/root"
"github.com/jrapoport/gothic/cmd/cli/user"
)
func init() {
root.AddCommand(user.Cmd)
root.AddCommand(codeCmd)
root.AddCommand(migrateCmd)
}
func main() {
if err := root.Execute(); err != nil {
fmt.Printf("Error: %s\n\n", err)
}
}
|
package main
import (
"fmt"
mathematic "golang-book-tasks/chapter-11/math"
)
func main() {
slice := []float64{231.213, 123.213, 4522.2, 2.44}
fmt.Println("Our slice: ", slice)
fmt.Println("Average value: ", mathematic.Average([]float64{}))
fmt.Println("Max value: ", mathematic.Max(slice))
fmt.Println("Min valu... |
// Copyright 2016 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 structs
type VideoDomains []VideoDomain
func (v *VideoDomains) FindAll() error {
return BroadvidDB.Table("video_domains").Find(&v).Error
}
type VideoDomain struct {
ID int64 `form:"id"`
Host string `form:"host"`
GaID string `form:"ga_id"`
ThemeID int64 `form:... |
package main
import (
"container/list"
"fmt"
"os"
"strconv"
"strings"
)
type Point struct {
x int
y int
id string
}
type Location struct {
closest *Point
distance int
tie bool
}
func main() {
points := read()
board := [400][400]Location{}
// fillFrom(&points[0], &board)
// fillFrom(&points[... |
package script
import "divsperf/script/parse"
func Register(addon parse.Addon) {
if _, ok := parse.Addons[addon.Name()]; !ok {
parse.Addons[addon.Name()] = addon
}
}
// todo: 按level并行串行执行各个最外层块 |
package users
import (
"io/ioutil"
"net/http"
"github.com/gin-gonic/gin"
"encoding/json"
"strconv"
)
//HTTPService ...
type HTTPService interface {
Register (*gin.Engine)
}
type httpService struct {
endpoints []*endpoint
}
type endpoint struct {
method string
path string
function gin.HandlerFunc
}
//NewHTT... |
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/gorilla/mux"
)
func main() {
fmt.Printf("Hi World! This is fbm-bot!")
router := mux.NewRouter()
router.
HandleFunc("/webhook", Verify).Methods("GET")
if err := http.ListenAndServe(fmt.Sprintf(":%v", getPort()), router); err != nil {
log.Fat... |
package interpreter
import (
"bytes"
"io"
"testing"
"github.com/pgavlin/warp/bench/data"
"github.com/pgavlin/warp/bench/flate"
"github.com/pgavlin/warp/bench/flate_go"
"github.com/pgavlin/warp/go_wasm_exec"
"github.com/pgavlin/warp/wasi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/requ... |
package chapter1
// ContainDuplicateCharBy2For は、target文字列中に同じ文字が複数入っていないかを確認する
func ContainDuplicateCharBy2For(target string) bool {
for i, k := range target {
for u, j := range target {
if i != u {
if k == j {
return true
}
}
}
}
return false
}
// ContainDuplicateCharByMap は、target文字列中に同じ文... |
package main
type NetworksResponse struct {
Networks []Network `json:"networks"`
}
type NetworkResponse struct {
Network Network `json:"network"`
}
type Network struct {
ID string `json:"id"`
Name string `json:"name"`
Location Location `json:"location"`
}
type Location struct {
City string ... |
/*
Copyright 2014 Jiang Le
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, software
distri... |
package odoo
import (
"fmt"
)
// BaseModuleUninstall represents base.module.uninstall model.
type BaseModuleUninstall struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *String ... |
package main
import (
"net"
"fmt"
"ipset/src/common"
)
func main() {
ip,ne,_ := net.ParseCIDR("1.2.3.4/19")
fmt.Println(ne.Mask.Size())
fmt.Println(ip)
fmt.Println([]byte(ne.IP))
fmt.Println([]byte(ne.Mask))
fmt.Println(ne.Contains(net.ParseIP("1... |
package api
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Response struct {
Usage float64
}
func CpuInfo(c *gin.Context) {
c.JSON(http.StatusOK, &Response{
Usage: 100.0,
})
}
|
package common_templates
import (
"fmt"
"strings"
"path/filepath"
"sync"
templatev1 "github.com/openshift/api/template/v1"
core "k8s.io/api/core/v1"
rbac "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/se... |
package altrudos
import (
"database/sql"
"errors"
"fmt"
"net/url"
"strconv"
"time"
"github.com/lib/pq"
"github.com/Masterminds/squirrel"
dbUtil "github.com/monstercat/golib/db"
"github.com/monstercat/pgnull"
"github.com/altrudos/api/pkg/justgiving"
"github.com/jmoiron/sqlx"
"github.com/satori/go.uuid... |
// Package httpx contains HTTP extensions. Specifically we have code to
// create transports and clients more suitable for the OONI needs.
package httpx
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
"net/url"
"time"
"github.com/ooni/probe-engine/httpx/httplog"
"github.com/ooni/probe-engine/httpx/... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package updateutil
import (
"context"
"encoding/json"
"testing"
"time"
)
func TestLoad(t *testing.T) {
wantLen := 5
ctx, cancel := context.WithTimeout(context.Backgr... |
package mocks
import (
"errors"
"github.com/joaodias/hugito-app/domain"
"golang.org/x/oauth2"
)
type UserRepository struct {
NewCalled bool
ReadCalled bool
IsError bool
}
func (ur *UserRepository) New(user domain.User) error {
ur.NewCalled = true
if ur.IsError {
return errors.New("Some Error")
}
retu... |
// Copyright 2016 Andreas Pannewitz. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package d
import (
"github.com/GoLangsam/do"
"github.com/GoLangsam/dk-7.2.2.1/internal/x" // all we need
)
// ==========================================... |
package tyVpnProtocol
import "github.com/tachyon-protocol/udw/udwBytes"
func (packet *VpnPacket) Encode(buf *udwBytes.BufWriter) (n int) {
buf.WriteByte_(packet.Cmd)
buf.WriteBigEndUint64(packet.ClientIdSender)
buf.WriteBigEndUint64(packet.ClientIdReceiver)
buf.Write_(packet.Data)
return buf.GetLen()
}
|
package v1beta1
import (
corev1 "k8s.io/api/core/v1"
)
type CapabilityDisplayName string
type ActiveGateCapability struct {
// The name of the capability known by the user, mainly used in the CR
DisplayName CapabilityDisplayName
// The name used for marking the pod for given capability
ShortName string
// T... |
// Copyright 2021 - 2021 The goword Authors. All rights reserved. Use of
// this source code is governed by a MIT license that can be found in
// the LICENSE file.
//
// Package goword providing a set of functions that allow you to write to
// and read from DOCX files. Supports reading and writing
// wordprocessing doc... |
package env
import (
"fmt"
"strconv"
)
// -- bool Value
type boolValue bool
func newBoolValue(val bool, p *bool) *boolValue {
*p = val
return (*boolValue)(p)
}
func (b *boolValue) Set(s string) error {
v, err := strconv.ParseBool(s)
*b = boolValue(v)
return err
}
func (b *boolValue) Get() interface{} { retu... |
package output
import (
"fmt"
)
// Log type levels
type Type int
const (
INFO Type = 0
WARN Type = 1
ERR Type = 2
VERB Type = 3
)
var logTypeTags = [4]string{"INFO", "WARN", "ERR", "VERB"}
// Generic Write function
func write(args ...interface{}) {
logType := INFO
m... |
package encryption
import (
"github.com/Luzifer/go-openssl"
)
type AESEncryptionService struct {
key []byte
}
func NewAESEncryptionService(key []byte) *AESEncryptionService {
return &AESEncryptionService{
key: key,
}
}
func (e *AESEncryptionService) Encode(text []byte) ([]byte, error) {
return openssl.New().... |
package model
import (
"time"
)
type View struct {
Database string
ViewName string
CurrentSequence uint64
CurrentTimestamp time.Time
}
|
package main
import (
"Backend/api"
"Backend/server"
"fmt"
"github.com/sirupsen/logrus"
"net/http"
"regexp"
"time"
)
type httpHandler struct {
Server *server.Server
}
// Pass ServeHttp to server instance
func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.Server.ServeHTTP(w, r)
}
//... |
// Copyright 2020 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 controls
import (
"github.com/labstack/echo/v4"
"github.com/rs/xid"
"sofuny/models"
"sofuny/utils"
"time"
)
// 创建 评论
func CreateComment(ctx echo.Context) error {
var comment models.Comment
if err := ctx.Bind(&comment); err != nil {
return ctx.JSON(200, utils.Response{
StatusCode: 201,
Msg: ... |
/**
*
* By So http://sooo.site
* -----
* Don't panic.
* -----
*
*/
package apicache
import (
"bytes"
"github.com/gin-gonic/gin"
)
// Response 用于缓存的实例
type Response struct {
gin.ResponseWriter
body *bytes.Buffer
}
// NewResponse 新建缓存实例
func NewResponse(ResponseWriter gin.ResponseWriter) *Response {
r... |
package handler
import (
"context"
"github.com/asim/go-micro/v3/client"
log "github.com/asim/go-micro/v3/logger"
authen "creapptive.com/ims-security/api/authen"
gateway "creapptive.com/ims-security/api/gateway"
message "creapptive.com/ims-security/api/message"
user "creapptive.com/ims-security/api/user"
)
co... |
// Copyright 2019 - 2022 The Samply Community
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law ... |
package kafka
import "time"
type ConsumerConfig struct {
Topics []string
Servers []string
UserName string
Password string
ConsumerGroup string
}
type ProducerConfig struct {
Servers []string
Ak string
Password string
}
var globalConfig Config
type Config struct {
Servers []s... |
package crybsy
// ByHash groups the files by file hash values
func ByHash(files []File) map[string][]File {
fileMap := make(map[string][]File)
for _, f := range files {
list, ok := fileMap[f.Hash]
if !ok {
list = make([]File, 0)
}
list = append(list, f)
fileMap[f.Hash] = list
}
return fileMap
}
// By... |
// Copyright 2020 cloudeng llc. All rights reserved.
// Use of this source code is governed by the Apache-2.0
// license that can be found in the LICENSE file.
// Package subcmd provides a multi-level command facility of the following form:
//
// Usage of <tool>
// <sub-command-1> <flags for sub-command-1> <args... |
package main
import (
json_sim "./simlejson"
"bufio"
"encoding/json"
"fmt"
"net"
"os"
"strings"
)
type Promise interface{}
var accept Promise
var storemap = make(map[string]map[string]interface{})
var new_config = make(map[string]string)
const (
IP string = "127.0.0.1"
PORT string = "... |
// 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 policy
import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/p... |
package main
import (
"encoding/csv"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
)
func readCsvFile(path string) [][]string {
file, err := os.Open(path)
if err != nil {
log.Fatal("Unable to read input file "+path, err)
}
defer file.Close()
csvReader := csv.NewReader(file)
records, err := csvReader.ReadAll(... |
package lc
import "strconv"
// Time: O(n)
// 0ms 2.6mb | 100%
func calPoints(ops []string) int {
stack := []int{}
sum, points := 0, 0
for _, v := range ops {
switch v {
case "C":
sum -= stack[len(stack)-1]
stack = stack[:len(stack)-1]
continue
case "D":
points = stack[len(stack)-1] * 2
sum +=... |
package BlackJack
import "testing"
func TestDeckHas52Cards(t *testing.T){
if len(InitializeDeck()) != 52 {
t.Errorf("Expected the result is not 52")
}
}
func TestDealerGetsTheDeck(t* testing.T){
if len(DeckToDealer())!=52 {
t.Errorf("Expected the result is not 52")
}
}
/*
func TestRandomCar... |
package testutils
import (
"database/sql"
"encoding/hex"
"errors"
"fmt"
"math/rand"
"github.com/renproject/darknode/abi"
"github.com/renproject/darknode/addr"
"github.com/renproject/kv"
"github.com/renproject/kv/db"
"github.com/renproject/lightnode/store"
)
// CheckTableExistence checks the underlying `db`... |
package main
import (
"fmt"
"strings"
"github.com/electricface/go-gir3/gi"
)
var globalFuncNextIdx int
func pFunction(s *SourceFile, fi *gi.FunctionInfo) {
symbol := fi.Symbol()
s.GoBody.Pn("// %s", symbol)
funcIdx := globalFuncNextIdx
globalFuncNextIdx++
fnName := fi.Name()
// 函数内参数分配器
var varReg VarRe... |
package main
import "fmt"
func dailyTemperatures(T []int) []int {
results := make([]int, len(T))
results[len(results)-1] = 0
stack := []int{}
stack = append(stack, T[len(T)-1])
for i := len(T) - 2; i >= 0; i-- {
count := 0
yes := false
for j := len(stack) - 1; j >= 0; j-- {
count++
if stack[j] > T[i... |
package concurrency
type WebsiteChecker func(string) bool
type result struct {
string
bool
}
func CheckWebsite(wc WebsiteChecker, urls []string) map[string]bool {
ret := make(map[string]bool)
resultChannel := make(chan result)
for _, url := range urls {
go func(u string) { resultChannel <- result{u, wc(u)} }(u... |
package models
import (
"database/sql"
"time"
)
type User struct {
ID int `db:"id" json:"id,omitempty" validate:"required"`
CreatedAt time.Time `db:"created_at" json:"created_at,omitempty"`
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at,omitempty"`
Emai... |
/*
*
* Copyright 2017 gRPC 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... |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
// 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
import (
"fmt"
"net/http"
)
type MyHander struct {
}
func (handler *MyHander) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
sayHelloGolang(w, r)
return
}
http.NotFound(w, r)
return
}
func sayHelloGolang(w http.ResponseWriter, r *htt... |
package config
import (
"fmt"
"log"
"github.com/streadway/amqp"
)
type RabbitConfig struct {
mydb *amqp.Connection
myqueue amqp.Queue
mychannel *amqp.Channel
}
var rabbit RabbitConfig
func (r *RabbitConfig) Configure() {
var err, err1 error
r.mychannel, err = r.mydb.Channel()
failOnError(err, "Fail... |
// initialize structures with composite literals
// with field name and val
// only val
// use of + sign to print the field name
// struct copy - changes the orig val
package main
import "fmt"
func main() {
type location struct {
lat, long float64
}
// variables are initialized using field-value pairs
opportun... |
package level_ip
import (
"testing"
)
func handleFrame(dev *NetDev, eth_hdr *EthHdr, ifce *TunInterface) {
switch eth_hdr.ethertype {
case ETH_P_ARP:
arpIncoming(dev, eth_hdr, ifce)
case ETH_P_IP:
ipv4_incoming(dev, eth_hdr, ifce)
default:
}
}
func TestArp(t *testing.T) {
dev := netdevInit("10.0.0.4", "00... |
package collectors
import (
"fmt"
"strconv"
"time"
"bosun.org/cmd/scollector/conf"
"bosun.org/metadata"
"bosun.org/opentsdb"
)
// SNMPCisco registers a SNMP CISCO collector for the given community and host.
func SNMPCisco(cfg conf.SNMP) {
mib := conf.MIB{
BaseOid: "1.3.6.1.4.1.9.9",
Trees: []conf.MIBTree{... |
// Copyright 2021 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, ... |
// Copyright 2019 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 utils
import (
"encoding/csv"
"fmt"
"log"
"os"
"github.com/tealeg/xlsx"
)
func GetCSVFile(path string) *os.File {
wd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
f, err := os.Open(wd + path)
if err != nil {
fmt.Print("Error: ", err)
}
defer f.Close()
return f
}
func ReadCSV(path st... |
package meter
import (
"errors"
"fmt"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/provider"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
)
func init() {
registry.Add("tq-em", NewTqEmFromConfig)
}
type tqemData... |
package common
import (
"context"
"net"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"
)
func IPWhiteListUnaryServerInterceptor(whitelist []string) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.... |
package main
import "fmt"
import "time"
func main() {
ans := 0
for year := 1901; year <= 2000; year++ {
for month := 1; month <= 12; month++ {
date := time.Date(year, time.Month(month), 1, 12, 0, 0, 0, &time.Location{})
if date.Weekday().String() == "Sunday" {
ans++
}
}
}
fmt.Println(ans)
}
|
package unmodel
// 存在しないページ
import (
"../get2ch"
"time"
)
type None struct {
ModelComponent
}
func NewNone(host string, _ []string) *None {
model := &None{ModelComponent: CreateModelComponent(ClassNameNone, host)}
model.url = ""
model.title = "そんなページないよ"
model.mod = time.Time{}
model.err = nil
model.g2ch =... |
package provider
type Message struct {
msg string
}
// NewMessage Message的构造函数
func NewMessage(msg string) Message {
return Message{
msg: msg,
}
}
|
package repository
import (
"fmt"
"github.com/go-log/log"
pb "github.com/i-coder-robot/go-micro-action-user/proto/frontPermit"
"github.com/jinzhu/gorm"
)
type FrontPermit interface {
Create(frontPermit *pb.FrontPermit) (*pb.FrontPermit, error)
Delete(frontPermit *pb.FrontPermit) (bool, error)
Update(frontPermi... |
/*
Copyright 2021 The DbunderFS Contributors.
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 ... |
package views // import "github.com/jenkins-x/octant-jx/pkg/plugin/views"
import (
"fmt"
"github.com/jenkins-x/jx-logging/v3/pkg/log"
"github.com/jenkins-x/octant-jx/pkg/admin"
"github.com/jenkins-x/octant-jx/pkg/common/links"
"github.com/jenkins-x/octant-jx/pkg/common/pluginctx"
"github.com/jenkins-x/octant-j... |
package main
import (
"fmt"
"sort"
)
func main() {
var n int
fmt.Scan(&n)
var nums []int
var sum int
for i := 0; i < n; i++ {
var f int
fmt.Scan(&f)
nums = append(nums, f)
sum += f
}
// print the mean
if len(nums) > 0 {
fmt.Printf("%.1f\n", float64(sum)/float64(len(nums)))
// print the media... |
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the Lice... |
package set1
func FixedXOR(data []byte, chiper []byte) []byte {
xor := make([]byte, len(data))
// Assert len(data) == len(chiper)
for i:=0; i<len(data); i+=1 {
xor[i] = data[i] ^ chiper[i]
}
return xor
}
|
package media
import (
"encoding/json"
"regexp"
"github.com/gempir/gempbot/internal/dto"
"github.com/gempir/gempbot/internal/helixclient"
"github.com/gempir/gempbot/internal/log"
"github.com/gempir/gempbot/internal/store"
"github.com/google/uuid"
"github.com/puzpuzpuz/xsync"
)
type PlayerState string
const ... |
package application
import (
"fmt"
"github.com/dolittle/platform-api/pkg/azure"
dolittleK8s "github.com/dolittle/platform-api/pkg/dolittle/k8s"
"github.com/dolittle/platform-api/pkg/platform"
"github.com/dolittle/platform-api/pkg/platform/application/k8s"
platformK8s "github.com/dolittle/platform-api/pkg/platfo... |
package rest
import (
"net/http"
"github.com/jrapoport/gothic/core"
"github.com/jrapoport/gothic/core/tokens"
"github.com/jrapoport/gothic/models/user"
"github.com/jrapoport/gothic/store"
"github.com/segmentio/encoding/json"
)
// Server represents an REST server.
type Server struct {
*core.Server
}
// NewSer... |
// +build ignore
package main
import (
"context"
"encoding/hex"
"fmt"
"io/ioutil"
"math/big"
"os"
"os/exec"
"strings"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github... |
package additional
import (
"context"
"fmt"
"strings"
"github.com/openshift/oc-mirror/v2/pkg/api/v1alpha2"
"github.com/openshift/oc-mirror/v2/pkg/api/v1alpha3"
clog "github.com/openshift/oc-mirror/v2/pkg/log"
"github.com/openshift/oc-mirror/v2/pkg/manifest"
"github.com/openshift/oc-mirror/v2/pkg/mirror"
)
fu... |
/**
* Copyright (2021, ) Institute of Software, Chinese Academy of Sciences
*/
package kubesys
/**
* author: wuheng@iscas.ac.cn
* date : 2021/9/30
*/
type RuleBase struct {
KindToFullKindMapper map[string][]string
FullKindToApiPrefixMapper map[string]string
FullKindToNameMapper map[stri... |
package lru_store
import (
"fmt"
"strconv"
"testing"
"github.com/minotar/imgd/pkg/storage"
"github.com/minotar/imgd/pkg/storage/util/test_helpers"
test_store "github.com/minotar/imgd/pkg/storage/util/test_store"
)
func TestRetrieveMiss(t *testing.T) {
store, _ := NewLruStore(10)
v, err := store.Retrieve(tes... |
package api_test
import (
"fmt"
"log"
"api"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
var (
server *httptest.Server
reader io.Reader
animalsUrl string
)
func init() {
router := api.NewRouter()
log.Fatal( http.ListenAndServe( ":8080", router ) )
animalsUrl = fmt.Sprintf... |
package main
import (
"fmt"
"io/ioutil"
"os"
"testing"
)
const expectedWriteLocationsPackageJson = `{
"name": "write-locations",
"version": "1.0.0",
"main": "stage.js",
"scripts": {
"start": "node stage.js"
},
"dependencies": {
"express": "^4.16.2",
"morgan": "^1.9.... |
package test
import (
"bytes"
"crypto/rand"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zhaohaijun/matrixchain/common/log"
"github.com/zhaohaijun/matrixchain/common/serialization"
"github.com/zhaohaijun/matrixchain/core/types"
. "github.com/zhaohaijun/matrixchain/smartcontract"
ne... |
package gowhere
import (
"bytes"
"testing"
)
func TestParseRules(t *testing.T) {
data := []byte("redirect 301 /project/def/new_page.html /project/def/other_page.html")
input := bytes.NewReader(data)
rs, err := ParseRules(input)
if err != nil {
t.Errorf("got error: %v", err)
}
if len(rs.rules) != 1 {
t.Err... |
package factory
import (
"fmt"
"github.com/RackHD/ipam/interfaces"
)
// factory is a storage map for resource creator functions registered via init.
var factory = make(map[string]interfaces.ResourceCreator)
// Register associates the resource identifier with a resource creator function.
func Register(resource str... |
package chat
import (
"errors"
"sync"
"time"
"github.com/microcosm-cc/bluemonday"
blackfriday "gopkg.in/russross/blackfriday.v2"
)
type Chat struct {
mutex sync.RWMutex
store Store
rooms map[string]*room
}
func New(s Store) *Chat {
return &Chat{
store: s,
rooms: map[string]*room{},
}
}
func (c *Chat)... |
package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"strings"
"github.com/cello-proj/cello/internal/requests"
"github.com/cello-proj/cello/internal/responses"
"github.com/cello-proj/cello/internal/types"
"github.com/cello-proj/cello/service/internal/credentials"
"github.com/cell... |
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this fi... |
package problem0073
func setZeroes(m [][]int) {
rows := make([]bool, len(m)) // rows[i] == true ,代表 i 行存在 0 元素
cols := make([]bool, len(m[0])) // cols[j] == true ,代表 j 列存在 0 元素
// 逐个检查元素
for i := range m {
for j := range m[i] {
if m[i][j] == 0 {
rows[i] = true
cols[j] = true
}
}
}
// 按行修改
... |
package encoder
import (
"fmt"
"github.com/shanexu/logn/common"
)
type Factory func(*common.Config) (Encoder, error)
type Config struct {
Namespace common.ConfigNamespace `logn-config:",inline"`
}
var encoders = map[string]Factory{}
func RegisterType(name string, gen Factory) {
if _, exists := encoders[name]; ... |
package game
import (
"github.com/go-gl/mathgl/mgl32"
)
type StaticPropV5 struct {
Origin mgl32.Vec3
Angles mgl32.Vec3
PropType uint16
FirstLeaf uint16
LeafCount uint16
Solid uint8
Flags uint8
Skin int32
FadeMinDist float32
FadeMaxDist... |
package ptrie
import (
"bytes"
"encoding/binary"
"fmt"
"github.com/stretchr/testify/assert"
"hash/fnv"
"io"
"log"
"reflect"
"testing"
)
func TestValues_Decode(t *testing.T) {
var useCases = []struct {
description string
values []interface{}
hasError bool
}{
{
description: "string coding... |
/*
* @lc app=leetcode id=344 lang=golang
*
* [344] Reverse String
*
* https://leetcode.com/problems/reverse-string/description/
*
* algorithms
* Easy (67.94%)
* Likes: 1422
* Dislikes: 682
* Total Accepted: 753.6K
* Total Submissions: 1.1M
* Testcase Example: '["h","e","l","l","o"]'
*
* Write a fu... |
package host
import (
"errors"
"io"
"net"
"os"
"path/filepath"
"strconv"
"github.com/NebulousLabs/Sia/crypto"
"github.com/NebulousLabs/Sia/encoding"
"github.com/NebulousLabs/Sia/modules"
"github.com/NebulousLabs/Sia/types"
)
var (
HostCapacityErr = errors.New("host is at capacity and can not take more fil... |
package auth
import (
"github.com/caos/logging"
"github.com/golang/protobuf/ptypes"
"github.com/caos/zitadel/internal/policy/model"
"github.com/caos/zitadel/pkg/grpc/auth"
)
func passwordComplexityPolicyFromModel(policy *model.PasswordComplexityPolicy) *auth.PasswordComplexityPolicy {
creationDate, err := ptype... |
package cmd
import (
"fmt"
"net"
"net/http/httptest"
"testing"
"github.com/bpicode/fritzctl/config"
"github.com/bpicode/fritzctl/mock"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)
// TestCommands is a unit test that runs most commands.
func TestCommands(t *testing.T) {
config.Dir = "../te... |
package player
import (
"testing"
c "github.com/sergivillar/rock-paper-scissors/config"
)
func TestCpuPlay(t *testing.T) {
result := RockPaperScissor()
if !contains(c.GameOptions, result) {
t.Fatal("Incorrect game option")
}
}
func TestCreatePlayer(t *testing.T) {
expected := Player{"Player"}
p, err := C... |
package health_test
import (
"fmt"
"time"
"github.com/cerana/cerana/acomm"
healthp "github.com/cerana/cerana/providers/health"
"github.com/cerana/cerana/providers/systemd"
"github.com/pborman/uuid"
)
func (s *health) TestUptime() {
goodStatus := s.addService()
tests := []struct {
name string
minU... |
// Copyright © 2016 Marc Sutter <marc.sutter@swissflow.ch>
//
// 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 ap... |
// 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, ... |
// generated by stringer -type=ErrorCode; DO NOT EDIT
package meechum
import "fmt"
const _ErrorCode_name = "OKWARNINGFATAL"
var _ErrorCode_index = [...]uint8{0, 2, 9, 14}
func (i ErrorCode) String() string {
if i+1 >= ErrorCode(len(_ErrorCode_index)) {
return fmt.Sprintf("ErrorCode(%d)", i)
}
return _ErrorCod... |
// 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.