text stringlengths 11 4.05M |
|---|
package models
import (
"encoding/json"
"flag"
"fmt"
"github.com/APTrust/exchange/constants"
"github.com/APTrust/exchange/util/fileutil"
"github.com/op/go-logging"
"os"
"path/filepath"
)
type WorkerConfig struct {
// This describes how often the NSQ client should ping
// the NSQ server to let it know it's s... |
package main
import (
"fmt"
"github.com/sam-blackfly/dabba/internal/colors"
)
func main() {
fmt.Printf("%s All checks %s\n", colors.Info("✓"), colors.Success("PASSED"))
}
|
package fileupload
import (
"mime/multipart"
"net/http"
"strings"
"github.com/pkg/errors" // external dependency
)
func isFileImage(mimetype string) bool {
mimetype = strings.ToLower(mimetype) // make it case insensitive
var types []string = []string{"image/jpeg", "image/png", "image/gif"}
return inSlice(type... |
package jqrepl
import (
"fmt"
"io"
"os"
"github.com/ashb/jqrepl/jq"
"gopkg.in/chzyer/readline.v1"
)
const promptTemplate = "\033[0;36m%3d »\033[0m "
const outputTemplate = "\033[0;34m$out[%d]\033[0m = %s\n\n"
var (
jvStringName, jvStringValue, jvStringOut, jvStringUnderscore, jvStringDunderscore *jq.Jv
)
fun... |
package pie_test
import (
"github.com/elliotchance/pie/v2"
"github.com/stretchr/testify/assert"
"testing"
)
func TestMap(t *testing.T) {
for _, test := range selectTests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.expectedMap, pie.Map(test.ss, func(a float64) float64 {
return a + 5.2
}))
}... |
package ca
import (
"crypto/x509"
"math/big"
)
type Datastore interface {
Store(cert *x509.Certificate) error
StoreCAKey(privateKey interface{}) error
StoreCACert(cert *x509.Certificate) error
GetCAKey() (interface{}, error)
GetCACert() (*x509.Certificate, error)
FindByFingerprint(fp string) (*x509.Certificat... |
// Copyright 2015 Walter Schulze
//
// 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... |
/*
* @lc app=leetcode.cn id=375 lang=golang
*
* [375] 猜数字大小 II
*/
package main
// @lc code=start
func max(x, y int) int {
if x > y {
return x
} else {
return y
}
}
func getMoneyAmount(n int) int {
f := make([][]int, n+1)
for i := 0; i < len(f); i++ {
f[i] = make([]int, n+1)
}
for i := n - 1; i > 0; i-... |
package alerts
import (
"errors"
"strconv"
"strings"
"github.com/dennor/go-paddle/events/types"
"github.com/dennor/phpserialize"
)
const NewAudienceMemberAlertName = "new_audience_member"
type AudienceMemberProducts []int64
func (n *AudienceMemberProducts) UnmarshalText(data []byte) error {
if len(data) == 0... |
package main
import (
"testing"
)
func TestTurning(t *testing.T) {
tests := []struct {
From, To Heading
Direction
}{
{From: North, Direction: Right, To: East},
{From: North, Direction: Left, To: West},
{From: East, Direction: Right, To: South},
{From: East, Direction: Left, To: North},
{From: South, ... |
package commandlineprocessors
import (
"errors"
"fmt"
"io/ioutil"
"os"
"github.com/BrunoMCBraga/HayMaker/globalstringsproviders"
"github.com/BrunoMCBraga/HayMaker/haymakerengines"
"github.com/BrunoMCBraga/HayMaker/haymakerutil"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.... |
package web
import (
"fmt"
"gosdk-example/sdkconnector"
"net/http"
)
//OrgSetupArray is an array of setups of organizations.
type OrgSetupArray []sdkconnector.OrgSetup
//Serve opens the API for http requests.
func Serve(setups OrgSetupArray) {
http.HandleFunc("/users", setups.EnrollUser)
http.HandleFunc("/chann... |
/*
Copyright 2020 Kamal Nasser 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 in wr... |
package orm
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConstraint(t *testing.T) {
for _, pgType := range []string{PgConstraintFK, PgConstraintPK, PgConstraintUnique} {
t.Run("ForeignKey", func(t *testing.T) {
constraint := &Constraint{
Type: pgType,
ColumnName: ... |
package admin
import (
// "github.com/astaxie/beego"
)
type LinkController struct {
baseController
}
func (this *LinkController) Index() {
this.Layout = "admin/layout.tpl"
this.LayoutSections = make(map[string]string)
this.LayoutSections["Sidebar"] = "admin/layout_sidebar.tpl"
this.TplNames = "admin/link.tpl"
}... |
package model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
//Create Struct
type Person struct {
_id primitive.ObjectID `json:”id,omitempty”`
FirstName string `json:”firstname,omitempty”`
LastName string `json:”lastname,omitempty”`
Email string `json:”emai... |
package tasks
import (
"encoding/json"
"fmt"
)
// UnmarshalJSON handles unmarshaling null, a single string, or an
// array of strings to OptionalStringArray.
func (sa *OptionalStringArray) UnmarshalJSON(data []byte) error {
switch data[0] {
case 'n':
if string(data) != "null" {
return fmt.Errorf("unexpected ... |
package etw
import (
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common/fmtstr"
"github.com/elastic/beats/v7/libbeat/processors"
"github.com/elastic/beats/v7/libbeat/processors/add_formatted_index"
"github.com/narph/etwbeat/config"
"github.com/pkg/errors"
"syscall"
)
const (... |
package slackintegration
import (
"encoding/json"
"fmt"
"golang.org/x/net/websocket"
"io/ioutil"
"log"
"net/http"
"sync/atomic"
"github.com/sur5an/WebhookSlackBotInGoLang/utils"
)
type SlackClient struct {
webSocket *websocket.Conn
memberChannels channelList
myID string
}
type responseRtmSt... |
package main
import (
"fmt"
"math"
)
type SQUARE struct {
length float64
wide float64
}
type CIRCLE struct {
radious float64
}
func main() {
s1 := SQUARE{
length: 34,
wide: 75,
}
c1 := CIRCLE{
radious: 19.34,
}
fmt.Println(s1, c1)
s1.AREA()
c1.AREA()
}
func (s SQUARE) AREA() {
fmt.Println("To... |
package reset
import (
"github.com/devspace-cloud/devspace/pkg/util/factory"
"github.com/spf13/cobra"
)
// NewResetCmd creates a new cobra command
func NewResetCmd(f factory.Factory) *cobra.Command {
resetCmd := &cobra.Command{
Use: "reset",
Short: "Resets an cluster token",
Long: `
#######################... |
package m3u8
//import (
// "fmt"
// "os"
// "path"
// "sync"
// "time"
//)
////callbacks
//type OnM3u8Generated func(m3u8FullName string, TsArray []*Ts)
//type OnGeneratorError func(gen *M3u8Generator, err error)
//type M3u8Generator struct {
// Sequence int
// TsArray []*Ts
// M3u8Lock sync.Mutex
// running ... |
package helper
import (
"testing"
)
type TestLevelCost struct {
SilverCost_QiangHua int32
SkillCostExp_Qianghua int32
PetCostExp_QiangHua int32
}
func TestLoadStruct(t *testing.T) {
LoadAllConfig("C:/home/work/goserver/assets")
cost := &TestLevelCost{}
LoadStructByFile("conf_level_cost.csv", "19", cost)
... |
package main
import (
"flag"
"net/http"
"github.com/Sirupsen/logrus"
"github.com/labstack/echo"
mw "github.com/labstack/echo/middleware"
"github.com/mikerjacobi/poker/server/controllers"
"github.com/spf13/viper"
"gopkg.in/mgo.v2"
)
// Handler
func hello(c *echo.Context) error {
return c.String(http.StatusOK... |
// Copyright 2023 Google LLC. 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 applica... |
/*
Copyright 2020 The Alameda 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, sof... |
package redisLayer
import (
"fmt"
"os"
"testing"
)
var testKeys []string
var testValues []string
func TestMain(m *testing.M) {
setup()
code := m.Run()
teardown()
os.Exit(code)
}
func setup() {
testKeys = append(testKeys, "Apple", "Orange", "Banana")
testValues = append(testValues, "Red", "Orange", "Yellow"... |
package main
import (
"backend/db"
"backend/handler"
"backend/mux"
"flag"
"fmt"
"os"
"strconv"
)
import "net/http"
//import _ "github.com/lib/pq"
type config struct {
dbURL string
dbName string
httpPort int
corsOrigin string
}
func main() {
fmt.Println("Starting College Control Backend...")
... |
// Copyright 2023 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 quit
func SafeExit() {
safeExit()
}
|
// Copyright 2017 Santhosh Kumar Tekuri. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package jsonschema_test
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"testing"
"github.com/ory/jsonschema/v3"
)
func powerOfExt() jsonsche... |
package worker
import (
"fmt"
"path"
"reflect"
"strings"
)
// const childEnvName = "CHILD_ID"
type Empty struct{}
var pkgName = path.Base(reflect.TypeOf(Empty{}).PkgPath())
var ChildEnvName = fmt.Sprintf("%s_CHILD_ID", strings.ToUpper(pkgName))
|
package main
import (
"github.com/nsf/termbox-go"
)
type Gameplay struct {}
func Clamp(value, min, max int) int {
if value < min {
return min
}
if value > max {
return max
}
return value
}
func (scene *Gameplay) Render(game *Game) {
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
... |
package utils
import (
"encoding/binary"
"encoding/json"
"fmt"
"go_code/project1/94chatroom/common/message"
"net"
)
//这里将这些方法关联到结构体中
type Transfer struct {
Conn net.Conn
Buf [8096]byte //这是传输时,使用缓存
}
//读取消息函数
func (this *Transfer) ReadPkg() (mes message.Message, err error) {
//buf := make([]byte, 8096)
//1... |
package task
import (
"fmt"
"testing"
)
func TestGetGameDetailInfo(t *testing.T) {
detail, err := GetGameDetailInfo("http://www.eshop-switch.com/game/3005.html")
detail.InsertToDB()
fmt.Println(detail, err)
}
|
package classfile
// ConstantNameAndTypeInfo
// 该字段的结构如下:
/**
ConstantNameAndType_info{
tag u1
index u2 该字段的方法名称常量索引
index u2 该字段的描述符号常量索引
}
1)类型描述符。
①基本类型byte、short、char、int、long、float和double的描述符
是单个字母,分别对应B、S、C、I、J、F和D。注意,long的描述符是J
而不是L。
②引用类型的描述符是L+类的完全限定名+分号。
③数组类型的描述符是[+数组元素类型描述符。
2)字段描述... |
package vminterface
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
)
type Message struct {
to *common.Address
from common.Address
nonce uint64
amount, price, gasLimit *big.Int
data []byte
checkNonce bool
}... |
package cbnet
import (
"fmt"
"github.com/cloud-barista/cb-larva/poc-cb-net/internal/file"
cblog "github.com/cloud-barista/cb-log"
"github.com/sirupsen/logrus"
"os"
"os/exec"
"path/filepath"
"strings"
)
// CBLogger represents a logger to show execution processes according to the logging level.
var CBLogger *lo... |
package config
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
)
var Config Conf
type Conf struct {
Debug bool
AppKey string
Db Db
Lvdb string
Sms Sms
Wechat Wechat
}
type Db struct {
Url string
}
type Sms struct {
Key string
Secret string
Sign string
RegTplCode strin... |
package virtual_security
import "github.com/google/uuid"
func newUUIDGenerator() iUUIDGenerator {
return &uuidGenerator{}
}
type iUUIDGenerator interface {
generate() string
}
type uuidGenerator struct{}
func (u *uuidGenerator) generate() string {
return uuid.NewString()
}
|
package testdata
import (
"github.com/frk/gosql/internal/testdata/common"
)
type InsertResultErrorInfoHandlerSingleQuery struct {
User *common.User2 `rel:"test_user:u"`
Result *common.User2
erh common.ErrorInfoHandler
}
|
package main
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"os"
"github.com/senslabs/alpha/sens/httpclient"
"github.com/senslabs/alpha/sens/logger"
)
type AuthRequestBody struct {
Medium string
MediumValue string
}
type TwilioSendOtpResponse struct {
ServiceSid string `json:"service_s... |
package main
type ListNode struct {
Val int
Next *ListNode
}
func main() {
l1 := makeListNode([]int{1, 8})
l2 := makeListNode([]int{0})
ret := addTwoNumbers(l1, l2)
for {
println(ret.Val)
ret = ret.Next
if ret == nil {
break
}
}
}
func makeListNode(is []int) *ListNode {
if len(is) == 0 {
ret... |
// Copyright 2020 Thomas.Hoehenleitner [at] seerose.net
// Use of this source code is governed by a license that can be found in the LICENSE file.
package decoder
import (
"encoding/binary"
"fmt"
"io"
"github.com/rokath/trice/internal/id"
)
// Esc is the Decoder instance for esc encoded trices.
type Esc struct ... |
package main
import (
"fmt"
"runtime"
)
var mem runtime.MemStats
func PrintMemory() {
runtime.ReadMemStats(&mem)
fmt.Printf(
"Alloc: %d KB, TotalAlloc: %d KB, HeapAlloc: %d KB, HeapSys: %d KB\n",
mem.Alloc/1024,
mem.TotalAlloc/1024,
mem.HeapAlloc/1024,
mem.HeapSys/1024,
)
}
func main() {
PrintMemory... |
package nfs
import (
"context"
"fmt"
nfsstoragev1alpha1 "github.com/johandry/nfs-operator/api/v1alpha1"
"github.com/johandry/nfs-operator/resources"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.... |
package main
import "fmt"
func main() {
scoreMap := make(map[string]int, 8)
scoreMap["Tom"] = 90
scoreMap["Shure"] = 100
fmt.Println(scoreMap)
fmt.Println(scoreMap["Shure"])
fmt.Printf("type of a:%T\n", scoreMap)
userInfo := map[string]string{
"username": "Shure",
"password": "123456",
}
fmt.Println(use... |
package tuntap
import (
"os"
"os/exec"
"strconv"
"syscall"
"unsafe"
)
type Tap struct {
Fd int
Mtu int
Name string
}
type ifreq struct {
Name [syscall.IFNAMSIZ]byte
Flags uint16
}
func ioctl(a1, a2, a3 uintptr) error {
if _,_,errno := syscall.Syscall(syscall.SYS_IOCTL, a1, a2, a3); errno != 0 {
return ... |
package main
import (
"math/rand"
"strconv"
)
const (
redisKeyChatIDByTokenPrefix = "cibt_"
redisKeyTokenByChatIdPrefix = "tbci_"
redisKeyChatIDByUserIDPrefix = "cibui_"
)
func getChatIDByTokenKey(token string) string {
return redisKeyChatIDByTokenPrefix + token
}
func getTokenByChatIDKey(cha... |
package action
import (
"github.com/agiledragon/trans-dsl"
"github.com/agiledragon/trans-dsl/test/context"
)
type StubConnectAbc struct {
}
func (this *StubConnectAbc) Exec(transInfo *transdsl.TransInfo) error {
stubInfo := transInfo.AppInfo.(*context.StubInfo)
stubInfo.Y = 2
return nil
}
func (this *StubConne... |
package main
import "fmt"
func main() {
var pilihan string = "Y";
for pilihan == "Y" {
fmt.Print("Jalankan aplikasi [Y/t]?");
fmt.Scanln(&pilihan);
}
fmt.Print("Sampai jumpa! Tekan enter untuk keluar dari aplikasi");
fmt.Scanln();
}
|
package provider
import (
"github.com/gookit/gcli/v3"
"github.com/ovrclk/akash/x/provider/config"
"github.com/ovrclk/akash/x/provider/types"
"github.com/ovrclk/akcmd/client"
"github.com/ovrclk/akcmd/flags"
"github.com/pkg/errors"
)
func TxCmd() *gcli.Command {
cmd := &gcli.Command{
Name: "provider",
Desc: ... |
package main
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestInitConfig(t *testing.T) {
var cfg *appConfig
require.NotPanics(t, func() {
os.Setenv("APP_HTTPSERVER_LISTENADDRESS", ":9988") // nolint: errcheck, gosec
cfg = initConfig("../../configs/trigger-api/default.yaml")
})
re... |
/*
Bytebeat is a style of music one can compose by writing a simple C program that's output is piped to aplay or /dev/dsp.
main(t){for(;;t++)putchar(((t<<1)^((t<<1)+(t>>7)&t>>12))|t>>(4-(1^7&(t>>19)))|t>>7);}
There is a good deal of information on the bytebeat site, a javascript implementation, and more demos and exa... |
package main
type WordDictionary struct {
next map[int32]*WordDictionary
isEnd bool
}
/** Initialize your data structure here. */
func Constructor() WordDictionary {
return WordDictionary{next: make(map[int32]*WordDictionary)}
}
func (this *WordDictionary) AddWord(word string) {
node := this
for _, c := rang... |
package server
import (
"context"
"github.com/spf13/cobra"
"github.com/tsaikd/KDGoLib/cliutil/cobrather"
"github.com/tsaikd/go-grpc-echo/logger"
"github.com/tsaikd/go-grpc-echo/server"
)
var flagAddr = &cobrather.StringFlag{
Name: "server.addr",
Default: ":8080",
Usage: "gRPC server listen port",
}
var... |
package main
import (
"encoding/json"
"fmt"
"github.com/3pings/acigo/aci"
"github.com/3pings/chiveAgent/utility"
"log"
"os"
"time"
)
func main() {
var nodeInfo = make(map[string][]string)
token := os.Getenv("SPARKTOKEN")
roomID := os.Getenv("SPARKROOMID")
// Get environment variables for APIC login
de... |
package main
import (
"fmt"
"github.com/jackytck/projecteuler/tools"
)
func nthPrime(n int) int {
k := 2
for {
primes := tools.SievePrime(n * k)
if len(primes) >= n {
return primes[n-1]
}
k *= 2
}
}
func main() {
fmt.Println(nthPrime(6))
fmt.Println(nthPrime(10001))
}
// The nth prime.
|
package main
import (
"encoding/json"
"fmt"
"labix.org/v2/mgo"
_ "labix.org/v2/mgo/bson"
)
type Person struct {
Name string
Phone string
}
type Phone struct {
Age int32
Id int32
ImageUrl string
Name string
Snippet string
}
func main344() {
session, err := mgo.Dial... |
// pkg/reflect/deepequal.
package main
import (
"fmt"
"reflect"
)
type T struct {
Name string `json:"name"`
}
func main() {
t := &T{"foo"}
var nt interface{} = &T{"foo"}
fmt.Println(reflect.DeepEqual(t, nt))
}
|
package common
import (
"testing"
)
var (
rA = NewStdRole("role-a")
pA = NewFirstP("dsa21`212e", "permission-a")
rB = NewStdRole("role-b")
pB = NewFirstP("asd2324323432", "permission-b")
rC = NewStdRole("role-c")
pC = NewFirstP("12312dsfsd", "permission-c")
auth *Auth
)
func TestauthPrepare(t *testing.T) {
... |
package geom
import (
"fmt"
"sort"
)
func convexHull(g Geometry) Geometry {
if g.IsEmpty() {
// Any empty geometry could be returned here to to give correct
// behaviour. However, to replicate PostGIS behaviour, we always return
// the original geometry.
return g.Force2D()
}
pts := convexHullPointSet(g)
... |
package ssvgc_test
import (
"os"
"testing"
"github.com/llgcode/draw2d/draw2dimg"
"github.com/stephenwithav/ssvgc"
)
func TestParseSVG(t *testing.T) {
if testing.Short() {
t.Skip("Skipping lengthier tests during short test run.")
}
var tests = []string{
"rectfull",
"rectfullwithtext",
"tworects",
"t... |
package gogo
import (
"bytes"
"encoding/gob"
"encoding/json"
"encoding/xml"
"io/ioutil"
"mime/multipart"
"net/http"
"strconv"
"sync"
"gopkg.in/mgo.v2/bson"
"github.com/golib/httprouter"
)
type AppParams struct {
mux sync.RWMutex
request *http.Request
params httprouter.Params
rawBody []byte
rawE... |
package tsing
import (
"bytes"
"encoding/json"
"errors"
"log"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
)
// 事件处理器
func eventHandler(e *Event) {
log.SetFlags(log.Lshortfile)
log.Println(e.Status)
log.Println(e.Message)
log.Println(e.Source)
for k := range e.Trace {
log.Println(" ",... |
package point
// Point : Pixel of field
type Point struct {
X int
Y int
Str string
IsAlive bool
}
// NewPoint : Constructor of Point
// @Param X X座標
// @param Y Y座標
// @Param str 文字
// @Param isAlive 生きているかどうか
// return Point
func NewPoint(x, y int, str string, isAlive bool) Point {
return Point{... |
package daemon
import (
"bytes"
"encoding/gob"
"net"
)
const CMD_GET = 1
const CMD_PUT = 2
const CMD_UNPIN = 3
const CMD_PIN = 4
type Command struct {
Command int
Arg string
}
const ERROR = -1
const OK = 1
type Response struct {
ResultCode int
Result string
}
func Encode(c *net.UDPConn, addr *net.U... |
func deleteDuplicates(head *ListNode) *ListNode {
var pre, ret, tail *ListNode
for head != nil{
if (pre == nil || pre.Val != head.Val) && (head.Next == nil || head.Next.Val != head.Val ){
if ret == nil{
ret = head
tail = head
} else {
... |
package cvetool
import (
"glsamaker/pkg/app/handler/authentication"
"glsamaker/pkg/app/handler/authentication/utils"
"glsamaker/pkg/cveimport"
"net/http"
)
// Show renders a template to show the landing page of the application
func Update(w http.ResponseWriter, r *http.Request) {
user := utils.GetAuthenticatedU... |
/*
* @lc app=leetcode.cn id=337 lang=golang
*
* [337] 打家劫舍 III
*/
package main
import (
"fmt"
)
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
/*
// DFS
// 4 个孙子偷的钱 + 爷爷的钱 VS 两个儿子偷的钱 哪个组合钱多,就当做当前节点能偷的最大钱数。
// 这就是动态规划里面的最优子结构
func rob(root *TreeNode) int {
if root == nil {
return 0
}
... |
// Copyright (C) 2015 Nicolas Lamirault <nicolas.lamirault@gmail.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 ... |
package param
import (
"ego/src/commons"
"fmt"
"strconv"
)
func selByPageDao(page, rows int) []TbItemParam {
r, err := commons.Dql("select * from tb_item_param limit ?,?", rows*(page-1), rows)
if err != nil {
fmt.Println(err)
return nil
}
ts := make([]TbItemParam, 0)
for r.Next() {
var t TbItemParam
... |
package linkedlists
// O(N) too much work
func middle(l *ListNode) {
cur := l
var prev *ListNode
for cur.next != nil {
cur.value = cur.next.value
prev = cur
cur = cur.next
}
if prev != nil {
prev.next = nil
}
}
func middleConstant(l *ListNode) {
if l.next != nil {
l.value = l.next.value
l.next = ... |
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Sample tiny demonstrates overall program structure:
// a main package with a main function that calls appengine.Main.
package main
import "google.golang.org/... |
package main
import (
"os"
"fmt"
"github.com/olekukonko/tablewriter"
)
func (this *Application) ProjectSearchAction(args []string) {
projects, err1 := this.Client.GetProjects()
if err1 != nil {
fmt.Printf("Unable to get projects: %v\n", err1)
os.Exit(1)
}
// fmt.Printf("# Projects\n")
// fmt.Printf("\n")
... |
/*
A semiprime is a composite number that is the product of two primes. Apart from these two primes, its only other proper (non-self) divisor is 1.
The two prime factors of a semiprime can be the same number (e.g. the semiprime 49 is the product of 7x7). A semiprime that has two distinct prime factors is called a squ... |
/*
Copyright 2022 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 model
// Question - a struct to rep question database model
type Question struct {
BaseModel
CourseID uint `json:"course_id" gorm:"not null;type:int(15)"`
Question string `json:"question" gorm:"type:varchar(200)"`
OptionA string `json:"option_a" gorm:"type:varchar(200)"`
OptionB string `json:"opti... |
package model
import "github.com/jinzhu/gorm"
type User struct {
Id uint32 `gorm:"primary_key;auto_increment" json:"id"`
Username string `gorm:"size:64" json:"username"`
Password string `gorm:"size:225" json:"password"`
}
func (User) TableName() string {
return "user"
}
func initUser(db *gorm.DB) error {
var e... |
//+build !amd64 noasm
package assembler
func Saxpy(a float32, X []float32, Y []float32) {
for i := range X {
Y[i] += a * X[i]
}
}
|
package config
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
)
//GetConfig config
func GetConfig() (*Configuration, error) {
filename := "./config/config.json"
flag.Parse()
data, err := ioutil.ReadFile(filename)
if err != nil {
fmt.Print(err)
}
var configuration Configuration
err = json.Unmarshal(... |
/*
* Copyright @ 2020 - present Blackvisor Ltd.
*
* 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 plant
import (
"time"
)
var plants map[int64]Plant
func init() {
plants = make(map[int64]Plant)
}
type Plant struct {
PlantId int64
CreatedAt time.Time
}
func Add(p Plant) (err error, plantId int64) {
plants[p.PlantId] = p
return nil, p.PlantId
}
func Update(p Plant) {
plants[p.PlantId] = p
}
|
// Copyright (c) 2018 ef-ds
//
// 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, distrib... |
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
//
// 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 ... |
// Copyright 2018 Google 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... |
package protobufserializer
import (
"encoding/base64"
"github.com/golang/protobuf/proto"
"github.com/juju/errors"
)
// ProtobufStateSerializer is a StateSerializer that uses base64 encoded protobufs.
type ProtobufStateSerializer struct{}
// Serialize serializes the given struct into bytes with protobuf, then bas... |
package search
import (
"testing"
"github.com/sko00o/leetcode-adventure/binary-search/test"
)
func TestSearch(t *testing.T) {
test.CommonTest(t, search)
}
|
package transport
import (
"context"
"fmt"
"net"
"github.com/mingo-chen/wheel-minirpc/core"
"github.com/mingo-chen/wheel-minirpc/ext"
)
func TcpServer(ctx context.Context, port int) error {
lister, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port))
if err != nil {
return err
}
for {
conn, err :=... |
package router
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"testing/quick"
"github.com/pachyderm/pachyderm/src/etcache"
"github.com/pachyderm/pachyderm/src/storage"
"github.com/pachyderm/pachyderm/src/traffic"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
... |
package restful
// import (
// "github.com/freelifer/gohelper/pkg/log"
// "github.com/freelifer/gohelper/server"
// "github.com/gin-gonic/gin"
// "strconv"
// )
// func getProjects(c *gin.Context) {
// mark := CreateMark()
// server := server.NewProjectServer(mark)
// respone := server.List()
// if !respone.I... |
package codewizards
type World struct {
TickIndex int
TickCount int
Width, Height float64
Players []*Player
Wizards []*Wizard
Minions []*Minion
Projectiles []*Projectile
Bonuses []*Bonus
Buildings []*Building
Trees []*Tree
}
func (w *World) GetMyPlayer() *Player... |
package api
import (
"log"
"net/http"
"strconv"
"strings"
"tradingview_udf_binance_go/crawler"
"tradingview_udf_binance_go/model"
"github.com/labstack/echo"
)
// func Filter(arr []model.SymbolInfo, f func(model.SymbolInfo) bool) []model.SymbolInfo {
// result := make([]model.SymbolInfo, 0)
// for _, v := ra... |
/*
* @lc app=leetcode.cn id=59 lang=golang
*
* [59] 螺旋矩阵 II
*/
package main
import "fmt"
// @lc code=start
func generateMatrix(n int) [][]int {
a := make([][]int, n)
for i := 0 ; i < n ; i++ {
a[i] = make([]int, n)
}
k := 1
l := 0
r := n -1
b := n -1
t := 0
det := n * n
for k <= det {
for i := t ; ... |
package acronym
import (
"strings"
"unicode"
)
const testVersion = 1
func abbreviate(l string) string {
a := ""
before := rune('_')
// string to rune array
for _, r := range l {
if unicode.IsUpper(r) {
a += string(r)
} else if unicode.IsSpace(before) ||
before == rune('-') {
a += string(r)
} els... |
package pricing
import (
"fmt"
"math/big"
"github.com/dustin/go-humanize"
)
var (
intZero = big.NewInt(0)
intOne = big.NewInt(1)
ratZero = big.NewRat(0, 1)
ratOne = big.NewRat(1, 1)
)
// Returns a new big.Int set to the ceiling of x.
func ratCeil(x *big.Rat) *big.Int {
z := new(big.Int)
m := new(big.Int)... |
package wrappers
import (
"bytes"
"crypto/cipher"
"net"
"github.com/juju/errors"
"go.uber.org/zap"
)
// StreamCipher is a wrapper which encrypts/decrypts stream with AES-CTR
// (as a part of obfuscated2 protocol).
type StreamCipher struct {
encryptor cipher.Stream
decryptor cipher.Stream
conn StreamRead... |
package controller
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUniqueQueue(t *testing.T) {
queue := newUniquePhaseNodeQueue()
assert.True(t, queue.empty())
phaseNodeA := phaseNode{nodeId: "node-a"}
queue.add(phaseNodeA)
assert.Equal(t, 1, queue.len())
assert.False(t, queue.empty())
q... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"time"
)
type Config struct {
Repository string
Branch string
Dir string
}
func GetJsonConfig(configFile string, config interface{}) error {
jsonFile, err := os.Open(configFile)
if err != nil {
return err
}... |
package scsprotov1
func (c *scsv1) End() {
c.mqttc.Unsubscribe("server")
c.concurrentRoutinesPool.AcquireMany(c.cb.MaxConcurrent)
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.