text stringlengths 11 4.05M |
|---|
package setting
import (
"flag"
"github.com/go-ini/ini"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
"log"
"path/filepath"
)
var (
Cfg *ini.File
KubeClient *kubernetes.Clientset
)
func init(){
LoadBase()
LoadKubeClient()
}
func ... |
// Copyright 2021 The Perses 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 ... |
package apistructs
type WorkflowParams []struct {
Parameter string `json:"param"`
Value interface{} `json:"value"`
}
|
//
// Practicing MongoDB
//
// Copyright © 2016. All rights reserved.
//
package http
import (
"github.com/moemoe89/go-mongodb-gita/api/api_struct/form"
"github.com/moemoe89/go-mongodb-gita/api/api_struct/model"
"github.com/moemoe89/go-mongodb-gita/api/service"
cons "github.com/moemoe89/go-mongodb-gita/constant... |
package main
type LoginResponse struct {
AccessToken string
RefreshToken string
}
|
package topic7_reverse
import (
"bytes"
"math"
"strconv"
)
func reverseByConvertString(x int) int {
m := strconv.Itoa(x)
flag := x >= 0
var res []byte
pos := 0
if !flag {
pos++
}
for i := len(m) - 1; i >= pos; i-- {
res = append(res, m[i])
}
rev, _ := strconv.ParseInt(string(bytes.TrimPrefix(res, []by... |
package apis
import v1 "github.com/tmax-cloud/registry-operator/pkg/apiserver/apis/v1"
func init() {
AddApiFuncs = append(AddApiFuncs, v1.AddV1Apis)
}
|
package sms
type TwilioAdapter struct {
accountSid string
authToken string
}
func NewTwilioAdapter(accountSid string, authToken string) *TwilioAdapter {
return &TwilioAdapter{
accountSid: accountSid,
authToken: authToken,
}
}
func (adapter *TwilioAdapter) Send(to string, from string, body string) error {
... |
package pkcs7
import (
"encoding/asn1"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// marshal and unmarshal so FullBytes is set
func roundTrip(t *testing.T, l AttributeList) AttributeList {
t.Helper()
raw, err := marshalUnsortedSet(l)
require.NoError(t, err)
... |
package Model
import (
_struct "1/struct"
)
func Oauth(userinfo map[string]interface{},token string) (bool,uint) {
var user _struct.User
DB.Where("token=?",token).Find(&user)
//row,err:=DB.Query("select name from user where token=?",token)
//defer row.Close()
//for row.Next() {
// err = row.Scan(&u.UserName)
... |
package msgpack
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"math"
"reflect"
"strings"
"testing"
)
// pack packs the values vs and returns the result.
//
// Go Type Encoder method
// nil PackNil
// bool PackBool
// int64 PackInt
// uint64 PackUint
// float64 PackFloat
// ar... |
package service
import (
"errors"
"fmt"
"mall/app/api/web/groups/model"
)
func (s *Service) CreateActivity(act model.EweiShopGroupsActivity) (*model.EweiShopGroupsActivity, error) {
if act.Id != "" {
act.Id = ""
}
if act.Uniacid == 0 {
return nil, errors.New("无效的应用ID")
}
if act.Uid == 0 {
return nil, ... |
package main
import (
"encoding/csv"
"flag"
"fmt"
"log"
"math/rand"
"os"
"strings"
"time"
)
// Result stores the data about quiz state for questions and answers
type Result struct {
QuestionsCount int
CorrectAnswersCount int
}
// Scanner is an interface to repeat fmt.Scan function
type Scanner func(a ... |
package main
import (
"fmt"
)
type list struct {
len int
head *listNode
}
type listNode struct {
data string
prev *listNode
next *listNode
}
func (n *listNode) String() string { return n.data }
func (l *list) String() string {
str := "("
tmp := l.head
for tmp != nil {
str = str + " " + fmt.Sprint(tmp)
... |
package armstrong
import "math"
// IsNumber checks a number whether is a armstrong number or not
func IsNumber(n int) bool {
var sum float64
digits := []int{}
temp := n
for temp > 0 {
r := temp % 10
digits = append(digits, r)
temp /= 10
}
length := len(digits)
for i := 0; i < len(digits); i++ {
sum = s... |
// 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 demomode
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/uiauto"
"chromiumos/tast/local/chrom... |
package types
//Article to be exported
type Article struct {
Title string `json:"Title"`
Desc string `json:"desc"`
Content string `json:"content"`
}
// Articles global variable
type Articles []Article
|
package scheduler
import (
"fmt"
"go.etcd.io/etcd/clientv3"
"golang.org/x/net/context"
"logserver/logs"
"logserver/slaver/common"
"logserver/slaver/conf"
"logserver/slaver/etcd"
"logserver/slaver/kafka"
"time"
)
func InitScheduler() {
NewScheduler()
go Gscheduler.ScheuleLoop()
Gscheduler.restartLogJob()
... |
package dist
import (
"errors"
)
type BernoulliDistribution struct {
DistributionType string
}
// Generate random numbers that fit the
// Bernoulli distribution given a probability
func (d BernoulliDistribution) RandVar(p float64) (int, error) {
if p < 0 || p > 1 {
return -1, errors.New("p must be a value bet... |
/*
* Npcf_SMPolicyControl API
*
* Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 1.0.4
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
import (
"time"
)
type... |
package aws
// This file contains all the supplementary functions that are required to query Cloud Watch (AWS)
import (
"testing"
"time"
"github.com/aws/aws-sdk-go/service/cloudwatch"
taws "github.com/gruntwork-io/terratest/modules/aws"
"github.com/stretchr/testify/require"
)
// getAlarmsNamesAndStatesByPrefix... |
package server
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/derry6/gleafd/pkg/log"
)
func TestGetFormValueInt(t *testing.T) {
defv := 1
var tests = map[string]int{
"": 1,
"count": 100,
"args": -102,
"key... |
package splitback
import (
"appengine"
"appengine/datastore"
"appengine/urlfetch"
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"text/template"
"strings"
)
const payTmplString = `{
"actionType":"PAY",
"currencyCode":"USD",
"receiverList":{"receiver":[{{.Receivers}}]},
"returnUrl":"{{.AppUrl}}/rest/... |
package main
import (
"fmt"
"time"
)
func main() {
// Like c#'s using - will get called as function completes
defer fmt.Println("Exiting")
// Run infinite goroutine
go printTimePeriodicallyInfinetly()
// Run finite inline goroutine
go func(milliseconds int) {
sleepDuration := time.Duration(milliseconds) *... |
package main
import(
"testing"
)
func Test_SearchVenues(t *testing.T){
venues, err := getVenues()
if err != nil {
t.Error("Failed", err)
} else {
t.Log("Passed", venues)
}
}
|
// Copyright 2020 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 kubernetesapply
import (
"bytes"
"context"
"fmt"
"sync"
"github.com/pkg/errors"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schem... |
package ioutil
import (
"bytes"
"crypto/md5" //nolint
"encoding/hex"
"reflect"
"testing"
)
func TestHashingReader(t *testing.T) {
src := []byte{'a', 'b', 'c'}
reader := NewHashReader(md5.New(), bytes.NewBuffer(src)) //nolint
tmp := make([]byte, 6)
n, err := reader.Read(tmp)
if err != nil {
t.Fatal(err)
... |
/*
Copyright 2022 The Skaffold Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, sof... |
package main
import "fmt"
func main() {
a := "홍춘삼"
b := "홍길동"
if a > b {
fmt.Printf("a인 %s가 더 크다\n", a)
} else {
fmt.Println("b인 %s가 더 크다\n", b)
}
c := 1
//var d int
c++
d := c
//컴파일에러-> d:=c++ 또는 d:=++c
//다른변수에 넣을 수 없음(자바,c++은 됨)
fmt.Println(c, d)
}
|
/*
* Copyright 2020 zpxio (Jeff Sharpe)
*
* 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 ag... |
// Copyright 2020 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, ... |
// +build tools
package tools
import (
_ "github.com/golang/mock/gomock"
_ "github.com/golang/mock/mockgen/model"
)
|
package postgres
import (
"context"
"database/sql"
"time"
"github.com/lib/pq"
"github.com/mainflux/mainflux/auth"
"github.com/mainflux/mainflux/pkg/errors"
)
var (
errSave = errors.New("failed to save key in database")
errRetrieve = errors.New("failed to retrieve key from database")
errDelete = errors... |
package cities
import (
"log"
"testing"
)
func TestOne(t *testing.T) {
log.Println("TEST ONE")
}
func TestTwo(t *testing.T) {
c, err := FromFile("../DATA/cities.json", 100)
if err != nil {
t.Fatal(err)
}
if len(c) != 100 {
t.Fatal("Len C: ", len(c))
}
pt := [2]float64{45.47711342, -75.52129503}
ct, d :... |
package service
import (
"encoding/json"
"errors"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"github.com/NYTimes/gizmo/examples/nyt"
"github.com/NYTimes/gizmo/examples/nyt/nyttest"
"github.com/NYTimes/gizmo/server"
)
func TestGetCats(t *testing.T) {
tests := []struct {
givenURI string
givenC... |
// Copyright © 2017 Sam Elliott <me@sam-e.co.uk>
//
// 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 l... |
package registry
import (
"fmt"
"io/ioutil"
"path/filepath"
"plugin"
"github.com/alessio/go-plugins-ex/module"
)
var registry map[string]registryEntry
type registryEntry struct {
path string
module module.Interface
}
func LoadFromDir(pluginsDir string) error {
registry = make(map[string]registryEntry)
... |
package main
import (
"fmt"
"time"
)
func main() {
timeout := make(chan bool, 1)
go func() {
fmt.Println("------------ 子进程1--------------")
t1 := time.Now().UnixNano()
fmt.Println(t1)
fmt.Println("这个一定会执行")
time.Sleep(3 * time.Second)
// timeout <- true
}()
fmt.Println("首先逻... |
package pullvet
import (
"bytes"
"context"
"encoding/json"
"fmt"
"log"
"os"
"regexp"
"strings"
"github.com/google/go-github/v28/github"
"github.com/variantdev/go-actions"
)
const DefaultNoteRegex = "[\\*]*([^\\*\r\n:]+)[\\*]*:\\s+```[^\n]*\n((?s).*?)\n```"
var newlineRegex = regexp.MustCompile(`\r\n|\r|\n... |
package buttons
import (
"encoding/json"
"io/ioutil"
"log"
"reflect"
"sort"
"github.com/Aegon-n/sentinel-bot/sno/constants"
"gopkg.in/telegram-bot-api.v4"
)
type B struct {
Text string
Data string
}
type Buttons struct {
SNOButtons []map[string]string `json:"SNOButtons"`
DownloadsButtons... |
package multicrc
func reflectByte(x uint8) uint8 {
x = (x&0x0F)<<4 | (x&0xF0)>>4
x = (x&0x33)<<2 | (x&0xCC)>>2
x = (x&0x55)<<1 | (x&0xAA)>>1
return x
}
func reflectWithLen(x uint64, len uint) uint64 {
if len <= 8 {
return uint64(reflectByte(uint8(x))) >> (8 - len)
}
result := uint64(0)
for i := uint(0); i ... |
package composter
import (
// "github.com/graphql-go/graphql"
// "github.com/stretchr/testify/assert"
// "encoding/json"
"testing"
)
func TestSchema(t *testing.T) {
_ = `query groupQuery {
group(id: "sg-badbadbad", type: "security") {
id
type
instance_count
resource {
... on aws.autoscaling... |
package main
import (
"github.com/NYTimes/gizmo/examples/nyt"
"github.com/NYTimes/gizmo/pubsub"
"github.com/NYTimes/gizmo/pubsub/aws"
"github.com/sirupsen/logrus"
)
func main() {
cfg := aws.LoadSNSConfigFromEnv()
pub, err := aws.NewPublisher(cfg)
if err != nil {
pubsub.Log.WithFields(logrus.Fields{
"erro... |
package operations
import (
"errors"
ct "github.com/traviscox1990/GoCalculate/coreTypes"
)
// MatrixScalarMulti is an operation for multiplying a Matrix by a scalar float64 value
func MatrixScalarMulti(scalar float64, matrix ct.Matrix) ct.Matrix {
newMatrix := matrix.Copy()
for i := 0; i < matrix.GetNumRows(); i... |
package main
import (
"fmt"
"sort"
)
func main() {
nums := []int{-1, 0, 1, 2, -1, -4}
fmt.Println(threeSum(nums))
}
func threeSum(nums []int) [][]int {
// 升序
sort.Ints(nums)
result := [][]int{}
// 固定第一个数
for first := range nums {
// 第一个数去重
if first > 0 && nums[first] == nums[first-1] {
continue
}
... |
package main
import (
"fmt"
)
type Node struct {
id int
next *Node
prev *Node
}
func main() {
players := 468
lastMarble := 7184300
n := &Node{0, nil, nil}
n.next = n
n.prev = n
first := n
first.print()
scores := make([]int, players)
currentPlayer := 1
for id := 1; id <= lastMarble; id++ {
current... |
package battery
import (
flutter "github.com/go-flutter-desktop/go-flutter"
"github.com/go-flutter-desktop/go-flutter/plugin"
)
// Make sure to use the same channel name as was used on the Flutter client side.
const channelName = "samples.flutter.dev/battery"
// MyBatteryPlugin demonstrates how to call a platform... |
package ini_test
import (
"fmt"
"github.com/DeedleFake/ini"
"io"
"strings"
"testing"
)
const test = `[Test 1]
This=is
# Comment
a=test.`
func TestNext(t *testing.T) {
p := ini.NewParser(strings.NewReader(test))
for {
tok, err := p.Next()
if err != nil {
if err == io.EOF {
break
}
t.Fatalf("... |
package main
import (
"math/rand"
"time"
)
func init() { rand.Seed(time.Now().UnixNano()) }
func gen(ci chan int) {
for {
ci <- rand.Intn(100)
}
}
func main() {
ci := make(chan int)
for i := 0; i < 10; i++ {
go gen(ci)
}
for i := 0; i < 100; i++ {
println(i, ":", <-ci)
}
}
|
package main
import (
"fmt"
"io/ioutil"
"os"
"code.cloudfoundry.org/garden"
gclient "code.cloudfoundry.org/garden/client"
gconn "code.cloudfoundry.org/garden/client/connection"
"github.com/urfave/cli"
"github.com/williammartin/garden-curator/blueprint"
yaml "gopkg.in/yaml.v2"
)
var GrowCommand = cli.Command... |
package usecase
import (
"marketplace/accounts/domain"
"marketplace/accounts/internal/infrastructure/ads"
"github.com/go-pg/pg/v10"
"github.com/gin-gonic/gin"
)
type DeleteMeCmd func (db *pg.DB, c *gin.Context, acc *domain.Account) error
func DeleteMe(adsFetcher ads.Fetcher) DeleteMeCmd {
return func (db *pg.D... |
package main
import (
"bufio"
"flag"
"fmt"
"io"
"log"
"net"
"os"
"strings"
)
var addr = flag.String("addr", "localhost:8080", "address of server")
func main() {
conn, err := net.Dial("tcp", *addr)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
go copy(os.Stdout, conn)
sendCmd(conn)
}
func c... |
package main
import (
"fmt"
"time"
)
/*
Return true or false if its possible to generate the target sum
using numbers from given array.
- We can use the elements of the array as many times as we want
- We can assume that all input numbers are nonnegative
*/
func main() {
defer timeTrack(time.Now(), "canSum")
/... |
package models
import (
"decept-defense/controllers/comm"
"fmt"
"strings"
)
type ProbeBaits struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;not null;unique;column:id" json:"id"`
CreateTime string `gorm:"not null"`
Creator string `gorm:"not nu... |
// Copyright 2014 Dirk Jablonowski. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package barometer
import (
"fmt"
"github.com/dirkjabl/bricker"
"github.com/dirkjabl/bricker/device"
"github.com/dirkjabl/bricker/net/packet"
)
// GetAlt... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"github.com/bitmark-inc/bitmarkd/command/bitmark-cli/rpccalls"
"github.com/urfave/cli"
)
func runBlockDump(c *cli.... |
package service
import (
"github.com/dmr/microservice/productservice/dbclient"
"net/http"
"github.com/gorilla/mux"
"encoding/json"
"strconv"
"github.com/dmr/microservice/productservice/model"
"fmt"
)
var DBClient dbclient.IBoltClient
func GetBrand(w http.ResponseWriter, r *http.Request) {
fmt.Print("Starting ... |
package utils
import (
"fmt"
"strconv"
)
func ConvertString2Int(value string) int {
intVal, err := strconv.Atoi(value)
if err != nil {
fmt.Println("err", err)
}
return intVal
} |
//Slice 中裝 slice
package main
import "fmt"
func main() {
x := []int{1, 3, 5, 7, 9}
y := []int{2, 4, 6, 8, 10}
// slice裡裝slice
z := [][]int{x, y}
fmt.Println(x, y)
fmt.Println(z)
}
|
/*
Copyright 2021 The KodeRover 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, s... |
package v1
import (
"errors"
"github.com/gorilla/sessions"
"github.com/labstack/echo/v4"
"github.com/traPtitech/trap-collection-server/src/domain"
)
const (
launcherUserKey = "launcherUser"
launcherVersionKey = "launcherVersion"
sessionContextKey = "session"
)
func getLauncherUser(c echo.Context) (*domai... |
package main
import "fmt"
/*
给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。
例:
输入:head = [1,2,3,4]
输出:[2,1,4,3]
示例 2:
输入:head = []
输出:[]
*/
type ListNode struct {
Val int
Next *ListNode
}
func main() {
l1 := &ListNode{
Val: 2,
Next: &ListNode{
Val: 4,
Next: &ListNode{
Val: 6,
... |
package k8s
import (
"fmt"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
engineConfigmap = "license-config"
)
var engineNamespace = "engine"
// update license-config configmap
func UpdateConfigmapWithLicense(k8sConf, mode, data string) ... |
package securityspy
import (
"crypto/tls"
"image"
"image/jpeg"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
"github.com/golift/ffmpeg"
"github.com/pkg/errors"
)
// All returns interfaces for every camera.
func (c *Cameras) All() (cams []*Camera) {
for _, cam := range c.server.systemInfo.Cam... |
package main
import (
"os"
log "github.com/Sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/stock"
)
var (
installConfigCommand = kingpin.Command("install-config", "Generate the Install Config asset")
dirFlag = kingpin.Fl... |
// Copyright 2016 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 client
import (
"github.com/kr/fs"
"github.com/pkg/sftp"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
)
type (
SFTPClient interface {
Connect() error
Close() error
StatVFS(path string) (*sftp.StatVFS, error)
Walk(root string) *fs.Walker
}
sftpClient struct {
*sftp.Client
sshC... |
package tt
var TT = "string"
|
package models
import (
"beegoBlog/utils"
"errors"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/toolbox"
_ "github.com/go-sql-driver/mysql"
)
/**
* 更改密码
*/
func (this *Users) ChangePassword(username, oldPassword, password string) error {
if !this.CheckLogin(username, utils.LoginPassword(oldPasswor... |
package diag
import (
"fmt"
"io"
"os"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"github.com/kapitanov/natandb/pkg/storage"
)
func init() {
cmd := &cobra.Command{
Use: "wal",
Short: "Inspect write-ahead file",
}
Command.AddCommand(cmd)
dataDir := cmd.Flags().StringP("data", "d", "./data",... |
/*
Gnit is a program for checking if new Git repositories has been initialised properly.
Not in the sense of the `git init` command but in the sense of configuration and hooks.
What it does:
- sanity checks on the global configuration
- checks configuration of repository
- checks for expected Git hooks
... |
package main
func main() {
var x = int()
}
|
package sub
import (
"net/http"
"github.com/labstack/echo"
)
func getUserName(c echo.Context) error {
name := c.Param("name")
return c.String(http.StatusOK, name)
}
func show(c echo.Context) error {
team := c.QueryParam("team")
member := c.QueryParam("member")
return c.String(http.StatusOK, "team:"+team+", m... |
package main
import (
"fmt"
"reflect"
)
type person struct {
Name string
Age int
}
func (p person) Print(prefix string) {
fmt.Printf("%s:Name is %s,Age is %d\n", prefix, p.Name, p.Age)
}
func main() {
p := person{Name: "飞雪无情", Age: 20}
pv := reflect.ValueOf(p)
//反射调用person的Print方法
mPrint := pv.MethodByNam... |
package backend
import (
"context"
"net/http"
"github.com/favclip/ucon"
"github.com/favclip/ucon/swagger"
)
func setupOrderP1(swPlugin *swagger.Plugin) {
api := &OrderP1API{}
tag := swPlugin.AddTag(&swagger.Tag{Name: "OrderP1", Description: "OrderP1 list"})
var hInfo *swagger.HandlerInfo
hInfo = swagger.New... |
package datastorehandler
type KindInfo struct {
Name string
Namespace string
}
type OpType int
const (
_ OpType = iota
UPDATE
DELETE
MODIFY_FIELD
// UPSERT, INSERT ?
)
type Relation int
const (
_ Relation = iota
EQUALS
GREATER_THAN
GREATER_EQ
LESSER
LESSER_EQ
)
type Condition struct {
rel Rel... |
package main
import (
"flag"
"fmt"
"os"
"runtime"
)
var flags struct {
Output string
Arch string
OS string
}
func init() {
flag.StringVar(&flags.Output, "o", "", "output file")
theArch := runtime.GOARCH
theOS := runtime.GOOS
if theArch == "arm" {
theArch = "arm6"
}
flag.StringVar(&flags.Arch, "... |
package main
import (
"net/http"
"github.com/gorilla/mux"
"github.com/spf13/viper"
"go.uber.org/zap"
cq "github.com/rapid7/cps/api/v1/conqueso"
health "github.com/rapid7/cps/api/v1/health"
props "github.com/rapid7/cps/api/v1/properties"
v2health "github.com/rapid7/cps/api/v2/health"
v2props "github.com/rapi... |
package user
import (
"fmt"
"github.com/pkg/errors"
"github.com/vmwarepivotallabs/cf-mgmt/uaa"
"github.com/xchapter7x/lo"
)
func (m *DefaultManager) SyncSamlUsers(roleUsers *RoleUsers, uaaUsers *uaa.Users, usersInput UsersInput) error {
origin := m.LdapConfig.Origin
for _, userEmail := range usersInput.UniqueS... |
/* Representation of a Client Connection */
package main
import (
"bufio"
"bytes"
"io"
"net"
"strings"
)
type Client struct {
Name string
Incoming chan string
Connection net.Conn
Reader *bufio.Reader
Writer *bufio.Writer
Quit chan bool
Server Server
}
func NewClient(connection n... |
package main
import (
"fmt"
"sync"
)
// using waitgroup allows you to
// make a function wait for it's
// go routines to finish
// before exiting
var wg sync.WaitGroup
func main() {
// add 2 go routines
// to the wait group
wg.Add(2)
go foo()
go bar()
// when wait group becomes 0
// the wait will finish
wg... |
package mock
import (
log15 "github.com/xuperchain/log15"
)
type MockLogger struct {
log15.Logger
}
func (*MockLogger) GetLogId() string {
return ""
}
func (*MockLogger) SetCommField(key string, value interface{}) {
}
func (*MockLogger) SetInfoField(key string, value interface{}) {
}
func NewMockLogger() *Moc... |
package multiparty
import (
"fmt"
"errors"
"sort"
"strings"
// "reflect"
)
// This package follows the descriptions of Multiparty Session Types as
// discussed in Honda et al. 2008 (POPL).
// GLOBAL TYPES
type GlobalType interface{
isWellFormed() bool
Prefixes() [][]Prefix
participants() []Participant
chan... |
package main
import "testing"
func TestSup(t *testing.T) {
expected := "Sup, Ewan"
outcome := sup("Ewan")
if outcome != expected {
t.Fatalf("Expected %s got %s", expected, outcome)
}
}
|
// 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 arc
import (
"context"
"regexp"
"runtime"
"unicode/utf8"
"chromiumos/tast/common/testexec"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testin... |
// Copyright 2019 Seth Vargo
//
// 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 w... |
package store
import (
"time"
"github.com/gempir/gempbot/internal/dto"
"gorm.io/gorm/clause"
)
type EmoteBlock struct {
ChannelTwitchID string `gorm:"primarykey"`
Type dto.RewardType `gorm:"primarykey"`
EmoteID string `gorm:"primarykey"`
CreatedAt time.Time
}
func (db... |
package main
func main() {
}
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
// 取得 node 長度
lengthA := GetLength(l1)
lengthB := GetLength(l2)
// 兩個 pointer 分別指向兩個 node
var longer *ListNode
var shorter *ListNode
if lengthA >= lengthB {
longer = l1
shorter = l2
} else {
longer = l2
shorter =... |
package model
type GetApprovalRequest struct {
ID string `json:"id"`
Status int `json:"status"`
}
type GetApprovalResponse struct {
ID string `json: "id"`
Status int `json:"status"`
ErrorCode int `json:"error_code"`
}
type StatusRequest struct{}
type StatusResponse struct {
Status strin... |
package expsearch
import (
"math"
b "github.com/GSlon/algorithmsGO/searches/binarysearch"
)
func ExpSearch(arr []int, target int) int {
bound := 1
for bound < len(arr) && arr[bound] <= target {
bound *= 2
}
if bound >= len(arr) {
return -1
}
// чтобы не выйти за преде... |
package syncer
import (
"fmt"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
"k8s.io/klog"
"github.com/baidu/ote-stack/pkg/util"
)
// NodeSyncer is responsible for synchronizing node from apiserver.
type NodeSyncer struct {
ctx *SyncContext
Informer cache.Sha... |
/*
Copyright 2021 The KodeRover 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, s... |
package Next_Greater_Node_In_Linked_List
type ListNode struct {
Val int
Next *ListNode
}
func nextLargerNodes(head *ListNode) []int {
values := make([]int, 0)
cur := head
for cur != nil {
values = append(values, cur.Val)
cur = cur.Next
}
result := make([]int, len(values))
stack := make([]int, 0)
for... |
package sqlcon
import (
"fmt"
"os"
"time"
logrusx "github.com/jkgx/logrus"
stringsx "github.com/jkgx/strings"
"github.com/jmoiron/sqlx"
"github.com/spf13/cobra"
)
// SchemaCreator is an interface that allows SQL schemas to be created and migrated.
type SchemaCreator interface {
// CreateSchemas migrates or... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type person struct {
Age int
}
func main() {
var p *person
fmt.Println(json.Unmarshal([]byte("null"), p).Error())
fmt.Println(p, &p)
fmt.Println(ioutil.ReadFile(""))
}
|
// 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 graphics
// To update test parameters after modifying this file, run:
// TAST_GENERATE_UPDATE=1 ~/trunk/src/platform/tast/tools/go.sh test -count=1 chromiumos/tast/l... |
package sin
import (
"image"
"image/color"
"image/png"
"log"
"math"
"os"
)
func main() {
// 设置图片大小
const picSize = 300
// 根据给定大小创建灰度图
pic := image.NewGray(image.Rect(0, 0, picSize, picSize))
// 遍历每个像素点,并填充为白色
for x := 0; x < picSize; x++ {
for y := 0; y < picSize; y++ {
pic.SetGray(x, y, color.Gray{2... |
package users
import (
"database/sql"
"networks2016-task1/configs"
"log"
"fmt"
_ "github.com/lib/pq"
)
var db *sql.DB = nil
func getDataSourceName(postgresConfig configs.PostgresConfig) string {
return fmt.Sprintf("postgres://%s:%s@%s/%s", postgresConfig.UserDb,
postgresConfig.PasswordDb,
... |
package mapper
import (
"context"
"github.com/ONSdigital/dp-hello-world-controller/config"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestUnitMapper(t *testing.T) {
ctx := context.Background()
Convey("test CreateFilterOverview correctly maps item to filterOverview page model", t, func() {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.