text stringlengths 11 4.05M |
|---|
package controllers
import (
"fmt"
"net/http"
"traceip/internal/helpers"
"traceip/internal/models"
"traceip/internal/services"
"github.com/go-redis/redis/v8"
"github.com/labstack/echo"
)
//IPController IP endpoints handlers
type IPController struct {
RedisConn *redis.Client
StatisticsService *servic... |
package main
import (
"github.com/astaxie/beego"
_ "test_proj/email/routers"
//"test_proj/email/controllers"
)
func main() {
beego.Run()
}
|
package entry
import (
"math"
"sort"
"sync"
"shared/common"
"shared/utility/errors"
"shared/utility/transfer"
)
const (
CfgWorldItemData = "cfg_world_item_data"
CfgWorldItemLevelUp = "cfg_world_item_level_up"
CfgWorldItemAdvance = "cfg_world_item_advance"
CfgWorldItem... |
package client
import (
"fmt"
"log"
"strings"
"time"
"github.com/Jeffail/gabs/v2"
"github.com/go-resty/resty/v2"
)
var uniswapPools map[string]bool
var quickswapPools map[string]bool
var balancerPools map[string]bool
func init() {
uniswapPools = map[string]bool{}
quickswapPools = map[string]bool{}
balancer... |
package client
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
)
type Params struct {
Url string
ApiKey string
}
type client struct {
url string
apiKey string
}
type requestParam struct {
name string
value string
}
func Create(params Params) *client... |
package health
import (
"io/ioutil"
"net"
"net/url"
"regexp"
"github.com/cerana/cerana/acomm"
"github.com/cerana/cerana/pkg/errors"
"github.com/cerana/cerana/pkg/logrusx"
)
// TCPResponseArgs are arguments for TCPResponse health checks.
type TCPResponseArgs struct {
Address string `json:"address"`
Body [... |
// Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
//
//
// Example 1:
// Input: nums = [1,3,5,6], target = 5
// Output: 2
// Example 2:
// Input: nums = [1,3,5,6], target = 2
// Output: 1
/... |
package examples
import (
"io"
"math/rand"
"os"
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/components"
"github.com/go-echarts/go-echarts/v2/opts"
)
var (
itemCntLine = 6
fruits = []string{"Apple", "Banana", "Peach ", "Lemon", "Pear", "Cherry"}
)
func generateLineI... |
// http://mschoebel.info/2014/03/09/snippet-golang-webapp-login-logout.html
// simple example for session management using secure cookies
// Serve two pages - an index page providing a login form and
// an internal page that is only accessible to authenticated users (= users that have used the login form).
// The int... |
package passwduser
import (
"io/ioutil"
"os"
"os/user"
"reflect"
"testing"
)
func TestLookup(t *testing.T) {
const passwdContent = `
root:x:0:0:root user:/root:/bin/bash
adm:x:42:43:adm:/var/adm:/bin/false
111:x:222:333::/home/111:/bin/false
this is just some garbage data
`
tests := []struct {
testDescripti... |
package main
import (
"context"
"encoding/binary"
"fmt"
"io"
logging "github.com/ipfs/go-log/v2"
pool "github.com/libp2p/go-buffer-pool"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
)
var log = logging.Logger("perf")
const (
ID ... |
/*
* 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
type UpPathChgEvent stru... |
package main
import (
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/aetest"
"google.golang.org/appengine/user"
"testing"
)
func TestUser(t *testing.T) {
inst, err := aetest.NewInstance(nil)
if err != nil {
t.Fatal(err)
}
defer inst.Close()
req, err := inst.NewReq... |
package persistence
import "testing"
func TestGetCategory(t *testing.T) {
c,err := GetCategory("BIRDS")
if err != nil {
t.Error(err)
}
t.Log(c,"categoryId:",c.CategoryId)
}
func TestGetCategoryList(t *testing.T) {
r,err := GetCategoryList()
if err != nil {
t.Error(err)
}
t.Log(r[1])
}
|
package elevengo
type _UserInfo struct {
UserId string
}
type _OfflineToken struct {
Sign string
Time int64
QuotaTotal int
QuotaRemain int
}
type _BasicResult struct {
State bool `json:"state"`
Error *string `json:"error"`
ErrorType *string `json:"errtype"`
MessageCode int ... |
package migration
import (
"fmt"
"io/ioutil"
"path/filepath"
"sort"
"strconv"
"strings"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq" // nolint
)
// upFiles search for migration up files and return
// a sorted array with the path of all found files
func upFiles(dir string) (files []string, err error) {
fi... |
package environment
import (
"bytes"
"log"
"os"
"strconv"
"strings"
"time"
)
//note: the sintax `json:"id"` bind the identifier in json to the variable in this code
//example: X uint64 `json:"x"` bind the name the x name in json to X point struct
// Point define a 2-axis coordinate type
type Point struct {
Row... |
package exec
import (
"fmt"
"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"
)
// processHelp processes help commands
func processHelp(componentType string, command string) error {
cliConfig := schema.CliConfiguration{}
cliConfig.Logs.Level = u.LogLevelTrace
if len(command) =... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 ... |
/*
Copyright 2019 Baidu, 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 to in writing, software
dis... |
package main
import (
"fmt"
"os"
"strings"
"rand"
"time"
"bytes"
"strconv"
)
const (
MAX_PHONES = 20
DICTIONARY_FILENAME = "/usr/share/dict/web2"
DICTIONARY_SIZE = 500000 // words (strings)
BUFFER_SIZE = 100 // bytes
)
var soundexDict []soundex
type soundex struct {
word string // plain word
code strin... |
package worker
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
)
const footerMsg = `
Показаны %d нод(ы) из %d, остальные ищи в логах.
Ошибки могут быть из-за того, что не забутстраплены беты/сенды из списка,
на этих нодах высокое значение Load Average либо остановлен redis@shared.service.
Для... |
func toLowerCase(str string) string {
r := []rune(str)
for i:=0;i<len(r);i++ {
if r[i]>='A' && r[i]<='Z' {
r[i]+= 32
}
}
return string(r)
}
|
package main
import "fmt"
func main() {
i := 38
fmt.Printf("%7b %#3o %d %#x %s \n", i, i, i, i, string(i))
i = 40
fmt.Printf("%7b %#3o %d %#x %s \n", i, i, i, i, string(i))
ch := 'e'
fmt.Printf("\n%T\n", ch)
fmt.Printf("%7b %#3o %d %#x %s \n", ch, ch, ch, ch, string(ch))
ch = 'E'
fmt.Printf("\n%T\n", ch... |
package main
import (
"archive/tar"
"archive/zip"
"bytes"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/AlexanderEkdahl/rope/version"
)
// ParseSdistFilename returns a Sdist package from a given filename
func ParseSdistFilenam... |
package port
import (
"errors"
"github.com/threez/intm/internal/model"
)
var ErrInvalidContent = errors.New("invalid interval")
type IntervalReader interface {
// Read reads an interval at a time and returns
// nil, io.EOF when there are no more intervals
Read() (*model.Interval, error)
}
|
package repository
import (
"context"
"github.com/caos/zitadel/internal/user/model"
)
type UserRepository interface {
UserByID(ctx context.Context, id string) (*model.UserView, error)
CreateUser(ctx context.Context, user *model.User) (*model.User, error)
RegisterUser(ctx context.Context, user *model.User, resou... |
package endure
import (
"encoding/json"
"encoding/xml"
"io"
yaml "gopkg.in/yaml.v2"
)
// NewJSONFileStorage creates a new value of the FileStorage type with
// the json.Marshal and json.Unmarshal funcs.
func NewJSONFileStorage(filename string) Storage {
return &FileStorage{
Filename: filename,
Marshal: j... |
package layout_test
import (
"testing"
"github.com/waybeams/assert"
"github.com/waybeams/waybeams/pkg/ctrl"
surface "github.com/waybeams/waybeams/pkg/env/fake"
"github.com/waybeams/waybeams/pkg/fakes"
"github.com/waybeams/waybeams/pkg/layout"
"github.com/waybeams/waybeams/pkg/opts"
"github.com/waybeams/waybea... |
package kojiapi_test
import (
"encoding/json"
"net/http/httptest"
"testing"
"github.com/osbuild/osbuild-composer/internal/jobqueue/testjobqueue"
"github.com/osbuild/osbuild-composer/internal/kojiapi"
"github.com/osbuild/osbuild-composer/internal/kojiapi/api"
distro_mock "github.com/osbuild/osbuild-composer/int... |
package backend
import (
"archive/tar"
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"time"
gocontext "context"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
docker "github.co... |
package leetcode_0148_排序链表
/*
在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序。
示例 1:
输入: 4->2->1->3
输出: 1->2->3->4
示例 2:
输入: -1->5->3->4->0
输出: -1->0->3->4->5
*/
// Definition for singly-linked list.
type ListNode struct {
Val int
Next *ListNode
}
func sortList(head *ListNode) *ListNode {
// 先返回异常值:head就是空的或者head的next是空的... |
package main
import (
"log"
"golang.org/x/net/context"
firebase "firebase.google.com/go"
"google.golang.org/api/option"
)
func main() {
opt := option.WithCredentialsFile("path/to/serviceAccountKey.json")
app, err := firebase.NewApp(context.Background(), nil, opt)
if err != nil {
log.Fatalf("error initiali... |
package models
import "go.mongodb.org/mongo-driver/mongo"
// 库存数量不足时,通知的是仓库管理员
type MessageType struct {
ID int64 `json:"id" bson:"id"` // 1 商品库存 2 仓库库存 3 订单 4 结算单(可能会拆分为客户和供应商两种)
Name string `json:"name" bson:"name"` // 类型名字
Template string `json:"template" bson:"template"` // 类型模板
... |
package model
type SearchResults struct {
MediaContainer struct {
Metadata []struct {
Genre []struct {
Tag string `json:"tag"`
} `json:"Genre"`
Role []struct {
Tag string `json:"tag"`
} `json:"Role"`
AddedAt int64 `json:"addedAt"`
AllowSync bool `json:"allowS... |
package webhook
import (
"encoding/json"
"reflect"
)
func Unmarshal(str string) Webhook {
var webhook Webhook
err := json.Unmarshal([]byte(str), &webhook)
if err != nil {
return Webhook{}
}
return webhook
}
type image struct {
namespace string
name string
tag string
}
var (
validImages = []i... |
package models
import "time"
type BaseModel struct {
ID uint `json:"id" gorm:"primary_key"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
}
|
package access
import (
"errors"
"time"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/mgalela/akses/db"
"github.com/mgalela/akses/utils"
)
//TokenCache represent token cache document
type TokenCache struct {
ID string `json:"id" bson:"_id"`
Token string `json:"token" bson:"token"`
UserID str... |
// Package kindergarten implements a solution of the exercise titiled `Kindergarten Garden'.
package kindergarten
import (
"errors"
"sort"
"strings"
)
// Garden represents a collection of a child and his/her own grasses.
type Garden map[string][]string
var plants = map[byte]string{'G': "grass", 'C': "clover", 'R'... |
package config
const (
RabbitURL = "amqp://admin:123456@192.168.2.3:5672/"
ExchangeName = "oss.transfer.exchange"
ExchangeType = "direct"
QueueName = "oss.transfer.queue"
RoutingKey = "oss"
)
|
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"myRPC/myService/game/generate"
)
//func main() {
// req := &pbGuide.Point{
// Latitude:100,
// Longitude:10000,
// }
// conn, err := grpc.Dial("127.0.0.1:8889", grpc.WithInsecure())
// if err != nil {
// fmt.Println("Dial:", err)
// return
// }
... |
package main
import (
"net/http"
"net/http/httputil"
"os"
"runtime/debug"
"strings"
"time"
"github.com/go-openapi/loads"
"github.com/go-openapi/runtime/middleware"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/z7zmey/golang-microservice... |
package httpServer
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"github.com/valyala/fasthttp"
"time"
)
var (
strContentType = []byte("Content-Type")
strApplicationJSON = []byte("application/json")
)
func GenerateResp(result interface{}, code int, message string) map[string]map[string]interface{... |
package grpchook
import (
"context"
"fmt"
"strings"
"github.com/SecuritasCrimePrediction/apitools-go/notification"
"google.golang.org/grpc"
)
type interceptor struct {
configs EndpointConfig
recipients []notification.Sender
}
// The hook for streaming endpoints
// Assembles all endpoint configurations to ... |
package controllers
import (
"github.com/gin-gonic/gin"
"github.com/mickaelmagniez/elastic-alert/models"
"net/http"
"github.com/mickaelmagniez/elastic-alert/store"
)
type AlertsController struct{}
func (AlertsController) All(c *gin.Context) {
alerts, err := store.AllAlerts()
if err != nil {
c.JSON(http.Statu... |
package domain
var (
DefaultStore NOSQLStore
)
type NOSQLStore interface {
CreateKeyspace(keyspace_name string) error
DropKeyspace(keyspace_name string) error
ShowKeyspaces() ([]Keyspace, error)
ShowColumnFamily(ks, cf string) ([]map[string]string, error)
}
type Columnfamily struct {
Name string
}
type Row st... |
package main
//808. 分汤
//有 A 和 B 两种类型 的汤。一开始每种类型的汤有 n 毫升。有四种分配操作:
//
//提供 100ml 的 汤A 和 0ml 的 汤B 。
//提供 75ml 的 汤A 和 25ml 的 汤B 。
//提供 50ml 的 汤A 和 50ml 的 汤B 。
//提供 25ml 的 汤A 和 75ml 的 汤B 。
//当我们把汤分配给某人之后,汤就没有了。每个回合,我们将从四种概率同为 0.25 的操作中进行分配选择。如果汤的剩余量不足以完成某次操作,我们将尽可能分配。当两种类型的汤都分配完时,停止操作。
//
//注意 不存在先分配 100 ml 汤B 的操作。
//
//需... |
package authJwtToken
import (
"encoding/json"
"github.com/ethereal-go/ethereal"
"github.com/ethereal-go/ethereal/root/app"
"github.com/ethereal-go/ethereal/root/config"
"github.com/justinas/alice"
"net/http"
)
type MiddlewareJWTToken struct {
EtherealClaims
StatusError int
ResponseError string
authentic... |
/*
Copyright 2019 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, ... |
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/szydell/mstools"
"github.com/szydell/rjgtm/rjerr"
"github.com/szydell/rjgtm/rjshared"
)
func getGlvn(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
glvn := string(ps.ByName("glvn"))
l... |
// Based on Gophercises tutorial
// https://gophercises.com/exercises/image
package graphgenerator
import (
"math/rand"
"os"
svg "github.com/ajstarks/svgo"
)
func rn(n int) int { return rand.Intn(n) }
// main - generates an SVG graph based on inputs given.
func main() {
data := []struct {
Label string
Valu... |
package main
import (
"strings"
"fmt"
)
/*
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.
Exampl... |
/*
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... |
package wire
import (
"io"
"github.com/multivactech/MultiVAC/base/rlp"
)
// Timestamp defines the type of time.
type Timestamp int64
// HeartBeatMsg is a type of message heartbeat.
type HeartBeatMsg struct {
Pk []byte // the miner's public key
TimeStamp Timestamp
Proof []byte // the proof of a mine
... |
package main
// service 层不处理error
func GetValue(id int) (string, error){
return DaoGet(id)
}
|
package poller
import (
"fmt"
"time"
"github.com/gbolo/vsummary/db"
)
// BuiltInCollector is a package-wide instance of InternalCollector
var BuiltInCollector InternalCollector
// internal poller that contains a list of pollers as well as a backend db
type InternalCollector struct {
ActivePollers []*InternalPol... |
package models
import "github.com/tahmooress/motor-shop/internal/pkg/customeerror"
var (
ErrEmptyEnvironment = customeerror.New("1000", "environment variables must be not empty",
"پارامترهای وروری برنامه خالی هستند")
ErrEmptyIPANDPORT = customeerror.New("1001", "some fields are empty in cli: IP, Port, routers",
... |
package main;
import (
"time"
"github.com/rcrowley/go-metrics"
"github.com/vrischmann/go-metrics-influxdb"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/bugsnag/bugsnag-go"
"strconv"
"log"
"os"
"github.com/caarlos0/env"
)
type C... |
package main
import (
"flag"
"fmt"
"github.com/syfaro/haste-client"
"io/ioutil"
"log"
"os"
)
var hasteClient *haste.Haste
func uploadFile(name string) {
data, err := ioutil.ReadFile(name)
if err != nil {
log.Printf("Unable to read file: %s\n", err.Error())
os.Exit(2)
}
resp, err := hasteClient.UploadB... |
package main
import (
"fmt"
"sync"
"time"
)
func helloWait(wg *sync.WaitGroup, name string, number uint8) {
defer wg.Done()
for i := uint8(0); i < number; i++ {
fmt.Println(i, ": Hello ", name)
time.Sleep(500 * time.Millisecond)
}
}
func main() {
var wg sync.WaitGroup
wg.Add(2)
go helloWait(&wg, "Michel... |
package gohotdraw
type DefaultFigureDecorator struct {
*DefaultFigure
figure Figure //the decorated figure
}
func NewDefaultFigureDecorator(figure Figure) *DefaultFigureDecorator {
this := new(DefaultFigureDecorator)
this.DefaultFigure = newDefaultFigure()
this.figure = figure
return this
}
//forward call to c... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package k8s
import (
"testing"
"github.com/stretchr/testify/require"
rbacv1 "k8s.io/api/rbac/v1"
rbacbetav1 "k8s.io/api/rbac/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func TestClust... |
// Package bufpool provides a sync.Pool of bytes.Buffer.
package bufpool
import (
"bytes"
"sync"
)
const maxSize = 1 << 16 // 64 KiB. See https://github.com/golang/go/issues/23199
var p = &sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
}
// Get gets a buffer from the pool, resets it and retu... |
package main
func main() {
// Simple iface
var a Iface1 = &Iface1Struct{"foo"}
println("iface 1", a.Foo("bar"))
a.Foo2("baz")
println("iface 2", a.Foo("test"), a.(*Iface1Struct).foo)
b := Iface1Struct{"bar"}
c := Iface1(&b)
println("iface 3", c.Foo3(a, "a", "b"), b.foo)
// // Embeds
var d Iface4Num
d += 14
... |
package main
import(
"fmt"
"net"
"code/chatroom/comon/message"
"code/chatroom/server/util"
"io"
"code/chatroom/server/process"
)
type Processor struct{
Conn net.Conn
}
func (this *Processor) process2() (err error) {
for{
tf := &util.Transfer {
Conn : this.Conn,
}
mes,err := tf.ReadPkg()
if err != ... |
package conn
import (
"fmt"
"reflect"
"time"
json "github.com/intel-go/fastjson"
nats "github.com/nats-io/go-nats"
. "github.com/sencydai/utils/log"
)
//SysMessage 系统消息
type SysMessage struct {
MsgID int
Data []byte
}
//ResponseMessage rpc消息
type ResponseMessage struct {
Subject string... |
package crawler
import (
"fmt"
"log"
"encoding/json"
"net/http"
"github.com/ReToCode/GoStats/config"
"github.com/ReToCode/GoStats/store"
"time"
)
var jobsBody struct {
Hits int `json:"total_hits"`
}
func CrawlStats() {
fmt.Println("creating ticker for crawler")
ticker := time.NewTicker(time.Hour * 24)
... |
package msgraph
import (
"encoding/json"
"fmt"
"time"
)
// CalendarEvent represents a single event within a calendar
type CalendarEvent struct {
ID string
CreatedDateTime time.Time // Creation time of the CalendarEvent, has the correct timezone set from OriginalStartTimeZone (json)
... |
package utils
import "reflect"
func GetTypeName(instance interface{}) string {
t := reflect.TypeOf(instance)
if t.Kind() == reflect.Ptr {
return "*" + t.Elem().Name()
}
return t.Name()
}
|
package types
import "time"
type Users struct {
ID int `json:"id"`
Created_at time.Time `json:"created_at"`
Updated_at time.Time `json:"updated_at"`
Deleted_at time.Time `json:"deleted_at"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Passw... |
package taillog
import (
"fmt"
"logagent_study/etcd"
"time"
)
var (
taskMgr *tailLogMgr
)
type tailLogMgr struct {
logEntryList []*etcd.LogEntry
taskMap map[string]*TailTask
newConfChan chan []*etcd.LogEntry
}
func Init(logEntryConf []*etcd.LogEntry) {
taskMgr = &tailLogMgr{
logEntryList: logEntryCo... |
package main
import (
"fmt"
"bufio"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("Type something: ")
scanner.Scan()
input := scanner.Text()
fmt.Printf("You typed %q \n", input)
} |
// 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 session
import (
"context"
"github.com/golang/protobuf/proto"
"chromiumos/policy/chromium/policy/enterprise_management_proto"
"chromiumos/tast/local/cryptohome... |
package imagerepository
import (
"alauda.io/diablo/src/backend/resource/common"
"log"
"alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1"
devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned"
"alauda.io/diablo/src/backend/api"
"alauda.io/diablo/src/backend/errors"
"alauda.io/diablo/src/bac... |
package dtacode
import (
"fmt"
"io/ioutil"
"github.com/derpl-del/gopro2/envcode/jscode"
"github.com/derpl-del/gopro2/envcode/logcode"
"github.com/derpl-del/gopro2/envcode/strcode"
)
//ListProduct array
var ListProduct []strcode.ProductData
//ReturnAllProduct for homepage
func ReturnAllProduct() strcode.AllProd... |
package day1
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
dat, err := os.Open("input.txt")
check(err)
scanner := bufio.NewScanner(dat)
var numbers []int
for scanner.Scan() {
number, err := strconv.Atoi(scanner.Text())
check(err)
nu... |
package floors
import (
"fmt"
"math/bits"
"regexp"
"sort"
"strings"
"github.com/golang/glog"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/currency"
"github.com/prebid/prebid-server/openrtb_ext"
)
const (
SiteDomain string = "siteDomain"
PubDomain string = "p... |
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// SmartLimiter is the Schema for the smartlimiters API
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=smartlimiters,scope=Namespaced
type SmartLimiter s... |
// 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 loginapi
import (
"context"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/policy/fakedms"
"chromiumos/tast/e... |
package main
import (
"log"
"net/rpc/jsonrpc"
)
type Agrs struct {
A, B int
}
type Quotient struct {
Quo, Rem int
}
// http rpc 方式
func main() {
//if len(os.Args) != 2 {
// log.Println("Usage: ", os.Args[0], "server")
// os.Exit(1)
//}
//
//serverAddress := os.Args[1]
//client, err := rpc.DialHTTP("tcp... |
package server
//服务器调度策略
const (
SERVERSCHENIL uint32 = iota //不接受调度
SERVERSCHEROUND //轮流调度
SERVERSCHELOAD //最小负载调度
)
// Info 服务器信息,用于代理发现服务器
// 服务器启动后发布自己的信息给代理
type Info struct {
Addr string `json:"addr"` //服务器地址
Type uint32 `json:"type"` //服务器类型
Sche uint32 `json:"sche"` /... |
package main
import (
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/db"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
"github.com/GoAdminGroup/go-admin/template/types/form"
)
func GetBlogArticleTable(ctx *context.Context) table.Table {
blogArticle := table... |
/**
* Testing file for linked list
**/
package linkedListTesting
import (
"testing"
// "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
ll "linkedList/main.go/linkedlist"
"fmt"
)
type removeSuite struct {
suite.Suite
}
var al ll.LinkedList
func (s *removeSuite) BeforeTest(suiteName, ... |
package main
import (
"flag"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/sjmudd/mysql_defaults_file"
"os"
"github.com/takaidohigasi/gtid-errant-fixer/src/replica"
)
func exitWithError(err error) {
fmt.Print(err)
os.Exit(1)
}
func main() {
var conf, monitorUser, monitorPass string
var forceOption ... |
//go:build !linux
// +build !linux
package main
import "github.com/sirupsen/logrus"
func notifyReady(_ *logrus.Logger) {
// No init service to notify
}
|
package drivers
// Driver are the names of supported driver names
type Driver string
const (
// MySQL database driver
MySQL = "mysql"
// Postgres database driver
Postgres = "postgres"
// SQLServer database driver
SQLServer = "sqlserver"
// SQLite database driver
SQLite = "sqlite"
// SQLite3 database driver
... |
package handler
import (
"net/http"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/Lunchr/luncher-api/db"
"github.com/Lunchr/luncher-api/db/model"
"github.com/Lunchr/luncher-api/router"
"github.com/Lunchr/luncher-api/session"
"github.com/deiwin/facebook"
"golang.org/x/oauth2"
)
// RedirectToFBForLogi... |
package v1alpha1
const (
// SystemSecretName it's a secret resource created and updated dynamically by a controller.
// It should be used for communicating between systems
SystemSecretName = "koli-system-token"
DefaultClusterRole = "koli:mutator:default"
)
|
package main
import (
"github.com/gocql/gocql"
"github.com/relops/cqlc/cqlc"
"log"
"twitter"
)
var TWEETS = twitter.TweetsTableDef()
func main() {
host := "127.0.0.1"
keyspace := "twitter_example"
cluster := gocql.NewCluster(host)
cluster.Keyspace = keyspace
session, err := cluster.CreateSession()
if er... |
// 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 (c) 2016, Randy Westlund and Jacqueline Kory Westlund.
* All rights reserved.
* This code is under the BSD-2-Clause license.
*/
package defs
// Album represents an album in the DB.
type Album struct {
Name string `json:"name"`
// See the comment in db/albums.go:scan_album() for why this is a poin... |
package controllers
//RequestContext exposes request context methods
type RequestContext interface {
NegotiateFormat(...string) string
ShouldBindJSON(interface{}) error
JSON(int, interface{})
Header(string, string)
Data(int, string, []byte)
DefaultQuery(string, string) string
BindQuery(interface{}) error
BindJ... |
package views
import (
"html/template"
"net/http"
"path/filepath"
)
type View struct {
Template *template.Template
Layout string
}
// Метод структуры View для возврата шаблона
func (v *View) RenderTemplate(w http.ResponseWriter, data interface{}) {
if err := v.Template.ExecuteTemplate(w, v.Layout, data); err... |
package internal
import (
"github.com/adamluzsi/frameless/pkg/teardown"
"reflect"
)
func Equal(v1, v2 any) bool {
if v1 == nil || v2 == nil {
return v1 == v2
}
return reflectDeepEqual(
&refMem{visited: make(map[uintptr]struct{})},
reflect.ValueOf(v1), reflect.ValueOf(v2))
}
func RegisterIsEqual(typ reflec... |
package main
import (
"log"
"net"
"net/http"
"sync"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/sleep2death/gotham"
"github.com/sleep2death/gotham/examples/pb"
)
func main() {
// SERVER
// Starts a new gotham instance without any middleware.
router := gotham... |
// 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 arc
import (
"context"
"time"
"chromiumos/tast/local/apps"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chr... |
package main
import (
"fmt"
"log"
"encoding/json"
)
type Book struct {
GUID string `json:"guid"`
FileName string `json:"fileName"`
}
type BookAux struct {
Title string `json:"title"`
}
type BookShelf struct {
Count int `json:"count"`
Books []Book `json:"b... |
package utils
import (
"golang.org/x/crypto/bcrypt"
)
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 10)
return string(bytes), err
}
func CheckPassowrd(password, hash string) error {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(passwo... |
package main
import (
"context"
"flag"
"fmt"
"os"
"strings"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
)
type help_t struct {
name string
text string
}
var CommandHelp = []help_t{
{"help", "display this help text"},
{"list", "list all repositories"},
{"find", "search go package git repos... |
package humanize_test
import (
"math"
"testing"
"github.com/git-lfs/git-lfs/tools/humanize"
"github.com/stretchr/testify/assert"
)
type ParseBytesTestCase struct {
Given string
Expected uint64
Err error
}
func (c *ParseBytesTestCase) Assert(t *testing.T) {
got, err := humanize.ParseBytes(c.Given)
i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.