text stringlengths 11 4.05M |
|---|
// 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 main
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"log"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"time"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
// // key -> task
// type Tasks map[string]*Task
// func (vis Tasks) Get(key string) *Task {
// return vis... |
package filemeta
import (
"easyfiler/pkg/db"
)
type FileMeta struct {
FileSha1 string
FileMD5 string
FileName string
FileSize int64
Location string
UploadAt string
}
func UpdateFileMeta(f FileMeta) bool {
return db.UploadAndFinished(f.FileSha1, f.FileName, f.Location, f.FileSize)
}
func GetFileMeta(filesha... |
// package k8s contains check implementations that rely on interacting with
// Kubernetes API server.
package k8s
import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/shell"
"github.com/redhat-openshift-ecosystem/openshift-preflight/cli"
)
// Create a package-level openshiftEng... |
package openrtb_ext
type ImpExtPangle struct {
Token string `json:"token"`
AppID string `json:"appid,omitempty"`
PlacementID string `json:"placementid,omitempty"`
}
|
package menu
import "github.com/google/uuid"
type Manager struct {
menuItems map[string]*Item
}
func (m *Manager) AddItem(Title string, ParentMenuID string) *Item {
if m.menuItems == nil {
m.menuItems = make(map[string]*Item)
}
menuItem := Item{
ID: uuid.New(),
Title: Title,
Children: make(map[... |
package directmessages
import (
"encoding/json"
"io/ioutil"
"testing"
)
func TestItUnmarchalsMessageCreateJson(t *testing.T) {
data, err := ioutil.ReadFile("testdata/messagecreate.json")
if err != nil {
t.Error("Failed to parse messagecreate.json", err)
}
var messageCreate MessageCreate
json.Unmarshal(da... |
//if the number is divisible by 3 say "fizz", if divisible by 5, say "buzz", if by both say "fizz buzz"
package main
import (
"fmt"
)
func main() {
fmt.Println("===========Start============")
i := 0
for {
i++
switch {
case (i%3 == 0 && i%5 == 0):
fmt.Println("fizz buzz")
case i%5 == 0:
fmt.Println(... |
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package selinux
import (
"context"
"chromiumos/tast/testing"
)
// FileTestCase specifies a single test case for files to test for SELinux labels
// Files should have bee... |
package util
import (
"io/ioutil"
"strings"
"time"
)
// TimeOut general timeout
var TimeOut = time.Duration(5 * time.Second)
// fileToStringList generate list from a dic file
func fileToStringList(path string) (strList []string, err error) {
byteContent, err := ioutil.ReadFile(path)
if err != nil {
return
}
... |
package gcb
const oauthScope = "https://www.googleapis.com/auth/cloud-platform"
const triggerURL = "https://cloudbuild.googleapis.com/v1/projects/%s/triggers/%s:run"
|
package main
import (
log "github.com/sirupsen/logrus"
"lhc.go.game.user/libs/mysql"
"lhc.go.game.user/conf"
"lhc.go.game.user/router"
"lhc.go.game.user/libs/redis"
"lhc.go.game.user/utitls/logs"
)
func main() {
if err := conf.InitConfige();err!=nil{
log.Fatal("加载配置文件失败:%s.....",err)
}
if err := redis.I... |
package odoo
import (
"fmt"
)
// IrMailServer represents ir.mail_server model.
type IrMailServer struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc... |
package optgen
import (
"bytes"
"fmt"
"strings"
)
type AcceptFunc func(expr Expr) Expr
type Expr interface {
Op() Operator
Children() []Expr
ChildName(pos int) string
Value() interface{}
Visit(accept AcceptFunc) Expr
String() string
Format(buf *bytes.Buffer, level int)
}
type expr struct {
op Oper... |
package spider
//import "fmt"
import "os"
import "path"
import "net/http"
import "io"
func Download(url, lujing, filename string)string{
_,err:=os.Stat(lujing)
if err!=nil{
return "path error"
}
lujing = path.Join(lujing, filename)
_,err =os.Stat(lujing)
f,_:=os.Create(filename)
//下载文件
res, err := http.Get(u... |
package testsupport
import (
"fmt"
"lib/db"
"os"
"os/exec"
"strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
type DBConnectionInfo struct {
Hostname string
Port string
Username string
Password string
}
type TestDatabase struct {
Name string
ConnIn... |
// Copyright 2019 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 "strings"
// Leetcode 139. (medium)
func wordBreak(s string, wordDict []string) bool {
dp := make([]bool, len(s)+1)
dp[0] = true
dict := make(map[string]bool, len(wordDict))
for _, word := range wordDict {
dict[word] = true
}
for i := 1; i <= len(s); i++ {
for j := 0; j < i; j++ {
if ... |
/*
* FED API
*
* FED API is designed to create FEDACH and FEDWIRE dictionaries. The FEDACH dictionary contains receiving depository financial institutions (RDFI’s) which are qualified to receive ACH entries. The FEDWIRE dictionary contains receiving depository financial institutions (RDFI’s) which are qualified to... |
package ipin
import (
"flag"
"fmt"
// "github.com/adonese/crypto"
"github.com/google/uuid"
)
var uid = uuid.New().String()
func main() {
key := flag.String("key", "", "public key from ebs")
ipin := flag.String("ipin", "0000", "ipin you want to create its pin block")
uid1 := flag.String("uuid", "", "uuid for ... |
// Copyright 2013 Travis Keep. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or
// at http://opensource.org/licenses/BSD-3-Clause.
// Package functional provides functional programming constructs.
package functional
import (
"bufio"
"er... |
package datastore
import (
"appengine"
"appengine/datastore"
M "github.com/ionous/sashimi/compiler/model"
"github.com/ionous/sashimi/meta"
"github.com/ionous/sashimi/metal"
)
func NewModelStore(ctx appengine.Context, m *M.Model, parent *datastore.Key) *ModelStore {
// yuck! mdl uses kvs ( for value lookup ), k... |
package tx
import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/transmutate-io/cryptocore/types"
)
var (
_ Tx = (*TxETH)(nil)
_ TxStateBased = (*TxETH)(nil)
)
type TxETH struct{ Tx *ethtypes.Transaction }
func (tx *TxETH) Hash() types.Bytes { return types.Bytes(tx.Tx.Hash().Bytes... |
package randstr
import (
"strings"
"testing"
)
func TestGenerate(t *testing.T) {
for round := 100; round > 0; round-- {
out := Generate(5)
if len(out) != 5 {
t.Logf("Result length error")
t.Fail()
}
for _, r := range out {
ch := string(r)
if !strings.Contains(seeds, ch) {
t.Logf("Result co... |
// 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, ... |
// Copyright 2019 Amazon.com, Inc. or its affiliates. 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. A copy of
// the License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" fil... |
package scaling
import (
"context"
"fmt"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
"github.com/giantswarm/e2etests/v2/scaling/provider"
)
type Config struct {
Logger micrologger.Logger
Provider provider.Interface
}
type Scaling struct {
logger micrologger.Logger
provider p... |
package models
import "time"
type Post struct {
Username string
Name string
Path string
CreatedOn time.Time
}
|
package main
import (
"context"
"fmt"
"github.com/gorilla/websocket"
"io"
"os"
"os/signal"
"syscall"
"time"
)
// Orca handles the communication between the
// local port and the proxy port
type Orca struct {
tunnelConn *TunnelConnection
localConn *LocalConn
queuedDataToSend []byte
qu... |
package handler
import (
"net/http"
"github.com/gin-gonic/gin"
)
// HealthHandler - ヘルスチェック用の handler
type HealthHandler interface {
GetHealth(c *gin.Context)
}
type healthHandler struct {
}
// NewHealthHandler - healthHandler の生成
func NewHealthHandler() HealthHandler {
return &healthHandler{}
}
func (h *heal... |
package main
import "fmt"
func main() {
var a, b int
a = a ^ b
b = a ^ b
a = a ^ b
fmt.Print(a, b)
}
|
package gophorem
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
// Client makes all the API calls to dev.to.
type Client struct {
apiKey string
baseURL string
http *http.Client
}
// Arguments are used for passing query parameters to the dev.to api.
type Ar... |
package kubernetes
import (
"testing"
"github.com/stretchr/testify/assert"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func Test_createPlatformInfoFromAPIObjects(t *testing.T) {
tests := []struct {
name string
tag string
apiGroups []*v1.APIGroup
apiResourceList ... |
/*
Copyright 2021-2023 ICS-FORTH.
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... |
//Package gologging provides a logger implementation based on the github.com/op/go-logging pkg
package gologging
import (
"fmt"
"io"
"log/syslog"
"os"
"github.com/devopsfaith/krakend/config"
"github.com/devopsfaith/krakend/logging"
gologging "github.com/op/go-logging"
)
// Namespace is the key to look for ext... |
package scrapers
import (
//"github.com/berryhill/web-scrapper/models"
"github.com/PuerkitoBio/goquery"
)
// simulating a db collection
var products_store = map[int]string {
1: "flyrods",
}
type Scraper interface {
getBrand(item *goquery.Selection) (string, error)
getName(item *goquery.Selection) (string, erro... |
package test
import (
"github.com/sirupsen/logrus"
"github.com/tietang/props/ini"
"github.com/tietang/props/kvs"
"go-resk/src/infra"
"go-resk/src/infra/base"
)
func init() {
logrus.Info("测试Starter初始化")
infra.Register(&base.PropsStarter{})
infra.Register(&base.DbxStarter{})
infra.Register(&base.LogStarter{})
... |
package cmd
import (
"fmt"
"os"
"strings"
"time"
"github.com/fugue/fugue-client/client/environments"
"github.com/fugue/fugue-client/client/scans"
"github.com/fugue/fugue-client/format"
"github.com/fugue/fugue-client/models"
"github.com/go-openapi/runtime"
"github.com/spf13/cobra"
)
// NewTriggerScanCommand... |
package transshipment
import (
"testing"
)
func TestOverwrite(t *testing.T) {
}
|
/*
* Copyright 2018, Oath Inc.
* Licensed under the terms of the MIT license. See LICENSE file in the project root for terms.
*/
package main
import (
"github.com/serhii-samoilenko/pod-startup-lock/lock/config"
"github.com/serhii-samoilenko/pod-startup-lock/lock/service"
"github.com/serhii-samoilenko/pod-startu... |
// Package triangle : all about triangle operation.
package triangle
import (
"math"
)
// Kind is to determine what kind triangle it is.
type Kind int
const (
// NaT means not a triangle
NaT = iota
// Equ means equilateral triangle
Equ
// Iso means isosceles triangle
Iso
// Sca means scalene triangle
Sca
)
... |
package models
import (
"errors"
"time"
"github.com/KEXPCapstone/shelves-server/library/models/releases"
"github.com/globalsign/mgo/bson"
)
type Shelf struct {
ID bson.ObjectId `json:"id" bson:"_id"`
OwnerID bson.ObjectId `json:"ownerId"`
OwnerName string `json:"own... |
package request
import (
"bytes"
"errors"
"io/ioutil"
"net/http"
"net/url"
"path"
"testing"
)
type clientFunc func(req *http.Request) (*http.Response, error)
func (f clientFunc) Do(req *http.Request) (*http.Response, error) {
return f(req)
}
func TestRequestSetHeaders(t *testing.T) {
server := clientFunc(f... |
package server
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestSimpleHealthCheck(t *testing.T) {
path := "/status.txt"
s := NewSimpleHealthCheck(path)
a := NewActivityMonitor()
s.Start(a)
req, _ := http.NewRequest("GET", path, nil)
wr := httptest.NewRecorder()
s.ServeHTTP(wr, req)
... |
package main
import (
"github.com/fedesog/webdriver"
"log"
"time"
)
func main() {
chromeDriver := webdriver.NewChromeDriver("./chromedriver83.0.4103.39")
err := chromeDriver.Start()
if err != nil {
log.Println(err)
}
desired := webdriver.Capabilities{"Platform": "Linux"}
required := webdriver.Capabilities{... |
package camo
import (
"encoding/binary"
"errors"
"fmt"
"io"
"net"
)
const (
// IPv4HeaderLen is IPv4 header length without extension headers
IPv4HeaderLen = 20
// IPv6HeaderLen is IPv6 header length without extension headers
IPv6HeaderLen = 40
)
// GetIPPacketVersion gets ip protocol version from ip packet
... |
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"math"
"net/http"
"strconv"
"sync"
"time"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/api"
hetznerapi "github.com/mxschmitt/golang-hetzner-robot-metrics/pkg/api"
"github.com/julienschmidt/httprouter"
"github.com/prome... |
package main
//847. 访问所有节点的最短路径
//存在一个由 n 个节点组成的无向连通图,图中的节点按从 0 到 n - 1 编号。
//
//给你一个数组 graph 表示这个图。其中,graph[i] 是一个列表,由所有与节点 i 直接相连的节点组成。
//
//返回能够访问所有节点的最短路径的长度。你可以在任一节点开始和停止,也可以多次重访节点,并且可以重用边。
//
//
//
//示例 1:
//
//
//输入:graph = [[1,2,3],[0],[0],[0]]
//输出:4
//解释:一种可能的路径为 [1,0,2,0,3]
//示例 2:
//
//
//
//输入:graph = [[1... |
// Copyright 2017 The Aiicy Team.
//
// 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... |
package main
import (
"math"
"os"
"github.com/veandco/go-sdl2/gfx"
"github.com/veandco/go-sdl2/sdl"
)
type Point [2]float64
type Sphere = [10][10]Point
const (
FRAMES_PER_SECOND = 60
MS_PER_FRAME = uint32(1000 / FRAMES_PER_SECOND)
)
var (
window *sdl.Window
render *sdl.Renderer
right = true
scale ... |
// 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 logger
import "go.uber.org/zap"
// TODO create general interface with generic fields
func Debug(msg ...interface{}) {
logger, _ := zap.NewProduction()
defer logger.Sync() // flushes buffer, if any
sugar := logger.Sugar()
sugar.Debug(msg...)
}
func Debugf(format string, args ...interface{}) {
logger, _ ... |
//go:build integration
// +build integration
package k8s
import (
"testing"
"time"
"github.com/libopenstorage/secrets"
"github.com/libopenstorage/secrets/test"
"github.com/pborman/uuid"
"github.com/portworx/sched-ops/k8s/core"
"github.com/stretchr/testify/assert"
kubernetes "k8s.io/client-go/kubernetes/fake"... |
/*
Copyright 2016 Tamás Gulácsi
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
... |
package app
import "time"
// Ad falksdjfs
type Ad struct {
ID int `json:"id"`
CreateAt time.Time `json:"created_at"`
Subject string `json:"subject"`
Body string `json:"body"`
Price *float64 `json:"price,omitempty"`
Email string `json:"email"`
}
|
package shared
import (
"go.uber.org/zap"
)
// loggingInitialized is a flag to keep track of whether logging has been set up
var loggingInitialized = false
// Logger is the global logger to use
var Logger zap.SugaredLogger
// InitLogging initializes the logger
func InitLogging() {
if loggingInitialized == true {
... |
package runtime
import (
"net/http"
"reflect"
"regexp"
"testing"
)
func TestNewRoute(t *testing.T) {
noopHandlerFn := http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})
type args struct {
pattern string
handler http.Handler
}
tests := []struct {
name string
args args
want *... |
// 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 main
//
// Notes:
//
// The life of the router is to pull its dataMsg channel, and feed it it
// to one of a number of worker queues.
//
// The life of a worker is to pull messages from it's queue, and for each,
// build metrics.
//
// A worker handles produceMetrics callbacks as follows:
// On build metric;
/... |
//go:build (!memtrace && !js && !plan9 && !windows && !armbe && !arm64be && !ppc && !ppc64 && !mips && !mips64 && !s390x)
// +build !memtrace,!js,!plan9,!windows,!armbe,!arm64be,!ppc,!ppc64,!mips,!mips64,!s390x
package exec
import (
"fmt"
"reflect"
"runtime/debug"
"syscall"
"unsafe"
)
var ErrLimitExceeded = fmt... |
package requests
import (
"fmt"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
)
// FetchingLatestQuizStatistics This endpoint provides statistics for all quiz versions, or for a specific
// quiz version, in which case the output is guaranteed to represent the
//... |
package blockparser
import (
"math/big"
"time"
)
// Parse requires and parses specified block by ID
func (p *Parser) Parse(block *big.Int) error {
// metrics
t := time.Now()
// require block
blockBytes, err := p.queryBlockData(block)
if err != nil {
return err
}
defer blockBytes.Close()
// metrics
if p... |
// 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"
"strings"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/inputs/fixture"
"chromiumos... |
package log
import (
"context"
"strings"
"sync"
"github.com/upfluence/log"
"github.com/upfluence/log/record"
elsink "github.com/upfluence/log/sink/error_logger"
"github.com/upfluence/log/sink/leveled"
"github.com/upfluence/log/sink/multi"
"github.com/upfluence/log/sink/writer"
"github.com/upfluence/pkg/cfg... |
package rdm
import "github.com/go-redis/redis/v8"
var RDM *redis.Client
func GetRdm() *redis.Client {
if RDM == nil {
RDM = redis.NewClient(&redis.Options{
Addr: "127.0.0.1:6379",
DB: 0,
})
}
return RDM
}
|
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package crostini
import (
"context"
"time"
"chromiumos/tast/local/bundles/cros/crostini/verifyapp"
"chromiumos/tast/local/chrome/browser"
"chromiumos/tast/local/chrome... |
// 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 main
import "golang-learning-playground/src/printer"
func main() {
words := []string{
"hi",
"there",
"johny",
}
multiLinePrinter := printer.MultiLinePrinter{}
multiLinePrinter.Print(words)
singleLinePrinter := printer.SingleLinePrinter{}
singleLinePrinter.Print(words)
}
|
package main
import (
"fmt"
"runtime"
"strconv"
"time"
"github.com/go-redis/redis/v8"
"gitlab.com/myikaco/msngr"
"gitlab.com/myikaco/saga"
)
var OpenTradeSaga saga.Saga = saga.Saga{
Steps: []saga.SagaStep{
{
Transaction: calcPosSize,
CompensatingTransaction: cancelCalcPosSize,
},
{
... |
// Copyright 2018 NetApp, Inc. All Rights Reserved.
package storageattribute
import (
"fmt"
)
func NewBoolOffer(offer bool) Offer {
return &boolOffer{
Offer: offer,
}
}
// Matches is a boolean offer of true matches any request; a boolean offer of false
// only matches a false request. This assumes that the re... |
// +build ignore
package main
import (
"bytes"
"context"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
flag "github.com/spf13/pflag"
)
var (
ganacheURL string
txH... |
package parsefb
import (
"github.com/PuerkitoBio/goquery"
"strings"
"testing"
)
func TestParseTime(t *testing.T) {
doc, err := goquery.NewDocumentFromReader(strings.NewReader(testhtml1))
if err != nil {
t.Error(err)
return
}
timestamp, err := GetTimeStamp(doc)
if err != nil {
t.Error(err)
return
}
... |
package flywheel
import (
"encoding/json"
"io"
"log"
"os"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/ec2"
)
// SpinINTERVAL determines how often flywheel will update its
// internal state a... |
/*
Copyright 2022-2023 ICS-FORTH.
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... |
// Copyright 2014 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 client
import (
"fmt"
"github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io"
fleetcontrollers "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/generated/controllers/core"
corev1 "github.c... |
package net
import "zinx/03-Request/iface"
type Request struct {
conn iface.IConnection
data []byte
len uint32
}
func NewRequest(conn iface.IConnection,data []byte,len uint32) iface.IRequest{
return &Request{
conn: conn,
data: data,
len: nil,
}
}
func (req *Request)GetConnection()iface.IConnection{
ret... |
package service
import (
"fmt"
"strings"
"time"
"github.com/mirzaakhena/admin/model"
log "github.com/mirzaakhena/common/logger"
"github.com/mirzaakhena/common/utils"
)
// IAdminService is
type IAdminService interface {
IUserService
GetOneSpace(sc model.ServiceContext) *model.Space
GetAllUserSpace(sc model.... |
package Wallet
import (
"fmt"
"testing"
)
const TestWalletNode = "1"
func TestGetWalletByNodeId(t *testing.T) {
ws := Wallets{}
wallet, err := ws.GetWalletByNodeId(TestWalletNode, "1M59oANzychihR3fXJRxQGUqXxDume2KZ2")
if err != nil {
fmt.Print(err)
}
fmt.Print(wallet)
}
func TestGetWallets(t *testing.T) {
... |
package mysql
import (
"database/sql"
"errors"
"time"
)
func CreateDB(db *sql.DB, createDB string) error {
_, err := db.Exec(createDB)
return err
}
func CreateTable(db *sql.DB, createTable string) error {
_, err :=db.Exec(createTable)
return err
}
func Insert(db *sql.DB, insert string, ) |
package factogo
import (
"math/rand"
"time"
)
const defaultCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func seededRand() *rand.Rand {
return rand.New(rand.NewSource(time.Now().UnixNano()))
}
/*
ProduceString produces a ramdom string.
*/
func ProduceString() string {
length := 20
... |
// Copyright 2020 The LUCI 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... |
//给定一个整数数组 prices,其中第 i 个元素代表了第 i 天的股票价格 ;prices = [1, 3, 2, 8, 4, 9], fee = 2
//结果:能够达到的最大利润: 该怎么买进卖出
package main
import (
"fmt"
"math"
)
func main(){
prices := []float64{1, 3, 2, 8, 4, 9}
fmt.Println(maxProfit(prices,2))
}
func maxProfit(prices []float64,fee float64) float64{
n := len(prices)
if n<1 {
retu... |
package main
import (
"fmt"
// "os"
// "os/user"
// "go-interpreter/repl"
"go-interpreter/ast"
"go-interpreter/token"
)
func main() {
Statements := []ast.Statement{}
t := token.Token{token.EOF, ""}
i := &ast.Identifier{t, "justRandom"}
statement1 := &ast.LetStatement{Token: t}
append(Statements, stateme... |
package tree
import (
"log"
)
type Cluster struct{
Cluster_id int
Num_of_points int
ListOfUnits map[Range]*Unit
}
func (c *Cluster) GetCenter() Point {
var Center_vec []float64
for _, unit := range c.ListOfUnits{
if len(unit.Points) > 0 && Center_vec == nil{
for _, p := range unit.Points{
Center_vec ... |
package pipeline
import (
"strconv"
"strings"
"github.com/project-flogo/core/data/path"
)
type scopeImpl struct {
values map[string]interface{}
}
func NewPipelineScope(input map[string]interface{}) *scopeImpl {
if input != nil {
return &scopeImpl{values: input}
}
values := make(map[string]interface{})
re... |
/*
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 agreed to in writing, ... |
// Copyright © Copyright 2020 Orion Labs, 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... |
package tydaapi
import (
"fmt"
"log"
"net/url"
"strings"
"github.com/PuerkitoBio/goquery"
)
// Languages is a map from short to long form of languages
var Languages = map[string]string{
"sv": "Svenska",
"en": "Engelska",
"fr": "Franska",
"de": "Tyska",
"es": "Spanska",
"la": "Latin",
"nb": "Norska",
}
/... |
package leetcode_go
func twoSum(nums []int, target int) []int {
m := make(map[int]int)
for idx, num := range nums {
if anotherIdx, ok := m[num]; ok {
return []int{idx, anotherIdx}
}
m[target-num] = idx
}
return []int{}
}
|
package utils
import (
"log"
"regexp"
)
// Str2Uint string表示的数字大于0
func Str2Uint(str string) int {
res := 0
for _, v := range str {
if '0' <= v && v <= '9' {
res = res*10 + int(v) - '0'
} else {
log.Fatal("this string is not a pure num")
return 0
}
}
return res
}
func RegFind(pattern, targetStr... |
package prov
import (
"fmt"
"io"
)
type AccessedPath struct {
AccessID string
RunID int64
Path string
PathIndex int64
PathRole string
}
func GetAccessedPaths(executed []Execution, opens []FileOpen) []AccessedPath {
var accessed []AccessedPath
for _, e := range executed {
fileIndex, _ := PathI... |
package content
import (
"io"
"github.com/webnice/transport/v3/data"
"golang.org/x/text/encoding"
)
// Interface is an interface of package
type Interface interface {
io.WriterTo
// Transcode is an transcoding content from the specified encoding to UTF-8
Transcode(e encoding.Encoding) Interface
// Transfor... |
package main
import "github.com/gin-gonic/gin"
func main() {
g := gin.Default()
g.GET("/gin", func(context *gin.Context) {
context.JSON(200,gin.H{"message":"hello gin"})
})
g.Run()
}
|
package mail
import (
"fmt"
"gopkg.in/gomail.v2"
"time"
)
type SMTPConfig struct {
Host string
Port int
Username string
Password string
SSL bool
}
type SMTPSender struct {
config SMTPConfig
}
func NewSMTPSender(config SMTPConfig) *SMTPSender {
return &SMTPSender{config}
}
func (m *SMTPSender... |
package routers
import (
"github.com/gin-gonic/gin"
"go-admin-starter/controllers/api"
"go-admin-starter/controllers/api/v1"
"go-admin-starter/middleware/authrole"
"go-admin-starter/middleware/jwt"
)
func initApiRouter(r *gin.Engine) *gin.Engine {
apiGroup := r.Group("/api")
{
apiGroup.POST("/auth", api.GetA... |
package server
import (
"net/http"
"github.com/cnrancher/autok3s/pkg/server/ui"
"github.com/gorilla/mux"
responsewriter "github.com/rancher/apiserver/pkg/middleware"
"github.com/rancher/apiserver/pkg/server"
"github.com/rancher/apiserver/pkg/store/apiroot"
"github.com/rancher/apiserver/pkg/types"
// pprof
... |
package store
// PlanRepository specifies the possible interactions with Plan records
type PlanRepository interface {
Get(id int) (Plan, error)
}
// SimplePlanRepository implements a simple, in-memory PlanRepository
type SimplePlanRepository struct {
store *MemoryStore
}
// NewSimplePlanRepository is a constructor... |
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
fileBytes, err := ioutil.ReadFile("text.txt")
if err != nil {
log.Fatal(err)
}
fmt.Println(fileBytes)
fileString := string(fileBytes)
fmt.Println(fileString)
}
|
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package pacs_v09
import (
"reflect"
"github.com/moov-io/iso20022/pkg/utils"
)
// Must be at least 1 items long
type ExternalAccountIdentification1Code string
func (r Ex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.