text stringlengths 11 4.05M |
|---|
package server
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"github.com/sjbodzo/review_system/db"
"github.com/sjbodzo/review_system/queue"
"github.com/sjbodzo/review_system/review"
)
// AddReviewResponse stores the response to the request
type AddReviewResponse struct {
Success bool `json:"succ... |
package telegram
import (
"context"
"github.com/strongo/db"
)
// TgChatInstanceDal is DAL for telegram chat instance entity
type TgChatInstanceDal interface {
GetTelegramChatInstanceByID(c context.Context, id string) (tgChatInstance ChatInstance, err error)
NewTelegramChatInstance(chatInstanceID string, chatID in... |
package models
import (
"errors"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type UndefinedComputer struct {
ID string
ClientInfo ClientInfo
}
func (UndefinedComputer) Get(session *mgo.Session, id string) (undefinedComputer UndefinedComputer, err error) {
collection, err := getCollection(session, MONGO_... |
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there")
}
func speaker(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "i am shiv pratap verma")
}
func nextItem(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, " welcome to... |
/*
* Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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://... |
package intercom
import (
"fmt"
"strings"
)
// MessageService handles interactions with the API through an MessageRepository.
type MessageService struct {
Repository MessageRepository
}
// MessageTemplate determines the template used for email messages to Users or Contacts (plain or personal)
type MessageTemplate... |
/*
* 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
import (
"net/url"
"strings"
"encoding/json"
"fmt"
)
type PlanetaryInteractionApi struct {
Configuration *Configuration
... |
package dbadmin
import (
"database/sql"
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/nagendra547/go-db-loadbalancer/log"
"github.com/nagendra547/go-db-loadbalancer/mydb"
"github.com/stretchr/testify/assert"
)
var master *sql.DB
var readReplica1 *sql.DB
var readReplica2 *sql.DB
var readReplica3 *sql.D... |
package problem0057
func insert(intervals [][]int, newInterval []int) [][]int {
startIndex, mergeLen, prevIndex := -1, 0, -1
for i := 0; i < len(intervals); i++ {
interval := intervals[i]
if isIntersect(interval, newInterval) {
if startIndex == -1 {
startIndex = i
}
mergeLen++
newInterval = merge... |
package repository
import (
"github.com/taniwhy/mochi-match-rest/domain/models"
)
// EntryHistoryRepository :
type EntryHistoryRepository interface {
FindAllEntryHistory() ([]*models.EntryHistory, error)
InsertEntryHistory(entryHistory *models.EntryHistory) error
UpdateEntryHistory(entryHistory *models.EntryHisto... |
package game_map
import (
"fmt"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"github.com/faiface/pixel/text"
"github.com/steelx/go-rpg-cgm/gui"
"github.com/steelx/go-rpg-cgm/utilz"
"github.com/steelx/go-rpg-cgm/world"
"reflect"
)
type BrowseListState struct {
Stack *gui.StateStack
X... |
package cclogger
import (
"fmt"
"log"
"os"
"runtime"
)
var (
globalDebug = false
stdout = os.Stdout
stderr = os.Stderr
debugLog *log.Logger = nil
infoLog *log.Logger = nil
errorLog *log.Logger = nil
warnLog *log.Logger = nil
defaultLog *log.Logg... |
package main
import (
"fmt"
"log"
"net/http"
)
func init() {
log.SetFlags(log.Lshortfile)
}
// middleware provides a convenient mechanism for filtering HTTP requests
// entering the application. It returns a new handler which performs various
// operations and finishes with calling the next HTTP handler.
type mi... |
package conf
import (
"flag"
"github.com/BurntSushi/toml"
"github.com/owenliang/myf-go/client/mhttp"
"github.com/owenliang/myf-go/client/mmongo"
"github.com/owenliang/myf-go/client/mmysql"
"github.com/owenliang/myf-go/client/mredis"
)
var (
confPath *string
MyfConf *MyfConfig
)
// 框架配置实例
type MyfConfig stru... |
package validator
import (
"net/http"
"github.com/casbin/casbin"
"github.com/dmitrymomot/jsonrpc2/request"
"github.com/gorilla/rpc/v2"
"github.com/gorilla/rpc/v2/json2"
)
// RBAC validation func
func RBAC(model, policy string) RPCRequestValidationFunc {
enforcer := casbin.NewEnforcer(model, policy)
return RBA... |
package ijvmasm
import (
"bufio"
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
)
var (
// Magic header for the IJVM binaries
Magic = uint32(0x1DEADFAD)
// ConstPoolOffset is the byte offset of the constant pool.
// Stolen from Mic1 emulator
ConstPoolOffset = uint32(0x10000)
)
// Generate IJVM binary code ... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package repo
// Branch ...
type Branch struct {
Commit string
Name string
}
// Branches ...
type Branches []Branch
// Rev ...
type Rev struct {
Commit string
Email string
Comment string
State string
}
// Revs ...
type Revs []Rev
|
package handler
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/milobella/oratio/internal/ability"
"github.com/milobella/oratio/internal/model"
"github.com/milobella/oratio/pkg/anima"
"github.com/milobella/oratio/pkg/cerebro"
)
func NewText(cerebroClient *cerebro.Client, animaClient *anima.Client... |
//strings is data type from bunch of char's
//null is string ?
// https://yourbasic.org/golang/string-functions-reference-cheat-sheet/
package main
import "fmt"
func main() {
var coba string = "bisa"
coba = "lain"
fmt.Println(coba)
var ini string = "coba char"
fmt.Println(ini)
var ok int32 = rune(len(ini)) //... |
/*
Tencent is pleased to support the open source community by making Basic Service Configuration Platform available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except
in compliance with the License. You may obtain... |
package httputils_test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/alejogs4/blog/src/shared/infraestructure/httputils"
"github.com/alejogs4/blog/src/shared/infraestructure/middleware"
)
func TestVerbMiddlewareUnit(t *testing.T) {
bareHandler := func(response http.ResponseWriter, request *http... |
package controllers
import (
"github.com/astaxie/beego"
"imeke_go/models"
"encoding/json"
"github.com/astaxie/beego/logs"
)
type UserController struct {
beego.Controller
}
// @router /user/selectUserById [post]
func (userController *UserController) SelectUserById(){
logs.Info("aaa")
userId:=userController.Ge... |
package server
import (
"strconv"
"testing"
"time"
)
var want200 int = 200
var want503 int = 503
func TestPrepMapOfClients(t *testing.T) {
clientMap = make(Clients)
for i := 1; i < 5; i++ {
clientMap[strconv.Itoa(i)] = &Client{startTime: time.Now(), requestCount: 1}
}
}
func TestFirstReq(t *testing.T) {
go... |
// Copyright 2021 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 pcpsd
import (
"database/sql"
"encoding/json"
"fmt"
"io"
"net/http"
"pcps/internal/conf"
"runtime"
"time"
"github.com/dgrijalva/jwt-go"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
//StartHTTPServer 启动http服务
func... |
// 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 repository
import (
"context"
"fmt"
"net/url"
"time"
"github.com/pkg/errors"
mgo "gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/diegob... |
package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/go-chi/chi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestUserCtx(t *testing.T) {
mysql := MySQL{db: openTestDBconnection()}
user := User{
Paid: ... |
package assert
func (w Wrapper) IsNil() {
if !w.isNil() {
w.t.Fatalf("Expected %#v to be nil", w.compared)
}
}
func (w Wrapper) IsNotNil() {
if w.isNil() {
w.t.Fatalf("Expected %#v not to be nil", w.compared)
}
}
func (w Wrapper) isNil() bool {
return w.compared == nil
}
|
package main
import (
"github.com/jin502437344/gf/frame/g"
"github.com/jin502437344/gf/os/gbuild"
)
func main() {
g.Dump(gbuild.Info())
g.Dump(gbuild.Map())
}
|
package message
import (
"github.com/airbloc/airbloc-go/account"
"github.com/klaytn/klaytn/common"
"github.com/klaytn/klaytn/common/hexutil"
"github.com/klaytn/klaytn/crypto"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
)
type Response interface {
Message
Signature() hexutil.Bytes
SetSignature(s... |
package model
import (
"errors"
"strconv"
"strings"
)
type TablePieces struct {
P1 *TablePiecesOne `json:"p1"` // 蓝方的棋子
P2 *TablePiecesOne `json:"p2"` // 红方的棋子
}
type TablePiecesOne struct {
Pieces Pieces `json:"pieces"`
Die []Piece `json:"die"` // 死掉的棋子
}
const (
FitResultAllDie = "bothdie"
FitResultP... |
package models
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"log"
"os"
"reflect"
"time"
"github.com/codegangsta/martini"
"github.com/coopernurse/gorp"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
)
const (
dbFormat = "2006-01-02 15:04:05"
jsonFormat = "2006-01-02"
)
var (
Dbm *go... |
package pacs
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00400102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:pacs.004.001.02 Document"`
Message *PaymentReturnV02 `xml:"PmtRtr"`
}
func (d *Document00400102) AddMessage() *PaymentRetur... |
package requests
type CreateIcs struct {
Name string `validate:"required,min=2,max=36"`
Description string
}
type UpdateIcs struct {
Name string `validate:"required,min=2,max=36"`
Description string
}
func (c *CreateIcs) Valid() error {
return validate.Struct(c)
}
func (c *UpdateIcs) Valid... |
// Copyright (C) 2015-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Li... |
package longestsubstringwithoutrepeating
// LengthOfLongestSubstring returns length of longest substring without rrepeating
func LengthOfLongestSubstring(s string) int {
var subStringLengths []int
for ind := 0; ind <= len(s)-1; ind++ {
subStringLengths = append(subStringLengths, LengthOfLongestSubstringFromSlice(... |
package models
import(
."go-test/bootstrap"
"golang.org/x/crypto/bcrypt"
)
type User struct{
Model
Mobile string `json:"created_at"`
Uname string `json:"created_at"`
Password string `json:"created_at"`
}
func (User) TableName() string {
return "users"
}
func (*User) CreateUser(data map[string]interface... |
package model
import (
"database/sql"
"fmt"
"github.com/benthor/clustersql"
"github.com/go-sql-driver/mysql"
"time"
"ImaginatoGolangTestTask/shared/database"
)
type Model struct {
Id int64 `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at" sql:"DEFAULT:CURRENT_TIMESTAMP"`
Upd... |
package main
import (
"fmt"
"os"
"github.com/torukita/go-fitbit/fitbit"
)
func main() {
expiry := "2592000" // one month expiry
access_token := os.Getenv("TEST_TOKEN")
id := os.Getenv("TEST_CLIENT_ID")
secret := os.Getenv("TEST_CLIENT_SECRET")
redirect := os.Getenv("TEST_CALLBACK_URL")
if access_token == ""... |
package clitable
// PrintRow - Prints table with only one row.
func PrintRow(fields []string, row map[string]interface{}) {
table := New(fields)
// add row
table.AddRow(row)
// And display table
table.Print()
}
// PrintTable - Prints table.
func PrintTable(fields []string, rows []map[string]interface{}) {
// Co... |
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"log"
"os"
"strings"
)
func main() {
v := visitor{fset: token.NewFileSet()}
for _, filepath := range os.Args[1:] {
if filepath == "--" {
continue
}
f, err := parser.ParseFile(v.fset, filepath, nil, 0)
if err != nil {
log.Fatalf("Faile... |
package multipaxos
// Acceptor represents an acceptor as defined by the Multi-Paxos algorithm.
type Acceptor struct {
// NEED TO WORK HERE
id int
rnd Round
}
// NewAcceptor returns a new Multi-Paxos acceptor.
// It takes the following arguments:
//
// id: The id of the node running this instance of a Paxos accept... |
// Package apmgrpc provides interceptors for tracing monitoring gRPC.
package apmgrpc
// var (
// defaultOptions = &options{}
// )
// options options for creating a request context object
// type options struct {
// apm *monitoringsystem.Agent
// }
// func evaluateOptions(opts []Option) *options {
// optCopy := &... |
package bleep
import (
"os"
"os/signal"
"sync"
"github.com/google/uuid"
)
var defaultBleep = New()
// Action is what will be performed on an os signal
type Action func(os.Signal)
// Bleep is the type for the handler
type Bleep struct {
actions map[string]Action
mu *sync.RWMutex
}
// New is used to crea... |
package main
import (
"github.com/Unknwon/goconfig"
)
type Config struct {
uploadpath string
port string
sslport string
maxImageSize int64
redisServer string
redisPass string
redisMaxIdleNum int
mongodbServer string
mongodbPort string
mongodbName string
msgMongodbName ... |
package main
import (
"fmt"
"log"
"net/http"
"sync"
"time"
"github.com/fsnotify/fsnotify"
"github.com/mmcdole/gofeed"
"github.com/patrickmn/go-cache"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang... |
package reddit
import (
"fmt"
)
type Comment struct {
Id string `json:"id"`
Body string `json:"body"`
Ups int `json:"ups"`
Downs int `json:"downs"`
Author string `json:"author"`
Subreddit string `json:"subreddit"`
}
func (c *Comment) String() string {
return fmt.Sprintf("Ups: %d, Downs: %d\n Author: %s\n=>\n... |
package database
import (
"database/sql"
"fmt"
"log"
"golang.org/x/crypto/bcrypt"
"../models"
_ "github.com/lib/pq"
)
var db *sql.DB
func CreateAndStoreUser(username string, password string, role string) bool {
hashedPW, err := bcrypt.GenerateFromPassword([]byte(password), 12)
if err != nil {
log.Printl... |
// Copyright 2016 The G3N 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 core
import (
"github.com/hecate-tech/engine/gls"
"github.com/hecate-tech/engine/math32"
"strings"
)
// INode is the interface for all... |
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build linux
package pcapgo
import (
"fmt"
"net"
"sync"
"syscall"
"time"
"unsafe"
"golang.org/x/sys/unix"
"githu... |
package entity
type Payload struct {
Status string `json:"status"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func (p *Payload) NewPayload(status, message string, data interface{}) *Payload {
return &Payload{
Status: status,
Message: message,
Data: data,
}
}
|
package main
import "fmt"
func main(){
favSport := "boxing"
switch favSport {
case "skiing":
fmt.Println("go to the mountain")
case "surfing":
fmt.Println("go to the sea")
case "boxing":
fmt.Println("go to the ring")
}
} |
package router
import (
"github.com/bearname/videohost/internal/common/db"
"github.com/bearname/videohost/internal/common/infrarstructure/profile"
"github.com/bearname/videohost/internal/common/infrarstructure/transport/handler"
"github.com/bearname/videohost/internal/common/infrarstructure/transport/middleware"
... |
package bench
import (
"io"
"log"
"math/rand"
"time"
"fmt"
"golang.org/x/crypto/sha3"
)
type SHA3Bench struct {
Name string
Thread int
Size int64
Duration time.Duration
Hashes int
Speed float64
finished bool
}
func NewSHA3Bench(thread int, size int64, duration time.Duration) (b *SHA3Be... |
package reloader
import (
"os"
"os/exec"
"os/signal"
"syscall"
"sync"
"net"
"log"
"net/http"
)
/*
基于`net.TCPListener`的无间断重启服务,暴露listener供业务代码扩充
1.`HTTP Server`简单用法:
func main(){
rl := reloader.NewReloader("127.0.0.1:8080")
if err:=rl.Bind(); err==nil {
http.HandleFunc("/", f... |
package product
import (
"encoding/json"
"net/http"
"strconv"
"github.com/keveaux/go_CRUD_application/entities"
"github.com/gorilla/mux"
"github.com/keveaux/go_CRUD_application/config"
"github.com/keveaux/go_CRUD_application/models"
)
func FindAll(response http.ResponseWriter, request *http.Request) {
db,... |
package util_test
import (
"testing"
"util"
"os"
)
func Test_WriteFile(t *testing.T) {
util.WriteFile("test.test", "Hello, Test!")
}
func Test_WriteFileToFolder(t *testing.T) {
folder := "../testfolder/test/"
filename := folder + "test.dat"
util.WriteFile(filename, "test data into testing... |
package Problem0149
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
xy [][]int
ans int
}{
{
[][]int{[]int{-54, -297}, []int{-36, -222}, []int{3, -2}, []int{30, 53}, []int{-5, 1}, []int{-36, -222}, []int{0, 2}, []int{1, 3}, []int{6, -47}, []int{0... |
/**
* @Author: korei
* @Description:
* @File: datasource.go
* @Version: 1.0.0
* @Date: 2020/11/17 上午11:19
*/
package datasource
import (
"gorm.io/driver/mysql"
"gorm.io/gorm"
"korei/ASM/models"
"sync"
"korei/ASM/config"
)
var (
DB * gorm.DB
dbConnectMutex sync.Mutex
/*
Coins ... |
package app
import "fyne.io/fyne/v2"
type Component struct {
Name string
Object *fyne.Container
Enabled bool
Props map[string]interface{}
ChildComponent *Component
}
func (c *Component) Enable() {
c.Enabled = true
}
func (c *Component) Disable() {
c.Enabled = false
}
func (... |
package main
import (
"testing"
"regexp"
)
func testall(t *testing.T, tst map[string][]string, reg *regexp.Regexp) {
for k,v:= range tst {
cnt := int(0)
cnt = 0
for s:= range reg.AllMatchesStringIter(k, 0) {
// fmt.Println(s)
if(cnt == len(v)) {
t.Error(k + " parse returned more elem... |
package tgo
import (
"fmt"
"sync"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/youtube/vitess/go/pools"
)
var (
MysqlClusterReadPool map[int]*MysqlConnectionPool
mysqlClusterReadPoolMux sync.Mutex
MysqlClusterWritePool map[int]*MysqlConnectionPool
mysqlClusterWritePoolMux sync.Mutex
)
type... |
package ast
import "github.com/fr3fou/monkey/token"
// Identifier is a name of a variable / function
// It implements the Expression interface, so that it can make things
// easier for us in the future:
// let a = 5;
// let b = a;
// in this case we can see that a IS an expression (it returns a value)
//
// Value is ... |
package gogitlab
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestProjects(t *testing.T) {
ts, gitlab := Stub("stubs/projects/index.json")
projects, err := gitlab.Projects()
assert.Equal(t, err, nil)
assert.Equal(t, len(projects), 2)
defer ts.Close()
}
func TestProject(t *testing.T) {
ts, ... |
package main
type float float32
const FLOAT_SIZE = 32
const (
TTYPE_IDENT = iota
TTYPE_PUNCT
TTYPE_NUMBER
TTYPE_CHAR
TTYPE_STRING
)
type Token struct {
typ int
// intends union
sval string
punct int
c byte
}
const (
AST_LITERAL = iota + 256
AST_STRING
AST_LVAR
AST_GVAR
AST_FUNCALL
AST_FUNC
AS... |
package control
import (
"instructions/base"
"rtda"
)
//LOOKUP_SWITCH
/*
matchOffsets有点像Map,它的key是case值,value是跳转偏移
量。Execute()方法先从操作数栈中弹出一个int变量,然后用它查找
matchOffsets,看是否能找到匹配的key。如果能,则按照value给出的
偏移量跳转,否则按照defaultOffset跳转。
lookupswitch
<0-3 byte pad>
defaultbyte1
defaultbyte2
defaultbyte3
defaultbyte4
npairs1
npairs2... |
package db
import (
"github.com/jinzhu/gorm"
)
type Events struct {
gorm.Model
User string
Type string
Timestamp int64
Notes string
Image string
}
|
// Package gotf provide methods to manipulate and use data from Trailforks
package gotf
import (
"errors"
"fmt"
"io"
"strconv"
"strings"
"github.com/kniren/gota/dataframe"
"github.com/kniren/gota/series"
)
//
// Load and Parse Functions
//
// LoadFromCSV populates a TrailData dataframe from a csv file
func (... |
package main
import (
"bytes"
"fmt"
"math/rand"
"strings"
)
var (
// month names
months []string = []string{"Jan", "Feb", "Mar", "Apr", "May", "June", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
)
func dataForUri(uri string) string {
if strings.HasSuffix(uri, "/reported_issues") {
return reportedIssues()
} e... |
// Package ibmcloud provides a cluster-destroyer for IBM Cloud clusters.
package ibmcloud
|
package accountinfo
import (
"reflect"
"testing"
)
func TestAccountInfo_Deserialize(t *testing.T) {
ac := New(9001, 50)
serAc, _ := ac.Serialize()
type args struct {
serializedAccountInfo []byte
}
tests := []struct {
name string
accInfo *AccountInfo
args args
wantErr bool
}{
{
accInfo: &A... |
// Copyright 2017 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 main
import "fmt"
func main() {
//n, err:=fmt.Println("Hello, playground")
//fmt.Println(n)
//fmt.Println(err)
// It returns the number of bytes written and any write error encountered
n, _ := fmt.Println("Hello, playground")
fmt.Println(n)
//_ throw away the return for error
}
|
package memdb
import (
"github.com/babyboy/leveldb"
"github.com/babyboy/common"
"github.com/babyboy/common/ds"
"github.com/babyboy/config"
"github.com/babyboy/core/types"
"log"
"sync"
)
var WmDb *WitnessMemDB
var onceWmDb sync.Once
// 获取见证人存储实例
func GetWitnessMemDBInstance() *WitnessMemDB {
onceWmDb.Do(func(... |
package session
import(
"net/http"
"encoding/json"
"log"
"github.com/ipastushenko/simple-chat/server/models"
"github.com/ipastushenko/simple-chat/server/services/session"
)
type SignInHandler struct {
sessionService session.ISessionService
}
type signInResponse struct {
AuthToken string `... |
package leetcode
func allCellsDistOrder(R int, C int, r0 int, c0 int) [][]int {
ans := make([][]int, 0, R*C)
ans = append(ans, []int{r0, c0})
for d := 0; d < R+C-1; d++ {
for i := 0; i < d; i++ {
x, y := r0+i, c0+(d-i)
if 0 <= x && x < R && 0 <= y && y < C {
ans = append(ans, []int{x, y})
}
}
for... |
package main
// InternalMemory ...
var InternalMemory map[string][]interface{}
// M ...
var M = make([]bool, 1000)
// R ...
var R = make([]float64, 1000)
|
/*
-----------------------------------------------------------------------------------
Lab : 03
File : config.go
Authors : François Burgener - Tiago P. Quinteiro
Date : 10.12.19
Goal : Config file for the network layer
-------------------------------------------------------------------... |
package main
import (
"context"
"time"
"cloud.google.com/go/datastore"
)
// Message is the object we store
type Message struct {
Timestamp time.Time
Message string
}
func (c *Controller) storeMessage(ctx context.Context, message string) error {
m := &Message{
Timestamp: time.Now(),
Message: message,
... |
package cmd
import (
"errors"
"fmt"
"github.com/Souhail-5/zeed/internal/changelog"
gonanoid "github.com/matoous/go-nanoid"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
)
// const improve performance
const ALPH = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ... |
package mail
import (
"github.com/devfeel/dotweb"
"master/define"
"strconv"
"fmt"
"master/api"
//"master/utils/mynsq/sspb"
"encoding/json"
"master/utils/mylog"
"master/utils"
)
func SendMailHander(ctx dotweb.Context)error{
defer ctx.End()
token:=ctx.FormValue("token")
title:=ctx.FormValue("mailTitle"... |
package observer
import "design-patterns-go/observerPattern/event"
type BillBoardDisplay struct {
}
func NewBillBoardDisplay() BillBoardDisplay {
println("Creating Bill Board Display Observer")
return BillBoardDisplay{}
}
func (bbd BillBoardDisplay) OnNotify(event event.Event) {
println("~~~~~~~Bill Board Dis... |
package contracts
import (
"fmt"
"github.com/DSiSc/contractsManage/utils"
"github.com/DSiSc/craft/log"
"github.com/DSiSc/craft/types"
"github.com/DSiSc/repository"
"math/big"
)
const (
GetContractById = "8ba9ac6f"
ContractMetaDate = "1e7936bd"
RegisteContract = "f38bbf6d"
)
type MetaData interface {
// ... |
package client
import (
"bufio"
"context"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"math/big"
"os"
"strconv"
"wallet/abi"
"wallet/hdkeystore"
"wallet/hdwallet"
"wallet/utils"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/eth... |
func countPrimes(n int) int {
result := 0
flags := make([] bool, n)
for i := 0; i < len(flags); i++ {
flags[i] = true
}
for i := 2; i < n; i++ {
if flags[i] {
result++
j := 2
for i * j < n {
flags[i * j] = fal... |
package main
import (
"fmt"
"sort"
"strings"
)
// https://leetcode-cn.com/problems/reorder-data-in-log-files/
var _ sort.Interface = &logFiles{}
type logFiles []string
func (l logFiles) Len() int {
return len(l)
}
func (l logFiles) Less(i, j int) bool {
const C = ' '
ii := strings.IndexByte(l[i], C)
ij := ... |
package binance
import (
"github.com/stretchr/testify/suite"
"testing"
)
type rebateServiceTestSuite struct {
baseTestSuite
}
func TestRebateService(t *testing.T) {
suite.Run(t, new(rebateServiceTestSuite))
}
func (s *rebateServiceTestSuite) TestSpotRebateHistory() {
data := []byte(`{
"status": "OK",
"... |
package core
import (
"github.com/jmigpin/editor/core/toolbarparser"
"github.com/jmigpin/editor/util/osutil"
)
type HomeVars struct {
m toolbarparser.VarMap
}
func NewHomeVars() *HomeVars {
return &HomeVars{}
}
func (hv *HomeVars) ParseToolbarVars(strs ...string) {
hv.m = toolbarparser.VarMap{}
for _, str := ... |
package floyd
import "fmt"
func Triangle(line_count int) {
number := 1
for i := 1; i <= line_count; i++ {
for j := 1; j <= i; j++ {
fmt.Print(" ", number, " ")
number ++
}
fmt.Println("")
}
} |
package connector
import (
"net/http"
"net/url"
"strings"
)
type basicAuthConnector struct {
cfg Config
httpClient *http.Client
semaphore semaphore
stat *statistics
}
func (r *basicAuthConnector) Delete(url *url.URL, headers map[string]string, hint string) (*http.Response, error) {
return r.Req... |
package app
import (
"github.com/gin-gonic/gin"
"github.com/yjagdale/siem-data-producer/controller/file_producer_controller"
"github.com/yjagdale/siem-data-producer/controller/files_controller"
"github.com/yjagdale/siem-data-producer/controller/override_controller"
"github.com/yjagdale/siem-data-producer/controll... |
package assembler
import (
"testing"
)
func sum(x []float32) float32 {
var s float32
for i := range x {
s += x[i]
}
return s
}
func TestSum(t *testing.T) {
vector2ScalarTest(Sum, sum, t)
}
func BenchmarkSum(b *testing.B) {
vector2ScalarBench(sum, b)
}
func BenchmarkOptimizedSum(b *testing.B) {
vector2Sca... |
package blobstore
import (
"crypto"
"encoding/hex"
"fmt"
"io"
)
// VFSBlobServer implements a generic BlobServer on a Virtual Filesystem (VirtualFS)
type VFSBlobServer struct {
VirtualFS
hash crypto.Hash
}
// VirtualFS contains the minimum methods required from any FileSystem to support a BlobServer
type Virtu... |
package main
import "testing"
func TestFindSumBelow(t *testing.T) {
tests := []struct {
input int
output int
}{
{1000, 233168},
{10, 23},
{1, 0},
{-1, 0},
{0, 0},
}
for _, test := range tests {
result := FindSumBelow(test.input)
if result != test.output {
t.Errorf("Expected %v, got %v", tes... |
package routes
import (
"devbook-api/src/controllers"
"net/http"
)
var commentsRoutes = []Route{
{
URI: "/comments",
Method: http.MethodPost,
RequestAuth: true,
Handler: controllers.CreateComment,
},
{
URI: "/comments/{commentId}",
Method: http.MethodPut,
RequestAuth: ... |
package storage
import (
"context"
"github.com/jmoiron/sqlx"
)
// SQLXConnection is a *sqlx.DB or *sqlx.Tx.
type SQLXConnection interface {
sqlx.Execer
sqlx.ExecerContext
sqlx.Preparer
sqlx.PreparerContext
sqlx.Queryer
sqlx.QueryerContext
sqlx.Ext
sqlx.ExtContext
}
// EncryptionChangeKeyFunc handles en... |
package main
import (
"fmt"
"log"
"sync/atomic"
"net/http"
"net/url"
"net/http/httputil"
"net"
"time"
"github.com/0xrishabh/balance/src/config"
"github.com/0xrishabh/balance/src/balance"
)
func checkerr(err error) {
if err != nil{
log.Fatal(err)
}
}
type Backend struct {
Url *url.URL
Online bool
Re... |
package main
import "fmt"
var processing bool
func flagTest() {
processing = true
fmt.Println(processing)
defer func() {
processing = false
}()
}
func main() {
flagTest()
fmt.Println(processing)
}
|
package os
import (
"errors"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime"
"strings"
)
var (
// ErrMutexesNotSupported is thrown when you try using mutexes on unsupported platforms
ErrMutexesNotSupported = errors.New("Mutexes not supported on this OS")
)
var (
// ErrNotScoped is thrown... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.