text stringlengths 11 4.05M |
|---|
package serializer
// Byter is a type constraint that ensures that the type can be serialized to bytes.
type Byter interface {
Bytes() ([]byte, error)
}
// FromByter is a type constraint that ensures that the type can be deserialized from bytes.
type FromByter interface {
FromBytes([]byte) (int, error)
}
type Mars... |
package openstack_test
import (
"errors"
"github.com/genevieve/leftovers/openstack"
"github.com/genevieve/leftovers/openstack/fakes"
"github.com/gophercloud/gophercloud/openstack/imageservice/v2/images"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Images", func() {
Describe("Type"... |
package game
import (
c "alive-dungeon/source/creature"
i "alive-dungeon/source/game/interactions"
w "alive-dungeon/source/world"
"bufio"
"fmt"
"math/rand"
"os"
"strconv"
"testing"
"time"
)
func TestGame(t *testing.T) {
var world = w.New(w.Create{20, 20})
world.Update(w.Modify{Position: w.Position{1, 5},... |
package thirdapi
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
// AliJiSuZNWD 阿里智能问答
type AliJiSuZNWD struct {
Status string `json:"status,omitempty"`
Msg string `json:"msg,omitempty"`
Result struct {
Type string `json:"type,omitempty"`
Content string `json:"content,omitempty"`
Re... |
// 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"
func main() {
nth := 10001
primes := []int{2, 3, 5, 7, 11, 13}
isPrime := func(x int) bool {
for i := 0; i < len(primes); i++ {
if x%primes[i] == 0 {
return false
}
}
return true
}
for num := 16; len(primes) < nth; num++ {
if isPrime(num) {
primes = append(primes, n... |
package handlers
import (
"github.com/go-openapi/runtime/middleware"
runtime "github.com/ahab94/ApnaSchool"
domainErr "github.com/ahab94/ApnaSchool/errors"
"github.com/ahab94/ApnaSchool/gen/models"
"github.com/ahab94/ApnaSchool/gen/restapi/operations"
)
// NewGetTeacher handles a request for retrieving teacher
... |
package subuser
type SetSubUserTransferabilityRequest struct {
SubUids string `json:"subUids"`
AccountType string `json:"accountType"`
Transferrable bool `json:"transferrable"`
}
|
package requestmessages
import (
"time"
)
type TCPTestRequest struct {
InPort string `json:"port"`
Timeout time.Duration `json:"timeout"`
Nonce string `json:"nonce"`
}
type UDPTestRequest struct {
InPort string `json:"port"`
Timeout time.Duration `json:"timeout"`
Nonce string ... |
package template
import (
"html/template"
"os"
"path/filepath"
"strings"
"github.com/raggaer/bison/app/config"
"github.com/raggaer/bison/app/lua"
glua "github.com/yuin/gopher-lua"
)
// TemplateFuncData data needed for template functions
type TemplateFuncData struct {
Config *config.Config
Files map[string]... |
package main
import (
"os"
"log"
"github.com/kniren/gota/dataframe"
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/plotter"
)
func main(){
irisFile,err:=os.Open("basicstatistic/data/iris.csv")
if err!=nil{
log.Fatal(err)
}
defer irisFile.Close()
irisDF:=dataframe.ReadCSV(irisFile)
p... |
package SqrtX
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestSqrt(t *testing.T) {
ast := assert.New(t)
ast.Equal(mySqrt(4), 2)
ast.Equal(mySqrt(8), 2)
ast.Equal(mySqrt(9), 3)
ast.Equal(mySqrt(1), 1)
ast.Equal(mySqrt(0), 0)
}
|
package dynamicProgamming
import (
"AlgorizmiGo/dynamicProgramming"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_should_calculate_binary_sequence_size(t *testing.T) {
tests := []struct {
n int
expectedSize int
}{
{n: 1, expectedSize: 2},
{n: 2, expectedSize: 4},
{n: 3, expected... |
package controller
import (
"fmt"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
"github.com/reechou/real-liebian/config"
)
var x *xorm.Engine
func InitDB(cfg *config.Config) {
var err error
x, err = xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset... |
package main
import "fmt"
func main(){
x:= [5]int{1,4,3,4,5,}
for _, value:= range x{
fmt.Println(value)
}
fmt.Println(x[0])
} |
package client
type Request struct {
Method string
Header map[string]string
URL string
Body []byte
}
type Response struct {
StatusCode int
Body []byte
}
// IHttpClient is a HTTP client abstraction for the API client.
// In some environments, like GopherJS, it's better to use other packages than stan... |
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package merger
import (
"reflect"
"testing"
commonv1 "github.com/Dat... |
// 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 launcher
import (
"context"
"fmt"
"regexp"
"time"
"chromiumos/tast/common/action"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/... |
package main
import (
"encoding/json"
"fmt"
"os"
"io/ioutil"
"log"
"net/http"
"strings"
"github.com/line/line-bot-sdk-go/linebot"
)
const (
OpenDataURL string = "http://opendata2.epa.gov.tw/AQI.json"
)
type AQI struct {
SiteName string `json:"SiteName"`
County string `json:"County"`
AQI ... |
package app
// 返回自定义状态码
const (
Success = 0
PermissionDenied = 403
NotFound = 404
Fail = 500
AuthFail = 401
)
// 自定义的一些错误消息的返回
const (
AuthFailMessage = "AuthFailed"
PermissionDeniedMessage = "PermissionDenied"
)
|
package models
import(
"encoding/json"
)
/**
* Type definition for Environments7Enum enum
*/
type Environments7Enum int
/**
* Value collection for Environments7Enum enum
*/
const (
Environments7_KVMWARE Environments7Enum = 1 + iota
Environments7_KHYPERV
Environments7_KSQL
En... |
package odoo
import (
"fmt"
)
// ReportAccountReportJournal represents report.account.report_journal model.
type ReportAccountReportJournal struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// Report... |
package main
import "fmt"
type Student struct {
Name string
Score float64
}
func (s *Student) ShowScore() {
fmt.Println("scores=", s.Score)
}
func (s *Student) SetScore(score float64) {
s.Score = score
}
func (s *Student) GetSum(m, n int) int {
return m + n
}
type Pupil struct {
Student
}
func (p *Pupil)... |
package acmetool_import_key
import (
"io/ioutil"
"github.com/hlandau/acme/acmeapi/acmeutils"
"github.com/hlandau/acme/acmetool"
"github.com/hlandau/acme/storage"
)
func Register(app *acmetool.App) {
cmd := app.CommandLine.Command("import-key", "Import a certificate private key")
filename := cmd.Arg("private-ke... |
package hash
import (
"log"
"os"
"github.com/pkg/errors"
)
func init() {
log.SetFlags(log.Lshortfile)
var logFileName = "test.log"
var logFile, err = os.Create(logFileName)
if err != nil {
log.Fatal(errors.Wrapf(err, "failed to os.Create(%q)", logFileName))
}
log.SetOutput(logFile)
log.Printf("NumIndex... |
package config
import (
"fmt"
"github.com/gomodule/redigo/redis"
)
//InitialRedisConn , open connection dan konfigurasi pool yang digunakan
//Cache menggunakan Redis
func InitialRedisConn() redis.Conn {
redisPool := &redis.Pool{
// Maximum number of idle connections in the pool.
MaxIdle: 80,
// max number o... |
package models
import (
"reflect"
"testing"
"github.com/caos/zitadel/internal/errors"
)
func testSetColumns(columns Columns) func(factory *SearchQueryFactory) *SearchQueryFactory {
return func(factory *SearchQueryFactory) *SearchQueryFactory {
factory = factory.Columns(columns)
return factory
}
}
func test... |
package main
// Leetcode 5892. (medium)
func stoneGameIX(stones []int) bool {
cnt := make([]int, 3)
for i := range stones {
cnt[stones[i]%3]++
}
if cnt[0]%2 == 0 {
return cnt[1] != 0 && cnt[2] != 0
}
return cnt[1] >= cnt[2]+3 || cnt[2] >= cnt[1]+3
}
|
package en
import (
"regexp"
"strconv"
"strings"
"time"
"github.com/olebedev/when/rules"
)
// <[]string{"third of march", "third", "", "march", "", ""}>
// <[]string{"march third", "", "", "march", "third", ""}>
// <[]string{"march 3rd", "", "", "march", "3rd", ""}>
// <[]string{"3rd march", "3rd", "", "march",... |
// The various methods, etc. for the actual server piece of the solver: socket listeners, message decoders, the like
package server
import (
"fmt"
"net"
"time"
"io"
"encoding/binary"
"encoding/json"
"nplsolver/properties"
"nplsolver/solver"
"nplsolver/dict"
)
const (
connectionTimeoutProp = "serv... |
/*
Copyright 2020 Docker Compose CLI 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... |
/**
* Auth : liubo
* Date : 2019/11/8 17:31
* Comment:
*/
package main
import (
"fmt"
"os"
"serve_file/proto"
)
func main() {
if len(os.Args) != 2 {
return
}
fmt.Println(proto.Md5File( os.Args[1]))
}
|
package main
import (
"encoding/json"
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/jordan-wright/cve-api/cve"
)
/*
TODO: - Add gzip encoding (Middleware)
- Support arbitrary fields (perhaps reflect can help with this?)
- Add proper offset and limits (Middleware)
- Add gt & lt
- Add Count ... |
package kth_smallest_element_in_a_bst
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func kthSmallest(root *TreeNode, k int) int {
v, _ := traverse(root, &k... |
package irc
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParseIRCMessage(t *testing.T) {
t.Parallel()
cases := []struct {
description string
raw string
shouldParse bool
expectedMessageType MessageType
}{
{
description: "PRIVMSG with pr... |
package main
import "fmt"
// ----------------------
func intToRoman(num int) string {
r1 := []string{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}
r2 := []string{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}
r3 := []string{"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}
r4 ... |
package gw
import (
"fmt"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
"github.com/oceanho/gw/conf"
"github.com/oceanho/gw/logger"
"github.com/oceanho/gw/utils/secure"
"gorm.io/gorm"
"io/ioutil"
"os"
"os/signal"
"path"
"plugin"
"regexp"
"strings"
"sync"
"sys... |
package commands
var Parameters struct {
// Options
Currency string `long:"currency" description:"The currency to display prices in."`
JSON bool `long:"json" description:"Output the results in JSON format."`
// Commands
Airport AirportCommand `command:"airport" description:"Search for an airport."`... |
package odoo
import (
"fmt"
)
// BasePartnerMergeAutomaticWizard represents base.partner.merge.automatic.wizard model.
type BasePartnerMergeAutomaticWizard struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *M... |
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"runtime"
"sync"
"time"
"wellmon/date"
wmlog "wellmon/log"
"github.com/antchfx/htmlquery"
)
func getHTML(URL string) {
found := false
defer func() {
if found == false {
wmlog.DLog("button not found", URL)
}
}()
doc, err := h... |
package commonresource
import (
"github.com/zdnscloud/gorest/resource"
)
func RegisterSchemas(version *resource.APIVersion, schemas resource.SchemaManager) {
schemas.MustImport(version, Namespace{}, &dumbHandler{})
schemas.MustImport(version, Deployment{}, &dumbHandler{})
schemas.MustImport(version, DaemonSet{}, ... |
// description : prints its commandline arguments
// author : Tom Geudens (https://github.com/tomgeudens/)
// modified : 2016/07/02
//
package main
import (
"flag"
"fmt"
"strings"
)
var n = flag.Bool("n", false, "omit trailing newline")
var sep = flag.String("s", " ", "separator")
func main() {
flag.Pars... |
package udwSqlite3Test
import (
"github.com/tachyon-protocol/udw/udwFile"
"github.com/tachyon-protocol/udw/udwMap"
"github.com/tachyon-protocol/udw/udwSqlite3"
"github.com/tachyon-protocol/udw/udwTest"
"strconv"
)
func TestBc() {
TestBcVersion()
TestBcEncrypt()
TestBcPlainDb()
}
const currentSqlite3Version =... |
package errutil
import "strings"
// Prefix the passed error with the passed string, returning a brand new error.
func Prefix(err error, s string) error {
return Func(func() string {
return strings.Join([]string{s, err.Error()}, ": ")
})
}
|
package app
import (
"io/ioutil"
"log"
"net/http"
"time"
"github.com/acaloiaro/di-tui/components"
"github.com/acaloiaro/di-tui/context"
"github.com/acaloiaro/di-tui/difm"
"github.com/faiface/beep/speaker"
)
// PlayChannel begins streaming the provided channel after fetching its playlist
// If a channel is al... |
package sqlbuilder
import (
"strconv"
)
// Dialect represents a SQL dialect.
type Dialect interface {
// Placeholder returns the placeholder binding string for parameter at index idx.
Placeholder(idx int) string
}
type MySQLDialect struct{}
type PostgresDialect struct{}
var (
MySQL MySQLDialect // MySQL
... |
package eventsourcing
import (
"context"
"testing"
"github.com/golang/mock/gomock"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/policy/model"
)
func TestGetPass... |
package main
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
type CustomerLoyalty struct {
}
func (cc *CustomerLoyalty) Init(stub shim.ChaincodeStubInterface) pb.Response {
return shim.Sucess(nil)
}
func (cc *CustomerLoyalty)... |
package main
import (
"fmt"
"os"
"github.com/milosgajdos/vaultops/command"
"github.com/mitchellh/cli"
)
const (
// cli version
version = "0.1"
// cli name
cliName = "vaultops"
)
func main() {
c := cli.NewCLI(cliName, version)
c.Args = os.Args[1:]
c.Commands = Commands()
exitStatus, err := c.Run()
if e... |
package mock
import "github.com/florianehmke/plexname/tmdb"
type tmdbClient struct {
response tmdb.SearchResponse
err error
}
func NewMockTMDB(response tmdb.SearchResponse, err error) tmdb.Client {
return &tmdbClient{response, err}
}
func (c *tmdbClient) Search(query string, year int, page int) (*tmdb.Searc... |
package gopaxos
type Breakpoint interface {
ProposerBP
AcceptorBP
LearnerBP
InstanceBP
CommitterBP
IOLoopBP
NetworkBP
LogStorageBP
AlgorithmBaseBP
CheckpointBP
MasterBP
}
type ProposerBP interface {
NewProposal(value []byte)
NewProposalSkipPrepare()
Prepare()
OnPrepareReply()
OnPrepareReplyButNotPrepa... |
package logf
import (
"fmt"
"io"
"log"
"os"
"sync"
)
// These flags define which text to prefix to each log entry generated by the Logger (compatible with log package).
const (
Ldate = 1 << iota // the date in the local time zone: 2009/01/23
Ltime // the ti... |
package qingstor
import (
"bytes"
"context"
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"net/http"
"reflect"
"strconv"
"strings"
"time"
storagedriver "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/registry/storage/driver/base"
"github.com/docker/distribu... |
package config
import "time"
type Http struct {
Addr string `default:"127.0.0.1"`
Port string `default:"8080"`
ReadTimeout time.Duration `default:"120"`
WriteTimeout time.Duration `default:"120"`
}
|
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/tharsis/ethermint/x/evm/types"
)
var _ types.EvmHooks = MultiEvmHooks{}
// MultiEvmHoo... |
package x
import (
"strconv"
"strings"
"unicode/utf8"
)
type CheckExist struct {
Name string
From string
Fail interface{}
StatusCode int
}
type CheckInt struct {
Name string
From string
Fail interface{}
Max interface{}
Min interface{}
MaxFail in... |
package transfer
//
// Copyright (c) 2019 ARM Limited.
//
// SPDX-License-Identifier: MIT
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without l... |
package schedule
import (
"context"
"github.com/adamluzsi/frameless/pkg/errorkit"
"github.com/adamluzsi/frameless/pkg/tasker"
"github.com/adamluzsi/frameless/ports/crud"
"github.com/adamluzsi/frameless/ports/guard"
"github.com/adamluzsi/testcase/clock"
"time"
)
type Scheduler struct{ Repository Repository }
t... |
package tests
import (
"reflect"
"testing"
)
/**
* [768] Partition Labels
*
*
* A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.
*
*
*... |
package cmd
import (
"io"
"os"
)
type FileRecord struct {
ChunkSize uint32
FileSize uint64
}
type ChunkRecord struct {
start uint64
length uint32
index uint32
}
func GetFileSizeForPath(path string) (uint64, error) {
file, err := os.Open(path)
if err != nil {
return 0, err
}
length, err := file.Seek(0,... |
// Copyright 2019 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 complian... |
package jsonx
import (
"bytes"
"errors"
"io"
"strings"
)
//
// Author: 陈永佳 chenyongjia@parkingwang.com, yoojiachen@gmail.com
//
var ErrNotJSONData = errors.New("json.compress: not json data")
// 将多行JSON文本压缩成一行
func CompressJSONText(data string) []byte {
out := bytes.NewBuffer(make([]byte, 0))
CompressJSON(str... |
package rules
import (
promresourcesv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"kubesphere.io/kubesphere/pkg/api/alerting/v2alpha1"
)
type ResourceRuleCollection struct {
GroupSet map[string]struct{}
IdRules map[string]*ResourceRuleItem
NameRules map[string][]*ResourceRule... |
package graphs
import "github.com/modocache/cargo/queues"
type DirectedGraph struct {
vertices VertexMap
}
func (graph *DirectedGraph) Vertices() VertexMap {
return graph.vertices
}
func NewDirectedGraph() *DirectedGraph {
return &DirectedGraph{vertices: make(VertexMap)}
}
func (graph *DirectedGraph) Append(key... |
package shuttle
import (
"net"
"net/http"
"strconv"
"bufio"
"strings"
"time"
"github.com/sipt/shuttle/util"
)
const (
HTTP = "http"
HTTPS = "https"
)
var allowMitm = false
var allowDump = false
var MitMRules []string
func SetAllowMitm(b bool) {
allowMitm = b
}
func SetAllowDump(b bool) {
allowDump = b
}... |
package main
import (
"fmt"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
)
var count = 0
func main() {
router := httprouter.New()
router.GET("/", post)
log.Fatal(http.ListenAndServe(":8091", router))
}
func post(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
count++
if count == ... |
package model
type RegisterParams struct {
Username string `json:"username"`
}
type LoginParams struct {
Username string `json:"username"`
Password string `json:"password"`
}
type LoginResponse struct {
Token string `json:"token"`
Player *Player `json:"player"`
}
|
package domain
// CarModel ...
type CarModel struct {
Base
CarModel string `gorm:"type:varchar(255)"`
Maker string `gorm:"type:varchar(255)"`
Color string `gorm:"type:varchar(255)"`
}
|
package option
import (
"time"
)
const (
defaultLotusGateway = "https://api.chain.love"
defaultPollInterval = Duration(24 * time.Hour)
defaultPollRetryAfter = Duration(5 * time.Hour)
defaultPollStopAfter = Duration(7 * 24 * time.Hour)
defaultRediscoverWait = Duration(5 * time.Minute)
defaultDisc... |
package entities
type Product struct {
ID string `json:"id"`
Name string `json:"name"`
PriceInCents uint64 `json:"price"`
}
|
// This file is part of CycloneDX GoMod
//
// Licensed under the Apache License, Version 2.0 (the “License”);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agr... |
package service_test
import (
"testing"
"testproject/service"
)
func TestKannelServiceLookupUnknown(t *testing.T) {
kannel := service.NewKannelService("http://unknown", "chandramouli", "Test12", service.GSM7)
_, err := kannel.SendSMS("79991002010", "79992001020", "Test")
if err == nil {
t.Fatal("error: got %... |
package gateclient
import (
"common"
"logger"
"proto"
"rpcplusclientpool"
)
type FailedCallback func()
type GateClient struct {
serviceName string
key string
callback FailedCallback
}
var pPoll *rpcplusclientpool.ClientPool
//初始化加锁客户端
func init() {
var gscfg common.GateServerCfg
err := common.R... |
// Package operator contains tools for manipulating operator catalogs.
package operator
|
// Copyright 2022 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 tests
import (
"math/rand"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
"github.com/beyondstorage/beyond-ftp/pprof"
"github.com/beyondstorage/beyond-ftp/tests/kit"
)
type ftpServerTestBase struct {
suite.Suite
}
func (b *ftpSer... |
package main
import "strconv"
// Leetcode m47. (medium)
func maxValue(grid [][]int) int {
dp := make([][]int, len(grid)+1)
for i := range dp {
dp[i] = make([]int, len(grid[0])+1)
}
for i := 1; i <= len(grid); i++ {
for j := 1; j <= len(grid[0]); j++ {
dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + grid[i-1][j-1]... |
package main
import "fmt"
func main() {
numeros := []int{10, 20, 30, 40}
// for i := 0; i < len(numeros); i++ {
// fmt.Println(numeros[i])
// }
for indice := range numeros {
fmt.Println(numeros[indice])
}
}
|
package test
import (
"github.com/icobani/goweather"
"log"
"testing"
)
func TestLocation(t *testing.T) {
apiKey := "Dl8ehKD1lCgL0GT6WCkGfRh9NtSn5GMO"
c := goweather.NewClient(nil, apiKey)
response, _, err := c.Location.GetCity("istanbul")
if err != nil {
log.Fatal(err)
}
log.Println(response)
}
|
package auth
import (
"google.golang.org/grpc"
"github.com/caos/zitadel/internal/api/authz"
"github.com/caos/zitadel/internal/api/grpc/server"
"github.com/caos/zitadel/internal/auth/repository"
"github.com/caos/zitadel/internal/auth/repository/eventsourcing"
"github.com/caos/zitadel/pkg/grpc/auth"
)
var _ auth... |
package editorapi
import (
"context"
"editorApi/controller/servers"
"editorApi/init/mgdb"
"editorApi/init/qmlog"
"editorApi/mdbmodel/editor"
"strconv"
"sync"
"time"
"github.com/gin-gonic/gin"
"github.com/mongodb/mongo-go-driver/mongo"
uuid "github.com/satori/go.uuid"
"go.mongodb.org/mongo-driver/bson"
"g... |
package libguestfs // import "yunion.io/x/onecloud/pkg/hostman/diskutils/libguestfs"
|
/*
* Copyright 2020 Torben Schinke
*
* 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 ... |
package util
const (
CodeSuccess = "0000"
MessageSuccess = "Success"
)
type ApplicationError struct {
HttpStatus int `json:"-"`
ErrorCode string `json:"code"`
Message string `json:"message"`
}
func (e *ApplicationError) Error() string {
return e.Message
}
var (
ErrorDataNotFound = &Applicat... |
package main
import (
"client/Process"
)
func main() {
//登录
Process.Sigin()
//下棋
Process.Play()
}
|
package nebula
import (
"time"
"github.com/flynn/noise"
"github.com/slackhq/nebula/header"
"github.com/slackhq/nebula/iputil"
"github.com/slackhq/nebula/udp"
)
// NOISE IX Handshakes
// This function constructs a handshake packet, but does not actually send it
// Sending is done by the handshake manager
func i... |
// 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 arcappcompat will have tast tests for android apps on Chromebooks.
package arcappcompat
import (
"context"
"time"
"chromiumos/tast/common/android/ui"
"chromi... |
package vc
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"path/filepath"
)
func CatFile(hash string) {
content := catFile(hash, "")
fmt.Println(content)
}
func catFile(oid, expected string) string {
hashFilePath := filepath.Join(VcDir, "objects", oid)
f, err := ioutil.ReadFile(hashFilePath)
if err != nil {
lo... |
package models
type Video struct {
ID string `json:"id"`
UserID string `json:"userId"`
Link string `json:"link"`
Title string `json:"title"`
View int `json:"view"`
Like int `json:"like"`
Dislike int `json:"dislike"`
DateUpload string `json:"dateUpload"`
D... |
package abstraction
import "github.com/ninjadotorg/SimEcon002/macro_economy/dto"
type Market interface {
Buy(string, *dto.OrderItem, Storage, AccountManager) (float64, error)
Sell(string, *dto.OrderItem, Storage, AccountManager) (float64, error)
}
|
// 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 main
import (
"testing"
)
func TestWeightedRoundRobin(t *testing.T) {
weights := []int{7, 3}
w := NewWeightedRoundRobin(weights)
for i := 0; i < 10; i++ {
t.Log(w.NextIndex())
}
}
|
package zhash
import (
"gopkg.in/yaml.v2"
"reflect"
"testing"
)
func copyTestMap() map[string]interface{} {
cp := map[string]interface{}{}
for key, val := range testMap {
cp[key] = val
}
return cp
}
func TestGetSlice(t *testing.T) {
hash := HashFromMap(testMap)
tests := []getTest{
{[]string{"strISlice"... |
// Package image contains logic for image selection logic.
//
// Worker supports two ways of selecting the image to use for a compute
// instance: An APISelector that talks to job-board
// (https://github.com/travis-ci/job-board) and an ENVSelector that gets the
// data from environment variables.
package image
|
package main
import "fmt"
// slices are typed by their elements, not by length
func main() {
// an empty slice with non-zero length
s := make([]string, 3)
fmt.Println("empty:", s)
s[0] = "a"
s[1] = "b"
s[2] = "c"
fmt.Println("set:", s)
fmt.Println("get:", s[2])
fmt.Println("len:", len(s))
// variable leng... |
package controllers
import (
"bytes"
"classOne/models"
"encoding/gob"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"math"
"path"
"strconv"
"time"
"github.com/gomodule/redigo/redis"
)
type ArticleController struct {
beego.Controller
}
func (ac * ArticleController)ShowArticleList(){
o:=orm.Ne... |
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
func main() {
var guess = 10
t := time.Now()
if len(os.Args) != 2 {
fmt.Println("Please enter a random number as argument")
return
}
maxTurns, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Println("Please enter a valid number")
... |
package main
import (
"fmt"
r "github.com/dancannon/gorethink"
"github.com/mitchellh/mapstructure"
)
func subscribeChannels(client *Client, data interface{}) {
fmt.Println("getting to the subscribeChannels func")
go func() {
var value interface{}
res, err := r.Table("channel").Changes().Run(client.session)
... |
package trade
import (
"errors"
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/jmoiron/sqlx"
tradedb "github.com/skycoin/getsky.org/db"
"github.com/skycoin/getsky.org/db/models"
"github.com/skycoin/getsky.org/src/util/logger"
"github.com/skycoin/getsky.org/src/util/test"
"github.com/... |
package gmail
import (
"encoding/base64"
"fmt"
"log"
"strings"
"photosaver/photo"
"google.golang.org/api/gmail/v1"
)
const _valideMessageSubject = "Save my photo pls"
//IncomingMessage - Inbound processed mail
type IncomingMessage struct {
Message *gmail.Message
From string
Subject string
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.