text stringlengths 11 4.05M |
|---|
/*
Copyright 2021 The KubeVela 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, softw... |
package util
import (
"os"
"os/signal"
"sync"
"syscall"
)
var (
quit chan os.Signal
shutdownOnce sync.Once
)
func NewShutdownListener() chan os.Signal {
shutdownOnce.Do(func() {
quit = make(chan os.Signal)
// pipe sigint and sigterm to quit channel
signal.Notify(quit, syscall.SIGINT, syscall.SIG... |
package inmemoryrepo
import "backend/internal/domain"
type playerRepository struct {
players map[domain.PlayerId]*domain.Player
}
func NewPlayerRepository() domain.PlayerRepository {
return &playerRepository{
players: map[domain.PlayerId]*domain.Player{},
}
}
func (r *playerRepository) Save(player *domain.Play... |
package handler
import (
"context"
"errors"
"path/filepath"
"testing"
"time"
"github.com/golang/protobuf/ptypes"
jinmuidpb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1"
generalpb "github.com/jinmukeji/proto/v3/gen/micro/idl/ptypes/v2"
"github.com/stretchr/testify/assert"
"github.com/str... |
package main
func main() {
}
func numTilings(n int) int {
mod := int(1e9 + 7)
switch n {
case 0:
return 0
case 1:
return 1
case 2:
return 2
}
dp := make([]int, n+1)
dp[0] = 1
dp[1] = numTilings(1)
dp[2] = numTilings(2)
for i := 3; i <= n; i++ {
dp[i] = (dp[i-1] + dp[i-2] + dp[0]*2) % mod
dp[... |
// Copyright 2021 MarkMonitor Technologies, 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 a... |
package models
type RankData struct {
Rank string `json:"rank"`
Url string `json:"url"`
}
|
// Copyright 2021 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package driver
import (
"fmt"
"testing"
"time"
"github.com/clivern/peanut/core/util"
"github.com/clivern/peanut/pkg"
"github.com/franela/goblin"
"github.com/spf1... |
package etcd
import (
"context"
"encoding/json"
"fmt"
"github.com/coreos/etcd/clientv3"
//"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
. "grm-searcher/types"
. "grm-service/dbcentral/etcd"
"grm-service/log"
"grm-service/util"
)
type DynamicDB struct {
DynamicEtcd
}
func (e DynamicDB) DeleteUserH... |
package lua
/*
#include "glua.h"
#include <stdlib.h>
#cgo linux LDFLAGS: -lm
*/
import "C"
import "unsafe"
import "sync"
import "fmt"
import "reflect"
type State struct {
S *C.lua_State
Lock *sync.Mutex
}
type GoFun func(*State) int
type Gofun_ struct {
T uintptr
F uintptr
}
type LuaState *C.lua_State
var ... |
package gotten
import "net/http"
type (
Client interface {
Do(r *http.Request) (*http.Response, error)
}
)
|
// The orbits program calculates the orbital speed of the International Space
// Station, the Hubble Space Telescope, the Astra 1KR TV broadcast satellite and
// a GPS satellite.
//
// This program is incomplete. You need to finish it before it will run.
//
// Important numbers you will need in the program
//
// The ra... |
package cmd
import (
"errors"
"fmt"
"github.com/juliabiro/expander/pkg/utils"
"github.com/spf13/cobra"
"os"
)
var configfile string
var configEnvvar string
func ParseInput(args []string) ([]string, error) {
configEnvVar := os.Getenv("EXPANDER_CONF")
if configEnvVar != "" {
configfile = configEnvVar
}
if... |
package main
import (
"encoding/json"
"io/ioutil"
"fmt"
"github.com/golang/protobuf/proto"
"gopkg.in/yaml.v2"
"github.com/xuperdata/teesdk/paillier"
"github.com/xuperdata/teesdk/paillier/xchain_plugin/pb"
)
var (
client *paillier.PaillierClient
pconfig *paillier.PaillierConfig
)
func loadConfigFile(confi... |
package fishy
import (
"errors"
"fmt"
"github.com/getcouragenow/core-bs/sdk/pkg/common/osutil"
rh "github.com/hashicorp/go-retryablehttp"
log "github.com/sirupsen/logrus"
"io"
"io/ioutil"
"os"
"strings"
"time"
)
func (g *GoFishInstallation) getArch() string {
platform := g.Platform
if strings.Contains(pla... |
// Copyright 2020 PingCAP, 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 i... |
package timeutil
import (
"time"
)
//time to string
func TimeToString(t time.Time) string {
return t.Format("2006-01-02 15:04:05")
}
//time to string
func TimeFromString(str string) (time.Time, error) {
return time.ParseInLocation("2006-01-02 15:04:05", str, time.Local)
}
func NowString() string {
return time.N... |
// Copyright (C) 2019 Cisco Systems 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 agr... |
package main
import (
"context"
b64 "encoding/base64"
"flag"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
"github.com/ckin-it/minedive/minedive"
"github.com/go-redis/redis"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"nhooyr.io/websocket/wsjson"
)
var s minedive.MinediveServer
var rdb *redis... |
package main
import (
"fmt"
"reflect"
)
func reflectNum(arg interface{}) {
fmt.Println("type : ", reflect.TypeOf(arg))
fmt.Println("value : ", reflect.ValueOf(arg))
}
func main() {
var num float64 = 1.2345
reflectNum(num)
}
|
/*
Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient.
If there is no solution for the equation, return "No solution".
If there are infinite solutions for the equation, return "Infinite solutions".
If t... |
package connect
import (
"fmt"
"github.com/micro/go-micro/v2/config"
"github.com/micro/go-micro/v2/config/encoder/yaml"
"github.com/micro/go-micro/v2/config/source"
"github.com/micro/go-plugins/config/source/consul/v2"
"github.com/sirupsen/logrus"
"os"
"path/filepath"
"sync"
)
var configs *configMap
type co... |
package checkpoints_test
import (
"context"
"database/sql"
"encoding/json"
"strings"
"testing"
"time"
"github.com/DATA-DOG/go-sqlmock"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/lightning/checkpoints"
"github.com/pingcap/tidb/br/pkg/lightning/mydump"
"github.com/pingcap/tidb/br/pkg/lightni... |
package user
import (
"context"
"github.com/thoohv5/template/internal/enum"
"github.com/thoohv5/template/internal/service/user/entity"
)
// IService 业务标准
type IService interface {
// Create 创建
Create(ctx context.Context, accountType enum.AccountType, identity string, extra string) (userIdentity string, err erro... |
package converter
import (
"fmt"
"github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/convert"
"github.com/zclconf/go-cty/cty/gocty"
)
func FromCtyValueToGoValue(ctyVal cty.Value) (interface{}, error) {
switch ctyVal.Type() {
case cty.Number:
var goVal int
err := gocty.FromCtyValue(ctyVal, &goVal... |
// Copyright (C) 2019 Cisco Systems 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 agr... |
package main
import . "./broker"
func main(){
server := Server{}
server.CreateServer(":8082")
server.Init()
}
|
/*
Copyright 2017 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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 ... |
// Copyright 2020 Adam Chalkley
//
// https://github.com/atc0005/go-lockss
//
// Licensed under the MIT License. See LICENSE file in the project root for
// full license information.
// Package portchecks provides types and functions used by this application to
// check access to one or more remote ports.
package port... |
package beacon_test
import (
beacon "."
"reflect"
"testing"
)
func TestEventCopy(t *testing.T) {
event := &beacon.Event{
Action: beacon.Start,
Container: &beacon.Container{
ID: "123456",
Service: "example",
Labels: map[string]string{
"a": "aye",
"b": "bee",
},
Bindings: []*beacon.B... |
/*
Task: Output the Swiss flag.
Happy Swiss National Day / Schweizer Bundesfeiertag / Fête nationale suisse / Festa nazionale svizzera / Fiasta naziunala svizra!
Details: The flag consists of a white (#FFFFFF) cross on a red (#FF0000) background. The cross consists of a 6x6 square with arms of size 6x7 glued to each... |
package lambdacalculus
// Flip flips the order in which parameters are passed to a function
var Flip = func(f interface{}) xl {
return func(x interface{}) Lambda {
return func(y interface{}) interface{} {
switch f := f.(type) {
case func(n ChurchNumber) nxl:
xChurch := x.(ChurchNumber)
yChurch := y.(C... |
// Copyright (c) 2015-2017 Marcus Rohrmoser, http://purl.mro.name/recorder
//
// 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 t... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/12/14 9:37 上午
# @File : lt_20_有序的括号.go
# @Description :
# @Attention :
*/
package hot100
// 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。
// 关键: 用栈处理
func isValid(s string) bool {
stack := make([]byte, 0)
for i := 0; i < len(s); i++ {
v := s[i]
if ... |
package main
import (
"bufio"
"fmt"
"io"
"net"
"os"
)
const Port = ":8085"
func main() {
conn, err := net.Dial("tcp", Port)
if err != nil {
panic(err)
}
defer conn.Close()
for {
userInput(conn)
checkResponse(conn)
}
}
func userInput(conn net.Conn) {
fmt.Print(">>")
userInput, err := bufio.NewRead... |
package errors
import (
"fmt"
"net/http"
"net/url"
)
type (
// Error interface
Error interface {
error
GetCode() int
GetTitle() string
GetDetail() interface{}
}
// Error struct
err struct {
Code int `json:"code"`
Title string `json:"title"`
Detail interface{} `json:"detail,omitem... |
package gortex
import (
"fmt"
"math"
"math/rand"
"os"
"testing"
"time"
)
func TestCharRnnVae(t *testing.T) {
words := true
delim := ""
// maintain random seed
rand.Seed(time.Now().UnixNano())
trainFile := "top.txt"
modelName := "CharRnnVAE"
if words {
modelName = "WordRnnVAE"
delim = " "
}
dic, e ... |
package main
import (
"fmt"
"strconv"
"strings"
"github.com/jnewmano/advent2020/input"
"github.com/jnewmano/advent2020/output"
)
func main() {
sum := parta()
fmt.Println(sum)
}
func parta() interface{} {
// input.SetRaw(raw)
// var things = input.Load()
// var things = input.LoadSliceSliceString("")
var... |
package discountsrv_test
import (
"testing"
"github.com/amanbolat/furutsu/internal/cart"
"github.com/amanbolat/furutsu/internal/discount"
"github.com/amanbolat/furutsu/internal/product"
"github.com/amanbolat/furutsu/services/discountsrv"
"github.com/stretchr/testify/assert"
)
func TestApplyDiscountsToCart(t *t... |
package user
import (
"context"
"errors"
uuid "github.com/nu7hatch/gouuid"
pb "github.com/u03013112/ss-pb/user"
)
// Srv :服务
type Srv struct{}
// Login :
func (s *Srv) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginReply, error) {
id, err := auth(in.Username, in.Passwd)
if err != nil {
return &pb... |
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in w... |
package data
import (
"github.com/ismayilmalik/avengers-api/models"
"github.com/ismayilmalik/avengers-api/common"
)
type UserRepository struct {
}
func (repo *UserRepository) Create(user models.User) error {
queryString := "INSERT INTO avengers.users(Name, Login, Password) values(?, ?, ?, ?);"
stmt, err := comm... |
package utils
import (
"fmt"
"testing"
)
func Test_MakeRandomStrSize(t *testing.T) {
data := MakeRandomStrSize(10)
fmt.Println("data:", data)
}
func Test_random(t *testing.T) {
data := random(10)
fmt.Println("data:", data)
}
func Test_NewUUID(t *testing.T) {
data, err := NewUUID()
if err != nil {
t.Error(... |
// +build e2e
package e2e
import (
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/test/e2e/fi... |
package gogen
import "go/ast"
// File encapsulates the physical File and it's ast
type File struct {
name string // name of the file
parent *ast.File
// imports
imports map[string]*Import
// types
structures map[string]*Structure
interfaces map[string]*Interface
functions map[string]*Function
constants ... |
package model
import "github.com/jinzhu/gorm"
type Data struct {
gorm.Model
Token string `redis:"token" json:"token" gorm:"column:token"`
Payload string `redis:"payload" json:"payload" gorm:"column:payload"`
}
|
package main
import (
"bufio"
"context"
"flag"
"fmt"
"log"
"net"
"os"
"sync"
"time"
)
func readRoutine(ctx context.Context, conn net.Conn) {
scanner := bufio.NewScanner(conn)
OUTER:
for {
select {
case <-ctx.Done():
break OUTER
default:
if !scanner.Scan() { // scan waites
log.Printf("unable... |
package main
import (
"encoding/csv"
"flag"
"fmt"
"math/rand"
"net/http"
//"net/http"
"os"
"strings"
"sync"
"time"
)
var file string
func init() {
// init random generator
rand.Seed(time.Now().UnixNano())
// read Flags
flag.StringVar(&file, "file", "urls.csv", "CSV file with URLs")
flag.Parse()
}
t... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Book struct {
Title string
Author string
}
func main() {
// Single struct object
book := Book{Title: "Harry Potter", Author: "J.K. Rowling"}
b, _ := json.Marshal(book)
err := ioutil.WriteFile("demo.json", b, 0644)
CheckError(err)
fileData, e... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package models
import (
"regexp"
"strings"
"time"
"github.com/ymomoi/goval-parser/oval"
)
var cveIDPattern = regexp.MustCompile(`(CVE-\d{4}-\d{4,})`)
// ConvertRedHatToModel Convert OVAL to models
func ConvertRedHatToModel(root *oval.Root) (defs []Definition) {
for _, d := range root.Definitions.Definitions {
... |
package main
import (
"github.com/akamai/cli-common-golang"
"github.com/bbucko/cli-iec/common"
"github.com/urfave/cli"
"log"
"time"
)
var commandConfigure = cli.Command{
Name: "configure",
ArgsUsage: "",
Description: "",
HideHelp: true,
Action: callConfigure,
Flags: []cli.Flag{
cli.Strin... |
package service
import (
"github.com/SungKing/blogsystem/models/entity"
"github.com/SungKing/blogsystem/models/dao"
"time"
)
type BlogService struct {
}
var blogDao = new(dao.BlogDao)
func (*BlogService) InsertBlog(blog entity.Blog) int64{
blog.Category = 1
blog.CreateTime = time.Now().Local()
blog.UpdateTime... |
package primitives
import (
"github.com/go-gl/gl/v4.1-core/gl"
)
type Drawer interface {
Draw(int, int)
RotateZ(float32)
Translate(Vec3)
RotateBy(float32)
MoveTo(Vec3)
}
type DrawPrimitive struct {
anchor Vec3
flat []float32
vbo uint32
vao uint32
dirty bool
}
func (dp *DrawPrimitive) syncVbo()... |
package web
import (
"fmt"
"os"
"golang.org/x/net/html"
)
var depth int
func PrintFromFile(filePath string) error {
file, err := os.Open(filePath)
if err != nil {
return err
}
doc, err := html.Parse(file)
if err != nil {
return err
}
VisitHtmlDoc(doc, startElement, endElement)
return nil
}
func Pr... |
package goSolution
import "testing"
func TestCheckPossibility(t *testing.T) {
nums := []int {4, 2, 1}
AssertEqual(t, false, checkPossibility(nums))
}
|
package webserver
import (
"context"
"net/http"
"github.com/go-chi/chi"
"github.com/mec07/rununtil"
"github.com/rs/zerolog/log"
)
// NewRunner returns a function that runs the http webserver
func NewRunner() rununtil.RunnerFunc {
return func() rununtil.ShutdownFunc {
r := chi.NewRouter()
r.Get("/ping", pin... |
package main
import "fmt"
func main() {
students := [...]string{"Yudistiro", "Wahyu", "Aldary"}
for _, student := range students { //kenapa dikosongin "_" karena nampung variable yang ga kepake
fmt.Println(student)
}
}
|
package timeout
import "time"
const (
timeoutErrorString = "withtimeout: Operation timed out"
)
type timeoutError struct{}
func (timeoutError) Error() string {
return timeoutErrorString
}
func Do(timeout time.Duration, fn func() (interface{}, error)) (result interface{}, timedOut bool, err error) {
resultCh := ... |
package config
import (
"encoding/json"
"github.com/imrenagi/go-payment"
)
// NewNonCardPayment returns new NonCardPayment. if value is not nil, the admin fee of this payment method
// can be calculated.
func NewNonCardPayment(cfg NonCard, value *payment.Money) *NonCardPayment {
return &NonCardPayment{
NonCard:... |
package queue
import (
"errors"
)
var (
ErrQueueEmpty = errors.New("queue empty")
ErrQueueFull = errors.New("queue full")
)
type queueItem interface {}
type queue struct {
list []queueItem
size uint64
}
type Queuer interface {
Dequeue() (queueItem, error)
Enqueue(i queueItem) error
... |
package main
// This program demonstrats how to set CAP_FOWNER as ambient capability for
// calling the `setfacl` program to set file ACL even the user running this
// program is neither root nor the owner of the file.
//
// The authorisation of setfacl is then "taken over" by the logic of this program.
//
// ```
// ... |
package sqlreport
import (
"bytes"
"context"
"fmt"
"sync"
"time"
"github.com/xackery/log"
"database/sql"
//used for database connection
_ "github.com/go-sql-driver/mysql"
"github.com/pkg/errors"
"github.com/xackery/talkeq/config"
"github.com/xackery/talkeq/discord"
)
// SQLReport represents a sqlreport... |
package controller
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/nicobianchetti/Go-CleanArchitecture/cache"
"github.com/nicobianchetti/Go-CleanArchitecture/model"
"github.com/nicobianchetti/Go-CleanArchitecture/repository"
"github.com/nicobianchetti/Go-Cle... |
package funcs
import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/elves-project/agent/src/g"
"github.com/elves-project/agent/src/thrift/apache-thrift"
"github.com/elves-project/agent/src/thrift/app"
"github.com/elves-project/agent/src/thrift/scheduler"
"github.com/gy-games-libs/file"
"github.com/gy-g... |
package http
import (
"git.dustess.com/mk-base/gin-ext/extend"
"git.dustess.com/mk-training/mk-blog-svc/pkg/blog/model"
"git.dustess.com/mk-training/mk-blog-svc/pkg/blog/service"
"git.dustess.com/mk-training/mk-blog-svc/pkg/common"
"github.com/gin-gonic/gin"
)
// BlogDetail 博客详情
// @Summary 博客详情
// @Description ... |
/**
* Copyright (c) 2018 ZTE Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and the Apache License 2.0 which both accompany this distribution,
* and are available at http://www.eclipse.org/legal/epl-v10.html
... |
package main
import (
"fmt"
)
func main() {
a := [2]string{"hallo", "world"}
fmt.Println(a)
fmt.Println("%s\n", a)
fmt.Println("%q\n", a)
}
|
// SPDX-License-Identifier: MIT
// Copyright (c) 2019 Stephan Gerhold
package hls
import (
"errors"
"log"
"sync"
"time"
)
type stream struct {
d *Dumper
name string
playlist playlist
output output
}
type Dumper struct {
URL string
Name string
SingleFile bool
Verbose bool
Hea... |
package router
import (
"github.com/gin-gonic/gin"
"github.com/liuhongdi/digv01/controller"
)
func Router() *gin.Engine {
router := gin.Default()
// 路径映射
/*
//router.GET("/user", InitPage)
router.POST("/user/create", CreateUser)
//router.GET("/user/create", CreateUser)
router.GET("/user/list", ListUser)
... |
package kpatch
import (
"encoding/base64"
"fmt"
"reflect"
"github.com/ansel1/merry"
"github.com/mikesimons/traverser"
yaml "gopkg.in/yaml.v2"
)
type kpatch struct {
targets []tTarget
missingKeyMode string
drop bool
doc map[interface{}]interface{}
currentItem interface{}
}
f... |
package models
type ServiceInstance struct {
Name string
Guid string
SpaceGuid string
}
type ServiceKey struct {
ServiceInstanceGuid string
Uri string
DbName string
Hostname string
Port string
Username string
Password str... |
package firewall
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/require"
)
var data = `0: 3
1: 2
4: 4
6: 4
`
func TestSeverity(t *testing.T) {
assert := require.New(t)
assert.Equal(24, Severity(data))
}
func TestSolveSeverity(t *testing.T) {
assert := require.New(t)
in, _ := ioutil.ReadFile("./... |
/*
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"
const (
ol = 10
il = 5
)
func main() {
//loopIntro()
//nestingLoops()
//simpleFor()
//eternalLoop()
breakContinue()
}
func loopIntro() {
// Loops follow an init; condition; post {} structure
// Loop to count from 0 to 100
for i := 0; i <= ol; i++ {
fmt.Println(i)
}
}
func ne... |
package plugins
import (
"io"
"net/url"
"os"
"path"
"strings"
)
type FrontendPluginBase struct {
PluginBase
}
func (fp *FrontendPluginBase) initFrontendPlugin() {
fp.IsExternal = isExternalPlugin(fp.PluginDir)
fp.handleModuleDefaults()
for i := 0; i < len(fp.Info.Screenshots); i++ {
fp.Info.Screenshots[i... |
package utils
import "time"
type ExtendedTimeRange struct {
base TimeRange
}
func (extendedTimeRange ExtendedTimeRange) Start() time.Time {
return extendedTimeRange.base.Start()
}
func (extendedTimeRange ExtendedTimeRange) End() time.Time {
return extendedTimeRange.base.End()
}
func ExtendTimeRange(base TimeRan... |
package checker
import (
"context"
"strings"
"testing"
"github.com/lithammer/dedent"
"github.com/openllb/hlb/builtin"
"github.com/openllb/hlb/diagnostic"
"github.com/openllb/hlb/errdefs"
"github.com/openllb/hlb/parser"
"github.com/stretchr/testify/require"
)
type testCase struct {
name string
input strin... |
package pathfileops
import (
"os"
"strings"
"testing"
)
func TestDirMgr_GetAbsolutePath_01(t *testing.T) {
sourceDir := "../filesfortest/levelfilesfortest"
sourceDMgr, err := DirMgr{}.New(sourceDir)
if err != nil {
t.Errorf("Test Setup Error returned by DirMgr{}.New(sourceDir).\n"+
"sourceDir... |
package controllers
import (
"context"
"testing"
"time"
autoscalingv1alpha1 "github.com/containers-ai/alameda/operator/api/v1alpha1"
"github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
... |
package models
import (
"database/sql"
"fmt"
"log"
"os"
"github.com/joho/godotenv"
)
var db *sql.DB
func dbConfig() map[string]string {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
conf := make(map[string]string)
host := os.Getenv("DBHOST")
if len(host) == 0 {
panic("... |
package main
import (
"errors"
"flag"
"os"
"github.com/nextdns/nextdns/config"
)
func cfg(args []string) error {
fs := flag.NewFlagSet(args[0], flag.ExitOnError)
args = args[1:]
configFile := fs.String("config-file", config.DefaultConfPath(), "Path to configuration file.")
_ = fs.Parse(args)
subCmd := "list... |
// hello signup!
/*
auth-basic
*/
// HOFSTADTER_BELOW
|
package basichost
import (
"context"
"sync"
ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr"
goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
lgbl "gx/ipfs/QmU7CkhdputERjy5QQr4kEUsKWzQPmkw3DZEMWxeShu6QR/go-libp2p-loggables"
inat "gx/ipfs/QmXFPLTyWRrWp4zkNrD5S3... |
package valexa
import (
"reflect"
"fmt"
)
//ForMethod 遍历方法
// x interface{} 类型
// string 字符串
func ForMethod(x interface{}) string {
var t = reflect.TypeOf(x)
var s string
for i:=0; i<t.NumMethod(); i++ {
tm := t.Method(i)
s += fmt.Sprintf("%d %s %s\t\t= %v \n", tm.I... |
package event
import (
"testing"
)
func TestOn(t *testing.T) {
var dispatcher = NewDispatcher()
var foo = 10
var callback = func(event *Event) {
foo ++
}
dispatcher.On("foo", (*Listener)(&callback))
var event = NewEvent("foo", nil)
dispatcher.Fire(event)
if foo != 11 {
t.Errorf("The Listener is n... |
// Copyright (c) 2016 Huawei Technologies Co., Ltd. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
... |
package log
import "testing"
func TestOriginalError(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
{"base-case", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := OriginalError(); (err != nil) != tt.wantErr {
t.Errorf("OriginalError() error = %v, ... |
package handle
import (
"bytes"
"context"
"net/http"
"cloud.google.com/go/pubsub"
)
//LogAPI is rest api handler for stream log
type LogAPI struct {
Topic *pubsub.Topic
Context context.Context
Cancle context.CancelFunc
CancleCondition func(r *http.Request) bool
}
func (l LogAPI) S... |
package handlers
import (
"bytes"
"errors"
"fmt"
"io"
"net/http"
"strconv"
"testing"
"github.com/stretchr/testify/require"
"github.com/root-gg/plik/server/common"
"github.com/root-gg/plik/server/context"
data_test "github.com/root-gg/plik/server/data/testing"
)
func createTestFile(ctx *context.Context, ... |
package main
import (
"fmt"
"os"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis"
)
func listStreams(svc *kinesis.Kinesis) error {
rsp, err := svc.ListStreams(&kinesis.ListStreamsInput{})
if err != nil {
return err
}
for _, s := r... |
package server
import (
"fmt"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/tzilist/m-service/config"
"github.com/tzilist/m-service/pkg/router"
"github.com/tzilist/m-service/pkg/util/validator"
)
type (
// Hook hook for before and after creating the server struct
Hook fun... |
package basic
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func resourceTestSchemaOrdering() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"vpc_id": {
Description: "",
Default: "",
Optional: true,
Computed: true,
Elem: &schema.Resource{... |
package basecmds
import (
"fmt"
"time"
"github.com/Nv7-Github/Nv7Haven/eod/types"
"github.com/Nv7-Github/Nv7Haven/eod/util"
"github.com/bwmarrin/discordgo"
)
func (b *BaseCmds) StatsCmd(m types.Msg, rsp types.Rsp) {
rsp.Acknowledge()
b.lock.RLock()
dat, exists := b.dat[m.GuildID]
b.lock.RUnlock()
if !exis... |
package model
import (
"reflect"
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/jinzhu/gorm"
)
func TestDomain_FindBy(t *testing.T) {
type fields struct {
db *gorm.DB
}
type args struct {
params map[string]interface{}
}
tests := []struct {
name string
domainRows *sqlmock.Rows
recordR... |
package server
import (
"github.com/googollee/go-socket.io"
"github.com/gophergala2016/Pomodoro_Crew/session"
"log"
"github.com/gophergala2016/Pomodoro_Crew/models"
"time"
"github.com/google/cayley"
"strconv"
)
const (
RoomName = "common"
)
type SocketServer struct {
*socketio.Server
session *session.Sessio... |
package database
import (
"testing"
"github.com/codenotary/immudb/embedded/store"
"github.com/codenotary/immudb/pkg/api/schema"
"github.com/stretchr/testify/require"
)
func TestStoreScan(t *testing.T) {
db, closer := makeDb()
defer closer()
db.Set(&schema.SetRequest{KVs: []*schema.KeyValue{{Key: []byte(`aaa`... |
package main
import (
"react-redux-todo/backend/app"
)
func main() {
app.Run(":5000")
}
|
package util
import (
api "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"testing"
)
var podNamespace = []string{
"testns1",
"testns2",
"testns3",
"testns4",
"testns5",
"testns6",
"testns7",
"testns8",
}
var podName = []string{
"testpod1",
"testpod2",
... |
package integration_test
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"sync"
"testing"
"github.com/microsoft/azure-databricks-operator/mockapi/router"
"github.com/stretchr/testify/assert"
azure "github.com/xinsnake/databricks-sdk-golang/azure"
dbmodel "github.com/xinsna... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.