text stringlengths 11 4.05M |
|---|
package controller
import (
"context"
"foreplay/manager"
"shared/protobuf/pb"
)
type ForeplayHandler struct {
*pb.UnimplementedForeplayServer
}
func NewForeplayHandler() (*ForeplayHandler, error) {
return &ForeplayHandler{
UnimplementedForeplayServer: &pb.UnimplementedForeplayServer{},
}, nil
... |
package main
import (
"io"
"log"
"net/http"
)
func Handler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
io.WriteString(w, "<form method=\"POST\" action=\"/upload\" enctype=\"multipart/form-data\">")
}
}
func main() {
http.HandleFunc("/upload", Handler)
err := http.ListenAndServe(":8080",... |
// 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, ... |
package msg
import (
"lemna/arpc"
"lemna/utils"
"reflect"
proto "github.com/golang/protobuf/proto"
)
//ProtoInfo Protobuf基本信息
type ProtoInfo struct {
id uint32
name string
elem reflect.Type
}
//ID Info的Protobuf实现
func (pi ProtoInfo) ID() uint32 {
return pi.id
}
//Name Info的Protobuf实现
func (pi ProtoInfo) ... |
package ws
import (
"fmt"
"net/url"
"strconv"
"strings"
"time"
"github.com/NodeFactoryIo/vedran/internal/actions"
"github.com/NodeFactoryIo/vedran/internal/configuration"
"github.com/NodeFactoryIo/vedran/internal/models"
"github.com/NodeFactoryIo/vedran/internal/record"
"github.com/NodeFactoryIo/vedran/inte... |
package main
const version = "0.1.5"
var revision = "Devel"
|
package backTrack
import (
"fmt"
"testing"
)
func TestCoinChange(t *testing.T) {
var arr []int
arr = []int{1, 3, 5}
cc := NewCoinChange(arr, len(arr), 9)
cc.find(0, 0, 0)
fmt.Println(cc.minNum)
}
|
package ravendb
var _ DynamicSpatialField = &PointField{}
type PointField struct {
latitude string
longitude string
}
func NewPointField(latitude string, longitude string) *PointField {
return &PointField{
latitude: latitude,
longitude: longitude,
}
}
func (f *PointField) ToField(ensureValidFieldName 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 model
import (
"errors"
)
var (
ErrInvalidInput = errors.New("invalid input")
ErrInvalidKind = errors.New("kind is not valid")
ErrInvalidCategory = errors.New("kind is not valid")
ErrInternalError = errors.New("server or network error")
)
|
package types
// Block is a basic type for db storage
type Block struct {
Hash string `json:"hash"`
Confirmations int `json:"confirmations"`
StrippedSize int `json:"strippedsize"`
Size int `json:"size"`
Weight int `json:"weight"`
Height ... |
// 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 wifi
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chr... |
package main
import (
"testing"
plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
"github.com/cyberark/secretless-broker/internal/plugin/v1/testutils"
"github.com/cyberark/secretless-broker/internal/providers"
"github.com/stretchr/testify/assert"
)
func TestKeychainProvider(t *testing.T) {
/... |
// HACK: This entire file is a hack!
//
// LLVM IR has a notion of unnamed variables and basic blocks which are given
// function scoped IDs during assembly generation. The in-memory representation
// does not include this ID, so instead of reimplementing the logic of ID slots
// we capture the output of Value.Dump to ... |
package version
import (
"fmt"
)
const VERSION = "0.0.1"
func ShowVersion() {
fmt.Println(" version : ", VERSION)
}
func GetVersions() string {
return VERSION
}
|
package config
import (
"shared/utility/glog"
"time"
"github.com/go-redis/redis/v8"
)
type Config struct {
Service string
ServerName string
TCPListenPort string
GRPCListenPort string
ETCDEndpoints []string
TCPConnKeepAlive time.Duration // tcp连接保持时间
MaxConn int
RequestRateC... |
package microservicesbinding
//import (
// client "k8s.io/client-go/kubernetes"
//)
//
//func PostMicroservicesBinding(client client.Interface, name string) (mscompDetail *asfv1.MicroservicesBinding, err error) {
// return
//}
//
//func DeleteMicroservicesComponentAction(client client.Interface, name string) (err erro... |
package main
import (
"fmt"
"net/http"
"./controller"
db "./database"
"github.com/julienschmidt/httprouter"
)
func main() {
// load data
go db.GetData()
r := httprouter.New()
r.GET("/", controller.HomeHandler)
r.GET("/json", controller.JsonResponse)
r.POST("/v2/post", controller.PostHandler)
r.ServeF... |
package testsupport
import (
"fmt"
"reflect"
"github.com/davecgh/go-spew/spew"
"github.com/google/go-cmp/cmp"
gomegatypes "github.com/onsi/gomega/types"
"github.com/pkg/errors"
)
// MatchInlineElements a custom matcher to verify that a document matches the given expectation
// Similar to the standard `Equal` m... |
package main
import (
"fmt"
)
type a struct {
b int
c string
}
func main() {
p := new(int)
fmt.Println(*p)
*p = 2
fmt.Println(*p)
fmt.Println("gcd-----")
// forLoop()
rs := gcd(100, 50)
fmt.Println(rs)
fmt.Println("fib-----")
fmt.Println(fib(10))
metal := []string{"gold", "silver", "bornze"}
fm... |
package storage
import (
"encoding/binary"
"strings"
"github.com/dgraph-io/badger"
"github.com/Gravity-Tech/gravity-core/common/account"
"github.com/ethereum/go-ethereum/common/hexutil"
)
type ScoresByConsulMap map[account.ConsulPubKey]uint64
func formScoreKey(pubKey account.ConsulPubKey) []byte {
return for... |
package Api
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/oceanho/gw"
)
func GetRole(c *gw.Context) {
c.JSON200(gin.H{
"payload": fmt.Sprintf("request id is: %s, Role ID is %s", c.RequestId(), c.Query("uid")),
})
}
func CreateRole(c *gw.Context) {
c.JSON200(gin.H{
"payload": fmt.Sprintf("request id ... |
/**
*
* By So http://sooo.site
* -----
* Don't panic.
* -----
*
*/
package apicache
import "encoding/json"
// ResponseData 接口数据
type ResponseData struct {
Code int
Msg string
}
func responseDataParse(data []byte) (resp *ResponseData, err error) {
err = json.Unmarshal(data, &resp)
return
}
|
/*
* Copyright IBM Corporation 2021
*
* 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 o... |
package datastore
import (
"golang.org/x/net/context"
"google.golang.org/appengine/datastore"
)
var ErrNoSuchEntity = datastore.ErrNoSuchEntity
func Put(ctx context.Context, key *Key, src interface{}) (*Key, error) {
if mock, ok := isMock(ctx); ok {
return mock.put(ctx, key, src)
}
dsKey := ConvertKeyToDsKey... |
package comproto
import (
"context"
)
type OnePhaseCommitProtocol interface {
// BeginTx creates a context with a transaction.
// All statements that receive this context should be executed within the given transaction in the context.
// After a BeginTx command will be executed in a single transaction until an ex... |
package view
import (
usr_model "github.com/caos/zitadel/internal/user/model"
"github.com/caos/zitadel/internal/user/repository/view"
"github.com/caos/zitadel/internal/user/repository/view/model"
"github.com/caos/zitadel/internal/view/repository"
)
const (
userTable = "management.users"
)
func (v *View) UserByI... |
package main
import (
"database/sql"
"fmt"
"net/http"
"path/filepath"
"regexp"
"strings"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/imjasonmiller/godice"
"golang.org/x/net/html"
)
type meeting struct {
id string
members []string
date string
canceled bool
location string
entities [... |
package aws
import (
"fmt"
"github.com/aws/aws-sdk-go/service/kms"
microerror "github.com/giantswarm/microkit/error"
)
type KMSKey struct {
arn string
AWSEntity
}
func (kk *KMSKey) CreateIfNotExists() (bool, error) {
return false, fmt.Errorf("KMS keys cannot be reused")
}
func (kk *KMSKey) CreateOrFail() err... |
package mint
import (
"encoding/json"
"fmt"
)
// SignatureSize is signature length in bytes
const SignatureSize = 64
// Signature bytes
type Signature [SignatureSize]byte
// Bytes of the instance
func (s Signature) Bytes() []byte {
b := make([]byte, len(s[:]))
copy(b, s[:])
return b
}
// String packs the inst... |
package toxics_test
import (
"bytes"
"io"
"net"
"strings"
"testing"
"time"
"github.com/Shopify/toxiproxy/toxics"
)
func TestBandwidthToxic(t *testing.T) {
ln, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatal("Failed to create TCP server", err)
}
defer ln.Close()
proxy := NewTestProxy("... |
package datastore
import (
"database/sql"
"log"
// Set up to only use sqlite
_ "github.com/mattn/go-sqlite3"
)
// DB is a global db handle
var db *sql.DB
var createPathMappingsTable = "CREATE TABLE IF NOT EXISTS `pathmappings` ( " +
"`randstring` varchar(64) PRIMARY KEY, " +
"`rootdir` varchar(512), " +
"`pa... |
package utils
import (
"math"
"sync"
"time"
)
type ComputeDuration func(totalTime int64, times []int64) time.Duration
type StopTimer func() time.Duration
func Av() ComputeDuration {
return func(totalTime int64, times []int64) time.Duration {
return time.Duration(totalTime / int64(len(times)))
}
}
func Std(n ... |
package model
import "github.com/google/uuid"
type UserReaction struct {
Username string `json:"username"`
LikedPosts []uuid.UUID `json:"likedPosts"`
DislikedPosts []uuid.UUID `json:"dislikedPosts"`
}
|
package main
type Point struct {
Visited bool
Is_safe bool
}
const k_safe_value int = 23
const k_x_axis_max int = 1000
const k_y_axis_max int = 1000
|
package main
import "testing"
func TestZeros(t *testing.T) {
e := zeros(3, 3)
if len(e) != 3 {
t.Errorf("Incorrect columns size, got %d, expected %d", len(e), 3)
}
if len(e[0]) != 3 {
t.Errorf("Incorrect rows size, got %d, expected %d", len(e[0]), 3)
}
for i := range e {
for j := range e[i] {
if e[i][... |
package server
import "fmt"
type pubArg struct {
subject []byte
reply []byte
sid []byte
azb []byte
size int
}
type parseState struct {
state int
as int
drop int
pa pubArg
argBuf []byte
msgBuf []byte
scratch [MAX_CONTROL_LINE_SIZE]byte
}
// 整个协议,用这个作为状态机记录。
// 其中state表示各个状态,... |
package api
import (
"context"
"errors"
)
// ErrNotImplemented is returned by a storer
// if the called operation is not implemented.
var ErrNotImplemented = errors.New("Not implemented")
// ListParams are parameters passed to storer list operations.
type ListParams struct {
// Search holds the string for a full ... |
package raindrops
import "fmt"
const TestVersion = 1
func Convert(input int) string {
var output string;
if (input % 3 == 0) {
output += "Pling"
}
if (input % 5 == 0) {
output += "Plang"
}
if (input % 7 == 0) {
output += "Plong"
}
if (output == "") {
output = fmt.Sprintf("%v",input);
}
return ou... |
package db
import (
"github.com/jmoiron/sqlx"
"github.com/skycoin/getsky.org/db/models"
)
// CurrenciesStorage provides an access to the DB storage of currencies
type CurrenciesStorage struct {
DB *sqlx.DB
}
// NewCurrenciesStorage creates a new instance of the NewCurrenciesStorage
func NewCurrenciesStorage(db *s... |
package main
import "fmt"
func main() {
fmt.Println("Hello, cloud!")
fmt.Println("This is my second go program")
}
|
package main
import (
"fmt"
"io/ioutil"
"bytes"
)
func main() {
body, _ := ioutil.ReadFile("input.txt")
result := bytes.Title(body)
fmt.Printf("%s", result)
}
|
package main
import (
"io/ioutil"
"net/http"
)
func requestToStorage(method string, url string, data string) (ResponseStorage, error) {
client := &http.Client{}
req, err := http.NewRequest(method, url, nil)
if err != nil {
return ResponseStorage{"", 500}, err
}
req.Header.Set("Authorization", "Bearer "+data)... |
// Copyright 2016 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 uast
import (
"fmt"
"strings"
"github.com/bblfsh/sdk/v3/uast"
"github.com/bblfsh/sdk/v3/uast/nodes"
"github.com/cayleygraph/cayley/quad"
"github.com/cayleygraph/cayley/voc/rdf"
)
const (
predUAST = quad.IRI("uast:Root")
predRole = quad.IRI("uast:Role")
predPos = quad.IRI("uast:Pos")
predFile = qua... |
// Copyright Contributors to the Open Cluster Management project
package managedcluster
import (
"context"
"fmt"
"strconv"
"time"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog"
"sigs.k8s.io... |
// 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 holidays
import (
"testing"
)
func TestParseTime(t *testing.T) {
d, err := parseTime("2019-08-04")
if err != nil {
t.Error(err)
}
if d.Year() != 2019 || d.Month() != 8 || d.Day() != 4 {
t.Fail()
}
}
func TestRangeDates(t *testing.T) {
s, _ := parseTime("2019-08-01")
e, _ := parseTime("2019-08-03... |
package main
import (
"html/template"
"log"
"os"
)
type player struct {
Name string
No int
Team string
}
var tpl *template.Template
func init() {
tpl = template.Must(template.ParseGlob("templates/*"))
}
func main() {
players := []player{
{
Name: "Ronaldinho",
No: 10,
Team: "Brazil",
}, {
... |
package santa
const _goUp string = "("
const _goDown string = ")"
const _basement int = -1
type Santa struct {
Floor int
}
func (s *Santa) ChangeFloor(directionIndicator string) {
switch directionIndicator {
case _goDown:
s.Floor--
case _goUp:
s.Floor++
}
}
func (s *Santa) InBasement() bool {
return s... |
package cloudflare
func (api *API) PublishWorker(scriptName string) (err error) {
uri := "/accounts/" + api.AccountID + "/workers/scripts/" + scriptName + "/subdomain"
_, err = api.makeRequest("POST", uri, &struct {
Enabled bool `json:"enabled"`
}{true})
return
}
|
package gopipe
// PipelineConfig defines the configuration for a pipeline.
type PipelineConfig struct {
Stages []string
Jobs []Job
}
type Job struct {
Name string
Stage string
Scripts []string
}
|
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Licen... |
package main
import (
"encoding/base64"
"fmt"
"log"
"net/http"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
requestString := r.URL.EscapedPath()[1:]
requestURL, err := base64.StdEncoding.DecodeString(requestString)
if err == nil {
fmt.Println("Redirected to " + string(requestURL))
http.Red... |
package main
import (
"net/http"
"strings"
"io/ioutil"
"fmt"
)
func main() {
url := "http://python.51universe.com/test.php"
reader := strings.NewReader("name=liuruichao&age=20")
resp, err := http.Post(url, "application/x-www-form-urlencoded", reader)
if err != nil {
panic(err)
}
defer resp.Body.Close()
... |
package heart
import (
"encoding/json"
"fmt"
"net/http"
"github.com/greenmochi/ultimate-heart/logger"
"github.com/greenmochi/ultimate-heart/process"
)
// Run TODO
func Run(port int, services map[string]process.Service, shutdown chan<- bool) error {
mux := http.NewServeMux()
mux.HandleFunc("/ping", pingHandler... |
package controllers
import (
"github.com/astaxie/beego"
"homework/common/encrypt"
"homework/models/datamodels"
"homework/models/services"
"strconv"
)
type ShopController struct {
beego.Controller
ShopService services.IShopService
}
func (this *ShopController) GetRegister() {
this.TplName = "shop/register.htm... |
// Copyright 2014 The Azul3D 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 main
import (
"go/doc"
"path/filepath"
"sort"
"strings"
)
// Code for package documentation in the "Files" section.
type sourceFile struct {
... |
package gibbon
import "net/http"
// Simple handler with middleware attached
type App struct {
http.Handler
middleware []http.Handler
}
// Entry point into the applicaton
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Load the response writer
rw, ok := w.(*ResponseWriter)
// Convert the t... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package tlsopts
import (
"crypto/x509"
"fmt"
"testing"
"github.com/stretchr/testify/require"
"storj.io/common/peertls"
)
func TestRemoveNils(t *testing.T) {
e1 := fmt.Errorf("error 1")
f1 := peertls.PeerCertVerificationFunc(func(... |
package graphql
import (
"fmt"
"github.com/graphql-go/graphql"
"github.com/juliotorresmoreno/unravel-server/graphql/users"
)
var schema graphql.Schema
//ExecuteQuery Ejecuta las consultas
func ExecuteQuery(query string) *graphql.Result {
result := graphql.Do(graphql.Params{
Schema: schema,
RequestStr... |
package main
import (
"os"
"testing"
"github.com/appleboy/easyssh-proxy"
"github.com/stretchr/testify/assert"
)
func TestMissingHostOrUser(t *testing.T) {
plugin := Plugin{}
err := plugin.Exec()
assert.NotNil(t, err)
assert.Equal(t, missingHostOrUser, err.Error())
}
func TestMissingKeyOrPassword(t *testin... |
package routes
import (
"net/http"
"time"
"github.com/angeldhakal/tv-tracker/handlers"
"github.com/angeldhakal/tv-tracker/middlewares"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
var AllowedOrigins = []string{"http://localhost:3000/"}
var AllowedMethods = []string{"GET", "POST"}
var AllowedHea... |
package main
import (
"encoding/json"
"flag"
"fmt"
"html/template"
"io/ioutil"
"log"
"net/http"
"strings"
)
func main() {
adventure, err := parseJSON()
if err != nil {
panic(err)
}
fs := http.FileServer(http.Dir("static"))
mux := http.NewServeMux()
mux.Handle("/static/", http.StripPrefix("/static/",... |
package main
import (
"fmt"
"github.com/BurntSushi/toml"
)
type Config interface {
Params() interface{}
Validate() error
}
func InitConfig(path string, c Config) error {
if _, err := toml.DecodeFile(path, c.Params()); err != nil {
return err
}
if err := c.Validate(); err != nil {
return err
}
return n... |
package docker
import (
"context"
"fmt"
"io"
"net"
"net/http"
"os"
"path/filepath"
"strconv"
"sync"
"github.com/blang/semver"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config"
cliflags "github.com/docker/cli/cli/flags"
"github.com/docker/distribution/reference"
"github.com/docker/d... |
package alertmanager
import (
"encoding/json"
"net/http"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/alertmanager/notify"
"github.com/prometheus/client_golang/prometheus"
)
// HandleWebhook returns a HandlerFunc that forwards webhooks to all bots via a channel
func Hand... |
/*
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
distributed under the License ... |
package crypto
import (
"golang.org/x/crypto/bcrypt"
)
func CreateHash(hash string) ([]byte, error) {
return bcrypt.GenerateFromPassword([]byte(hash), bcrypt.DefaultCost)
}
func VerifyHash(dbHash string, hash string) error {
return bcrypt.CompareHashAndPassword([]byte(dbHash), []byte(hash))
}
|
package bosh
import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/http/httputil"
"net/url"
"regexp"
"strings"
"sync"
"time"
"github.com/starkandwayne/signalfire/config"
"github.com/starkandwayne/signalfire/log"
)
type Client struct {
client *ht... |
package structs
import (
"time"
)
type Status string
type UpdateType string
type ElementType string
const (
SUCCESS Status = "success"
PENDING Status = "pending"
FAILED Status = "failed"
INCOMPLETE Status = "incomplete"
NEW Status = "new"
ADD UpdateType = "add"
DELETE UpdateType = "delet... |
package main
import (
"flag"
"fmt"
"os"
"github.com/yuanyu90221/link"
)
func main() {
filename := flag.String("file", "ex1.html", "the html file to parse")
flag.Parse()
fmt.Printf("Parse the html file in %s.\n", *filename)
r, err := os.Open(*filename)
if err != nil {
panic(err)
}
links, err := link.Pars... |
package mapping
import (
"fmt"
"github.com/ernoaapa/eliot/pkg/model"
)
var (
labelPrefix = "io.eliot"
podNameLabel = "pod.name"
containerNameLabel = "container.name"
)
// ContainerLabels is helper type for managing container labels
type ContainerLabels map[string]string
func (l ContainerLabels) g... |
package conf
import (
"encoding/json"
"io/ioutil"
"reflect"
"time"
)
// Conf defines server options.
type Conf struct {
API API
Storage Storage
Coordinator Coordinator
Secrets Secrets
Mesos Mesos
Logging Logging
}
// API defines API server options.
type API struct {
Addr stri... |
package main
import (
"flag"
"fmt"
"log"
"net/http"
"net/url"
"strings"
"time"
"github.com/ayushin78/go_mini_projects/html_link_parser"
)
func main() {
var rootlink = flag.String("url", "https://example.com", "path of the url")
flag.Parse()
visitedLinks := make(map[string]bool)
crawl2(*rootlink, visite... |
package gocc
import (
"encoding/xml"
"reflect"
"strings"
"testing"
)
// Example taken from http://www.currentcost.com/cc128/xml.htm
const testRealtimeData = `<msg><src>CC128-v0.11</src><dsb>00089</dsb><time>13:02:39</time><tmpr>18.7</tmpr><sensor>1</sensor><id>01234</id><type>1</type><ch1><watts>00345</watts></ch... |
package webserver
import (
"encoding/json"
"fmt"
"github.com/joostvdg/cmg/cmd/context"
"net/http"
"net/http/httptest"
"testing"
"github.com/joostvdg/cmg/pkg/game"
"github.com/joostvdg/cmg/pkg/webserver/model"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
)
var (
baseApiPath = "/a... |
/*
MIT License
Copyright (c) 2020-2021 Kazuhito Suda
This file is part of NGSI Go
https://github.com/lets-fiware/ngsi-go
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, inc... |
// Copyright 2015 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 println
type ControllerInterface interface {
Init()
Get()
Post()
}
|
// Copyright 2018-present The Yumcoder Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Author: yumcoder (omid.jn@gmail.com)
//
package tl
import (
"fmt"
"testing"
)
func Test_TLConstructorCrc32ToHexadecimal(t *testing.T) {
... |
package http
import (
"WarpCloud/walm/pkg/k8s"
"WarpCloud/walm/pkg/models/http"
k8sModel "WarpCloud/walm/pkg/models/k8s"
"WarpCloud/walm/pkg/setting"
httpUtils "WarpCloud/walm/pkg/util/http"
errorModel "WarpCloud/walm/pkg/models/error"
"fmt"
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful-ope... |
package image
import (
"fmt"
"net/http"
"github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta1"
"github.com/longhorn/longhorn-manager/types"
ctlcorev1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
v1 "github.com/rancher/wrangler/pkg/generated/controllers/storage/v1"
corev1 "k8s.i... |
// Copyright 2020 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/li... |
// Copyright 2019-2020 go-gtp authors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
package main
import (
"errors"
"log"
"net"
"strings"
v2 "github.com/wmnsk/go-gtp/v2"
"github.com/wmnsk/go-gtp/v2/ies"
"github.com/wmnsk/go-gtp/v2/... |
// Smartling SDK v2 Auth Test Example.
//
// Example shows usage of Smartling authentication API
// https://help.smartling.com/v1.0/reference#authentication-1
//
// This example does nothing except the authentication call.
// Useful for testing your user identifier / token.
//
// `UserID` and `TokenSecret` should be sp... |
package connections
import (
"strconv"
"github.com/gin-gonic/gin"
"github.com/w-zengtao/socket-server/api/admin/managers"
"github.com/w-zengtao/socket-server/sockets"
)
/*
按照我们的实际情况来看、这个地方需要先存在有 Manager
所以最终路由应该如右侧: DELETE /managers/:manager_id/connections/:id
*/
func loadConnection(c *gin.Context) *sockets.Clie... |
package main
import (
"context"
_ "github.com/asim/go-micro/plugins/client/grpc/v4"
_ "github.com/asim/go-micro/plugins/registry/etcd/v4"
pb "github.com/xpunch/go-micro-example/v4/helloworld/proto"
"go-micro.dev/v4"
"go-micro.dev/v4/logger"
)
func main() {
srv := micro.NewService(
micro.Name("helloworld.cli... |
package manager
import (
"github.com/Diode222/etcd_service_discovery/etcdservice"
"sync"
)
var serviceManager *etcdservice.ServiceManager
var serviceMangerOnce sync.Once
func ServiceMangerInstance(etcdAddr string) *etcdservice.ServiceManager {
serviceMangerOnce.Do(func() {
serviceManager = etcdservice.NewServic... |
package raws // import "github.com/BenLubar/dfide/gui/raws"
import (
"bytes"
"strings"
"golang.org/x/text/encoding/charmap"
"github.com/BenLubar/dfide/gui/file"
"github.com/BenLubar/dfide/raws"
)
var cp437Dec = charmap.CodePage437.NewDecoder()
func OpenFile(f *file.File) {
contents, err := cp437Dec.Bytes(f.C... |
// 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 meta
import (
"context"
"os"
"strings"
"syscall"
"github.com/shirou/gopsutil/v3/process"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing... |
package main
import "fmt"
func main() {
var name = "Firli"
var name1 = "Firli"
fmt.Println(name == name1)
var value1 = 200
var value2 = 400
fmt.Println(value1 == value2)
fmt.Println(value1 < value2)
fmt.Println(value1 > value2)
fmt.Println(value1 != value2)
}
|
package message
import (
"errors"
"time"
)
// Message ...
type Message struct {
ID int64 `json:"message_id,string"`
Chat int64 `json:"chat,string"`
Author int64 `json:"author,string"`
Text string
CreatedAt time.Time
}
type Messages interface {
Find(chatID int64) ([]*Message, error)
Creat... |
package main
import "fmt"
func system() int {
fmt.Println("system started...")
defer func(msg string) {
if r := recover(); r != nil {
fmt.Println("recovered")
}
fmt.Println(msg)
}("blah")
var data []int
var x = data[0] //causes runtime panic, accessing an empty array
//the deferred function above wil... |
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"time"
"github.com/cnf/structhash"
)
// Maintains a chain of blocks, as well as
// the list of current transactions
type blockchain struct {
chain []block
currentTransactions []transaction
}
// Create a new Block in the Blockchain
// :p... |
/*
Copyright 2020 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 docker
import (
"io"
"github.com/moby/buildkit/session/filesync"
)
type BuildOptions struct {
Context io.Reader
Dockerfile string
Remove bool
BuildArgs map[string]*string
Target string
SSHSpecs []string
SecretSpecs []string
Networ... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
)
// UpdateTabForCourse Home and Settings tabs are not manageable, and can't be hidden or moved
//
// Returns a ... |
// 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 ezgobot
import (
"bufio"
"fmt"
"io"
"regexp"
"strings"
)
type transitionMapping struct {
inputMatch *regexp.Regexp
transition string
}
// State defines a node in the state machine representing a conversation.
type State struct {
id string
transitions map[string]*Stat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.