text stringlengths 11 4.05M |
|---|
package bot
import (
"strings"
"time"
"github.com/gempir/gempbot/internal/bot/commander"
"github.com/gempir/gempbot/internal/chat"
"github.com/gempir/gempbot/internal/config"
"github.com/gempir/gempbot/internal/dto"
"github.com/gempir/gempbot/internal/helixclient"
"github.com/gempir/gempbot/internal/log"
"gi... |
package e
const (
CACHE_ARTICLE = "cache:article"
CACHE_TAG = "cache:tag"
)
|
package main
import "fmt"
/*
slice删除元素的坑
copy复制会比等号复制慢。但是copy复制为值复制,改变原切片的值不会影响新切片。
而等号复制为指针复制,改变原切片或新切片都会对另一个产生影响。
*/
func main() {
nums := []int{1,2,3,4}
k := 2
//res := append(nums[:k], nums[k+1:]...)
//fmt.Println(res) // [1 2 4]
//fmt.Println(nums) // [1 2 4 4]
//正确处理方式
temp := make([]int, len(nums[:k... |
package main
import "fmt"
func main() {
a := 10
b := &a
fmt.Println(a, b, *b)
fmt.Printf("%T %T %T\n", a, b, *b)
// Function can take pointer as parameter or can return a pointer
x := 10
doubleIt(&x)
fmt.Println(x)
}
func doubleIt(a *int) {
*a = *a * 2
}
|
package cache
import (
"testing"
)
func TestCache_Cache(t *testing.T) {
cacher := NewCommonCacher()
if success, err := cacher.Cache("a", Entry{RegionName:"region_a", CityName:"cityname_a"}); success == true {
t.Log("cache a success")
}else{
t.Error(err)
}
if success, err := cacher.Cache("b", Entry{RegionNa... |
package main
import "fmt"
//测试
func test() {
//定义一个长度为3的数组
/**
长度不一致的数组 或者类型不一致 不可赋值交换
*/
//会自动初始化 [0,0,0]
var a[3] int
fmt.Println(a)
//数组初始化
var testArray [3]int //数组会初始化为int类型的零值
var numArray = [3]int{1, 2} //使用指定的初始值完成初始化
var cityArray = [3]string{"北京", "上海", "深... |
package predo
import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/BurntSushi/toml"
"github.com/mafengwo/confd/log"
)
// 找出需要用命名空间替换的一对对的模版文件(需要做验证 文件名的开头是以服务名开头的)
type tomlConfig struct {
Ini info
Nginx info
}
type info struct {
Tomlx []string
Tmplx []string
}
/*
* 完成confd前的任务:根... |
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complian... |
package main
import (
"container/list"
"fmt"
)
/*
Set operation:
1. If the key already exists, update the key with the new value
2. If the key doesn't exist, the 2 cases can happen
2a. There is enough space in the dictionary, add key, value to dictionary in the set operation
2b. There is not enough space, need to re... |
package globals
var (
InstallerImage = "ibuildthecloud/fleet"
)
|
/*
* Copyright 2019 The Knative 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... |
// Copyright 2014 Matthias Zenger. 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 appl... |
// Copyright 2020 Ye Zi Jie. 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 ... |
// Copyright (c) 2016-2019 Uber 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... |
package requirements
import "testing"
type TestStruct struct {
num int
res []int
}
var toTest = []TestStruct{
{
num: 60,
res: []int{1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60},
},
{
num: 42,
res: []int{1, 2, 3, 6, 7, 14, 21, 42},
},
{
num: -1,
res: nil,
},
}
func TestGetPositiveDevisors(t *testing... |
// Package sgf describes the SGF file formatting and provides functions
// for working with SGF data. SGF FF[4] is the current file format
// as of this writing. See https://www.red-bean.com/sgf/ and
// https://www.red-bean.com/sgf/proplist_t.html
package sgf
import (
"fmt"
)
const (
// xletters is a string to tran... |
package quikface
import (
"testing"
htest "net/http/httptest"
ntest "golang.org/x/net/nettest"
)
func TestIndexHandler(t *testing.T) {
r := NewSessionRouter()
htest.
}
|
// 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 transfer
// CheckAmount checks if the amount is valid and returns nil if not, it returns an error
func CheckAmount(amount int) error {
if amount <= 0 {
return ErrInvalidAmount
}
return nil
}
|
package test
import (
"github.com/mandatorySuicide/ts-common/comutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"testing"
)
type AccessoryTestSuit struct {
suite.Suite
}
func (s *AccessoryTestSuit) Test01() {
var str1 string = ""
var str2 string = "text-1"
var str3 string = "te... |
package pay
import "github.com/acupple/alipay/enums"
type AppPayDetail struct {
PayDetail
/**
* 客户端号,标识客户端
*/
AppId string
/**
* 客户端来源
*/
Appenv string
/**
* 是否发起实名校验
*/
RnCheck string
/**
* 授权令牌(32)
*/
ExternToken string
/**
* 商户业务扩展参数
*/
OutContext string
/**
* 商品详情
*/
Body... |
package handler
import (
"log"
"google.golang.org/protobuf/proto"
)
// TODO: 抽象出来,支持多种解码引擎,实现Unmarshal和Marshal即可
type Handler struct {
in []byte
out []byte
}
func NewHandler(in []byte) *Handler {
return &Handler{
in: in,
out: []byte{},
}
}
func (h *Handler) In(in []byte) {
h.in = in
}
func (h *Handler... |
//sorted map and produce custom json string on the sorted map
package util
import (
"bytes"
"encoding/json"
)
type OrderedMap struct {
M map[string]interface{}
ByKey bool `description:"if false, then sort by Val"`
Ascending bool
}
func (o OrderedMap) MarshalJSON() ([]byte, error) {
buf := bytes.Buf... |
package models
import (
"errors"
"strings"
"golang.org/x/crypto/bcrypt"
"github.com/jinzhu/gorm"
"profile.com/hash"
"profile.com/rand"
)
var (
// ErrInternalServerError is returned when err cannot be determined
ErrInternalServerError = errors.New("models: Something went wrong, contact for help")
// ErrNam... |
package package2
import (
"package1"
)
type Type2 struct {
Field1 *package1.Type1
}
func (this *Type2) Equal(that *Type2) bool {
return deriveEqual(this, that)
}
|
package merger
import (
"github.com/google/btree"
"github.com/threez/intm/internal/model"
)
// Btree attempts so sort and extend to reduce the memory
// consumption without requiring the full list to be in
// memory while processing. Processing is O(n*log(n)),
// Memory is O(n)
type Btree struct {
tree *btree.BTre... |
package transwarpjsonnet
import (
"encoding/json"
"io/ioutil"
"k8s.io/klog"
"os"
"path"
"path/filepath"
"strings"
"github.com/ghodss/yaml"
"helm.sh/helm/pkg/chart"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"transwarp/release-config/pkg/apis/transwarp/v1beta1"
"WarpCloud/walm/pkg/helm/impl/plugins"
"... |
package models
import(
"encoding/json"
)
/**
* Type definition for UpgradabilityEnum enum
*/
type UpgradabilityEnum int
/**
* Value collection for UpgradabilityEnum enum
*/
const (
Upgradability_KUPGRADABLE UpgradabilityEnum = 1 + iota
Upgradability_KCURRENT
Upgradability_KUNKNOW... |
package palinfrome
import (
"fmt"
"testing"
)
func TestIsPalindrome(t *testing.T) {
x := 1
re := IsPalindrome(x)
if !re {
t.Error("check number is error, expected result is true")
}
x = 1221
fmt.Println(IsPalindrome(x))
}
|
package migrator
import (
"testing"
"github.com/stretchr/testify/assert"
)
type testColumnType string
func (c testColumnType) buildRow() string {
return string(c)
}
func TestColumnRender(t *testing.T) {
t.Run("it renders row from one column", func(t *testing.T) {
c := columns{column{"test", testColumnType("r... |
package main
import "fmt"
func sort(arr []int) {
for i := 0; i < len(arr) - 1; i++ {
for j := i + 1; j < len(arr); j++ {
if (arr[i] > arr[j]) {
temp := arr[i]
arr[i] = arr[j]
arr[j] = temp
}
}
}
}
func print(arr []int) {
for i := 0; i < len(arr); i++ {
fmt.Printf("%d, ", arr[i])
}
fmt.Pr... |
package adapter
import (
"github.com/case2912/go-curd-clean-architecture/domain"
)
type UserRepository interface {
Store(domain.User) domain.User
FindByUserName(domain.User) domain.User
}
|
package _4_Exploring_the_Water
import "fmt"
func main() {
//str := "hello"
str := "aabb"
res := palindromeRearranging(str)
fmt.Println(res)
}
func palindromeRearranging(inputString string) bool {
mapUniquValues := map[string]int{} // map for keeping quantities of every letter in string value
numberEven := 0 ... |
package main
//Invaliud
//Checks if assigment calls for implicit type cast to base type when passed that of defined type resolvable to that base type
func main() {
type num int
var a int = (num)(3)
} |
package k8s
import "k8s.io/apimachinery/pkg/types"
type UIDSet map[types.UID]bool
func NewUIDSet(uids ...types.UID) UIDSet {
ret := make(map[types.UID]bool)
for _, uid := range uids {
ret[uid] = true
}
return ret
}
func (s UIDSet) Add(uids ...types.UID) {
for _, uid := range uids {
s[uid] = true
}
}
func... |
package core
import (
"container/list"
"sync"
)
type TargetOptions struct {
Protocol string
Host string
Port int
ClientId string
UserName string
Password string
}
type optionList struct {
TargetInfo *list.List
}
var optsList *optionList
var optsOnce sync.Once
func getTargetInfo() *optionList {
op... |
package reltest
import (
"context"
"reflect"
"github.com/go-rel/rel"
)
type find []*MockFind
func (f *find) register(ctxData ctxData, queriers ...rel.Querier) *MockFind {
mf := &MockFind{
assert: &Assert{ctxData: ctxData},
argQuery: rel.Build("", queriers...),
}
*f = append(*f, mf)
return mf
}
func (f... |
package supers
import (
"errors"
"fmt"
"strings"
"github.com/LiveSocket/bot/channel-service/helpers"
"github.com/LiveSocket/bot/conv"
"github.com/LiveSocket/bot/service"
"github.com/LiveSocket/bot/service/socket"
)
type channelInput struct {
SubCommand string
Channel string
BotName string
}
// Chann... |
package controller
import (
"encoding/json"
"net/http"
"foreplay/csv/entry"
"foreplay/manager"
"shared/common"
"shared/utility/errors"
"shared/utility/glog"
)
func RegisterHttpHandler() {
http.Handle("/patch", NewPatchHandler())
http.Handle("/announcement", NewAnnouncementHandler())
http.Handle("/caution",... |
package v1
import (
"context"
"errors"
"fmt"
"time"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/domain/values"
"github.com/traPtitech/trap-collection-server/src/repository"
"github.com/traPtitech/trap-collection-server/src/service"
)
type Game s... |
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
"github.com/modood/wpm"
"github.com/tidwall/gjson"
)
var (
width = "32px"
height = "32px"
size = ""
)
// NewsFeed newsfeed
type NewsFeed struct {
ID string `json:"id"`... |
package cfg
import (
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go4eat-api/pkg/cfg"
)
// NewConfig func
func NewConfig() (*viper.Viper, *pflag.FlagSet, error) {
return cfg.NewConfig(
cfg.NewOptions().UseFile("config.file").UseEnv("go4eat").UseFlags(),
[]*cfg.Property{
cfg.NewProperty("help", fals... |
package main
import "fmt"
import "os"
import "math"
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
func main() {
// W: width of the building.
// H: height of the building.
var W, H int
fmt.Scan(&W, &H)
// N: maximum n... |
package lc
// Time: O(mn)
// Benchmark: 0ms 2mb | 100% 73%
const (
EAST = iota
SOUTH
WEST
NORTH
)
func spiralOrder(matrix [][]int) []int {
if len(matrix) == 0 {
return []int{}
}
m := len(matrix)
n := len(matrix[0])
nums := make([]int, m*n)
bounds := []int{n, m, 0, 1}
direction := EAST
pos := []int{0, ... |
package set
func subset(set, sub []int) bool {
s := deriveSet(set)
for _, k := range sub {
if _, ok := s[k]; !ok {
return false
}
}
return true
}
|
package leetcode
import (
"fmt"
"testing"
)
type question20 struct {
para20
ans20
}
// para 是参数
// one 代表第一个参数
type para20 struct {
one string
}
// ans 是答案
// one 代表第一个答案
type ans20 struct {
one bool
}
func Test_Problem20(t *testing.T) {
qs := []question20{
{
para20{"()[]{}"},
ans20{true},
},
... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package dgapi2 contains helper functions to interact with the DGAPI2 test app.
// See go/dgapi-v2.0-test-plan for the details
package dgapi2
|
package project_manager
import (
"../models"
"../repos/grant"
"../repos/project"
"../repos/schema"
"../repos/task"
"../repos/user"
)
// ProjectAggr aggregate of required entities
type ProjectAggr struct {
Project models.Project
Schema models.ProjectSchema
}
// ProjectManager manages all things about creatin... |
package grpc
import (
"context"
"github.com/payfazz/fazzkit/server/common"
"github.com/payfazz/fazzkit/server/validator"
)
//DecodeOptions executed before decode process
type DecodeOptions func(ctx context.Context, model interface{}, request interface{}) error
//DecodeParam decode model with DecodeOptions
type D... |
package v1alpha1
import (
v1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
PhasePending = "PENDING"
PhaseScheduling = "SCHEDULING"
PhaseRunning = "RUNNING"
PhaseDone = "DONE"
)
// DroneFederatedDeploymentSpec defines the desired state of DroneFederatedDeployment
// +k8s:openap... |
package errutil
// Append joins two errors into one; either or both can be nil.
func Append(err error, e error) (ret error) {
if err == nil {
ret = e
} else if e != nil {
ret = multiError{err, e}
} else {
ret = err
}
return ret
}
// multiError chains errors together.
// it can expand "recursively", allowin... |
package pool
import (
"errors"
"math"
"sync"
"sync/atomic"
"time"
)
var POOLFULL error = errors.New("pool is full")
type genObjectPool struct {
config *PoolConfig
factory PoolObjectFactoryer
objNum int64
idlObject chan interface{}
lock sync.Mutex
}
func DefaultGenObjectPool(f PoolObjectFactor... |
package main
import (
"fmt"
)
func countAndSay(n int) string {
now := "1"
for i := 1; i < n; i = i + 1 {
next := ""
count := 1
value := int(now[0])
for _, x := range now[1:] {
if int(x) == int(value) {
count = count + 1
} else {
next = next + fmt.Sprintf("%d%c", count, value)
count = 1
... |
package providers
import (
awsProvider "github.com/cyberark/secretless-broker/internal/providers/awssecrets"
conjurProvider "github.com/cyberark/secretless-broker/internal/providers/conjur"
envProvider "github.com/cyberark/secretless-broker/internal/providers/env"
fileProvider "github.com/cyberark/secretless-broke... |
package gitlabClient
import (
"github.com/xanzy/go-gitlab"
)
func (git *GitLab) GetListProject() ([]*gitlab.Project, error) {
FALSE := false
TRUE := true
opt := &gitlab.ListProjectsOptions{
Archived: &FALSE,
Membership: &TRUE,
ListOptions: gitlab.ListOptions{
PerPage: 100,
Page: 1,
},
}
for... |
package middleware
import (
"net/http"
"github.com/BalkanTech/goilerplate/session"
"log"
"github.com/BalkanTech/goilerplate/alerts"
)
var RequireLoginRedirectTo string = "/login"
func RequireLogin(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := s... |
package sqlite
import (
"database/sql"
//sqlite realization
_ "github.com/mattn/go-sqlite3"
"gitlab.com/alex-user-go/art/pkg/listing"
)
//Storage - sqlite db
type Storage struct{
db *sql.DB
}
//NewStorage - create and init new sqlite storage
func NewStorage()(*Storage, error){
db, err := sql.Open("sqlite3", "... |
//Slice append 加入
package main
import "fmt"
func main() {
x := []int{1, 2, 3, 4, 5}
y := []int{321, 456, 789}
fmt.Println(x)
x = append(x, 66, 77)
fmt.Println(x)
x = append(x, y...) // (目標, 要加入的內容 如果是其他陣列全部就 目標...)
fmt.Println(x)
x = append(x[:2], x[4:]...) //結束值不包括 注意要有...
fmt.Println(x)
}
|
package infrastructure
import (
"encoding/csv"
"errors"
"fmt"
"io"
"log"
"os"
"github.com/jesus-mata/academy-go-q12021/infrastructure/dto"
)
//go:generate mockgen -package mocks -destination $ROOTDIR/mocks/$GOPACKAGE/mock_$GOFILE . CsvSource
type CsvSource interface {
WriteLines(newsItems []dto.NewItem) erro... |
package protobuf
import (
"encoding/binary"
"io"
"sync"
"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
)
var bufPool = &sync.Pool{New: func() interface{} { return proto.NewBuffer(nil) }}
func nextBuffer(buf []byte) *proto.Buffer {
b := bufPool.Get().(*proto.Buffer)
b.SetBuf(buf)
return b
}
func... |
package main
import "fmt"
func arrayToCounter(arr []string) map[string]int {
out := make(map[string]int)
for _, i := range arr {
out[i] += 1
}
return out
}
func main() {
in := []string{"cat", "cat", "dog", "cat", "tree"}
out := arrayToCounter(in)
fmt.Println(out)
}
|
// http://my.oschina.net/Jacker/blog/32837
// Two way encipherment ported from PHP.
package scrypt
import (
"bytes"
"crypto/md5"
"fmt"
"math/rand"
"time"
)
func keyEd(txt []byte, encryptKey string) []byte {
m := md5.New()
fmt.Fprint(m, encryptKey)
t := bytes.NewBufferString("")
keyBytes := m.Sum(nil)
for i... |
package metatest
import (
"fmt"
"github.com/ionous/sashimi/meta"
"github.com/ionous/sashimi/util/ident"
"github.com/ionous/sashimi/util/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"reflect"
"testing"
)
// ApiTest allows implementations of the meta interface to share tests.... |
package resources
import (
"fmt"
"net"
"github.com/RackHD/ipam/interfaces"
"github.com/RackHD/ipam/models"
"github.com/RackHD/ipam/resources/factory"
"gopkg.in/mgo.v2/bson"
)
// LeaseResourceType is the media type assigned to a Lease resource.
const LeaseResourceType string = "application/vnd.ipam.lease"
// L... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package main
import (
"encoding/json"
"net/http"
"net/url"
"strings"
"github.com/gorilla/mux"
moovhttp "github.com/moov-io/base/http"
"github.com/moov-io/base/log"
... |
package delayqueue
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
"github.com/mlkr/delay-queue/config"
)
var (
// 每个定时器对应一个bucket
timers []*time.Ticker
// bucket名称chan
bucketNameChan <-chan string
)
// Init 初始化延时队列
func Init() {
RedisPool = initRedisPool()
initT... |
package main
// import (
// "log"
// "strconv"
// "time"
// "net/http"
// "database/sql"
// )
//
// func rootHandler(res http.ResponseWriter, req *http.Request) {
// var (
// sensor string
// value int
// created_at time.Time
// )
// // DB öffnen...
// db, err := sql.Open("postgres", con... |
package service
import (
"encoding/json"
"fmt"
"net/http"
"sync"
"github.com/Emoto13/photo-viewer-rest/follow-service/src/auth"
"github.com/Emoto13/photo-viewer-rest/follow-service/src/feed"
"github.com/Emoto13/photo-viewer-rest/follow-service/src/follow"
"github.com/Emoto13/photo-viewer-rest/follow-service/s... |
package app
import (
"sort"
"strings"
)
func transformUserSet(userSet map[string]struct{}, userIDs []string, action string) map[string]struct{} {
switch action {
case "replace":
userSet = make(map[string]struct{})
fallthrough
case "append":
for _, userID := range userIDs {
userSet[userID] = struct{}{}
... |
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
"github.com/ysmood/kit"
)
var flagPort = flag.Int("port", 8544, "port")
// This example demonstrates how to upload a file on a form.
func main() {
flag.Parse()
// get wd
wd,... |
package JsStatistics
import (
"JsGo/JsLogger"
"JsGo/JsStore/JsRedis"
)
type Statistics struct {
Type string // 类型 0:产品 1:内容
VisitNum int // 访问量
PraiseNum int // 点赞数量
AttentionNums int // 关注数量
CompositeScore float64 // 综合评分(所有评分的平均值)
CommentNum int // 评论的人数
Sal... |
package m2go
const (
stockItemsRelative = "stockItems"
)
|
package model
type ProductGroup struct {
HotelId int64 `json:"hotel,omitempty"`
ProductGroupId int64 `json:"id,omitempty"`
Description string `json:"descricao,omitempty"`
DisplayProduct string `json:"exibir,omitempty"`
Code int64 `json:"codigo,omitempty"`
Printer string `json:"impre... |
package odoo
import (
"fmt"
)
// AccountTaxTemplate represents account.tax.template model.
type AccountTaxTemplate struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AccountId *Many2One `xmlrpc:"account_id,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
Amount ... |
package main
import (
"bytes"
"image"
"image/draw"
_ "image/jpeg"
"image/png"
"log"
"math"
"net/http"
"strings"
"github.com/golang/freetype/truetype"
"github.com/nfnt/resize"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
type Handler struct {
// these are read only, safe for access from m... |
// 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 lottery
import (
"errors"
"math/big"
"github.com/MatrixAINetwork/go-matrix/baseinterface"
"github.com/MatrixAINetwork/go-matrix... |
package main
import (
database "github.com/fr05t1k/wallet/db"
_ "github.com/joho/godotenv"
)
import (
"github.com/fr05t1k/wallet/config"
"github.com/fr05t1k/wallet/operation"
"github.com/fr05t1k/wallet/server"
)
func main() {
RunWallet()
}
func RunWallet() {
runner := GetWalletServer()
runner.Run(config.Get... |
package shark
import (
"testing"
)
func Test_parsePattern(t *testing.T) {
r1 := "/assets/*filepath/hep.css"
t.Log(parsePattern(r1))
}
func TestNode(t *testing.T) {
n := &node{}
pattern := "/assets/:path/data"
parts := parsePattern(pattern)
n.insert(pattern, parts, 0)
t.Log(n)
}
func TestRouter(t *testing.T)... |
package bytedance
import "fmt"
func Code1016() {
s1 := "abcdxabcde"
s2 := "abcdeabcdx"
fmt.Println(checkInclusion(s1, s2))
}
/**
给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的排列。
换句话说,第一个字符串的排列之一是第二个字符串的子串。
示例1:
输入: s1 = "ab" s2 = "eidbaooo"
输出: True
解释: s2 包含 s1 的排列之一 ("ba").
示例2:
输入: s1= "ab" s2 = "eidboaoo"
输出:... |
package dependencies
import (
_ "github.com/cweill/gotests"
) |
package utils
type BulkInsertStruct struct {
Columns *string
Query *string
Values *[]string
}
|
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"regexp"
colorize "github.com/sabhiram/go-colorize"
)
// Version & Revision
var (
Version string
Revision string
)
func init() {
Version = "0.0.1"
Revision = "0000000"
}
func main() {
if len(os.Args) != 2 {
fmt.Println(colorize.ColorStrin... |
package web
import (
"net/http"
"net/url"
)
type Request interface {
Method() string
URL() *url.URL
}
type request struct {
r *http.Request
}
func NewRequest(r *http.Request) Request {
return &request{
r: r,
}
}
func (r *request) Method() string {
return r.r.Method
}
func (r *request) URL() *url.URL {
... |
package httpservice
import (
"github.com/gin-gonic/gin"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
_ "github.com/mattn/go-sqlite3"
_ "httpservice/docs"
"fmt"
"define"
"httpservice/services"
)
type HServer struct {
}
func NewHTTPServer() *HServer {
s := &HServer{}
retur... |
package compiler
import (
"fmt"
"runtime"
"github.com/BlankRain/gal/ast"
"github.com/BlankRain/gal/llvm/strings"
"github.com/BlankRain/gal/llvm/types"
"github.com/BlankRain/gal/llvm/value"
"github.com/llir/llvm/ir"
"github.com/llir/llvm/ir/constant"
llvmTypes "github.com/llir/llvm/ir/types"
)
type Compiler ... |
package game
import (
"log"
"math"
"runtime"
"time"
"github.com/veandco/go-sdl2/sdl"
)
type Game struct {
Renderer *sdl.Renderer
Window *sdl.Window
}
// NewGame returns an entire game object. Only one should exist.
func NewGame() *Game {
return &Game{}
}
// Init initializes the display and locks the goro... |
package client
import (
"log"
"net/rpc"
"pub/dtos"
)
func Publish(client *rpc.Client, topicID, message string) error {
var replyDto dtos.PublishDto
publishDto1 := dtos.PublishDto{TopicID: topicID, Message: dtos.MessageDto{MessageData: message}}
err := client.Call("RPC.Publish", publishDto1, &replyDto)
if err !... |
package thirdparty
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
settingsapi "alauda.io/diablo/src/backend/settings/api"
thirdpartyapi "alauda.io/diablo/src/backend/thirdparty/api"
"k8s.io/client-go/kubernetes"
)
type ThirdPartyManager struct {
}
func NewThirdPartyManager() thirdpartya... |
package binarysearch
// return index of target or -1 if does not exist
func BinarySearch(arr []int, target int) int {
startIndex := 0
endIndex := len(arr) - 1
for startIndex <= endIndex {
mid := (startIndex + endIndex) / 2
if arr[mid] > target {
endIndex = mid - 1
} el... |
package optgen
//go:generate stringer -type=Operator operator.go
type Operator int
const (
UnknownOp Operator = iota
RootOp
DefineSetOp
DefineOp
DefineFieldOp
RuleSetOp
RuleHeaderOp
RuleOp
BindOp
RefOp
MatchNamesOp
MatchInvokeOp
MatchFieldsOp
MatchAndOp
MatchNotOp
MatchAnyOp
MatchListOp
Replace... |
package azure
import (
"time"
"github.com/cortexproject/cortex/pkg/util/flagext"
)
type Config struct {
StorageAccountName flagext.Secret `yaml:"storage-account-name"`
StorageAccountKey flagext.Secret `yaml:"storage-account-key"`
ContainerName string `yaml:"container-name"`
Endpoint str... |
package controllers
import (
"github.com/gin-gonic/gin"
)
type (
SessionsController struct{}
User struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
}
)
func NewSessionsController() *SessionsController {
return &SessionsController... |
package arrays
import (
"fmt"
"hackerrank/util"
)
/**
Sample Input
4
1 4 3 2
Sample Output
2 3 4 1
*/
func ArraysDs() {
var n int
if _, err := fmt.Scan(&n); err != nil {
panic(err)
}
a, err := util.IntScanlnSlice(n)
if err != nil {
panic(err)
}
loop := len(a) / 2
last := len(a) - 1
for i, num := ran... |
package userdetails
import (
"context"
"encoding/json"
"fmt"
"log"
"time"
"github.com/sinha-abhishek/jennie/awshelper"
"github.com/sinha-abhishek/jennie/confighelper"
"github.com/sinha-abhishek/jennie/cryptohelper"
"github.com/sinha-abhishek/jennie/linkedin"
"golang.org/x/oauth2"
"google.golang.org/api/gma... |
package main
import (
"github.com/Bourne-ID/winrm-dns-client/dns"
)
type config struct {
ServerName string
Username string
Password string
Port int
HTTPS bool
Insecure bool
}
// Client configures the WinRM endpoint for managing Microsoft DNS
func (c *config) Client() (*dns.Client, error) {
c... |
package main
import(
"fmt"
"net/http"
"html/template"
)
type Pessoa struct{
Nome string
Idade int
}
type TodasPessoas struct{
Pessoas []Pessoa
}
func main(){
tmpl := template.Must(template.ParseFiles("index.html"))
http.HandleFunc("/", func( w http.ResponseWriter, r *http.Request){
data := T... |
package gator
import (
"fmt"
"math/rand"
"net/http"
"path/filepath"
"time"
"strings"
"github.com/gorilla/websocket"
"github.com/cloudfoundry/loggregatorlib/logmessage"
"io"
"regexp"
"encoding/json"
"math"
)
func StartHTTPServer(config Config, outputChan chan string) {
metricsChan := make(c... |
package main
import "fmt"
func main() {
fmt.Printf("nothing to see here, I'm just a dummy file so we can build")
}
|
package ubernet
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"log"
"math"
"math/rand"
"net"
"net/http"
"net/url"
"os"
"runtime"
"strings"
"time"
)
func defaultPooledTransport() *http.Transport {
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Time... |
package consumer
import (
"bytes"
"errors"
"hash/crc32"
"net"
"os/exec"
"sync"
"sync/atomic"
"time"
"github.com/couchbase/eventing/common"
"github.com/couchbase/eventing/dcp"
mcd "github.com/couchbase/eventing/dcp/transport"
cb "github.com/couchbase/eventing/dcp/transport/client"
"github.com/couchbase/ev... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.