text stringlengths 11 4.05M |
|---|
// +build !amd64
package ahash
// bit population count, take from
// https://code.google.com/p/go/issues/detail?id=4988#c11
// credit: https://code.google.com/u/arnehormann/
func Distance(hash1 uint64, hash2 uint64) int {
x := hash1 ^ hash2
x -= (x >> 1) & 0x5555555555555555
x = (x>>2)&0x3333333333333333 + x&0x333... |
package teamsnap
import (
"os"
"strings"
"testing"
)
var authToken = os.Getenv("AuthToken")
func TestAuthToken(t *testing.T) {
if authToken == "" {
t.Error("Please set AuthToken environment variable.")
}
}
func TestInitialize(t *testing.T) {
teamSnap := &TeamSnap{AuthToken: authToken}
teamSnap.Initialize()... |
package main
import (
auth "github.com/lidstromberg/auth"
)
//HdlError is a handler error wrapper
type HdlError struct {
StatusID int `json:"statusid"`
Error string `json:"error"`
}
//Token is the jwt container
type Token struct {
SessionID string `json:"sessionid"`
}
//TokenResult wraps Token
type TokenR... |
package domain
import (
"github.com/bearname/videohost/internal/common/db"
commonDto "github.com/bearname/videohost/internal/common/dto"
"github.com/bearname/videohost/internal/videoserver/domain/dto"
"github.com/bearname/videohost/internal/videoserver/domain/model"
"github.com/google/uuid"
)
type VideoService i... |
package textbox
import (
"sync"
)
type Window struct {
backend Backend
closed chan struct{}
closeOnce sync.Once
buffer *Buffer
adjustDependencies, fillDependencies *Dependencies
Events chan Even... |
package authorization
import (
"github.com/authelia/authelia/v4/internal/utils"
)
// AccessControlSubjects represents an ACL subject.
type AccessControlSubjects struct {
Subjects []SubjectMatcher
}
// AddSubject appends to the AccessControlSubjects based on a subject rule string.
func (acs *AccessControlSubjects) ... |
package config
import (
"sync"
"github.com/TuiBianWuLu/samplewechat/util/cache"
)
type Config struct {
AppID string
Secret string
AESKey string
Token string
MchID string
MchKey string
PrefixAcce... |
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
cli "github.com/codegangsta/cli"
)
//returns a command or erros if invlaid options given
func NewAddCommand(c *cli.Context) (*Command, error) {
var err error
config := new(Config)
//we will load file con... |
package main
import (
"fmt"
"io"
"net/http"
"os"
"github.com/codegangsta/cli"
)
var confDumpCommand = cli.Command{
Name: "confdump",
Usage: "Dump the current config of a server",
Flags: []cli.Flag{
cli.StringFlag{
Name: "server, s",
Value: "http://localhost:9966",
Usage: "The meduza control serv... |
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package commands
import (
"fmt"
"sync"
"time"
"github.com/scaleway/scaleway-cli/pkg/api"
"github.com/sirupsen/logrus"
)
// StartArgs are flags for the ... |
package ibmcloud
import (
"net/http"
"strings"
"github.com/IBM/platform-services-go-sdk/iampolicymanagementv1"
"github.com/pkg/errors"
)
const iamAuthorizationTypeName = "iam authorization"
// listIAMAuthorizations lists IAM authorizations
func (o *ClusterUninstaller) listIAMAuthorizations() (cloudResources, er... |
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
)
func shutdownServer() {
fmt.Println("Server shutdown")
os.Exit(0)
}
func sendJSON(w http.ResponseWriter, data interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(data)
}
|
package main
import (
"fmt"
)
//匿名函数
var f1=func(x,y int){
fmt.Println(x+y)
}
//匿名函数一般用于函数内部,因为函数内部不可以有命名函数
func main(){
f:=func(x,y int){ //匿名函数
fmt.Println(x+y)
}
f(666,999) //执行匿名函数
//如果是一次执行函数那么可以简写为立即执行函数
func(x,y int){ //匿名函数 ,就不需要变量去接收变量了
fmt.Println(x+y)
}(100,999)
} |
package main
import (
"fmt"
"runtime"
"time"
)
func longWait(ch chan string) {
time.Sleep(3e9)
fmt.Println("long wait start")
ch <- "long wait end"
}
func mediumWait(ch chan string) {
time.Sleep(2e9)
fmt.Println("medium wait start")
ch <- "medium wait end"
}
func shortWait(ch chan string) {
time.Sleep(... |
package restapi_test
import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
stdsort "sort"
"testing"
"time"
"github.com/etf1/kafka-message-scheduler-admin/server/db/simple"
"github.com/etf1/kafka-message-scheduler-admin/server/resolver/schedulers"
"github.com/etf1/kafka-message-... |
package web
import (
"net/http"
"database/sql"
)
const (
GET = "GET"
POST = "POST"
PUT = "PUT"
DELETE = "DELETE"
)
const MissingParamErr = "Missing param %v"
// Router is an interface used for all incoming and outgoing network requests
// in the services
type Router interface {
HandleRoute(m... |
package main
import (
"fmt"
"github.com/alejandrodgb/learn-golang/S28-Tests/04_benchmarking/saying"
)
func main() {
fmt.Println(saying.Greet("Alex"))
}
|
// Play the game "pig". A codewalk from Go documentation.
//
// https://golang.org/doc/codewalk/functions/
package main
import (
"fmt"
"math/rand"
)
const winningScore = 100 // The winning score in a game of Pig
// Number of times to play each strategy against each other one
const gamesPerSeries = 100
// A score ... |
package controllers
import (
"io"
"fmt"
"net"
"time"
"net/http"
"context"
"commontest/Config"
"commontest/Test"
"github.com/gorilla/mux"
"io/ioutil"
"encoding/json"
)
type General struct {
conf *Config.Config
c chan int
isTestRunning bool
tc *TestingController
}
func GetOutboundIP() net.IP {
conn,... |
package sorts
import (
"sort"
"strings"
)
//ASCII码从小到大排序(字典序)
func Strings(a []string) []string {
StringSlice(a).Sort()
return a
}
type StringSlice []string
func (p StringSlice) Len() int { return len(p) }
func (p StringSlice) Less(i, j int) bool {
return strings.Split(p[i], "=")[0] < strings.Split(p[j], "=")[... |
package reverseproxy
import (
"testing"
"net/url"
"net/http"
)
func Test_DirectorFunc_RequestUpdate_RequestUpdatedCorrectly(t *testing.T) {
var expectedRawQuery string = "q1=1&q2=2&q3=3&q4=4"
target := &url.URL{
Host: "api.target.com",
Scheme: "https",
Path: "/apitarget/testtarget",
RawQuery: ... |
package node
import (
"babyboy-dag/p2p"
"babyboy-dag/p2p/nat"
"os"
"os/user"
"path/filepath"
"runtime"
)
// DefaultConfig contains reasonable default settings.
var DefaultConfig = Config{
DataDir: "data/",
RpcServer: "0.0.0.0:8545",
RemoteServer: "http://192.168.1.13:8888",
P2P: p2p.Config{
Listen... |
package main
import (
"fmt"
"net/http"
"github.com/enjoy-web/ehttp"
"github.com/gin-gonic/gin"
)
var doc = &ehttp.APIDocCommon{
Summary: "doc summary",
Produces: []string{ehttp.Application_Json},
Consumes: []string{ehttp.Application_Json},
Parameters: map[string]ehttp.Parameter{
"file": ehttp.Parameter{In... |
package pathfind_test
import (
"testing"
"pathfind"
)
func Test_8Puzzle_ValidMoves(t *testing.T) {
game := pathfind.RandomG8State()
moves := game.ValidMoves()
if moves.Len() < 2 || moves.Len() > 4 {
t.Errorf("ValidMoves returned an impossible number of moves")
}
}
func Test_Solve_8Puzzle_Rotat... |
package main
import (
"io"
)
var _ = declareDay(2, func(part2 bool, inputReader io.Reader) interface{} {
if part2 {
return day02Part2(inputReader)
}
return day02Part1(inputReader)
})
func day02Part1(inputReader io.Reader) interface{} {
var computer computer
computer.init(inputReader)
computer.run()
return ... |
package tunnel
import (
"context"
"crypto/tls"
"fmt"
"io"
"os"
"time"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"github.com/batchcorp/collector-schemas/build/go/pro... |
package main
import (
"math/rand"
"time"
)
type AI3 struct {
}
func (self *AI3) Start(client *Client) {
for {
switch rand.Intn(13 * 10) {
case 0:
client.InviteCode()
case 1:
client.RankInfo()
case 2:
client.RankSeasonReward()
case 3:
client.RankTiers()
case 4:
client.RankSelf()
case 5... |
package infrastructure
import (
"log"
)
//Logger ...
type Logger struct{}
//Log log messages to console
func (logger Logger) Log(args ...interface{}) {
log.Println(args...)
}
|
package graphql
import (
"context"
"errors"
"fmt"
"github.com/nomkhonwaan/myblog/pkg/blog"
"github.com/nomkhonwaan/myblog/pkg/facebook"
slugify "github.com/nomkhonwaan/myblog/pkg/slug"
"github.com/nomkhonwaan/myblog/pkg/storage"
"github.com/nomkhonwaan/myblog/pkg/timeutil"
"github.com/russross/blackfriday/v2"... |
package pixeldrain
type Upload struct {
Success bool `json:"success"`
ID string `json:"id"`
}
|
package factories
import (
"database/sql"
"github.com/barrydev/api-3h-shop/src/connections"
"github.com/barrydev/api-3h-shop/src/model"
)
func FindProductItemById(productItemId int64) (*model.ProductItem, error) {
connection := connections.Mysql.GetConnection()
stmt, err := connection.Prepare(`
SELECT
_id,... |
package model
import (
"database/sql"
"database/sql/driver"
"encoding/base64"
"fmt"
"net"
"github.com/authelia/authelia/v4/internal/utils"
)
// NewIP easily constructs a new IP.
func NewIP(value net.IP) (ip IP) {
return IP{IP: value}
}
// NewNullIP easily constructs a new NullIP.
func NewNullIP(value net.IP)... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-09-23 09:23
# @File : lt_57_Insert_Interval.go
# @Description :
# @Attention :
*/
package array
import (
"testing"
)
func Test_insert(t *testing.T) {
a:=make([][]int,0)
// {
// []int{1,3},
// []int{6,9},
// }
a=append(a,[]int{1,3})
a=append(a,[]in... |
package web
import (
"accountBook/application/web/controllers"
"accountBook/models/beans/dbBeans"
"accountBook/models/endpoints/web"
"encoding/json"
)
// 银行相关接口
type BankController struct {
controllers.RestController
Serv web.IBankEndpoint
}
// @Title 银行列表
// @Description 银行列表
// @Param token header string tru... |
package file
import (
"encoding/json"
"fmt"
"io/ioutil"
)
func ReadJson(path string, dest interface{}) error {
data, err := ioutil.ReadFile(path)
if err != nil {
return fmt.Errorf("read file err: %s", err)
}
if err := json.Unmarshal(data, &dest); err != nil {
return fmt.Errorf("json unmarshall file [%s] d... |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
package apilib
import (
"fmt"
"io"
"io/ioutil"
"os"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/wasp/client"
"github.com/iotaledger/wasp/client/multiclient"
"github.com/iotaledger/wasp/pa... |
package app
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
type requestHandler struct {
internalHandler http.Handler
}
func (h *requestHandler) applyCORS(w http.ResponseWriter) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST")
w.Header().Set(
... |
package cars
// CarsPerHour how many cars can be made at maximum successrate per unit speed
const CarsPerHour = 221
// SuccessRate is used to calculate the ratio of an item being created without
// error for a given speed
func SuccessRate(speed int) float64 {
if speed == 0 {
return 0.0
} else if speed <= 4 {
re... |
package docker
import (
"fmt"
"path"
"time"
"github.com/orcaman/concurrent-map"
"github.com/baidu/openedge/logger"
"github.com/baidu/openedge/master/engine"
"github.com/baidu/openedge/utils"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docke... |
package handler
import (
"bytes"
"encoding/json"
"errors"
"net/http"
"net/http/httptest"
"testing"
model "github.com/geeksheik9/sheet-CRUD/models"
"github.com/geeksheik9/sheet-CRUD/pkg/db/mocks"
"github.com/gorilla/mux"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func InitMockCharacterService(sheetsToRe... |
package nats
import (
"bytes"
"context"
"fmt"
"regexp"
"strconv"
"strings"
"sync"
"github.com/gogo/protobuf/proto"
"github.com/xackery/log"
nats "github.com/nats-io/nats.go"
"github.com/pkg/errors"
"github.com/xackery/talkeq/config"
"github.com/xackery/talkeq/database"
"github.com/xackery/talkeq/pb"
"... |
// Package gitlab contains the errors available
package gitlab
import "fmt"
// ErrGitLabUnmarshal error if can't possible unmarshal gitHub input slack-bot
type ErrGitLabUnmarshal struct {
Err error
}
// IsErrGitLabUnmarshal returns if the error type is ErrGitLabUnmarshal or not.
func IsErrGitLabUnmarshal(err error)... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/11/22 10:44 上午
# @File : lt_191_位1的个数.go
# @Description :
# @Attention :
*/
package v2
func hammingWeight2(num uint32) int {
ret := 0
for num > 0 {
num = num & (num - 1)
ret++
}
return ret
}
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
package server
import (
"net/http"
"strings"
"github.com/fanalis/go-daydream/modules/chrome"
)
type Server struct {
mux *http.ServeMux
isConfigured bool
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if s.mux == nil {
s.mux = http.NewServeMux()
}
err := s.configure()
if err != n... |
package main
import (
"fmt"
"log"
"os"
"os/exec"
)
func local_exec(content []string) {
//Write File
cmdLines := String(30)
f, err := os.Create(cmdLines)
if err != nil {
fmt.Println(err)
f.Close()
log.Fatalf("%s\n", err)
}
for _, v := range content {
fmt.Fprintln(f, v)
if err != nil {
fmt... |
package utils
import "github.com/kataras/iris/v12"
var Addr = iris.Addr("0.0.0.0:8144")
const UploadsDir = "../../public/uploads/firmware/" |
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00800104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.008.001.04 Document"`
Message *ReversalOfTransferInConfirmationV04 `xml:"RvslOfTrfInConf"`
}
func (... |
/*
A cruise control has 3 different options to move the handle to set the speed you want to drive with.
Towards you: Adds 1 speed.
Upwards: Increases speed to the next multiple of 10 (e.g. 20-->30, 32-->40)
Downwards: Decreases speed to the next multiple of 10 (e.g. 20-->10, 32-->30)
Input
2 integers: the first is ... |
package futures
import (
"context"
"encoding/json"
"net/http"
)
// GetRebateNewUserService
type GetRebateNewUserService struct {
c *Client
brokerageID string
type_future int
}
// BrokerageID setting
func (s *GetRebateNewUserService) BrokerageID(brokerageID string) *GetRebateNewUserService {
s.broker... |
package account
import (
"github.com/ijidan/jnet/jnet"
"reflect"
"strconv"
)
//用户相关
type User struct {
Common
jnet.BaseService
}
//账号密码登录
func (u *User) LoginByAccount(account string, password string) jnet.Response {
path := "/user/index/login"
url := u.buildReqUrl(path, "")
param := map[string]string{"accou... |
package data
type HeartBeatData struct {
IfNewBlock bool `json:"ifNewBlock"`
Id int32 `json:"id"`
BlockJson string `json:"blockJson"`
PeerMapJson string `json:"peerMapJson"`
Hops int32 `json:"hops"`
Addr string `json:"Addr"`
}
//Hops should be decremented on forward
func NewHeartBe... |
package main
import (
"bufio"
"fmt"
"os"
"path"
"sort"
"strconv"
"strings"
knapsack "github.com/ivanpesin/golang-knapsack"
)
var store = []knapsack.Item{}
var knapsackCapacity = -1.
// readStore reads items and their properties from a file
func readStore(fn string) {
f, err := os.Open(fn)
if err != nil {
... |
//
// 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 handlers
import (
"github.com/bogdanov-d-a/gocourse2018/workshop2/simplevideoserver/database"
"github.com/google/uuid"
"io"
"net/http"
)
func uploadVideo(db database.Database, w http.ResponseWriter, r *http.Request) {
fileReader, header, err := r.FormFile("file[]")
if err != nil {
http.Error(w, err.Er... |
package main
import (
"fmt"
"io/ioutil"
"log"
"math"
"os"
"sort"
"strconv"
"strings"
)
var size = 350
var lessThan = 10000
type coordinateType struct {
x, y int
}
func check(e error) {
if e != nil {
log.Fatal(e)
}
}
func main() {
file := "data"
if len(os.Args) > 1 {
file = os.Args[1]
}
rawData,... |
// Copyright 2018 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 commit
import "github.com/scjalliance/drivestream/resource"
// Reference is a drivestream commit reference.
type Reference interface {
// Drive returns the drive ID of the commit.
Drive() resource.ID
// SeqNum returns the sequence number of the commit.
SeqNum() SeqNum
// Exists returns true if the comm... |
package restish
import (
"github.com/llewekam/assertion"
"testing"
)
// Controller Stub object
type ControllerStub struct {
assertion.Stuber
}
func (stub *ControllerStub) Create(resource *Resource) (*Resource, StatusCode) {
stub.Stuber.Register("Create")
resource.Properties = map[string]string{
"action": "Cr... |
package gortex
import (
"fmt"
"github.com/vseledkin/gortex/assembler"
)
// Gated recurrent unit
type VAE struct {
z_size int
W *Matrix
WB *Matrix
W1 *Matrix
W1B *Matrix
WM *Matrix
WD *Matrix
WW1 *Matrix
WW1B *Matrix
WW *Matrix
WWB *Matrix
}
func MakeVae(x_size, z_size int) *VAE {
vae := new(... |
package models
import "time"
// AddressTypes ENUM for address types...
var AddressTypes = map[string]string{
"GROUP": "group",
"SPACE": "space",
"USER": "user",
}
// Address Defines address model user by groups, events and users
type Address struct {
AddressID string `json:"addressId,omitempty" db:"a... |
// Package workbench - messing around, breaking stuff... you know, learning!
package workbench
|
package models
import (
"github.com/jinzhu/gorm"
"github.com/jungju/circle_manager/_example/beegoapp/envs"
"github.com/jungju/circle_manager/_example/beegoapp/utils"
"github.com/jungju/circle_manager/modules"
)
var (
gGormDB *gorm.DB
)
var registedModels []interface{}
func registModel(model interface{}) {
if ... |
package main
import (
"bytes"
"encoding/json"
"io"
"math/rand"
"net/http"
"os"
"strconv"
"time"
"github.com/an-jun/xuanwu-test/conf"
"github.com/an-jun/xuanwu-test/sign"
)
type PurchaseQuantityRequest struct {
BeginRow int `json:"begin_row"`
Size int `json:"size"`
SaleOrganizat... |
package main
import (
"fmt"
)
// https://leetcode-cn.com/problems/house-robber/
//------------------------------------------------------------------------------
// 设 f[i] 为从[0..i]号房屋中, 必须偷窃 i 号房屋后所能获得的最大金额.
// 因为只能隔屋偷窃, 所以 f[0], f[1] 就只能偷窃0号/1号房屋.
// 所以 f[i] 为偷窃i号房屋, 再加上 MAX(f[0],f[1],...,f[i-2]).
// 为了节约空间, 可以令:
/... |
package main
import (
"github.com/ouspg/tpm-ble/pkg/ble"
"io/ioutil"
"log"
"os"
"os/signal"
)
var adapterID = "hci0"
const TargetHwaddr = "DC:A6:32:28:34:E4"
const CharUuid = "10000001"
const CharNotifyUuid = "10000002"
func main() {
cert, err := ioutil.ReadFile("/usr/local/share/keys/tpm_cert.pem")
if err... |
package problem0733
func floodFill(image [][]int, sr int, sc int, newColor int) [][]int {
if len(image) == 0 {
return image
}
width := len(image)
height := len(image[0])
oldColor := image[sr][sc]
if oldColor == newColor {
return image
}
bfs(&image, sr, sc, width, height, oldColor, newColor)
return image
}... |
package main
/**
* created: 2019/8/8 9:46
* By Will Fan
*/
func main() {
tee := func(
done <-chan interface{},
in <-chan interface{},
) (_, _ <-chan interface{}){
out1 := make(chan interface{})
out2 := make(chan interface{})
go func() {
defer close(out1)
defer close(out2)
//for val := range o... |
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
"time"
)
// ARCHTIMEFMT Time format A
const ARCHTIMEFMT string = "20060102"
// ARCHTIMEFMT2 Time format 2
const ARCHTIMEFMT2 string = "2006-01-02"
type errorString struct { // TODO... |
package main
func mod(a int, m int) int {
if a >= 0 {
return a % m
} else {
return m + a%m
}
}
func modSquareRoot(n int, p int) []int {
squares := make([]int, 0)
n = n % p
for i := 0; i < p; i++ {
if (i*i)%p == n {
squares = append(squares, i)
}
}
return squares
}
func modInverse(b int, m int) int... |
package mdfile
import (
"bytes"
"errors"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/hashicorp/hcl/v2/hclwrite"
"gopkg.in/russross/blackfriday.v2"
)
type MdFile interface {
FmtHclCodeInMd() ([]byte, error)
}
type impleMdFile struct {
md *[]byte
filename string
}... |
package httputils
import (
"fmt"
"net/http"
"github.com/alejogs4/blog/src/shared/infraestructure/middleware"
)
// Verb middleware ensures that petition is made with the rigth http verb
func Verb(acceptedHTTPMethodgo string) middleware.Middleware {
return func(nextHandler http.HandlerFunc) http.HandlerFunc {
re... |
package packager
import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
)
// The content that will be packaged
var Content map[string][]byte = make(map[string][]byte)
func Create(path, output string) {
//Test := []byte("Install gentoo")
Traverse(path)
Write(output)
}
// Traverse the content of dirname recursiv... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//227. Basic Calculator II
//Implement a basic calculator to evaluate a simple expression string.
//The expression string contains only non-negative in... |
package boil
import (
"github.com/volatiletech/strmangle"
)
// Columns kinds
// Note: These are not exported because they should only be used
// internally. To hide the clutter from the public API so boil
// continues to be a package aimed towards users, we add a method
// to query for each kind on the column type i... |
package repository
import (
"fmt"
"time"
"github.com/Hudayberdyyev/weather_api/models"
"github.com/jackc/pgx"
)
type ForecastPostgres struct {
db *pgx.Conn
}
func NewForecastPostgres(db *pgx.Conn) *ForecastPostgres {
return &ForecastPostgres{db: db}
}
func (r *ForecastPostgres) GetCities() (*[]models.Regions... |
package segment
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
"github.com/pkg/errors"
)
const (
apiVersion = "v1beta"
defaultBaseURL = "https://platform.segmentapis.com"
mediaType = "application/json"
)
// Client manages communication with Segment Config API.
type ... |
package main
import (
"fmt"
"strings"
"unicode"
)
/*
字符串中 中大小写 转换
1、func Title(s string) string
将字符串s每个单词首字母大写返回
2、func ToLower(s string) string
将字符串s转换成小写返回
3、func ToLowerSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成小写返回
4、func ToTitle(s string) string
将字符串s转换成大写返回
5、func ToTitl... |
package main
import (
"fmt"
"log"
"rabbitMQ/rabbitMQ"
)
func main() {
url := fmt.Sprintf("amqp://%s:%s@%s:%d/", "admin", "admin", "127.0.0.1", 5672)
err := rabbitMQ.RabbitMQ.Init(url)
if err != nil {
log.Fatalln(err)
}
rabbitMQ.RabbitMQ.SubscribeTopic(subscribe, "finebaas", "title")
rabbitMQ.RabbitMQ.Su... |
/*
* Copyright 2018, CS Systemes d'Information, http://www.c-s.fr
*
* 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 requir... |
package routes
import (
"lec13/controllers"
"github.com/gin-gonic/gin"
)
//SetupRouter ...
func SetupRouter() *gin.Engine {
r := gin.Default()
gr1 := r.Group("/api")
{
gr1.GET("user", controllers.GetUsers) //api/user +GET
gr1.POST("user", controllers.CreateUser) //api/user + POST (.json)
gr1.GET("user/... |
// 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 texture
import (
"github.com/hecate-tech/engine/gls"
"time"
)
// Animator can generate a texture animation based on a texture sheet
typ... |
package service
import (
"engine/config"
"engine/model"
"github.com/containerd/cgroups"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/ventu-io/go-shortid"
"log"
"sync"
)
const cgroupPrefix = "/fre_"
type CgroupPoolService struct {
pool []*CgroupInfo
mutex sync.Mutex
}
type CgroupInfo struc... |
package log
// Logger -
type Logger struct {
}
|
package main
import (
"flag"
"fmt"
"github.com/elliotchance/gedcom"
"os"
)
func runWarningsCommand() {
err := flag.CommandLine.Parse(os.Args[2:])
if err != nil {
fatalln(err)
}
gedcomFile := flag.Arg(0)
if gedcomFile == "" {
fatalln("you must provide a gedcom file")
}
doc, err := gedcom.NewDocumentFr... |
package main
import "fmt"
import "math"
func main() {
getRoot:=func(x float64) float64{
return math.Sqrt(x)
}
fmt.Println(getRoot(16))
var n[10] int
for i:=0;i<=9;i++ {
n[i]=i+100
}
for j:=0;j<=9;j++{
fmt.Printf("a[%d]= %d\n",j ,n[j])
}
var name = [] int {1000,3,2,50,17}
var avg float64
avg=get... |
/*
An array is positive dominant if it contains strictly more unique positive values than unique negative values.
Write a function that returns true if an array is positive dominant.
Notes
0 neither counts as a positive nor a negative value.
*/
package main
import "fmt"
func main() {
fmt.Println(isposdom([]int... |
package std
// short cut function to create specific error
func NewNeo4jQueryErr(msg string) *Err {
return &Err{
Code: Neo4jQueryErrCode,
Msg: msg,
}
}
type Err struct {
Code int64
Msg string
}
func (self *Err) Error() string {
return self.Msg
}
var (
SuccessCode int64 = 20000
DefaultErrCode i... |
package baikal
import (
"context"
"encoding/json"
"fmt"
"sync"
"github.com/ka2n/masminer/minerapi"
"golang.org/x/sync/errgroup"
"github.com/ka2n/masminer/machine/asic/base"
)
func (c *Client) GetStats() (stat MinerStats, err error) {
return c.GetStatsContext(context.Background())
}
func (c *Client) GetStat... |
package site
import (
"errors"
"io"
"log"
"text/template"
)
var (
ErrTemplateDoesNotExist = errors.New("The template does not exist.")
)
type Renderer struct {
path string
templates *template.Template
}
func NewRenderer(templatespath string, router *Router) (*Renderer, error) {
renderer := &Renderer{}
... |
/**
Create a slice to store the names of all the states. What is the length of your slice? What is
the capacity? Print out all the values along with their index position in the slice, without
using the range clause. Here is a list of all the states:
Andhra Pradesh, Arunachal Pradesh, Assam, Bihar, Chhattisgarh, Goa, G... |
package main
import (
"fmt"
"time"
)
func main() {
tick := time.Tick(time.Millisecond * 500)
for {
select {
case t:= <-tick:
fmt.Println("tick",t)
}
}
}
|
package table
import (
"bytes"
"strings"
)
func SimpleFormat(values [][]string) (string, string) {
headerBuffer := bytes.Buffer{}
valueBuffer := bytes.Buffer{}
for _, v := range values {
appendTabDelim(&headerBuffer, v[0])
if strings.Contains(v[1], "{{") {
appendTabDelim(&valueBuffer, v[1])
} else {
... |
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/pkg/model"
"github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/pkg/registry"
)
func (in *ServiceInsight) GetObjectMeta() *met... |
package main
import "fmt"
func main() {
type month int
type salary struct {
pf int
basePay int
}
type fullTimeEmp struct {
empId int
name string
WorkingHours int
salary
}
type ContractEmp struct {
empId int
name string
Duration month
salary //salary salary
}
... |
package e2e
// E2eEnrolementEntry structure repesenting an E2E public key enrolement
type E2eEnrolementEntry struct { // nolint
// ID string `json:"id" structs:"id" mapstructure:"id"`
Name string `json:"name" structs:"name" mapstructure:"name"`
PubKey string `json:"pubkey" structs:"pubkey" mapstructure:"pubkey"`
... |
package override_controller
import (
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"github.com/yjagdale/siem-data-producer/models/override_model"
"github.com/yjagdale/siem-data-producer/services/override_service"
"github.com/yjagdale/siem-data-producer/utils/response"
"io"
)
func AddOverride(c *gi... |
package hamming
import "errors"
//Distance - computes the hamming disstance between 'a' and 'b'
func Distance(a, b string) (int, error) {
if len(a) != len(b) {
return 0, errors.New("shit's on fire yo (and the strings should be the same length)")
}
ctr := 0
for i := 0; i < len(a); i++ {
if a[i] != b[i] {
c... |
package main
import (
"github.com/stretchr/testify/assert"
"testing"
"errors"
"time"
)
type TestClientSessionTransport struct {
ClientSessionTransport
sendError bool
sended []string
ch chan string
recvError chan error
}
func (t *TestClientSessionTransport) Send(str string) error {
if t.... |
// Copyright © 2018 Christian Müller <cmueller.dev@gmail.com>
//
// 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, cop... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.