text stringlengths 11 4.05M |
|---|
package script
import (
E "github.com/ionous/sashimi/event"
G "github.com/ionous/sashimi/game"
S "github.com/ionous/sashimi/source"
)
// statement to declare an default action handler
func To(action string, c G.Callback) IFragment {
source := NewOrigin(2)
return NewFunctionFragment(func(b SubjectBlock) error {
... |
package main
import (
"errors"
"fmt"
"strings"
)
type Identifiable interface {
ID() string
}
type Person struct {
firstName string
lastName string
twitterHandler string
}
func NewPerson(firstName, lastName string) Person {
return Person{
firstName: firstName,
lastName: lastName,
}
}
func (... |
package main
import (
"fmt"
"strings"
//"runtime"
//"mathoperator"
"math"
"io"
)
type Vertex struct {
lat, lon float64
}
type MyFloat64 float64
func main() {
//fmt.Println("My favorite number is", rand.Intn(10))
//
//fmt.Println(add(42, 13))
//fmt.Println(add(2))
//
//fmt.Print("Go runs on ")
//switc... |
package fastjob_test
import (
"context"
"time"
"cloud.google.com/go/pubsub"
"github.com/pior/fastjob"
)
func ExampleNewPubsubWorker() {
ctx := context.Background()
client, err := pubsub.NewClient(ctx, "my-gcp-project-id")
if err != nil {
// TODO: Handle error.
}
sub := client.Subscription("subscription-... |
package management
import (
"github.com/caos/logging"
"github.com/golang/protobuf/ptypes"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/policy/model"
"github.com/caos/zitadel/pkg/grpc/management"
)
func passwordAgePolicyFromModel(policy *model.PasswordAgePolicy) *managem... |
package constant
const (
MEMBERS_JSON = "MEMBERS:JSON:"
EXPIRE_TIME = 7200
)
|
package person_infrastructure
import (
"net/http"
person_application "github.com/MeliCGS/go-project-api-arq-hexa/api/person/application"
person_domain "github.com/MeliCGS/go-project-api-arq-hexa/api/person/domain"
"github.com/gin-gonic/gin"
)
type PersonAddController struct {
PeopleAdd *person_application.Peopl... |
// Copyright 2023 The gVisor 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 agree... |
package app
import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"reflect"
"shpong/gomatrix"
"strings"
"time"
matrix_db "shpong/db/matrix/gen"
"github.com/Jeffail/gabs/v2"
"github.com/jackc/pgx/v5/pgtype"
)
type NewPostBody struct {
RoomID string `json:"room_id"`
Content interfa... |
package main
import "fmt"
func main () {
a := "późno"
b := 10
c := 4.30
d := false
fmt.Printf("%T \n", a)
fmt.Printf("%T \n", b)
fmt.Printf("%T \n", c)
fmt.Printf("%T \n", d)
}
|
package countluck
// https://www.hackerrank.com/challenges/count-luck
type here struct {
row int
col int
}
func lookAround(forest [][]rune, at here) []here {
deltas := [][]int{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}
ways := make([]here, 0)
for _, delta := range deltas {
dr := at.row + delta[0]
dc := at.col + delt... |
package main
import (
"net"
log "github.com/sirupsen/logrus"
//"gitlab.com/sdce/service/currency/pkg/config"
"gitlab.com/sdce/service/currency/pkg/rpc"
pb "gitlab.com/sdce/protogo"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
mgo "gitlab.com/sdce/exlib/mongo"
"gitlab.com/sdce/service/cur... |
// Copyright (c) 2018 The MATRIX Authors
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php
package blkreward
import (
"github.com/MatrixAINetwork/go-matrix/common"
"github.com/MatrixAINetwork/go-matrix/core/matrixstate"
"github.... |
package main
import (
"flag"
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/G-Node/gin-repo/internal/testbed"
"github.com/G-Node/gin-repo/store"
)
var server *Server
func TestMain(m *testing.M) {
flag.Parse()
repoDir, err := testbed.MkData("/tmp")
if err != nil {
fmt.Fprintf(os... |
/*
Copyright 2014 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
Unless required by applicable la... |
package _4Sum
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test4Sum(t *testing.T) {
ast := assert.New(t)
ast.EqualValues([][]int{
{-2, -1, 1, 2}, {-2, 0, 0, 2}, {-1, 0, 0, 1}},
fourSum([]int{1, 0, -1, 0, -2, 2}, 0))
ast.EqualValues([][]int{
[]int{-4, 1, 4, 4}, []int{-2, 0, 3, 4}, []int... |
package graphs_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestGraphs(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Graphs Suite")
}
|
package main
import (
"flag"
"fmt"
"github.com/futurehomeno/fimpgo"
"github.com/futurehomeno/fimpgo/discovery"
"github.com/futurehomeno/fimpgo/edgeapp"
log "github.com/sirupsen/logrus"
"github.com/thingsplex/thingsplex_service_template/model"
"github.com/thingsplex/thingsplex_service_template/router"
"time"
)... |
package services
import (
"github.com/jinzhu/gorm"
"github.com/MetalRex101/auth-server/app/models"
"strings"
"github.com/labstack/echo"
"strconv"
"time"
)
type UserMerger struct {
DB *gorm.DB
um IUserManager
}
func NewUserMerger (db *gorm.DB, um *UserManager) IUserMerger {
return &UserMerger{db, um}
}
type... |
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you ... |
package main
import (
"gopkg.in/jarcoal/httpmock.v1"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
)
var testLoginData = `{"login":"test", "password":"test"}`
func before(t *testing.T) {
// Mock response from token storage
httpmock.Activate()
httpmock.RegisterResponder(http.MethodPut, settings.Tok... |
package main
import "fmt"
type adder interface {
add(string) int
}
type handler func(name string) int
func (h handler) add(name string) int {
return h(name) + 10
}
func doubler(name string) int {
return len(name) * 2
}
// func tester(name int) int{
// return name * 2
// }
//非函数类型
type my... |
package lrhook
import (
"bytes"
"io"
"os"
"strings"
"sync"
"testing"
"time"
"github.com/multiplay/go-slack/chat"
"github.com/multiplay/go-slack/test"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
// sbuf is a minimal locked bytes.Buffer so its thread safe.
type sbuf struct {
mtx sy... |
package keeper_test
import (
"fmt"
"math/big"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtyp... |
package go_sql_hook
import "database/sql/driver"
type TxHooks struct {
CommitHook
RollbackHook
}
type tx struct {
TxHooks
}
func newTx(txHooks TxHooks) driver.Tx {
return &tx{
txHooks,
}
}
func (t *tx) Commit() (err error) {
return t.CommitHook()
}
func (t *tx) Rollback() (err error) {
return t.RollbackH... |
package main
// BouncingBall solve the kata
func BouncingBall(h, bounce, window float64) int {
if bounce <= 0 || bounce >= 1 || window >= h {
return -1
}
nh := bounce * h
if nh < window {
return 1
}
return BouncingBall(nh, bounce, window) + 2
}
|
package main
import (
"strings"
"testing"
)
type tuple struct {
p, q string
}
func TestStrsubs(t *testing.T) {
for k, v := range map[tuple]string{
tuple{"10011011001", "0110,1001,1001,0,10,11"}: "11100110",
tuple{"1001101100010", "0110,1001,1001,0,10,11"}: "1110011110011"} {
if r := strsubs(k.p, k.q); r ... |
package mysql
import (
"strings"
mysqld "github.com/go-sql-driver/mysql"
gormigrate "gopkg.in/gormigrate.v1"
)
// Available impl.
func (d *Database) Available() bool {
return d.DB.DB().Ping() == nil
}
// DuplicateError impl.
func (d *Database) DuplicateError(err error) bool {
if err != nil {
if merr, yes := ... |
/*
2 red_black_tree.go
Implement a red-black tree that support search, insert and delete.
Based on C code at http://en.literateprograms.org/Red-black_tree_(C)
*/
package main
import (
"fmt"
"rand"
"strings"
)
type node struct {
black bool
p *node
rc *node
lc *node
data elem
}
type elem interface {
less(e e... |
// Copyright 2018 The gVisor 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 agree... |
package findrestaurant
import (
"reflect"
"testing"
)
type Tables struct {
list1 []string
list2 []string
expect []string
}
func TestFindRestaurant(t *testing.T) {
var result []string
tables := []Tables{
{[]string{"Shogun", "Tapioca Express", "Burger King", "KFC"},
[]string{"Piatti", "The Grill at Torre... |
package model
var (
// MathOperatorMul a math operator symbol for Multiplication
MathOperatorMul = MathOperator(1)
// MathOperatorDiv a math operator symbol for Division
MathOperatorDiv = MathOperator(2)
// MathOperatorPlus a math operator symbol for Addition
MathOperatorPlus = MathOperator(3)
// MathOperatorMi... |
package threeSum
import "testing"
func TestThreeSumCornered(t *testing.T) {
var arr []int
var rs [][3]int
var target int
arr = []int{-1, 0, 1, 2, -1, -4}
target = 0
rs = ThreeSumCornered(arr, len(arr), target)
t.Logf("rs: %v", rs)
}
|
package frei
import (
"fmt"
// "log"
"sort"
"time"
)
const DEMURRAGE time.Duration = time.Second
var Nomine []int64 = []int64{1 * mult, 4 * mult, 13 * mult, 40 * mult, 121 * mult, 364 * mult, 1093 * mult} //(3^i) / 2
const mult = 364
const COIN = mult
type Account interface {
ID() int64
Amount() int64
Prepar... |
package main
import "fmt"
func main() {
f2 := make(chan int)
f3 := make(chan int)
go receiveOnly(f2, f3)
go sendOnly(f2)
for f := range f3 {
fmt.Println("done", f)
}
}
func receiveOnly(f <-chan int, g chan<- int) {
for i := range f {
fmt.Println(i)
}
g <- 0
close(g)
}
func sendOnly(f chan<- int) {
f ... |
package dict
const LogDir = "logs/"
const SysTimeFmt ="2006-01-02 15:04:05"
const SysTimeFmt4compact ="20060102150405"
const HttpPost = "POST"
const HttpGet = "GET"
const HttpPut = "PUT"
const HttpDelete = "DELETE"
|
package modeltest
import (
M "github.com/ionous/sashimi/compiler/model"
"github.com/ionous/sashimi/util/ident"
)
var TestInstance = ident.MakeId("i")
var OtherInstance = ident.MakeId("x")
var NumProp, NumsProp = ident.MakeId("Num"), ident.MakeId("Nums")
var TextProp, TextsProp = ident.MakeId("Text"), ident.MakeId("... |
package leetcode
import (
"testing"
)
func TestTrieNode_Insert(t *testing.T) {
type fields struct {
m map[int32]*TrieNode
weights []int
endOfPath bool
}
type args struct {
s string
i int
}
tests := []struct {
name string
fields fields
args args
}{
{
name: "",
args: arg... |
package main
import (
"testing"
"time"
)
func TestFeedCurrencyData(t *testing.T) {
data := NewData()
go FeedCurrencyData(data)
timeout := time.After(time.Duration(IntervalConfig-1) * time.Second)
cnt := 0
for {
select {
case <-data.eurUSD:
cnt++
case <-data.activeCUR:
cnt++
case <-timeout:
... |
package mcuser
import (
"io"
"strings"
"github.com/minotar/imgd/pkg/minecraft"
"github.com/minotar/imgd/pkg/util/log"
)
const TexturesBaseURL = "http://textures.minecraft.net/texture/"
type TextureIO struct {
io.ReadCloser
TextureID string
}
// DecodeTexture reads and closes the ReadCloser, returning a minec... |
package mvc
import (
"net/http"
"strconv"
)
func getParamString(r *http.Request, name string, defaultValue string) string {
queryValue := r.URL.Query().Get(name)
if (queryValue == "") {
return defaultValue
}
return queryValue
}
func getParamFloat64(r *http.Request, name string, defaultValue float64) float64 ... |
/*
B1 Yönetim Sistemleri Yazılım ve Danışmanlık Ltd. Şti.
User : ICI
Name : Ibrahim ÇOBANİ
Date : 25.07.2019 11:44
Notes :
*/
package models
type Regions struct {
ID string `json:"ID,omitempty"`
LocalizedName string `json:"LocalizedName,omitempty"`
EnglishName string `json:"E... |
package config
import (
"net/url"
"strings"
"time"
"github.com/jrapoport/gothic/core/events"
)
// Webhooks config
type Webhooks struct {
Events []events.Event `json:"events"`
// URL is the url for the webhook callback. If the url includes an ':event'
// string it will automatically be replaced with name of th... |
package models
type ZonesResponse struct {
Meta Meta `json:"meta"`
Zones []Zone `json:"zones"`
}
type Zone struct {
Created string `json:"created"`
ID string `json:"id"`
IsSecondaryDNS bool `json:"is_secondary_dns"`
LegacyDNSHost string `json:"legacy_dns_host"`
LegacyNs ... |
package tests
import (
"github.com/YeffyCodeGit/Govid/govid"
"testing"
)
func TestGetGlobalData(t *testing.T) {
output, err := govid.GetGlobalData()
if err != nil {
t.Fatalf("error getting global data %+v", err)
}
if output == nil {
t.Fatalf("unable to get global data")
}
} |
// 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 cryptohome
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/ta... |
package serve
// Authentication forms authentication
type Authentication struct {
server *Server
}
// Authenticate authenticate with username and password
func (auth *Authentication) Authenticate(param map[string]string) int {
//var count int
// server := auth.server
// system := server.System
// client := syst... |
package services
import (
"fmt"
"log"
"strings"
"time"
"github.com/gosimple/slug"
"github.com/microcosm-cc/bluemonday"
"gopkg.in/mgo.v2/bson"
"models"
"utils"
"repository"
"controllers/viewmodels"
"github.com/dustin/go-humanize"
"strconv"
)
type CategoryService struct {
repo *repository.Repository
}
f... |
package main
import (
"github.com/aws/aws-lambda-go/events"
"github.com/stretchr/testify/assert"
"testing"
)
func TestHandler(t *testing.T) {
if testing.Short() {
request := events.APIGatewayProxyRequest{}
var paths = map[string]string{
"location": "Richmond",
}
request.PathParameters = paths
expec... |
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writi... |
package e2e
import (
"os"
"path"
"testing"
"time"
gohfc "github.com/zhj0811/gohfc/pkg"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const (
policy = "OR('Org1MSP.member', 'Org2MSP.member')"
andpolicy = "AND('Org1MSP.member', 'Org2MSP.member')"
)
// TestE2E setup and run
f... |
// Package nocache provider a baa middleware for http no-cache control.
package nocache
import (
"time"
"github.com/go-baa/baa"
)
// Unix epoch time
var epoch = time.Unix(0, 0).Format(time.RFC1123)
// Taken from https://github.com/mytrile/nocache
var noCacheHeaders = map[string]string{
"Expires": epoch,
... |
package main
import (
"encoding/json"
"os"
)
type Config struct {
Test string `json:"test"`
}
func NewConfig(filename string) Config {
c := Config{}
c.loadConfig(filename)
return c
}
func (c *Config) loadConfig(filename string) error {
configFile, err := os.Open(filename)
if err != nil {
return err
}
... |
package almanack
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"github.com/carlmjohnson/errorx"
"github.com/spotlightpa/almanack/internal/db"
"github.com/spotlightpa/almanack/internal/mailchimp"
"github.com/spotlightpa/almanack/internal/stringx"
"github.com/spotlightpa/almanack/inte... |
package blocko
import (
"strings"
"testing"
"github.com/carlmjohnson/be"
"github.com/spotlightpa/almanack/internal/xhtml"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func TestIsEmpty(t *testing.T) {
tcases := map[string]struct {
in string
empty bool
}{
"span": {"<span></span>", true... |
package kad
import (
"fmt"
"hahajing/com"
"io/ioutil"
"net"
"net/http"
"time"
)
// Prefs is my preferences.
type Prefs struct {
kadID ID
tcpPort uint16 // useless only for sending packet to client
udpKey uint32 // used to generate my verify key with destination IP for sending packet. Pleas... |
package conf
type CmdConfig struct {
ServerPort int64 `json:"server_port"`
Username string `json:"username"`
Password string `json:"password"`
ConfigPath string `json:"config_path"`
KubeConfig string `json:"kube_config"`
TillerPort int64 `json:"tiller_port"`
TokenExpire int64 `json:"token_expire"`
L... |
package route
import (
"github.com/gin-gonic/gin"
"net/http"
)
func routeApi(g *gin.Engine) {
apis := g.Group("/api")
apis.GET("/index", func(c *gin.Context) {
c.String(http.StatusOK, "Hello World!")
})
} |
// Copyright 2018 The gVisor 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 agree... |
package parser
import (
"fmt"
"io/ioutil"
"reflect"
"testing"
)
func TestParseCityList(t *testing.T) {
t.SkipNow()
contents, err := ioutil.ReadFile("text.html")
if err != nil {
t.Errorf("Fetch failed:%s\n", err.Error())
}
expectedUrls := []string{
"http://www.zhenai.com/zhenghun/beijing",
}
expectedC... |
package game
import (
"sort"
"container/vector"
)
type Game struct {
rootBoard [] int
goalBoard [] int
w,h int
distances [][] int
}
func BoardString(a [] int) string {
temp := make([]int, len(a))
for i,x := range a {
if (x >= 1 && x <= 9) {
temp[i] = x + '1' - 1
} else if x == 36 {
temp[i] = '0'
... |
package main
import (
"github.com/grandcat/zeroconf"
"os"
"syscall"
"fmt"
"os/signal"
)
func RegisterZeroConf() {
server, err := zeroconf.Register("LedMatrix", "_leds._tcp", "local.", Global.Port, []string{"txtv=0", "lo=1", "la=2"}, nil)
if err != nil {
panic(err)
}
defer server.Shutdown()
// Clean exit.
sig :=... |
package csv
import (
"bytes"
"encoding/csv"
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_JoinPath_Extention(t *testing.T) {
assert.Equal(t, "join-path.csv", joinPath(".", "join-path"))
assert.Equal(t, "join-path.csv", joinPath(".", "join-path.csv"))
}
func Test_JoinPath_Relation... |
package noolite
import (
"testing"
)
func TestBytesToResponse(t *testing.T) {
raw := []byte{}
_, err := bytesToResponse(raw)
if err == nil {
t.Error("not error on short slice!")
}
raw = make([]byte, 17)
_, err = bytesToResponse(raw)
if err != ErrWrongST {
t.Error("wrong ST but not error!")
}
raw[0] = 17... |
package controllers
import (
"github.com/astaxie/beego/logs"
"myproject/models"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego"
"fmt"
)
//ModelController is
type ModelController struct {
beego.Controller
}
/*
//CreateModel is
func (c *ModelController) CreateModel() {
//orm.RunSyncdb("default", fals... |
package main
import "unicode"
//736. Lisp 语法解析
//给你一个类似 Lisp 语句的字符串表达式 expression,求出其计算结果。
//
//表达式语法如下所示:
//
//表达式可以为整数,let 表达式,add 表达式,mult 表达式,或赋值的变量。表达式的结果总是一个整数。
//(整数可以是正整数、负整数、0)
//let 表达式采用"(let v1 e1 v2 e2 ... vn en expr)" 的形式,其中let 总是以字符串"let"来表示,接下来会跟随一对或多对交替的变量和表达式,也就是说,第一个变量v1被分配为表达式e1的值,第二个变量v2被分配为表达式e2... |
package Redis
import (
C "AlgorithmPractice/src/common/Constant"
"AlgorithmPractice/src/common/conf"
"fmt"
"github.com/go-redis/redis"
"time"
)
// 声明一个全局的redisDb变量
// var redisDb *redis.Client
type CacheRedisCli struct {
redisDb *redis.Client
}
// NewRedisCli 根据redis配置初始化一个客户端
func NewRedisCli() (*CacheRedisC... |
// 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 resource
import (
"context"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// ClusterRoleBindingKind is the name of k8s ClusterRoleBinding resource kind.
const ClusterRoleBindingKind = "ClusterRoleBi... |
package consul
import (
svc "github.com/halivor/goutil/service"
"github.com/hashicorp/consul/api"
)
func (c *Consul) AddService() {
c.cc.Agent().ServiceRegister(&api.AgentServiceRegistration{
ID: c.ID,
Name: c.Name,
Tags: c.Tags,
Address: c.IP,
Port: ... |
package trees_test
import (
"github.com/modocache/cargo"
"github.com/modocache/cargo/comparators"
. "github.com/modocache/cargo/trees"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("BinaryTraversable", func() {
var traversable BinaryTraversable
Describe("Root()", func() {
Context... |
// Copyright (c) 2020 Tailscale Inc & 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 dns
import "tailscale.com/types/logger"
func NewOSConfigurator(logf logger.Logf, _ string) (OSConfigurator, error) {
return newDirectMana... |
// Copyright (C) 2019-2020 Zilliz. 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 l... |
package main
import (
"log"
"path/filepath"
"time"
)
func main() {
for {
files, err := filepath.Glob("*.log")
if err != nil {
log.Fatal(err)
}
if len(files) == 0 {
time.Sleep(1 * time.Second)
continue
}
log.Printf("%v\n", files)
time.Sleep(1 * time.Second)
}
}
|
package gcb
type Option func(*Job)
func WithCommitSha(v string) Option {
return func(j *Job) {
j.commitSha = v
}
}
func WithProjectId(v string) Option {
return func(j *Job) {
j.projectID = v
}
}
func WithRepoName(v string) Option {
return func(j *Job) {
j.repoName = v
}
}
func WithTriggerId(v string) O... |
package Controllers
import (
"fmt"
"github.com/CRUD-Gin-Gorm/Api"
"github.com/CRUD-Gin-Gorm/Models"
"github.com/gin-gonic/gin"
)
//AllUser Show All User in database
func AllUser(c *gin.Context) {
var users []Models.User
err := Models.GetAllUser(&users)
fmt.Println(users)
if err != nil {
Api.Res(c, 404, use... |
package app
import (
"fmt"
"log"
"net/http"
"rest-secure/controllers"
"rest-secure/models"
"github.com/gorilla/mux"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres" // init postgresql drivers
)
var err error
// App struct holds router and db references
type App struct {
Router *mux.R... |
package main
import (
"fmt"
"log"
"sort"
"strconv"
)
/*
Programme requests numbers from the user, adding these to a slice, until the user enters 'x' or 'X' to quit
the programme.
Then the slice is returned, sorted.
*/
func main() {
// Define slice variable
numSlice := make([]int, 0)
for {
fmt.Println("Ple... |
package stack
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestThreadSafeStack_Push(t *testing.T) {
stack := newThreadSafeStack[int]()
assert.Equal(t, stack.Size(), 0, "stack should initially be empty")
stack.Push(1)
assert.Equal(t, stack.Size(), 1, "wrong stack size")
stack.Push(2)
assert... |
package leetcode
func isUgly2(num int) bool {
if num == 1 {
return true
}
if num <= 0 {
return false
}
for _, i := range [3]int{2, 3, 5} {
for ; num%i == 0 && num > 0; num /= i {
}
}
return num == 1
}
|
package main
import "fmt"
/*
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
Example 1:
Input: [3,2,1,5,6,4] and k = 2
Output: 5
Example 2:
Input: [3,2,3,1,2,4,5,5,6] and k = 4
Output: 4
Note:
You may assume k is always va... |
package widgets
import (
"./button"
"./menu"
"./label"
"./layout"
"./edittext"
"./align"
lua "github.com/yuin/gopher-lua"
)
func Loader(L *lua.LState) int {
label.RegisterLabelType(L)
button.RegisterButtonType(L)
layout.RegisterVerticalType(L)
layout.RegisterHorizontalType(L)
edittext.RegisterLineEditType... |
package main
import (
"fmt"
"github.com/urfave/cli"
"log"
"net"
"net/http"
"os"
"path/filepath"
)
var (
app = cli.NewApp()
defaultPort = 8080
defaultMessage = "Hello World"
)
func info() {
app.Name = "goprox"
app.Usage = "Simple proxy server made with Go"
app.Version = "1.0.0"
}
func star... |
// project euler (projecteuler.net) problem 70
// solution by Kevin Retzke (retzkek@gmail.com), May 2012
package main
import (
"fmt"
"math"
)
const NCPU = 15
type Primes struct {
Primes []int
Last int
}
// Init initializes a Primes struct with the first two primes.
func (p *Primes) Init() {
p.Primes = []int{... |
package racer
import (
"errors"
"net/http"
"time"
)
func Race(a, b string, timeout time.Duration) (winner string, err error) {
select {
case <-ping(a):
return a, nil
case <-ping(b):
return b, nil
case <-time.After(timeout):
return "", errors.New("请求超时")
}
}
func ping(url string) chan bool {
ret := mak... |
package provider
import (
"os"
"reflect"
"strings"
"testing"
)
func TestEnvVarsProviderWatch(t *testing.T) {
p := NewEnvVars()
unsubFn := p.Watch("GOPATH", func(_ string, _ map[string]string) {
t.Fatalf("unexpected call to watch value setter")
})
unsubFn()
}
func TestEnvVarsProviderForUnknownPath(t *testin... |
package products
import (
"net/http"
data "github.com/ancalabrese/MicroGo/Products/data/product"
"github.com/ancalabrese/MicroGo/Products/middleware"
)
//AddProducts to the dataset
func (p *Products) AddProducts(rw http.ResponseWriter, r *http.Request) {
prod := r.Context().Value(middleware.ProductKey{}).(data.P... |
package main
import (
"fmt"
)
func main() {
i:= 10 //se for um numero qualquer e so declarar a (var i int)
for i>0{
fmt.Print(i)
i=i-1
}
fmt.Println()
} |
/*
go-ipipnet-downloader提供针对ipip.net网站的数据下载器,支持数据文件本地或远程的更新监控和更新通知
Example:
d := &Downloader{
LocalPath: "data/mydata4vipweek2.dat",
RemoteURL: "https://user.ipip.net/download.php?token=",
CheckETag: true,
ErrorCallback: func(err error) { fmt.Fprintf(os.Stderr, "%s", err.Error()) }... |
// 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 wpa provides a Config type for WPA protected network.
package wpa
import (
"encoding/hex"
"strconv"
"strings"
"chromiumos/tast/common/shillconst"
"chromiumo... |
package task
import (
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/toolbox"
)
// 初始化定时任务
func Init() {
// 链上链下容错,如果有效广告没有对应链上的抵押资产,则将此广告改为无效
checkOnChainStatus := toolbox.NewTask("checkOnChainStatus", "0 0 0/1 * * *", CheckOnChainStatusPanic)
toolbox.AddTask("checkOnChainStatus", checkOnChainStatus)... |
// Copyright 2021 The gVisor 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 agree... |
// Package generator provides the functions to convert the data
// to xml format or pdf format
package generator
import (
"encoding/xml"
"fmt"
"io/ioutil"
"log"
"github.com/signintech/gopdf"
)
// SingleInventory is responsible to unpack each obj inside inventory
type SingleInventory struct {
Name string `json... |
package router
import (
"github-trending/handler"
middleware "github-trending/middleware"
"github.com/labstack/echo/v4"
)
type API struct {
Echo *echo.Echo
UserHandler handler.UserHandler
RepoHandler handler.RepoHandler
}
func (api *API) SetupRouter() {
api.Echo.POST("/user/sign-in", api.UserHandler.H... |
package rabbitmq
const (
ExchangeTypeDirect ExchangeType = iota
ExchangeTypeFanout
ExchangeTypeTopic
ExchangeTypeHeaders
)
var mapExchangeTypeString = map[ExchangeType]string{
ExchangeTypeDirect: "direct",
ExchangeTypeFanout: "fanout",
ExchangeTypeTopic: "topic",
ExchangeTypeHeaders: "headers",
}
type Ex... |
package main
import (
"database/sql"
"fmt"
"os"
"strings"
"text/template"
"time"
"github.com/fatih/color"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
)
func connectDB(driver string, args string) *sql.DB {
db, err := sql.Open(driver, args)
if err != nil {
panic(err.Error())
}
return db
}
fu... |
package facepp
import (
"encoding/json"
"errors"
"net/http"
)
/**
* 文档地址:https://console.faceplusplus.com.cn/documents/4887586
* 将两个人脸进行比对,来判断是否为同一个人,返回比对结果置信度和不同误识率下的阈值。
* 支持传入图片或 face_token 进行比对。使用图片时会自动选取图片中检测到人脸尺寸最大的一个人脸。
*/
const compareAPIURL = APIBaseURL + "/compare"
// CompareFaceResponse 人脸对比响应数据
ty... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"os/exec"
"strings"
)
type Symbol struct {
Name string
File string
Line string
}
const repo = "http://github.com/qcoh/dmgb"
func main() {
cmd := exec.Command("/bin/sh", "cloneandtag.sh", repo)
out, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
}... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/url"
"os"
"os/signal"
"strconv"
"time"
"github.com/gorilla/websocket"
)
var addr = "api2.poloniex.com"
type RecentTrade struct {
Id string
Side string
Pair string
Price float64
Amount float64
Timestamp time.Time
}
type Po... |
package runner
import (
"os/signal"
"os"
"time"
"errors"
)
var ERR_TIMEOUT = errors.New("timeout")
var ERR_INTER = errors.New("interupter")
type TaskContext struct {
tasks []func(delta int) int
interuptChan chan os.Signal
exitChan chan int
timeExpireChan <-chan time.Time
}
func NewTaskCont... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.