text stringlengths 11 4.05M |
|---|
package config
import (
"errors"
"net/url"
"strings"
)
// URL stands for URL from configuration
type URL string
func (u URL) String() string {
return string(u)
}
// IsEmpty returns true if URL contains empty string
func (u URL) IsEmpty() bool {
return len(u) == 0
}
// ToGoURL converts URL struct into Golang U... |
package taco_box
// const TacoBoxMyDaily = "@MY_DAILY"
// const TacoBoxImportant = "@IMPORTANT"
// const TacoBoxTask = "@TASK"
// const TacoBoxSchedule = "@SCHEDULE"
// const TacoBoxAll = "@ALL"
// var CommonTacoBoxes = [...]string{TacoBoxMyDaily, TacoBoxImportant, TacoBoxTask, TacoBoxSchedule, TacoBoxAll}
// var Ty... |
// 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 (
"fmt"
"strconv"
)
type Person struct {
//first string
//last string
//age int
//gender string
first, last, gender string
age int
}
// value receiver (just reading values)
func (p Person) greet() string {
return "Hello, my name is " + p.first + " " + p.last + " and I'm " + strconv.Itoa... |
package main
import (
"fmt"
"math"
)
// Square ...
type Square struct {
side float64
}
func (z Square) area() float64 {
return z.side * z.side
}
// Circle ...
type Circle struct {
radius float64
}
func (z Circle) area() float64 {
return math.Pi * z.radius * z.radius
}
// Shape ...
type Shape interface {
ar... |
package qcloud
import "yunion.io/x/pkg/errors"
type SElasticcacheTask struct {
Status string `json:"Status"`
StartTime string `json:"StartTime"`
TaskType string `json:"TaskType"`
InstanceID string `json:"InstanceId"`
TaskMessage string `json:"TaskMessage"`
RequestID string `json:"RequestId"`
}
// ... |
package main
import (
"context"
"log"
"net/http"
"os"
"time"
"urfu-abiturient-api/ent"
"urfu-abiturient-api/ent/abituriententry"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
_ "github.com/lib/pq"
)
func main() {
DBURL := os.Getenv("DB_URL")
if DBURL == "" {
DBURL = "postgres:... |
package main
import (
"fmt"
)
func printStatus(s status) {
fmt.Println("The status is:", s)
}
type status string
const (
running status = "running"
waiting status = "blocked"
)
func main() {
var s status
s = running
// s = "undefined"
fmt.Println(s) // Default value
fmt.Printf("%v, %T\n", s, s)
}
|
// 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 leetcode
//func removeElement(nums []int, val int) int {
// if len(nums) == 0 {
// return 0
// }
//
// ans := 0
// for _, v := range nums {
// if v != val {
// nums[ans] = v
// ans++
// }
// }
// return ans
//}
func removeElement(nums []int, val int) int {
left, right := 0, len(nums)
if right == 0 {
... |
package utils
import (
"fmt"
"reflect"
"strings"
)
// FillStruct set the field value of ptr according data kv map.
func FillStruct(ptr interface{}, data map[string]interface{}) {
err := Bind(ptr, "", data)
if err != nil {
panic(err)
}
}
var defaultStructFieldTag = "field"
// FillStructByTag set the field va... |
package bd
import (
"context"
"log"
"time"
"github.com/Estiven9644/twittor-backend/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
)
func LeoTweets(ID string, pagina int64) ([]*models.DevuelvoTweets, bool) {
ctx, cancel := context.WithTimeout(context.Background(), 15*tim... |
package distributed
import (
"time"
"github.com/dbogatov/dac-lib/dac"
"github.com/dbogatov/fabric-amcl/amcl"
"github.com/dbogatov/fabric-amcl/amcl/FP256BN"
"github.com/dbogatov/fabric-simulator/helpers"
)
// RPCRevocation ...
type RPCRevocation struct {
keys KeysHolder
}
var epoch int = 1
// MakeRPCRevocatio... |
package handlers
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/tmaesaka/cellar/config"
)
func TestIndexConfigHandler(t *testing.T) {
cfg := config.NewApiConfig()
handler := IndexConfigHandler(cfg)
req, _ := http.NewRequest("GET", "/config", nil)
recorder := httptest.NewRecor... |
package utils
import (
"github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/drawing"
"os"
"time"
)
func DrawChart(timestamps [][]time.Time, datas [][]float64, chartName string, seriesNames []string) {
var timeseries []chart.Series
for i := 0; i < len(datas); i++ {
timeseries = append(timeseries, ch... |
package main
import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
)
type Comm struct {
Key string `json:"key"` //参数个数
Num int `json:"num"` //参数个数
Param []string `json:"param"` //各个参数类型
}
var Commend map[string]Comm
// 练习从终端输入
func main() {
initComm()
input := bufio.NewScanner(... |
// Package domain describes the (simplified) models used in the system and their relations to each other
package domain
// User represents a user in the system.
// It can have many Subscriptions.
type User struct {
Username string
Email string
Subscriptions []Subscription
}
// Subscription represents ... |
package list
import (
"context"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"
)
type ListAdapterInterface interface {
ListNs(ctx context.Context) (*corev1.NamespaceList, error)
Li... |
package main
import "fmt"
func largest(args ...int) int{
smallest := args[0]
for _, value := range args{
if value > smallest{
smallest = value
}
}
return smallest
}
func main(){
fmt.Println(largest(34, 534, 3, 133, 90))
}
|
package info
import (
"encoding/json"
"net/http"
"sort"
"strings"
"github.com/golang/glog"
"github.com/julienschmidt/httprouter"
"github.com/prebid/prebid-server/config"
)
var invalidEnabledOnly = []byte(`Invalid value for 'enabledonly' query param, must be of boolean type`)
// NewBiddersEndpoint builds a ha... |
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package commands
import (
"fmt"
"github.com/go-openapi/spec"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/cmd/config/ext"
"sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/fieldmeta"
"sigs.k8s.io/kustomize/kyam... |
package compose
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
"github.com/loft-sh/devspace/pkg/util/log"
"gopkg.in/yaml.v3"
"gotest.tools/assert"
"gotest.tools/assert/cmp"
)
func TestLoad(t *testing.T) {
dirs, err := os.ReadDir("testdata... |
/*
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 auth
import (
"dena-hackathon21/entity"
"fmt"
jwt "github.com/dgrijalva/jwt-go"
"os"
"strconv"
"time"
)
type JWTHandler struct {
SigninKey string
}
func NewJWTHandler() (*JWTHandler, error) {
return &JWTHandler{}, nil
}
func (j JWTHandler) GenerateJWTToken(userID uint64) (string, error) {
claims :... |
// 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 security
import (
"context"
"strings"
chk "chromiumos/tast/local/bundles/cros/security/filecheck"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&t... |
// SPDX-License-Identifier: MIT
package ast
import (
"strconv"
"testing"
"github.com/issue9/assert/v3"
"github.com/issue9/version"
)
func TestVersion(t *testing.T) {
a := assert.New(t, false)
a.True(version.SemVerValid(Version))
v := &version.SemVersion{}
a.NotError(version.Parse(v, Version))
major, err :... |
package pkg
type MySQLStatus struct {
File string
Position uint32
Binlog_Do_DB string
Binlog_lgnore_DB string
Executed_Gtid_Set string
}
type MySQLSchema struct {
Field string
Type string
Collation *string
Null string
Key *string
Default *string
Extr... |
package counter
import (
"math"
"sync/atomic"
)
type CASFloatCounter struct {
number uint64
}
func NewCASFloatCounter() *CASFloatCounter {
return &CASFloatCounter{0}
}
func (c *CASFloatCounter) Add(num float64) {
for {
v := atomic.LoadUint64(&c.number)
newValue := math.Float64bits(math.Float64frombits(v) +... |
/*
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 groto
import (
"errors"
"log"
"net"
)
type Client struct {
user string
password string
id []byte
pwHashKey []byte
}
func NewClient(user, password string) *Client {
return &Client{
user: user,
password: password,
}
}
func (c *Client) Do(conn net.Conn) error {
if err := c.stepHa... |
package csigc
import (
"context"
"os"
"testing"
"github.com/Dynatrace/dynatrace-operator/src/controllers/csi/metadata"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const (
testImageDigest = "5f50f658891613c752d524b72fc"
)
var (
testPathResolver = met... |
package main
import (
"fmt"
"kafka_study/conf"
"gopkg.in/ini.v1"
)
func main() {
p := new(conf.AppConf)
ini.MapTo(&p, "conf/config.ini")
fmt.Println(p)
}
|
package eventstore
import (
_ "bytes"
"crypto/rand"
"github.com/FoundationDB/fdb-go/fdb"
"github.com/FoundationDB/fdb-go/fdb/subspace"
_ "sync"
"time"
)
func nextRandom() []byte {
b := make([]byte, 20)
if _, err := rand.Read(b); err == nil {
return b
} else {
panic(err)
}
}
type EventRecord struct {
... |
package application
import (
metricapi "alauda.io/diablo/src/backend/integration/metric/api"
"alauda.io/diablo/src/backend/resource/dataselect"
)
type ApplicationCell Application
func (self ApplicationCell) GetProperty(name dataselect.PropertyName) dataselect.ComparableValue {
switch name {
case dataselect.NameP... |
package main
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/typed/apps/v1beta1"
)
func getDeployments(client v1beta1.AppsV1beta1Interface, namespace string) ([]string, error) {
objects, err := client.Deployments(namespace).List(metav1.ListOptions{})
if err != nil {
r... |
package users
import (
"encoding/json"
"log"
"net/http"
"github.com/zuhrulumam/learning-go/pkg/database"
"github.com/go-chi/chi"
"github.com/go-chi/render"
)
func v1UpdateUsersHandler(w http.ResponseWriter, r *http.Request) {
log.Println("updating user")
id := chi.URLParam(r, "id")
var req v1CreateUsersP... |
package main
import (
"errors"
"fmt"
"testing"
)
func TestRecover(t *testing.T) {
fmt.Println("Enter function main")
defer func() {
if p := recover(); p != nil {
fmt.Printf("panic: %s\n", p)
}
fmt.Println("Exit function defer")
}()
panic(errors.New("something error"))
fmt.Println("Exit function main"... |
package kubernetes
import (
"context"
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/epmd-edp/admin-console-operator/v2/pkg/apis/edp/v1alpha1"
"github.com/epmd-edp/admin-console-operator/v2/pkg/client/admin_console"
adminConsoleSpec "github.com/epmd-edp/admin-console-operator/v2/pkg/service/admin_conso... |
package main
import "fmt"
// linear search function
// input is an integer array and a target value
// output is the index of element if found or else -1
func search(array []int, target int) int {
for i, val := range array {
if val == target {
return i
}
}
return -1
}
func main() {
var array []int = []int... |
package main
import "fmt"
type Vertex struct {
X, Y int
}
func (this *Vertex) ShowX() {
fmt.Println(this.X)
}
func main () {
v := Vertex{2,4}
v.ShowX()
}
|
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* 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 applicab... |
package main
import (
"bytes"
"fmt"
)
func main() {
s := "1234567"
s = comma(s)
fmt.Println(s)
}
func comma(s string) string {
n := len(s)
if n <= 3 {
return s
}
var buf bytes.Buffer
for i := 0; i < n; i++ {
buf.WriteString(string(s[i]))
if (i < n-1) && ((i+1)%3 == n%3) {
buf.WriteString(",")
}
... |
package main
import (
"container/ring"
"encoding/json"
"errors"
"github.com/satori/go.uuid"
"sync"
)
type BalanceStrategy string
const (
Round_Robin BalanceStrategy = "round-robin"
Source_Hashing BalanceStrategy = "source-hashing"
)
type Service struct {
UniqueId string `json:"id" bson:"_... |
package cmd
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"regexp"
"strconv"
"strings"
"sync"
"github.com/btm6084/utilities/fileutil"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/crypto/ssh/terminal"
)
const (
// VERSION is the current version of goack
VERSION = `1.0.0`
)
va... |
package lexers
import (
"embed"
"io/fs"
"github.com/alecthomas/chroma/v2"
)
//go:embed embedded
var embedded embed.FS
// GlobalLexerRegistry is the global LexerRegistry of Lexers.
var GlobalLexerRegistry = func() *chroma.LexerRegistry {
reg := chroma.NewLexerRegistry()
// index(reg)
paths, err := fs.Glob(embe... |
// GridIndexer
package GridSearch
import (
"github.com/rcrowley/go-metrics"
"log"
"os"
)
type gridIndexer struct {
gridTopArray []gridTop //top grid array
InputDataFlow chan []GridData //Data Index Flow
memIxr []*memIndexer //Memory Index
indexMeter metrics.Meter //Indexing sp... |
package eventbus
import (
"time"
uuid "github.com/satori/go.uuid"
)
type Event interface {
TriggeredAt() time.Time
EventID() uuid.UUID
EventName() string
}
|
package core
import (
"flag"
"fmt"
"mqtts/utils"
"os"
"strconv"
"strings"
)
type ScanArgs struct {
CommonScan bool
UnauthScan bool
AnyPwdScan bool
SystemInfo bool
BruteScan bool
AutoScan bool
TopicsList bool
WaitTime int
UserPath str... |
package main
import (
"fmt"
"net"
"sync"
"time"
st "github.com/TheSmallBoat/carlo/streaming_transmit"
)
func main() {
check := func(err error) {
if err != nil {
panic(err)
}
}
st.StartPoolMetrics()
ln, err := net.Listen("tcp", ":4444")
check(err)
client := &st.Client{Addr: ln.Addr().String()}
... |
package postgresql
import (
"context"
"database/sql"
"database/sql/driver"
"fmt"
"github.com/adamluzsi/frameless/ports/guard"
)
// Locker is a PG-based shared mutex implementation.
// It depends on the existence of the frameless_locker_locks table.
// Locker is safe to call from different application instances,
... |
package logger
import (
"context"
)
type ctxKeyDetails struct{}
type ctxValue struct {
Super *ctxValue
Details []LoggingDetail
}
func ContextWith(ctx context.Context, lds ...LoggingDetail) context.Context {
if len(lds) == 0 {
return ctx
}
var v ctxValue
if prev, ok := lookupValue(ctx); ok {
v.Super = p... |
package login
import (
"errors"
"fmt"
"time"
"github.com/google/uuid"
"github.com/jrapoport/gothic/core/tokens"
"github.com/jrapoport/gothic/core/users"
"github.com/jrapoport/gothic/core/validate"
"github.com/jrapoport/gothic/models/types/provider"
"github.com/jrapoport/gothic/models/user"
"github.com/jrapo... |
package service
import (
"encoding/json"
"fmt"
patternUtils "github.com/layer5io/meshery/models/pattern/utils"
"github.com/layer5io/meshkit/models/oam/core/v1alpha1"
meshkube "github.com/layer5io/meshkit/utils/kubernetes"
v1 "k8s.io/api/core/v1"
)
func Deploy(kubeClient *meshkube.Client, oamComp v1alpha1.Compo... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package store
import (
"testing"
"time"
"github.com/mattermost/mattermost-cloud/internal/testlib"
"github.com/mattermost/mattermost-cloud/model"
"github.com/pborman/uuid"
"github.com/stretchr/test... |
/***** Partie commande.go : liste des commandes et traitement en fonction *****/
package serveurchat
import (
"./../db" // importation du package db contenant la structure Message notamment
"fmt"
"runtime"
"strings"
"time"
)
/*** Fonction qui permet d'obtenir le résultat de la commande "/info" ***/
func getInfo... |
package tx
import (
"bytes"
"encoding/hex"
"math/big"
"os"
"strings"
"testing"
"github.com/VIVelev/btcd/crypto/ecdsa"
"github.com/VIVelev/btcd/crypto/elliptic"
"github.com/VIVelev/btcd/script"
)
var (
tx Tx
txBytes []byte
txBip143 Tx
)
func TestMain(m *testing.M) {
txBytes, _ = hex.DecodeString(... |
package connection
import (
"errors"
"fmt"
"github.com/rbroggi/tlayer/acknowledge"
"github.com/rbroggi/tlayer/pkg"
"time"
)
//NewMockConnection returns a new mockConnection with
// a receiver binded and in listening state
func NewMockConnection(conParam ConParam) Connection {
c := &mockConnection{
segmentTopi... |
package main
import "github.com/bjatkin/golf-engine/golf"
// conversation with joe gopher
var gopherConvo *convo
func initGopher() {
for x := 0; x < 128; x++ {
for y := 0; y < 128; y++ {
if g.Mget(x, y) == 201 { // The gopher sprite
// erase the gopher tiles
g.Mset(x, y, 0)
g.Mset(x+1, y, 0)
g... |
package folder3
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
// F3Chaincode definition
type F3Chaincode struct {
}
// F3Method1 returns a successful message from the current method
func (t *F3Chaincode) F3Method1(stub shim.ChaincodeStubInterf... |
package wire
import (
"errors"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
// mockFIIntermediaryFIAdvice creates a FIIntermediaryFIAdvice
func mockFIIntermediaryFIAdvice() *FIIntermediaryFIAdvice {
fiifia := NewFIIntermediaryFIAdvice()
fiifia.Advice.AdviceCode = AdviceCodeLetter
fiifia.Advice.... |
// 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 webcodecs
import (
"context"
"fmt"
"io"
"math"
"net/http"
"os"
"path/filepath"
"chromiumos/tast/common/perf"
"chromiumos/tast/errors"
"chromiumos/tast/loc... |
package html5_test
import (
. "github.com/bytesparadise/libasciidoc/testsupport"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("quoted texts", func() {
Context("bold content", func() {
It("bold content alone", func() {
source := "*bold content*"
expected := `<div class="pa... |
package admin_console
import (
"github.com/epmd-edp/admin-console-operator/v2/pkg/apis/edp/v1alpha1"
_ "github.com/lib/pq"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kuber... |
package clusters
import "github.com/cohesity/management-sdk-go/models"
import "github.com/cohesity/management-sdk-go/configuration"
/*
* Interface for the CLUSTERS_IMPL
*/
type CLUSTERS interface {
GetExternalClientSubnets () (*models.SpecifiesTheExternalClientSubnetsThatCanCommunicateWithThisCluster, ... |
package main
import (
"bufio"
"fmt"
"log"
"net/http"
)
// doesn't work
// moby dick returns a lot of data
// and a panic index out of range error occurs
func main() {
// get the book moby dick
res, err := http.Get("http://www.gutenberg.org/files/2701/2701-0.txt")
if err != nil {
log.Fatal(err)
}
// scan ... |
package stdlib
import (
"context"
"encoding/json"
"time"
"github.com/niolabs/gonio-framework"
"github.com/niolabs/gonio-framework/props"
)
// IdentityIntervalSimulatorBlock
type IdentityIntervalSimulatorBlock struct {
nio.Producer
Config IdentityIntervalSimulatorConfig
duration time.Duration
limit int64... |
package rbn
import (
"math"
"math/rand"
)
// RBNNode : data type that represents a node in the network
type RBNNode struct {
id int
links []int
value bool
layers int
}
func (node *RBNNode) flip() {
node.value = !node.value
}
func (node *RBNNode) getIntFromLinks(rbn RandomBooleanNetwork) int {
result :... |
//go:build e2e
package environment
import (
"os"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/e2e-framework/klient/conf"
"sigs.k8s.io/e2e-framework/pkg/env"
"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/envfuncs"
)
const (
useKind = "TEST_ENV_USE_KIND"
)
func Get() e... |
// Copyright 2020 Red Hat, Inc. and/or its affiliates
//
// 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 applic... |
package bench_test
import (
"sync"
"testing"
)
// =============================================================
// goroutine を起動するにもコストがかかる
// 軽い処理であればあるほどシーケンシャルに処理したほうが速い
// =============================================================
func BenchmarkGoroutine(b *testing.B) {
n := 10
var wg sync.WaitGroup
... |
package main
import (
"fmt"
"io"
"net"
"os"
"sync"
)
func main() {
fmt.Printf("[+] Listening on 127.0.0.1:8080\n")
lAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:8080")
if err != nil {
panic(err)
}
oAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:80")
if err != nil {
panic(err)
}
ln, err := ... |
/*
Copyright 2022 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... |
package main
import (
"flag"
"fmt"
"github.com/astaxie/beego"
"github.com/chai2010/winsvc"
"log"
"os"
"path/filepath"
_ "smartapp/initial/common"
_ "smartapp/initial/plugins"
_ "smartapp/routers"
)
var (
serve string="beegoTest"
appPath string
flagServiceName = flag.String("service-name", serve, "Set ser... |
package ast
import (
"strings"
"github.com/makramkd/go-monkey/token"
)
type Node interface {
TokenLiteral() string
String() string
}
type Statement interface {
Node
statementNode()
}
type Expression interface {
Node
expressionNode()
}
// Program represents a Monkey program.
// Monkey programs are a sequen... |
package io
import (
"jean/constants"
"jean/native"
"jean/rtda/jvmstack"
)
// private static native void initIDs();
func fdInitIDs(frame *jvmstack.Frame) {
// todo
}
// private static native long set(int d);
// (I)J
func set(frame *jvmstack.Frame) {
// todo
frame.OperandStack().PushLong(0)
}
func init() {
nat... |
package main
import (
"encoding/json"
"github.com/gorilla/mux"
"github.com/playgrunge/monicore/control"
"github.com/playgrunge/monicore/core/api"
"github.com/playgrunge/monicore/core/hub"
"github.com/playgrunge/monicore/service"
"log"
"net/http"
"time"
)
var h = hub.GetHub()
func main() {
r := mux.NewRoute... |
package ernie
var Version = "v2.0.0"
|
/**
* Created by: Jianyi
* Date: 2019/1/4
* Time: 13:37
* Description:
**/
package models
import (
"github.com/astaxie/beego/orm"
)
type Leader struct{
Id int `pk:"auto"`
Name string `orm:"size(40)"`
ProField string `orm:"size(200)"`
Wechat string `orm:"size(100)"`
Status int ... |
package main
// Simple program to list databases and the tables
import (
"context"
"database/sql"
"log"
impala "github.com/bippio/go-impala"
)
func main() {
opts := impala.DefaultOptions
opts.Host = "<impala host>"
opts.Port = "21050"
// enable LDAP authentication:
opts.UseLDAP = true
opts.Username = "... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
func main() {
//http.HandleFunc("/getTest",getRequest)
//http.HandleFunc("/postTest",postRequest)
http.HandleFunc("/postForm",postRequest2)
http.HandleFunc("/getJson",getJsonData)
log.Fatal(http.ListenAndServe(":8080",nil))
}
// get请求
func getRe... |
package configuration
import (
"fmt"
"github.com/stretchr/testify/assert"
"runtime"
"sync"
"testing"
)
func TestParseKeyOrder(t *testing.T) {
wg := &sync.WaitGroup{}
fn := func() {
defer func() {
wg.Done()
}()
for i := 0; i < 100000; i++ {
conf := LoadConfig("tests/configs.conf")
for g := 1;... |
package main
import (
"bytes"
"fmt"
"github.com/adiabat/btcd/wire"
"github.com/adiabat/goodelivery/extract"
"github.com/mit-dci/lit/portxo"
)
func (g *GDsession) extractmany() error {
if *g.inFileName == "" {
return fmt.Errorf("extract needs input file (-in)")
}
filetext, err := g.inputText()
if err != n... |
package main
import (
"fmt"
"io"
"log"
"net/url"
"time"
)
//Common atributes of a crawler.
type crawlerInternals struct {
finishTime time.Time
fetcher fetcher
rules accessPolicy
frontier urlFrontier
store urlStore
sitemap sitemap
}
func initCommonAttributes(c *crawlerInternals, seed []st... |
package main
import (
"fmt"
// 如果想使用包的 init,而不使用它的方法,用匿名别名包,不使用它的方法不报错
// 如果把 _ 改成其他名字,就是重命名包了
_ "go-demo/_import/package"
)
func main() {
fmt.Print("666\n")
} |
// Copyright 2020 cloudeng llc. All rights reserved.
// Use of this source code is governed by the Apache-2.0
// license that can be found in the LICENSE file.
package signals_test
import (
"context"
"io"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
"syscall"
"testing"
"time"
"clou... |
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"strings"
)
func serve(conn net.Conn) {
body := "Hello World! \nMethod: %s \nURI: %s \n"
scanner := bufio.NewScanner(conn)
var i = 0
var method string
var uri string
for scanner.Scan() {
ln := scanner.Text()
if ln == "" {
break
}
if i == 0 {... |
package handlers
type ArchLinux = archLinux
type Darwin = darwin
|
package helper
import (
"encoding/base64"
"math/rand"
"net/http"
"strconv"
"strings"
"time"
"regexp"
"github.com/asaskevich/govalidator"
"golang.org/x/crypto/bcrypt"
)
func init() {
alphaSpaces, _ := regexp.Compile("^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑ... |
package workers
import (
"log"
"github.com/nicholasjackson/sorcery/data"
"github.com/nicholasjackson/sorcery/logging"
)
type DeadLetterQueueWorkerFactory struct {
EventDispatcher EventDispatcher `inject:"eventdispatcher"`
Dal data.Dal `inject:"dal"`
StatsD logging.StatsD `inject:"s... |
package main
import (
"context"
"fmt"
"sync"
"time"
)
//使用channel和WaitGroup同步
func main() {
done:=make(chan int ,100)
defer close(done)
//开启线程
for i := 1; i <= cap(done); i++ {
go func(i int) {
fmt.Println("开启线程", i)
done <- i
}(i)
}
//使用channel阻塞的方式来出来同步
//此处不能使用range 会引起主线程deadline
/*
for m ... |
package attacker
import (
"io/ioutil"
"net/http"
"github.com/AmyangXYZ/barbarian"
"../logger"
"../utils"
"github.com/gorilla/websocket"
)
// BasicSQLi checks basic sqli vuls.
// WebSocket API.
type BasicSQLi struct {
mconn *utils.MuxConn
fuzzableURLs []string
payload0 string
payload1 st... |
package lc
// Time: O(n)
// Benchmark: 108ms 7.4mb | 100%
type ListNode struct {
Val int
Next *ListNode
}
func mergeInBetween(list1 *ListNode, a int, b int, list2 *ListNode) *ListNode {
n := list1
var startRef, endRef *ListNode
for i := 0; i <= b; i++ {
if i == a-1 {
startRef = n
}
if i == b {
end... |
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
type Command struct {
name string
Execute func(args []string) bool
usage string
}
var commands []Command
func commandManager() {
defer commandQueue.Done()
var args []string = consoleRead()
inputCommand(args)
}
func registerCommand(command Command) {
... |
package main
import "fmt"
func main0901() {
a := 10
//b := 20
// 一级指针 指向变量的地址
p := &a
//二级指针 指向一级指针的地址
var pp **int = &p
//通过二级指针连接修改一级指针的值
//*pp = &b
//通过二级指针间接修改变量的值
**pp = 100
//var ppp ***int
//var pppp ****int
//pp := &p
//*int
fmt.Printf("%T\n", p)
fmt.Printf("%T\n", pp)
}
func main0902() {
... |
package main
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestSimpleRequest(t *testing.T) {
jsonUrls := `
[
"http://jsonplaceholder.typicode.com/posts/1",
"http://jsonplaceholder.typicode.com/po... |
package dbslite
import (
"database/sql"
"fmt"
"log"
_ "github.com/mattn/go-oci8"
)
var Db *sql.DB
func init() {
var err error
Db, err = sql.Open("oci8", "wang/1824611967")
if err != nil {
fmt.Print(err.Error())
log.Fatal(err)
}
err = Db.Ping()
if err != nil {
fmt.Print("未连接")
}
}
|
// Package main initializes and runs the server.
// This package is small, because it is main.
package main
import (
"log"
"github.com/MangoHacks/Mango2019-API/server"
)
func main() {
s, err := server.New()
if err != nil {
log.Fatal(err)
}
if err := s.Start(); err != nil {
log.Fatal(err)
}
}
|
package client_route
import (
"ehsan_esmaeili/route/client_route/v1_client_route"
"github.com/julienschmidt/httprouter"
)
func ClientInit(r *httprouter.Router) {
v1_client_route.V1ClientInit(r)
}
|
package portfolio
import (
"sort"
)
func Join(portfolios ...Portfolio) Portfolio {
jp := Portfolio{}
for _, p := range portfolios {
for _, t := range p.Transactions() {
jp.Add(t)
}
}
return jp
}
type Portfolio struct {
Name string
transactions []Transaction
holdings map[key]Holding
}
type... |
package main
import "testing"
func BenchmarkParallelRequest(b *testing.B) {
for i:=0;i<b.N;i++{
ParallelRequest(5)
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.