text stringlengths 11 4.05M |
|---|
package crypt
import "testing"
func TestCrypt(t *testing.T) {
got, err := Crypt("test", "$1$Bb6jzHiC$")
if err != nil {
t.Fatal(err)
}
want := "$1$Bb6jzHiC$Yt25IchKE4VSFK5Vg7qFp/"
if got != want {
t.Errorf("s, _ := Crypt(%q, %q); s = %q, want %q", "test", "$1$Bb6jzHiC", got, want)
}
}
func TestMD5(t *test... |
package main
import (
"database/sql"
"fmt"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/rabierre/scrooge/db"
"github.com/rabierre/scrooge/models"
"github.com/stretchr/testify/assert"
)
func setup() {
err := error(nil)
db.Db, err = sql.Open("sqlite3", "testdb")
if err != ni... |
package entity
type User struct {
id string
}
func (user User) ID() string {
return user.id
}
func CreateUser(id string) *User {
return &User{
id: id,
}
}
|
package session
import (
"database/sql"
"encoding/json"
"fmt"
"time"
)
/*
MySQLStore is a session storage for a MySQL database.
*/
type MySQLStore struct {
db *sql.DB
startSessionStmt *sql.Stmt
commitSessionStmt *sql.Stmt
gcSessionStmt *sql.Stmt
delSessionStmt *sql.Stmt
}
/*
NewMySQLS... |
package main
import "fmt"
var currentId int
var newsList NewsList
var news News
// Give us some seed data
func init() {
RepoCreateNews(News{Title: "Write presentation", Author: "Raka Westu"})
RepoCreateNews(News{Title: "Host meetup", Author: "Kuncara Adi"})
}
func RepoFindNews(id int) News {
for _, t := range n... |
package main
import (
"fmt"
)
type P struct {
Name string
}
func main(){
p:=p1()
p=4
fmt.Println(p1())
fmt.Println(p)
}
func p1()int {
return 2
}
|
// 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 packet
// UDPHeader represents an UDP packet header.
type UDPHeader struct {
IPHeader
SrcPort uint16
DstPort uint16
}
const (
udpHeade... |
/*
Package sample implements some useful functions to process samples from
statistical populations. The standard Go `float64` type is used in all
computations.
*/
package sample // import "github.com/alcortesm/sample"
import (
"errors"
"math"
)
// ErrSampleTooSmall is returned when the provided data sample set is t... |
// Copyright © 2019 mg
//
// 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
// to use, copy, modify, merge, publish, distribute, ... |
package bo
//返回用户详细列表
type RecordUserHalf struct {
Id int `json:"id"`
DeptId int `json:"deptId"`
CreateBy int `json:"createBy"`
UpdateBy int `json:"updatedBy"`
PwdResetTime int64 `json:"pwdResetTime"`
CreateTime int64 `json:"createTime"`
UpdateTime int64 `json:"updateT... |
package doclient
import (
"errors"
"fmt"
"strconv"
"time"
"github.com/bryanl/dolb/pkg/app"
"github.com/digitalocean/godo"
"golang.org/x/oauth2"
)
var (
// coreosImage is the agent image.
coreosImage = "coreos-alpha"
// actionTimeout is how long to wait before checking an action's status.
actionTimeout = ... |
package gsheets
import (
"context"
"log"
"golang.org/x/oauth2"
sheets "google.golang.org/api/sheets/v4"
)
func Append(conf *oauth2.Config, token *oauth2.Token, sheetid string, writeRange string, data []interface{}) error {
ctx := context.Background()
client := conf.Client(ctx, token)
srv, err := sheets.New(cl... |
package gortex
import (
"fmt"
"math/rand"
"testing"
"time"
)
func TestClassifier(t *testing.T) {
// maintain random seed
rand.Seed(time.Now().UnixNano())
trainFile := "train.txt"
dic, e := DictionaryFromFile(trainFile, CharSplitter{})
if e != nil {
t.Fatal(e)
}
hidden_size := 128
fmt.Printf("Dictionary ... |
package fbinterview
import (
"testing"
"github.com/magiconair/properties/assert"
)
func TestNewFastString(t *testing.T) {
TEST:
for _, tc := range []struct {
str string
}{
{"Grumming"},
{"L"},
{"Very large sentence with big attitude to test this test case"},
// empty test case
{""},
} {
str := N... |
package function
import "fmt"
func ExamplePow() {
fmt.Println(Pow(4, 3))
fmt.Println(Pow(-5, 3))
fmt.Println(Pow(3, 0))
// Output:
// 64
// -125
// 1
}
|
package client
import (
"context"
"strconv"
"time"
appootb "github.com/appootb/substratum/metadata"
"github.com/appootb/substratum/proto/go/common"
"github.com/appootb/substratum/proto/go/permission"
"github.com/appootb/substratum/proto/go/secret"
"github.com/appootb/substratum/service"
"github.com/appootb/s... |
/*
Copyright (C) 2016 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwa... |
/*
For a lot of the questions today we are going to be doing some simple numerical calculus. Don't worry, its not too terrifying.
For the easy problem, write a function that can take in a list of y-values that represents a function sampled on some domain. The domain can be specified as a list of x-values or two value... |
package main
import (
"crypto/md5"
"fmt"
"io"
"log"
"os"
"strings"
"time"
"github.com/anaskhan96/soup"
"github.com/davecgh/go-spew/spew"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
type newsItem struct {
title string
text string
date string
}
var news map[string]*newsItem
func loadNews(start... |
func maxSubArray(nums []int) int {
if len(nums) == 0{
return 0
}
max := nums[0]
for _, n := range(nums){
if n > max{
max = n
}
}
if max < 0{
return max
}
tmp := 0
for _, n := range(nums){
if tmp + n > 0{
tmp = tmp ... |
package blocks
import (
"fmt"
"github.com/bouncepaw/mycomarkup/v2/globals"
"github.com/bouncepaw/mycomarkup/v2/util"
)
// Img is an image gallery, consisting of zero or more images.
type Img struct {
// All entries
Entries []ImgEntry
HyphaName string
}
func (img Img) isBlock() {}
// ID returns the gallery's... |
package models
import (
"time"
)
type UserBalance struct {
ID int `gorm:"primary_key" json:"id"`
UserID int `gorm:"column:user_id" json:"user_id"`
Balance int `gorm:"column:balance"`
BalanceAchieve int `gorm:"column:balance_achieve"`
//UserBalanceHistory []UserBalanceHistory
CreatedAt tim... |
//
// Copyright © 2017 Ikey Doherty <ikey@solus-project.com>
//
// 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... |
package libRpc
type CmdParams struct {
Name string `json:"name"`
Type string `json:"type"`
ProtoBufPath string `json:"protubuf_path"`
ClientOutputPath string `json:"client_output_path"`
ProtoGenOutputPath string `json:"proto_gen_output_path"`
ServiceOutputPath string `json:"s... |
package resourcetypes
import (
"errors"
"github.com/shwetha-pingala/HyperledgerProject/InvoiveProject/go-api/models"
)
type UpdateOpts struct {
Replace bool
}
func Update(id string, usr *models.ResourceType, opts *UpdateOpts) (*models.ResourceType, error) {
var exists bool
if opts == nil {
opts = &UpdateOpt... |
package mbclient
import "encoding/xml"
const ArtistEntity = "artist"
type ArtistMetadata struct {
XMLName xml.Name `xml:"metadata" json:"-"`
ArtistList artistList `xml:"artist-list"`
}
type artistList struct {
XMLName xml.Name `xml:"artist-list" json:"-"`
Count string `xml:"count,attr" json:"count"`
A... |
package ipchkr
import (
"fmt"
"net"
)
var privateNetworks []*net.IPNet
func init() {
for _, CIDRBlock := range []string{
"127.0.0.0/8", // IPv4 loopback
"10.0.0.0/8", // RFC1918
"172.16.0.0/12", // RFC1918
"192.168.0.0/16", // RFC1918
"169.254.0.0/16", // RFC3927 link-local
"::1/128", /... |
package main
//Always Capitalize Variable names to be exported.Best practice
//gofmt <goscript> helps you fix style standard errors
//Cant use single quotes for strings
import("fmt")
func main(){
i :=0
for {
fmt.Println(i)
i +=2
if i > 12{
break
}
}
fmt.Println("Stoped")
//for _,Location := range s.... |
/**
* @Author: korei
* @Description:
* @File: status.go
* @Version: 1.0.0
* @Date: 2020/11/18 下午7:27
*/
package api
var Work chan string
func init() {
Work = make(chan string,1)
Work <- "begin"
}
func BeginWork() {
<-Work
}
func EndWork() {
Work<-"end"
} |
package functions
func GetNameFromType(t string) (name string) {
switch t {
case "error":
return "err"
case "string":
return "str"
case "[]string":
return "ids"
case "[]types.Type":
return "types"
case "types.Package":
return "package"
default:
panic("no name for type " + t)
}
}
|
// object_test
package object
import "testing"
func Test_object(t *testing.T) {
var a = Create()
a.SetValue(40)
var b = Create()
b.SetValue(100)
t.Log(a.GetTypeName())
t.Log(b.GetTypeName())
if a.GetType() == b.GetType() {
t.Log("same type")
}
}
|
package main
/*
Fix the race condition you created in the previous exercise
by using package atomic
*/
import (
"fmt"
"runtime"
"sync"
"sync/atomic"
)
func main() {
var incrementedValue int64
const goRouNum = 12
var wg sync.WaitGroup
wg.Add(goRouNum)
for i := 0; i < goRouNum; i++ {
go func() {
atom... |
package main
import (
"testing"
)
func BenchmarkSphericalTrigonometr(b *testing.B) {
for i := 0; i < b.N; i++ {
p1 := geoPoint{22.386651, 114.169922}
p2 := geoPoint{21.4225, 39.8261}
sphericalTrigonometry(p1, p2)
}
}
func BenchmarkHubenyFormula(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
... |
package codesnippets
// diff to string filespackage testdata
import "github.com/pmezard/go-difflib/difflib"
// Diff returns the diff between to strings
func Diff(a, b string) string {
diff := difflib.UnifiedDiff{
A: difflib.SplitLines(a),
B: difflib.SplitLines(b),
FromFile: "Got",
ToFile: "W... |
// Copyright 2017 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 main
import (
"log"
"time"
"github.com/elos/models"
"github.com/elos/tyche"
)
func main() {
auction := tyche.NewAuction()
master := tyche.NewMaster(auction)
events := make(tyche.Producer)
master.AddProducer(events)
sa := tyche.NewSleepAgent(100, master.Auction)
master.AddConsumer(sa.Consumer())
... |
package strategy
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"pixivic/pixiv"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
)
// 根据输入关键字获取图片id
func KeywordStrategy(p *pixiv.Pixiv) {
baseGroup, _ := url.QueryUnescape(p.KeyWord)
keyword := p.KeyWord +
"%20" + strconv.Itoa(getM... |
package structs
import "encoding/xml"
type IssueComplete struct {
XMLName xml.Name `xml:"IssueComplete"`
Text string `xml:",chardata"`
Xmlns string `xml:"xmlns,attr"`
Ns2 string `xml:"ns2,attr"`
Ns3 string `xml:"ns3,attr"`
Request struct {
Text string `xml:",chardata"`
Branc... |
package main
import (
"context"
"fmt"
"gin-blog/models"
"gin-blog/pkg/logging"
"gin-blog/pkg/setting"
"gin-blog/routers"
"log"
"net/http"
"os"
"os/signal"
"time"
)
func init() {
setting.Setup()
models.Setup()
logging.Setup()
}
func main() {
//router := gin.Default()
//router.GET("/test", func(c *gin... |
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.4.1.dev1
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
package swagger
// victim object
type GetKillmailsKillmailIdKillmailHashVictim struct {
// alliance_id integer
AllianceId int32 `json:"alli... |
var cnt int
func helper(node, parent *TreeNode) bool {
if node == nil {
return true
}
left_result, right_result := helper(node.Left, node), helper(node.Right, node)
if left_result && right_result {
cnt += 1
if parent != nil && node.Val == parent.Val {
return true
}
}
return false
}
func countUnivalSu... |
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package core
import (
"io"
"log"
"net"
"regexp"
"strings"
"sync"
"github.com/OWASP/Amass/amass/utils"
)
// AmassConfig passes along optional Amass enumeration c... |
package say
import (
"strings"
)
var (
lessThanTwenty = map[int64]string {
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
7: "seven",
8: "eight",
9: "nine",
10: "ten",
11: "eleven",
12: "twelve",
13: "thirteen",
14: "fourteen",
15: "fifteen",
16: "sixteen",
17: "se... |
package wom
import (
"context"
"fmt"
"io"
"os"
cli "github.com/jawher/mow.cli"
)
type Input struct {
Context context.Context
}
type Output interface {
Print(...interface{})
Error(...interface{})
Fatal(int, ...interface{})
}
type Print func(...interface{})
type Fatal func(int, ...interface{})
type Exiter ... |
package api
import (
"errors"
"net/http"
gErrors "github.com/go-openapi/errors"
"github.com/go-openapi/loads"
"github.com/go-openapi/runtime"
"mingchuan.me/api/restapi"
"mingchuan.me/api/restapi/operations"
)
// API - alias of operations.MceAPI
type API = operations.MceAPI
// Server - API server instance, ge... |
package routers
import (
"github.com/barrydev/api-3h-shop/src/common/response"
"github.com/barrydev/api-3h-shop/src/controllers"
"github.com/gin-gonic/gin"
)
func BindStatistic(router *gin.RouterGroup) {
}
func BindStatisticAdmin(router *gin.RouterGroup) {
router.GET("/order", func(c *gin.Context) {
handle :... |
package main
import (
"fmt"
"github.com/rcanepa/cs-fundamentals/datast/linkedlist"
)
func main() {
l := linkedlist.New()
fmt.Println(l)
l.PushFront(10)
fmt.Println(l)
l.PushFront(20)
fmt.Println(l)
l.PushBack(30)
l.PushFront(0)
l.PushBack(50)
fmt.Println(l)
fmt.Println("Romoving ", l.PopBack().Value(), ... |
// Copyright (c) 2017 mgIT GmbH. All rights reserved.
// Distributed under the Apache License. See LICENSE for details.
package mqv
import (
"math/big"
"math/bits"
)
// SubtleIntSize returns the size of a SubtleInt that can store at least
// numBits of information.
func SubtleIntSize(numBits int) int {
const word... |
package stun
import (
"fmt"
"hash/crc32"
)
// FingerprintAttr represents FINGERPRINT attribute.
//
// https://tools.ietf.org/html/rfc5389#section-15.5
type FingerprintAttr byte
// CRCMismatch represents CRC check error.
type CRCMismatch struct {
Expected uint32
Actual uint32
}
func (m CRCMismatch) Error() str... |
package locker
import (
"context"
"fmt"
"math/rand"
"os"
"testing"
"time"
"github.com/jmoiron/sqlx"
)
func TestPostgresLockHandlesSessionError(t *testing.T) {
if os.Getenv("POSTGRES_ALREADY_RUNNING") == "" {
t.Skip()
}
db, err := sqlx.Open("postgres", testPostgresURI)
if err != nil {
t.Fatalf("unable... |
package server
import (
"bytes"
"errors"
"math"
"strconv"
"strings"
"github.com/mmcloughlin/geohash"
"github.com/tidwall/btree"
"github.com/tidwall/geojson"
"github.com/tidwall/gjson"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/internal/clip"
"github.com/tidwall/tile38/internal/collection"
"gith... |
package servicea_svc
import (
"context"
"log"
"net/http"
"os"
servicea "github.com/shihanng/gaegoasample/svc/servicea"
api "github.com/shihanng/gaegoasample/svc/servicea/gen/api"
apisvr "github.com/shihanng/gaegoasample/svc/servicea/gen/http/api/server"
goahttp "goa.design/goa/http"
"goa.design/goa/http/midd... |
package nginx
import (
"fmt"
"strings"
)
// ParseLBMethod parses method and matches it to a corresponding load balancing method in NGINX. An error is returned if method is not valid
func ParseLBMethod(method string) (string, error) {
method = strings.TrimSpace(method)
if method == "round_robin" {
return "", nil... |
package humanize
// TODO : iota support is very limited and bad
import (
"fmt"
"go/ast"
"go/token"
)
var (
lastConst Type
)
// Constant is a string represent of a function parameter
type Constant struct {
pkg *Package
Name string
Type Type
Docs Docs
Value string
caller *ast.CallExpr
index int
}
f... |
package main
import (
"crypto/tls"
"dynamicpath/lib/loadbalancer_api"
"flag"
"fmt"
"golang.org/x/net/http2"
"log"
"net/http"
"time"
)
var host string
var times, period int
var client *http.Client
var pathList *loadbalancer_api.PathListAll
func Start(host string) {
client = &http.Client{}
client.Transport =... |
package o3e
import (
"time"
"sync/atomic"
"testing"
"runtime"
"fmt"
)
// TODO start & stop
type SleepTask struct {
ExecCounter *int32
SleepDuration time.Duration
Dependency int
}
func (t *SleepTask) DepFactors() map[int]EmptyType {
deps := make(map[int]EmptyType)
deps[t.Depen... |
package gen
import (
"bytes"
"fmt"
"strings"
"unicode"
// "github.com/vugu/vugu/internal/html"
// "golang.org/x/net/html"
"github.com/vugu/html"
)
// compactNodeTree operates on a Node tree in-place and find elements with static
// contents and converts them to corresponding vg-html expressions with static ou... |
package handlebars
import (
"testing"
)
func TestStack(t *testing.T) {
stack := NewStack()
if stack.Len() != 0 {
t.Errorf("expected new stack to be empty")
}
one := stack.Pop()
if one != nil {
t.Errorf("expected Pop on empty stack to return nil")
}
stack.Push(NewBlockNode("aaa"))
if stack.Len() != 1 {... |
package packet
import (
"bytes"
"errors"
"github.com/cpusoft/goutil/asn1util"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/convert"
)
func ExtractSkiOid(oidPackets *[]OidPacket, fileByte []byte) (ski string, err error) {
for _, oidPacket := range *oidPackets {
if oidPacket.Oid == oidSubjectK... |
/*
* @lc app=leetcode.cn id=48 lang=golang
*
* [48] 旋转图像
*/
package main
import "fmt"
// @lc code=start
func rotate(matrix [][]int) {
n := len(matrix)
for i := 0; i < n/2; i++ {
for j := 0; j < (n+1)/2; j++ {
matrix[i][j], matrix[n-j-1][i], matrix[n-i-1][n-j-1], matrix[j][n-i-1] =
matrix[n-j-1][i], mat... |
package xmlsec
import (
"encoding/xml"
"testing"
"github.com/stretchr/testify/assert"
)
func TestEncryptMarshalTemplate(t *testing.T) {
emptyTemplate := NewEncryptedDataTemplate(
"http://www.w3.org/2001/04/xmlenc#aes128-cbc",
"http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p",
)
out, err := xml.MarshalInde... |
package main
import(
"fmt"
"strings"
"net/http"
"encoding/json"
)
// - - - - - - - Struct for ID or title request - - - - - - - - - - -
type Movie struct {
Title string `json:"Title"`
Genre string `json:"Genre"`
Language string `json:"Language"`
Country string `json:"Country"`
Runtim... |
package cidutil
import (
"fmt"
"testing"
c "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
mb "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase"
)
func TestFmt(t *testing.T) {
cids := map[string]string{
"cidv0": "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn",
"cidv1": "z... |
package ratelimit
import (
"math"
"sync"
"xg-go/log"
"xg-go/xg/common"
)
type redisCounterLimiter struct {
limit DistLimit
limitCount int32 // 内部使用,对 limit.count 做了 <0 时的转换
redisClient *common.RedisClient
once sync.Once // 退化为本地计数器的时候使用
localLim Limiter
//script string
}
func (lim *redisCounterL... |
package cmd
import (
"io/ioutil"
"fmt"
"os"
"strings"
"errors"
"github.com/spf13/cobra"
"github.com/ghodss/yaml"
)
var target string
var outputDir string
var cmdBuild = &cobra.Command{
Use: "convert",
Short: "convert project",
Run: nil,
}
var cmdConvert = &cobra.Command{
Use: "toJSON",
Short: "Con... |
package remote
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRequest(t *testing.T) {
c, _ := createTestClient(func(rw http.ResponseWriter, r *http.Request) {
assert.Equal(t, "application/vnd.pterodactyl.v1+json", r.Header.Get("Accept"))
assert.Equal(t, "application/... |
package queue
import (
"runtime"
"time"
timerate "golang.org/x/time/rate"
"gopkg.in/go-redis/rate.v4"
"gopkg.in/redis.v4"
)
type Redis interface {
SetNX(string, interface{}, time.Duration) *redis.BoolCmd
SAdd(key string, members ...interface{}) *redis.IntCmd
SMembers(key string) *redis.StringSliceCmd
Pipeli... |
package api
import (
"encoding/json"
"net/url"
"path"
"strings"
"github.com/valyala/fasthttp"
)
// Response from an API endpoint.
func Response(ctx *fasthttp.RequestCtx, code int, data interface{}) {
ctx.SetStatusCode(code)
if data == nil {
return
}
ctx.SetContentType("application/json")
switch d := dat... |
package chords
import "strings"
type Note int
var noteNames = [12]string{"C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B"}
func (n Note) String() string {
return noteNames[int(n)]
}
func (n Note) Inc() Note {
return n.Move(1)
}
func (n Note) Dec() Note {
return n.Move(-1)
}
func (n Note) Move(p... |
package main
import (
"C"
"fmt"
"io/ioutil"
"net/http"
_ "net/http/pprof"
)
var queue = make(chan string, 100)
var stop = make(chan struct{})
//export queueSize
func queueSize() int {
return len(queue)
}
//export PushUrl
func PushUrl(str string) {
queue <- str
}
//export Start
func Start() {
go func() {
... |
package main
type Response struct {
Status Status `json:"status"`
Outputs []*Outputs `json:"outputs"`
}
type Status struct {
Code int64 `json:"code"`
Description string `json:"description"`
}
type Outputs struct{
OutputData *OutputData `json:"data"`
Input ResponseInput `json:"input"`
}
type ResponseInput ... |
package components
import (
"fmt"
"html/template"
"github.com/GoAdminGroup/go-admin/modules/language"
"github.com/GoAdminGroup/go-admin/modules/utils"
"github.com/GoAdminGroup/go-admin/template/icon"
"github.com/GoAdminGroup/go-admin/template/types"
)
type ButtonAttribute struct {
Name string
Content ... |
package interactive
// An Action is implemented by the package user and used by the session.
type Action func(*Context) error
|
package report
func SearchCustomData(){
}
func ExportCustomSummary(){
}
func ExportCustomDetails(){
} |
// This program demonstrates attaching a fentry eBPF program to
// tcp_connect. It prints the command/IPs/ports information
// once the host sent a TCP SYN packet to a destination.
// It supports IPv4 at this example.
//
// Sample output:
//
// examples# go run -exec sudo ./fentry
// 2021/11/06 17:51:15 Comm Src addr... |
package lists
import (
"errors"
)
type Node struct {
Value interface{}
NextNode *Node
PrevNode *Node
}
type LinkedList struct {
Head *Node
}
func New(init interface{}) *LinkedList {
return &LinkedList{
Head: &Node{
Value: init,
NextNode: nil,
PrevNode: nil,
},
}
}
func (node *Node) remove() ... |
package defaults
import (
"testing"
"github.com/stretchr/testify/assert"
"k8s.io/utils/pointer"
"github.com/openshift/installer/pkg/ipnet"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/aws"
awsdefaults "github.com/openshift/installer/pkg/types/aws/defaults"
"github.com/... |
package main
import (
"fmt"
"net"
"net/rpc"
"errors"
"net/http"
)
type Hello struct {
}
func (h *Hello)Echo(args string, resp *string) error{
*resp = args + "world"
fmt.Println("Echo come in")
return nil
}
func main() {
var err = errors.New(" ")
err = rpc.Register(new(Hello))
if err != nil{
f... |
package spaghetti
import "github.com/lachee/noodle"
//Prepare some aliases, this will help us in the long run.
//Matrix alias of noodle.Matrix
type Matrix = noodle.Matrix
//Vector2 alias of noodle.Vector2
type Vector2 = noodle.Vector2
//Vector3 alias of noodle.Vector3
type Vector3 = noodle.Vector3
//Vector4 alias... |
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package worker
import (
"context"
"encoding/json"
"github.com/pkg/errors"
"github.com/diegobernardes/flare"
"github.com/diegobernardes/flare/infra/work... |
package microsvc
import (
"context"
"crypto/rsa"
"errors"
"fmt"
"net/http"
"net/url"
"strings"
stdjwt "github.com/dgrijalva/jwt-go"
"github.com/go-kit/kit/auth/jwt"
"github.com/go-kit/kit/endpoint"
)
// Claims - struct for jwt claims
type Claims struct {
stdjwt.StandardClaims
LastName string `json:"LNAME... |
package conf
const (
MONGODB_HOST = "localhost:27017"
DB_NAME = "twitter"
REDIS_HOST = "localhost:6379"
REDIS_EX = 60 * 60 * 24
SIGNING_KEY = "secret"
)
|
/*
Copyright 2021 CodeNotary, Inc. 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 i... |
package main
import(
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
"time"
"xorm.io/core"
)
var engine *xorm.Engine
type User struct {
Id int64
Name string `xorm:"varchar(25) not null unique 'usr_name'"`
CreateAt time.Time `xorm:"created"`
GroupId int64 `xorm:index`
}
type Group struct ... |
package cmd
import (
"fmt"
"github.com/benjlevesque/task/pkg/cli"
"github.com/benjlevesque/task/pkg/db"
"github.com/benjlevesque/task/pkg/tasks"
"github.com/benjlevesque/task/pkg/util"
"github.com/spf13/cobra"
)
var addCmd = &cobra.Command{
Use: "add",
Short: "Adds a task",
ValidAr... |
// Copyright 2020
//
// 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, softwar... |
package main
import (
"./proto"
"context"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
"google.golang.org/grpc"
"log"
"math/rand"
"net/http"
"strconv"
"time"
)
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
// De... |
package feedback
import (
"github.com/therudite/api/errors"
"github.com/therudite/api/models/feedback"
"github.com/therudite/api/services/feedback/utils"
"github.com/gin-gonic/gin"
"reflect"
)
type HTTPTransportInterface interface {
// RequestMapper takes an interface as a param and binds the request to that in... |
package core
import (
"jmcs/core/library"
)
func Start() {
library.Run()
}
|
package ddl
import (
"database/sql"
"errors"
"github.com/iftsoft/gopack/lla"
"reflect"
)
const (
ddlTimeReturnError = "SQL %s works %d mcs; Return error: %v"
ddlTimeRowsFetched = "SQL %s works %d mcs; Rows fetched: %d"
ddlTimeRowsAffected = "SQL %s works %d mcs; Rows affected:%d"
)
const (
ddl_Select = "Sel... |
package main
type Node struct {
Val int
Left *Node
Right *Node
Next *Node
}
func connect(root *Node) *Node {
dfs(root, nil)
return root
}
func dfs(node, next *Node) {
if node != nil {
node.Next = next
dfs(node.Left, node.Right)
if node.Next != nil {
dfs(node.Right, node.Next.Left)
} else {
df... |
package demo
import (
"github.com/apache/thrift/lib/go/thrift"
"github.com/go-xe2/xthrift/builder/test/build/go/com/mnyun/types"
"github.com/go-xe2/xthrift/lib/go/xthrift"
"golang.org/x/net/context"
)
type HelloServiceClient struct {
*xthrift.TXClient
}
func NewHelloServiceClient(trans thrift.TTransport, in, ou... |
package repository
import (
"github.com/gerardmrk/erogen/svc/user/database/postgres"
)
type UserRepo struct {
DB postgres.UserDB
}
|
package cli
import (
. "github.com/logrusorgru/aurora"
"github.com/mattn/go-colorable"
"github.com/mikerapa/FolderWatcher"
"log"
)
func init() {
// create colorize and set the output of log
log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime))
log.SetOutput(colorable.NewColorableStdout())
}
func recursiveBoolT... |
package get
import (
"github.com/spf13/cobra"
"github.com/makkes/gitlab-cli/api"
"github.com/makkes/gitlab-cli/cmd/get/accesstokens"
"github.com/makkes/gitlab-cli/cmd/get/issues"
"github.com/makkes/gitlab-cli/cmd/get/jobs"
"github.com/makkes/gitlab-cli/cmd/get/logs"
"github.com/makkes/gitlab-cli/cmd/get/output... |
package gobwc
import (
"bytes"
"io"
"sync"
"time"
)
// BucketWriteCloser is a data structure that wraps an io.WriteCloser, but groups the written
// new-line terminated lines by buckets, combining lines written to the same bucket if possible. A
// bucketed line starts with the at-sign, @, followed by the bucket ... |
//
// MinIO Object Storage (c) 2021 MinIO, 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 l... |
package main
import "fmt"
func main() {
a := []int{2, 4, 4, 4}
b := singleNumber(a)
fmt.Println(b)
}
func singleNumber(nums []int) int {
res := 0
for _, num := range nums {
res = res ^ num
}
return res
}
|
package bili
import (
"fmt"
"testing"
)
func TestAvailableVideo(t *testing.T) {
url := "https://bbq.bilibili.com/video/?id=1583402526078074470" // https://b23.tv/Bisisw https://www.bilibili.com/video/BV1p5411879s //https://m.bilibili.com/bangumi/play/ss28777 https://bbq.bilibili.com/video/?id=1583402526078074470
... |
/*
Introduction
I think everyone agrees that nice pictures have to have a nice frame. But most challenges on this site about ASCII-Art just want the raw picture and don't care about it's preservation.
Wouldn't it be nice if we had a program that takes some ASCII-Art and surrounds it with a nice frame?
The Challenge
W... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.