text stringlengths 11 4.05M |
|---|
package airplay
// A Device is an AirPlay Device.
type Device struct {
Name string
Addr string
Port int
Extra DeviceExtra
}
// A DeviceExtra is extra information of AirPlay device.
type DeviceExtra struct {
Model string
Features string
MacAddress string
ServerVersion str... |
package majorityElement
import "testing"
func TestMajorNumMemo(t *testing.T) {
var arr []int
var rs int
arr = []int{3, 2, 3}
arr = []int{2, 2, 1, 1, 1, 2, 2}
rs = MajorNumMemo(arr, len(arr))
t.Logf("rs: %d", rs)
}
func TestMajorNumMiddle(t *testing.T) {
var arr []int
var rs int
arr = []int{3, 2, 3}
arr ... |
package main
import "fmt"
func main() {
a := 40 // declare variable a
fmt.Println(a)
fmt.Println(&a) // print the memory address of a
var b *int = &a // create variable b that is of pointer to an int and assign the value of memory address of a to it
fmt.Println(b)
fmt.Println(*b) // dereference
*b = 45 // ... |
package backend
import (
"github.com/anabiozz/yotunheim/backend/common/datastore"
)
// Gatherer ...
type Gatherer interface {
Gather(c datastore.Datastore, acc Accumulator)
}
|
// 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, ... |
//
// SimpleCommandTestCommand.go
// PureMVC Go Multicore
//
// Copyright(c) 2019 Saad Shams <saad.shams@puremvc.org>
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//
package command
import "github.com/puremvc/puremvc-go-multicore-framework/src/interfaces"
/*
A SimpleCommand subclass ... |
package cmd
import (
"reflect"
"strings"
"testing"
"time"
)
func TestUsage(t *testing.T) {
f := newFlags()
f.Flag("-x", new(bool), "")
f.Flag("-y", new(bool), "")
got := f.usage()
want := "[OPTION]..."
if got != want {
t.Errorf("usage returned %v, want %v", got, want)
}
}
func TestParse(t *testing.T) {
... |
package cmd
import (
"cmp"
"context"
"errors"
"fmt"
"net"
"net/http"
"slices"
"strconv"
"strings"
"sync"
"time"
paho "github.com/eclipse/paho.mqtt.golang"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/charger"
"github.com/evcc-io/evcc/charger/eebus"
"github.com/evcc-io/evcc/cmd/shutdown"
"gi... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package feedback
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/fsutil"
"chromiumos/tast/local/chrome"
"chro... |
package main
import (
"flag"
"fmt"
"os"
"log"
//"github.com/sapcc/hermes-etl/sink"
"github.com/sapcc/hermes-etl/source"
"github.com/spf13/viper"
)
func main() {
// Handle Config options, command line support for config location
configPath := parseCmdFlags()
setDefaultConfig()
readConfig(configPath)
//UR... |
package main
import (
"bytes"
"fmt"
"net/url"
"sort"
"strings"
"github.com/pkg/errors"
"github.com/mattermost/mattermost-plugin-api/experimental/command"
"github.com/mattermost/mattermost-plugin-api/experimental/flow"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-serv... |
// 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 passpoint
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net"
"path/filepath"
"strings"
"text/template"
"time"
"chromiumos/tast/common/crypto/certificate"
... |
package main
import (
"fmt"
)
/**
关于这个并行模型, 整个流程可以说是非常操蛋的。。。
1. 首先建立两个 chan 类型的变量, 然后把这两个变量赋予 函数 Processor, 从 Processor(origin, wait),下面就是 赋值到 origin channel 的流程,
Processor(origin, wait) 这一行是不会立马执行的, 因为参数是 channel 类型的, 所以要等 channel全部 读完才执行, 直到 close(origin),
<-wait 这个很重要, 这个是表示程序一直要等 wait 这个 channel 消费完才能结束
... |
package tests
import (
"testing"
)
/**
* [122] Best Time to Buy and Sell Stock II
*
* Say you have an array for which the i^th element is the price of a given stock on day i.
*
* Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share o... |
package requests
import (
"fmt"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
)
// ListMultipleAssignmentsGradeableStudents A paginated list of students eligible to submit a list of assignments. The caller must have
// permission to view grades for the requested... |
package command
import (
"fmt"
"testing"
)
func TestCommands(t *testing.T) {
Add("test", test, "test function")
Add("test1", test1, "test1 function")
for _, c := range Commands {
c.Run()
}
}
func test() error {
fmt.Println("test run here")
return nil
}
func test1() error {
fmt.Println("test1 run here")
... |
// use of big
// var distance int64 = 41.3e12 - use of exponential format in go
package main
import (
"fmt"
"math/big"
)
func main() {
ls := big.NewInt(299792)
scndsperday := big.NewInt(86400)
dist := new(big.Int)
// 24 quintillion. It won’t fit in an int64, so instead you can create a big.Int from a string:
/... |
package database_test
import (
"os"
"testing"
"github.com/matthew-burr/db/database"
"github.com/matthew-burr/db/file"
"github.com/stretchr/testify/assert"
)
func SetupDBForTests() (db *database.DB, cleanup func()) {
db = database.Init("db_test")
cleanup = func() {
db.Shutdown()
os.Remove("db_test.dat")
}... |
package configutil_test
import (
"strings"
"testing"
"github.com/cerana/cerana/pkg/configutil"
"github.com/spf13/pflag"
"github.com/stretchr/testify/suite"
)
type ConfigUtil struct {
suite.Suite
}
func TestConfigUtil(t *testing.T) {
suite.Run(t, new(ConfigUtil))
}
func (s *ConfigUtil) TestNormalizeFunc() {
... |
package array
// StringElementsMatch compares two arrays of strings irrespective of order.
func StringElementsMatch(one, two []string) bool {
if len(one) != len(two) {
return false
}
diff := make(map[string]bool)
for _, dim := range one {
diff[dim] = true
}
for _, dim := range two {
if !diff[dim] {
retu... |
package azuretoken
import (
"context"
"crypto"
"crypto/ecdsa"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"strings"
"github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault"
"github.com/go-jose/go-jose/v3"
"github.com/sassoftware/relic/v7/config"
"g... |
package cryptocore
import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"github.com/transmutate-io/cryptocore/types"
)
type jsonRPCClient struct {
Address string
Username string
Password string
tlsConfig *TLSConfig
cachedTLSConfig *tls.... |
package main
import (
"fmt"
"os"
"strconv"
)
// It's a example without recursive function
func not_recursive_3n1(f int) int {
var counter int = 1
for {
if f%2 == 0 {
f = f / 2
} else {
f = (f * 3) + 1
}
counter = counter + 1
// when f is equal to 1, program exit
if f =... |
package api
import (
"encoding/json"
"net/http"
"github.com/patrickoliveros/bookings/models"
)
var Articles []models.Article
func GetArticles(w http.ResponseWriter, r *http.Request) {
Articles = []models.Article{
{Title: "Hello", Desc: "Article Description 1", Content: "Article Content 1"},
{Title: "Hello 2... |
package maps
type Rating struct {
// 1. Create a struct for storing CSV lines and annotate it with JSON struct field tags
Tconst string `json:"tconst"`
AverageRating string `json:"averageRating"`
NumVotes string `json:"numVotes"`
}
func CreateRatings(lines [][]string) []Rating {
// Loop through line... |
package main
import (
"fmt"
"os"
"github.com/gcla/gowid"
"github.com/gcla/gowid/widgets/list"
"github.com/gcla/gowid/widgets/pile"
"github.com/gcla/gowid/widgets/selectable"
"github.com/gcla/gowid/widgets/styled"
"github.com/gcla/gowid/widgets/text"
)
func main() {
palette := gowid.Palette{
"default": gow... |
// +build !windows
package lib
// Defaults for linux/unix if none are specified
const (
conmonPath = "/usr/local/libexec/crio/conmon"
seccompProfilePath = "/etc/crio/seccomp.json"
cniConfigDir = "/etc/cni/net.d/"
cniBinDir = "/opt/cni/bin/"
lockPath ... |
package component
import "sync/atomic"
// Status indicates the health status of this component
type Status int
const (
// StatusHealthy indicates a healthy component
StatusHealthy Status = iota
// StatusUnhealthy indicates an unhealthy component
StatusUnhealthy
)
// GetStatus gets the health status of the compo... |
// 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 ocr
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"chromiumos/tast/common/testexec"
"chromiumos/tast/local/printing/document"
"chromiumos/tast/shutil"
... |
package adapter
import (
"fmt"
"github.com/dustin/go-humanize"
"github.com/tidwall/gjson"
"github.com/zcong1993/badge-service/utils"
)
var defaultErrorResp = makeUnknownTopicInput("docker")
// VALID_TOPICS is valid topic docker api support
var VALID_TOPICS = []string{"stars", "pulls"}
// DockerApi is docker hub... |
package client
import (
"errors"
"fmt"
"math/rand"
"testing"
"time"
"github.com/mkocikowski/libkafka/api/Metadata"
)
func (c *PartitionClient) Kill() error { // implement io.Closer
c.Lock()
defer c.Unlock()
c.disconnect()
return nil
}
func init() {
rand.Seed(time.Now().UnixNano())
}
func TestIntergation... |
package main
import (
"fmt"
"log"
"net/http"
"database/sql"
"github.com/adammohammed/groupmebot"
_ "github.com/mattn/go-sqlite3"
"regexp"
"strings"
)
/*
Test hook functions
Each hook should match a certain string, and if it matches
it should return a string of text
Hooks will be traversed until match occ... |
package repowatch
import (
"context"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"io"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/Cloud-Foundations/golib/pkg/log"
"github.com/Cloud-Foundations/Dominator/lib/fsutil"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"github.com/go-git/go... |
package battleship
import (
"strconv"
"strings"
)
type Location string
func (l Location) Row() int {
row := strings.Index("ABCDEFGHIJKLMNOPQRSTUVWXYZ", string(l[0:1]))
return row
}
func (l Location) Column() int {
column, _ := strconv.Atoi(string(l[1:]))
return (column - 1)
}
|
package db
import (
"time"
"github.com/gorilla/feeds"
)
func NewsletterToFeed(title string, archive []Newsletter) feeds.JSONFeed {
feed := feeds.JSONFeed{
Title: title,
Items: make([]*feeds.JSONItem, len(archive)),
}
for i, nl := range archive {
var date time.Time = nl.PublishedAt
feed.Items[i] = &feeds... |
// +build ignore
// package level documents
package main
// test
import (
"encoding/json"
"fmt"
"github.com/fzerorubigd/onion"
"github.com/goraz/humanize"
)
const (
alpha = iota
beta
)
const (
x1 int = iota
y1
)
var maked = make([]int, 10)
var (
// Booogh
test, bogh /*doogh*/ string
)
// the hes var
v... |
package main
import (
"fmt"
"time"
"gocv.io/x/gocv"
)
// MatBuffer is a matrix ring buffer, which stores the last frames added to it.
type MatBuffer struct {
imgs []*gocv.Mat
times []time.Time
writes int
}
// NewMatBuffer creates a new MatBuffer with enough frames to store the given
// duration at the give... |
package testing
import (
"fmt"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
qsv1a1 "code.cloudfoundry.org/quarks-operator/pkg/kube/apis/quarkssecret/v1alpha1"
)
// DefaultQuarksSecret for use in tests
func (c *Catalog) DefaultQuarksSecret(name string) qsv1a1.QuarksSecret {
return q... |
package main
import (
"fmt"
m "math"
"github.com/MaxHalford/gago"
)
// DropWave minimum is -1 reached in (0, 0)
// Recommended search domain is [-5.12, 5.12]
func DropWave(X []float64) float64 {
numerator := 1 + m.Cos(12*m.Sqrt(m.Pow(X[0], 2)+m.Pow(X[1], 2)))
denominator := 0.5*(m.Pow(X[0], 2)+m.Pow(X[1], 2)) +... |
package graphql
//https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1
import (
"fmt"
"log"
ge "github.com/OIT-ads-web/graphql_endpoint"
"github.com/OIT-ads-web/graphql_endpoint/elastic"
"github.com/graphql-go/graphql"
ms "github.com/mitchellh/mapstructure"
)
func personResolver(params graphql... |
package dht
import (
"errors"
"os"
"time"
"github.com/google/logger"
)
const (
bootstrapTimeOut = 3 * time.Second
minNodeNum = 10
)
var (
dhtLogger *logger.Logger
defaultBootNode []*node
)
func init() {
dhtLogger = logger.Init("DHT", false, false, os.Stdout)
bootNodes := []string{
"router.bitto... |
package main
import "sort"
func p12917(s string) string {
a := []byte(s)
sort.Slice(a, func(i, j int) bool {
return a[i] > a[j]
})
return string(a)
}
|
package space
// Planet ...
type Planet string
// PlanetMap ...
var PlanetMap = make(map[Planet]float64)
const earthSecond = 31557600
func setData() {
PlanetMap["Mercury"] = 0.2408467
PlanetMap["Venus"] = 0.61519726
PlanetMap["Mars"] = 1.8808158
PlanetMap["Jupiter"] = 11.862615
PlanetMap["Saturn"] = 29.447498
... |
package main
import (
"os"
"github.com/rzyns/gogen/cli"
)
func main() {
code := cli.Main(os.Args)
os.Exit(code)
}
|
// 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 cryptohome
import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
uda "chromiumos/system_api/user_data_auth_proto"
"chromiumos/tast/comm... |
package tiltfile
import (
"context"
"strings"
"testing"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/tilt-dev/tilt/pkg/apis"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
"github.com/google/go-cmp/cmp"
"github.com/moby/buildkit/frontend/dockerfile/dockerignore"
"github.com/stretch... |
package tests
import (
"testing"
)
/**
* [797] Rabbits in Forest
*
* In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Those answers are placed in an array.
*
* Return the minimum number of rabbits that could be in... |
// Copyright 2012 Joe Wass. All rights reserved.
// Use of this source code is governed by the MIT license
// which can be found in the LICENSE file.
// MIDI package
// A package for reading Standard Midi Files, written in Go.
// Joe Wass 2012
// joe@afandian.com
// Constants and values.
package midi
// SMF format
... |
package main
import (
"github.com/micro/go-micro"
rpc "github.com/micro/go-plugins/micro/disable_rpc"
"github.com/micro/go-plugins/micro/metrics"
"github.com/micro/micro/cmd"
"github.com/micro/micro/plugin"
"github.com/paitime/gateway/plugins/gzip"
)
func init() {
plugin.Register(gzip.NewPlugin())
plugin.Regi... |
package repository
import (
"context"
"github.com/sapawarga/userpost-service/model"
)
type PostI interface {
// query for get userpost
GetListPost(ctx context.Context, request *model.UserPostRequest) ([]*model.PostResponse, error)
GetMetadataPost(ctx context.Context, request *model.UserPostRequest) (*int64, err... |
package main
import (
"HeeloBeego/db_mysql"
_ "HeeloBeego/routers"
"github.com/astaxie/beego"
_ "github.com/go-sql-driver/msyql"
)
func main() {
db_mysql.OpenDB()
defer db_mysql.Db.Close()
beego.Run()
}
|
package httputils
import (
"encoding/json"
"fmt"
"net"
"net/http"
)
// **** Request handler ****
type RequestHandler struct {
getRemoteHostAddress func(r *http.Request) string
Method string
Handler func(remoteHostAddress string, params *json.RawMessage) (bool, error)
}
// Should be ... |
package main
func main() {
//panic("call panic")
//死锁
//死锁(Deadlock)就是一个进程拿着资源A请求资源B,
//另一个进程拿着资源B请求资源A,双方都不释放自己的资源,导致两个进程都进行不下去。
ch := make(chan int)
<-ch
}
|
package menu
import (
"github.com/kenshaw/envcfg"
"github.com/sirupsen/logrus"
)
// Methode is the methode type
type Method int
const (
// List of different Methods
Get Method = iota
POST
other
)
// Server is the server object for this api service.
type Server struct {
config *envcfg.Envcfg
logger *logrus.... |
// Copyright 2018 xgfone
//
// 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 operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// GetSpecificAttributeOfUserReader is a Reader for the GetSpecificAttrib... |
package multipartfile
import (
"mime/multipart"
)
type MultipartFile struct {
multipart.File
Header *multipart.FileHeader
}
func (m MultipartFile) Name() string {
if m.Header == nil {
return ""
}
return m.Header.Filename
}
|
package cmd
import (
"context"
"github.com/geospace/sac"
"github.com/machinebox/graphql"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
// DeleteTokenM : query for mutation `deleteToken`
var DeleteTokenM = `
mutation($token: String) {
deleteToken(token: $token)
}
`
// DeleteTokenR : response struct for m... |
package xml2map
import (
"testing"
"strings"
)
func BenchmarkEncode(b *testing.B) {
for n := 0; n < b.N; n++ {
NewEncoder(strings.NewReader(`<container uid="FA6666D9-EC9F-4DA3-9C3D-4B2460A4E1F6" lifetime="2019-10-10T18:00:11">
<cats>
<cat>
<id>CDA035B6-D453-4A17-B090-84295AE2DEC5</id>
<name>... |
package goutil
import "testing"
import "fmt"
func TestPrintStrEle(t *testing.T) {
cases := []string{
"string",
"hello",
}
for _, str := range cases {
count := PrintStrEle(str)
if count == len(str) {
fmt.Println("test %s ok", str)
} else {
t.Errorf("test %s error for %d, excepted %d ", str, count, ... |
package main
import (
"fmt"
"github.com/mutao-net/go-weather/weather"
)
func main() {
result := weather.GetWeather("XXXXXX", "35.4660694", "139.6226196")
// fmt.Printf("result: %+v\n", result)
fmt.Println(result.Current.Feelslike)
for _, value := range result.Current.Weather {
fmt.Println(value.Description)... |
package main
import (
"github.com/jessevdk/go-flags"
"log"
"os"
)
func main() {
os.Exit(run())
}
func run() int {
var options struct{}
var parser = flags.NewParser(&options, flags.Default)
if _, err := parser.AddCommand("new", "Create a new memo", "", &NewCommand{}); err != nil {
log.Fatal(err)
}
if _, e... |
package verify
import (
"reflect"
"testing"
)
// --- Helpers ---
func expect(t *testing.T, a interface{}, b interface{}) {
if a != b {
t.Errorf(
"Expected %v (type %v) - Got %v (type %v)",
b,
reflect.TypeOf(b),
a,
reflect.TypeOf(a),
)
}
}
func refute(t *testing.T, a interface{}, b interface{})... |
package main
import (
"errors"
"log"
"regexp"
"strconv"
"strings"
)
var TypeMap map[string]string = map[string]string{
"other": "string",
"token": "string",
"dateTime": "string",
"duration": "string",
"time": "string",
"anyURI": "string",
"base64Binary": "[]byte",
"str... |
// This file was generated by counterfeiter
package fakes
import (
"sync"
"github.com/cloudfoundry-incubator/garden-shed/repository_fetcher"
"github.com/cloudfoundry-incubator/garden-shed/rootfs_provider"
)
type FakeLayerCreator struct {
CreateStub func(id string, parentImage *repository_fetcher.Image, sp... |
package metadata
import "github.com/caicloud/simple-object-storage/pkg/metadata/apis"
type Bucket interface {
ListBucket() ([]apis.Bucket, error)
PutBucket(bucket *apis.Bucket) error
GetBucket(name string) (*apis.Bucket, error)
DeleteBucket(name string) error
Close() error
}
type Object interface {
ListObject(... |
package controllers
import (
"errors"
"github.com/gin-gonic/gin"
"go-architecture-mysql/api/exceptions"
"go-architecture-mysql/api/middlewares"
"go-architecture-mysql/api/payloads"
"go-architecture-mysql/api/securities"
"go-architecture-mysql/api/services"
"go-architecture-mysql/api/utils"
"net/http"
"strcon... |
package service
import godd "github.com/pagongamedev/go-dd"
// Service interface
type Service interface {
MessageRead(str string) (*godd.Map, *godd.Error)
}
// Repository interface
type Repository interface {
GetMessage(str string) (*godd.Map, *godd.Error)
}
// ======== service.go ============
// NewService New ... |
package extract
import (
"bufio"
"encoding/csv"
"errors"
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"
"github.com/jszwec/csvutil"
)
type ExtractCmd struct{}
type LineCsau struct {
DtEpreuve string
Organisateur string
CdRace string
CdLO string
NumLO string
TatooChip stri... |
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package server
import (
"errors"
"regexp"
"golang.org/x/debug/dwarf"
)
func (s *Server) lookupRE(re *regexp.Regexp) (result []string, err error) {
r := s... |
package bip39
import (
"encoding/hex"
"fmt"
"reflect"
"testing"
)
func TestIsMnemonicValid(t *testing.T) {
type args struct {
mnemonic string
lang Language
}
tests := []struct {
name string
args args
want bool
}{
{
name: "English",
args: args{
mnemonic: "check fiscal fit sword unlock... |
package main
func foo(a, a int) {
}
|
/*
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... |
/*
Copyright 2020 The Kubermatic Kubernetes Platform 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 ... |
package imagechange
import (
"flag"
"testing"
kapi "k8s.io/kubernetes/pkg/api"
ktestclient "k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/runtime"
"github.com/openshift/origin/pkg/client/testclient"
deployapi "github.com/openshift/origin/pkg/deploy/api"
testapi "github.com/opens... |
package kiteroot
import (
"net/http"
"strings"
"sync"
"testing"
)
func TestParse(t *testing.T) {
html := `
<html>
<head>
<title> KiteRoot </title>
<meta name="user" content="phynalle"/>
<meta name="profile" content="nothing"/>
</head>
<body>
omg
</body>
</html>
`
r := strings.NewReader(html)
_, err := Parse... |
package routers
import (
"github.com/astaxie/beego"
"z2665/t12/controllers"
"z2665/t12/fliters"
)
//20150928移除命名空间只使用注解路由
//20150929将表单控制器加入路由,将过滤器加入路由
//20151004加入index路由
func init() {
beego.InsertFilter("/api/froms/changs/*", beego.BeforeRouter, fliters.UserFliter)
beego.InsertFilter("/api/users/changs/*", bee... |
package main
import (
"fmt"
"sync"
"time"
)
var (
in chan int
a chan int
b chan int
c chan int
done chan struct{}
//wg sync.WaitGroup
lock sync.Mutex
)
func init() {
in = make(chan int, 1)
a = make(chan int, 1)
b = make(chan int, 1)
c = make(chan int, 1)
done = make(chan struct{})
}
func printA() {
... |
package main
import "fmt"
type User struct {
Id int `json-converter:"json:id"`
Name string `json-converter:"json:name"`
Address string `json-converter:"json:address"`
}
func main() {
var (
hogeUser User
hogeStr string = `{"id":5,"name":"hoge","address":"東京"}`
)
Decode(&hogeUser, hogeStr)
fmt... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekasys
import (
"os"
"sync"
)
type (
stdSynced struct {
f *os.File
sync.Mutex
}
)
var (
stdout *stdSynced
)
func (ss *stdSyn... |
package main
import (
"firstgo_app/src/controllers"
"fmt"
"log"
"net/http"
"github.com/gofiber/fiber/v2"
)
func indexRoute(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Bienvenido a mi API")
}
func setupRoutes(app *fiber.App) {
api := app.Group("/api")
v1 := api.Group("/v1")
v1.Get("/task", ... |
package main
import (
"log"
"net/http"
)
func main() {
// calling our run function and handling the error
if err := run(); err != nil {
log.Fatal(err)
}
}
// run is used so we can just return errors and handle a single exit point in main.
func run() error {
// START OMIT
http.HandleFunc("/hello", func(write... |
package ship
type Ship struct{}
func (S Ship) GetTransport() string {
return "Ship"
}
|
package module
import (
"context"
"github.com/go-redis/redis/v8"
clientv3 "go.etcd.io/etcd/client/v3"
"shared/utility/key"
)
// server discover
type Discover struct {
prefix string
client *clientv3.Client
}
func NewDiscover(service string, client *clientv3.Client) *Discover {
return &Discover{
prefix: key... |
package dao
import (
"db"
"errors"
"strconv"
"time"
"types"
"utils"
"github.com/google/uuid"
"github.com/kisielk/sqlstruct"
)
//AccountDAO - data access for accounts
type AccountDAO struct {
}
//CheckDuplicates - checks if account info already exists.
//Returns empty string and no error if no duplicates are... |
package noolite
import (
"errors"
"reflect"
"unsafe"
)
type Response struct {
st byte
Mode byte
Ctr byte
Togl byte
Ch byte
Cmd byte
Fmt byte
D0 byte
D1 byte
D2 byte
D3 byte
ID0 byte
ID1 byte
ID2 byte
ID3 byte
crc byte
sp byte
}
var (
ErrWrongST = errors.New("wrong st")
Er... |
package commands
import "github.com/genevieve/leftovers/app"
type Delete struct {
leftovers leftovers
}
func NewDelete(l leftovers) Delete {
return Delete{
leftovers: l,
}
}
func (d Delete) Execute(o app.Options) error {
if o.Type == "" {
return d.leftovers.Delete(o.Filter, o.RegexFiltered)
}
return d.le... |
package p_00101_00200
// 153. Find Minimum in Rotated Sorted Array, https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
func findMin(nums []int) int {
lo, hi := 0, len(nums)-1
for lo < hi {
mid := lo + (hi-lo)/2
if nums[mid] > nums[hi] {
lo = mid + 1
} else {
hi = mid
}
}
return nums... |
/*
Copyright © 2021 Damien Coraboeuf <damien.coraboeuf@nemerosa.com>
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 limitation the rights
to use, copy, modi... |
package provider
import (
"github.com/fnbk/pim/app/model"
)
type ProductProvider struct {
Products []model.Product
}
func (s *ProductProvider) ProductIDs() []string {
IDs := []string{}
for _, p := range s.Products {
IDs = append(IDs, p.ID)
}
return IDs
}
func (s *ProductProvider) GetProduct(id string) *mode... |
// 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... |
// 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 meta
import (
"context"
"strconv"
"time"
"chromiumos/tast/local/shill"
"chromiumos/tast/testing"
)
var (
sleepDuration = testing.RegisterVarString(
"meta.L... |
/*
Copyright 2019 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 LeetCode
func Code105() {
headTree := InitTree()
headTree = &TreeNode{3, nil, nil}
headTree.Left = &TreeNode{9, nil, nil}
headTree.Right = &TreeNode{20, nil, nil}
headTree.Right.Left = &TreeNode{15, nil, nil}
headTree.Right.Right = &TreeNode{7, nil, nil}
levelOrder(headTree)
//fmt.Println("leetcode 102... |
// 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 owner_test
import (
"crypto/ed25519"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/bitm... |
package card
import (
"bank/pkg/bank/types"
"fmt"
)
func ExampleWithdraw_positive() {
result := Withdraw(types.Card{Balance: 20000_00, Active: true}, 10000_00)
fmt.Println(result.Balance)
// Output:
// 1000000
}
func ExampleWithdraw_noMoney() {
result := Withdraw(types.Card{Balance: 1000, Active: true}, 1500)... |
// 关闭 一个通道意味着不能再向这个通道发送值了。 该特性可以向通道的接收方传达工作已经完成的信息
package main
import "fmt"
func main() {
// 在这个例子中,我们将使用一个 jobs 通道,将工作内容, 从 main() 协程传递到一个工作协程中
// 当我们没有更多的任务传递给工作协程时,我们将 close 这个 jobs 通道
jobs := make(chan int, 5)
done := make(chan bool)
// 这是工作协程。
go func() {
for {
// 使用 j, more := <- jobs 循环的从 jobs 接收数... |
//go:generate gen-static-data-go
//go:generate protoc --enum-go_out=. enum.proto global.proto
package sd
import "mlgs/src/conf"
func init() {
success := LoadAll(conf.Server.XlsxPath)
if success != true {
panic("sd LoadAll faild")
}
success = AfterLoadAll(conf.Server.XlsxPath)
if success != true {
panic("sd A... |
package deque
import (
"reflect"
"testing"
)
func TestDeque(t *testing.T) {
q := &Deque{}
q.EnqueueBack(12) // 12
q.EnqueueFront(1) // 1 12
q.EnqueueBack(23) // 1 12 23
q.EnqueueFront(908) // 908 1 12 23
a := []int{908, 1, 12, 23}
b := []int{}
for v := range q.Traverse() {
b = append(b, v)
}
if !... |
package entity
import (
DB "rnl360-api/database"
"rnl360-api/models"
)
func GetAllCommunication(communicationModel *[]models.CommunicationModel) (err error) {
if err = DB.GetDB().Where("status = ?", 1).Order("id DESC").Find(&communicationModel).Error; err != nil {
return err
}
return nil
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.