text stringlengths 11 4.05M |
|---|
package cli
import (
"fmt"
"strings"
"github.com/10gen/realm-cli/internal/cli/user"
"github.com/10gen/realm-cli/internal/cloud/atlas"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/local"
"github.com/10gen/realm-cli/internal/terminal"
"github.com/10gen/realm-cli/interna... |
package main
/*
---------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any lat... |
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"github.com/gorilla/mux"
)
// UploadStartHandler accepts start upload session by
// returning an UploadID
func UploadStartHandler(w http.ResponseWriter, req *http.Request) {
type UploadStartOutput struct {
UploadID string `json:"upload_id"`
}
k :... |
/*
Copyright 2021 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 ksuid
import (
"testing"
)
func BenchmarkStandardGenerator_Next(b *testing.B) {
for i := 0; i < b.N; i++ {
Next()
}
}
func BenchmarkAsyncGenerator_Next(b *testing.B) {
g := NewAsyncGenerator()
go g.Run()
for i := 0; i < b.N; i++ {
g.Next()
}
} |
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"os"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/gobuffalo/pop"
"github.com/g... |
package pie
// A pair struct containing two zipped values.
type Zipped[T1, T2 any] struct {
A T1
B T2
}
// Zip will return a new slice containing pairs with elements from input slices.
// If input slices have diffrent length, the output slice will be truncated to
// the length of the smallest input slice.
func Zip[... |
// Copyright 2016 Matthew Endsley
// All rights reserved
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted providing that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions ... |
package proxy
import (
"encoding/json"
"fmt"
"time"
"golang.org/x/oauth2"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/pomerium/pomerium/internal/identity"
"github.com/pomerium/pomerium/internal/identity/manager"
"github.com/pomerium/pome... |
package server
import (
"bytes"
"context"
"fmt"
"log"
"testing"
config "github.com/chutommy/metal-price/currency/config"
currency "github.com/chutommy/metal-price/currency/service/protos/currency"
"gopkg.in/go-playground/assert.v1"
)
func TestNewCurrency(t *testing.T) {
l := log.New(bytes.NewBufferString("... |
package receivers
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
"strings"
"sync"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
"github.com/ClusterCockpit/cc-metric-collector/pkg/hos... |
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func findMode(root *TreeNode) []int {
if root==nil{return nil}
res:=[]int{}
max:=0
cur:=math.MinInt16
cnt:=0
return po(root,res,&max,&cur,&cnt)
}
func po(node... |
package controllers
import (
"context"
"fmt"
"github.com/humio/humio-operator/pkg/humio"
humioapi "github.com/humio/cli/api"
humiov1alpha1 "github.com/humio/humio-operator/api/v1alpha1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)
func (r *HumioActionReconciler) reco... |
package validator
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/authelia/authelia/v4/internal/configuration/schema"
"github.com/authelia/authelia/v4/internal/utils"
)
func TestShouldValidateGoodKeys(t *testing.T) {
configKeys := schema.Keys
v... |
package preprocess
import (
"encoding/json"
"fmt"
"strconv"
"github.com/docker/libcompose/config"
"github.com/ouzklcn/rancher-compose/utils"
)
type BindingProperty struct {
Services map[string]Service `json:"services"`
}
type Service struct {
Labels map[string]interface{} `json:"labels"`
Ports []interface{... |
package server
import (
"fmt"
"io/ioutil"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"gopkg.in/yaml.v2"
)
type config struct {
Port string `yaml:"port"`
}
type Server struct {
route *echo.Echo
cfg *config
}
//This function is unused for now
func getConfig(path string) (*config... |
package x
// GENERATED BY XO. DO NOT EDIT.
import (
"errors"
"strings"
//"time"
"ms/sun/shared/helper"
"strconv"
"github.com/jmoiron/sqlx"
)
// (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// PostCount represents a row from 'sun.post_coun... |
package main
type Human interface {
SayHi()
}
type Student struct {
name string
id int
}
func (s *Student) SayHi(){
fmt.Printf("Student [%s, %d] sayhi \n", s.name, s.id)
}
type Teacher sturct{
addr string
group string
}
func (t *Teacher) SayHi(){
fmt.Printf("Teacher [%s, %s] sayhi \n", t.addr, t.group)
}
... |
package main
import (
"fmt"
"github.com/gavincabbage/hello"
)
func main() {
fmt.Println(hello.Say())
} |
/*
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; th... |
package bundler
import (
"log"
"net/http"
"os"
"github.com/gorilla/mux"
"github.com/nytimes/gziphandler"
)
func initRouter() *mux.Router {
router := mux.NewRouter()
router.Handle("/v1/push/{app_id}/",
gziphandler.GzipHandler(AuthMiddleware(Push))).Methods("GET", "POST")
router.Handle("/v1/pull/{app_id}/",
... |
// Copyright 2021 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... |
package app
import (
"fmt"
"io"
"math/rand"
"net/http"
"os"
"time"
"./domain"
"./infrastructure"
"./providers"
"./usecase"
"./utils"
gzip "github.com/gin-contrib/gzip"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
)
//App has router and db instances
type App struct{}
var auth = providers... |
/*
* Copyright 2018- The Pixie 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 ag... |
package db
import (
"config"
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
const (
DEFAULT_DB_CONFIG = "db.ini"
)
// db 包装类
type SDBManager struct {
DB *sql.DB
DBCfg config.DBConfig
}
type SDBContainer struct {
dbc map[string]*SDBManager
}
var (
DBC SDBContainer
DBHandler *sql.DB
Err error
)... |
package gbnet
import (
"fmt"
"gober/gbinterface"
"gober/utils"
"net"
)
type Server struct {
logo string
//服务器名称
Name string
//服务器绑定的ip版本
IPVersion string
//服务器监听ip
Ip string
//服务器端口
Port int
//多路由处理器
msgHandler gbinterface.IMsgHandler
}
func (s *Server) Start(){
fmt.Printf("[Gober]Server Name : %s ,l... |
package graphql
import (
"context"
"github.com/Tinee/go-graphql-chat/middleware"
)
func (r *queryResolver) Me(ctx context.Context) (Viewer, error) {
tkn := middleware.GetToken(ctx)
id, err := r.validateAndExtractId(tkn)
if err != nil {
return Viewer{}, err
}
u, err := r.u.Find(id)
if err != nil {
return... |
package main
import (
"fmt"
"log"
"net/http"
"net/url"
"proxy/lib/proxy"
"regexp"
"strings"
)
const port = ":8080"
var imgReg = regexp.MustCompile(`<img[\s\S]*?src="([^"]+)`)
// convertResponse replaces all img's srcs' with Scarlet's pic
func convertResponse(body []byte) []byte {
s := string(body)
for _,... |
package main
import (
"fmt"
"encoding/hex"
"github.com/lt/go-cryptopals/cryptopals"
"sort"
)
type Score struct {
Value float64
Character byte
}
type ScoreSort []Score
func (slice ScoreSort) Len() int {
return len(slice)
}
func (slice ScoreSort) Less(i, j int) bool {
return slice[i].Value < slice[j].Value
}... |
package storage
import (
"docktor/server/types"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
)
// UsersRepo is the repo for users
type UsersRepo interface {
// Drop drops the content of the collection
Drop() error
// Save a user into database
Save(user types.User) (types.User, error)
// Delet... |
package main
import (
"encoding/json"
"fmt"
"github.com/hoisie/web"
"labix.org/v2/mgo"
"os"
)
var (
dbSession *mgo.Session
globalConfiguration *Configuration = new(Configuration)
)
// structs
type Reading struct {
Id string
Name string
}
type Configuration struct {
DatabaseServer str... |
package mysqldb
import (
"time"
)
// SmsSendStatus 短信发送状态
type SmsSendStatus int32
const (
// Pending 待定
Pending SmsSendStatus = 0
// Sending 发送中
Sending SmsSendStatus = 1
// SendSucceed 发送成功
SendSucceed SmsSendStatus = 2
// SendFailed 发送失败
SendFailed SmsSendStatus = 3
)
// Language 语言
type Language string... |
package accounts
import (
"errors"
"fmt"
)
var errNoMoney = errors.New("Can't withdraw")
// Account struct
type Account struct {
owner string
banlance int
}
// NewAccount create Account
func NewAccount(owner string) *Account {
account := Account{owner: owner, banlance: 0 }
return &account
}
// Deposit... |
/*
* @lc app=leetcode.cn id=1122 lang=golang
*
* [1122] 数组的相对排序
*/
package solution
import (
"sort"
)
// @lc code=start
var m map[int]int
type slice1122 []int
func (arr slice1122) Len() int {
return len(arr)
}
func (arr slice1122) Swap(i, j int) {
arr[i], arr[j] = arr[j], arr[i]
}
func (arr slice1122) Less(... |
package 性质判定
func isCompleteTree(root *TreeNode) bool {
if root == nil {
return true
}
leftTreeHeight, rightTreeHeight := getHeight(root.Left), getHeight(root.Right)
return leftTreeHeight == rightTreeHeight && isFullTree(root.Left) && isCompleteTree(root.Right) ||
leftTreeHeight == rightTreeHeight+1 && isCompl... |
package main
import "fmt"
type trueValue struct{}
type set map[int]trueValue
var t = trueValue{}
func main() {
fmt.Println(criticalConnections(4, [][]int{
[]int{0, 1}, []int{1, 2}, []int{2, 0}, []int{1, 3},
}))
}
func criticalConnections(n int, connections [][]int) [][]int {
result := make([][]int, 0)
verti... |
package fasthttpmiddleware
import (
"github.com/valyala/fasthttp"
"go.uber.org/zap"
)
// Middleware is a function which receive a fasthttp.RequestHandler then return a fasthttp.RequestHandler.
type Middleware func(h fasthttp.RequestHandler) fasthttp.RequestHandler
// MiddlewareOnion represent the middleware like a... |
// Copyright 2014 William H. St. Clair
// 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 ... |
package db
import (
"encoding/json"
"fmt"
"github.com/couchbase/gocb"
)
type DataStore interface{
Counter(key string, delta, initial int64, expiry uint32) (uint64, gocb.Cas, error)
Get(key string, valuePtr interface{}) (gocb.Cas, error)
Upsert(key string, value interface{}, expiry uint32) (gocb.Cas, error)
Rep... |
package transport_test
import (
"testing"
"time"
chat "github.com/greatchat/gochat/transport"
"github.com/greatchat/gochat/transport/mock"
)
func TestWappedClient(t *testing.T) {
c := &mock.Client{
SendFunc: func(dest string, msg chat.Message) error {
return nil
},
ReceiveFunc: func(src string) (chat.M... |
package main
import (
"fmt"
"os"
"sync"
)
type progressIndicator struct {
mutex sync.Mutex
cfg *Config
}
func (p *progressIndicator) Start(status string) {
if p.cfg.progress {
fmt.Fprint(os.Stderr, status+" ")
}
}
func (p *progressIndicator) Progress() {
if p.cfg.progress {
p.mutex.Lock()
fmt.Fprint... |
package input
import (
"io/ioutil"
"strconv"
"strings"
"github.com/truggeri/go-sudoku/cmd/go-sudoku/puzzle"
)
// LoadInput Creates Puzzle from a file path
func LoadInput(filepath string) (puzzle.Puzzle, error) {
var nums puzzle.Puzzle
bytes, err := ioutil.ReadFile(filepath)
if err != nil {
return nums, err... |
package common
//
// 文件名: calculator.go<br/>
// 创建时间: 2017年3月28日-下午3:20:58<br/>
// 简介: <br/>
// 详情: 公式计算器
// Copyright (C) 2013 duhaibo0404@gmail.com. All Rights Reserved.<br/>
//
import (
l4g "base/log4go"
"math"
"strconv"
)
// ($HP+ 12.7925 * $ATTACK + 12.7925 * $DEFENSE) * pow((1 + $HURT_PERCENT + $DEFEND_PERCE... |
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCalcPaymentPattarn(t *testing.T) {
haveCoin := CoinPattern{
coinOf500yen: 50,
coinOf100yen: 50,
coinOf50yen: 50,
}
result := CalcPaymentPattarn(7500, haveCoin)
expect := 266
assert.Equal(t, expect, len(result))
haveCoin ... |
package main
import (
"bufio"
"flag"
"fmt"
"math/rand"
"os"
"strings"
"time"
)
const (
numberOfCharactersPerWord float64 = 5.0
countBackFrom = 3
)
var (
numberOfExpectedWords = flag.Int("w", 20, "number of words")
numberOfTests = flag.Int("t", 1, "number of tests")
)
func init... |
package suuid
import (
uuid "github.com/nu7hatch/gouuid"
"log"
)
func GenUUID() string {
UUID, err := uuid.NewV4()
if err != nil {
log.Panic("suuid: ", err)
}
return UUID.String()
}
|
// 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... |
package libStarter
import (
"github.com/bb-orz/gt/utils"
"io"
"text/template"
)
func NewFormatterStarterTesting() *FormatterStarterTesting {
return new(FormatterStarterTesting)
}
type FormatterStarterTesting struct {
FormatterStruct
}
func (f *FormatterStarterTesting) Format(cmdParams *CmdParams) IFormatter {
... |
package service
import (
"reflect"
"testing"
"time"
"github.com/yogihardi/guestbook/model/servicemodel"
"github.com/yogihardi/guestbook/service/daomock"
"golang.org/x/net/context"
)
var serviceTest Service
func init() {
serviceTest, _ = NewService(context.Background(), daomock.DaoMock{})
}
func Test_service... |
/*
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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/li... |
package log
import (
"net/http/httptest"
"testing"
)
func TestStatusResponseWriter(t *testing.T) {
recorder := httptest.NewRecorder()
rw := &StatusResponseWriter{0, recorder}
rw.WriteHeader(300)
if res := rw.Status(); res != 300 {
t.Errorf("Expected status to be 300, but was %d", res)
}
}
|
package main
import (
"flag"
"fmt"
"os"
)
var cmdline = flag.NewFlagSet("", flag.ExitOnError)
var name = cmdline.String("name", "***", "your real name")
func loginprompt() {
fmt.Println(*name + " login successfully.")
}
func main() {
cmdline.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage Of %s: \n", "Questio... |
package numericconversion_test
import (
"testing"
"github.com/nandarimansyah/gobasicbenchmark/numericconversion"
)
func BenchmarkParseBool(b *testing.B) {
for n := 0; n < b.N; n++ {
_, err := numericconversion.MParseBool("true")
if err != nil {
panic(err)
}
}
}
func BenchmarkParseInt(b *testing.B) {
f... |
package master
import (
"github.com/OHopiak/fractal-load-balancer/core"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
"net/http"
)
func (m *Master) routes() {
m.balancer = NewWorkerBalancer(m.db)
proxy := Proxy(m.balancer)
userRequired := UserRequiredM... |
/**
* Created with IntelliJ IDEA.
* User: Administrator
* Date: 14-4-9
* Time: 下午4:12
* To change this template use File | Settings | File Templates.
*/
package main
import (
"net"
"time"
// "fmt"
)
type ClientCommand func (pConn *connection)
type connection struct {
id uint32 //
conn ... |
package main
import (
"github.com/alecthomas/kong"
"github.com/mattn/go-shellwords"
"io"
)
type CLI struct {
Tag CmdTag `cmd help:"Create/delete tags; View/add/remove users from tags;"`
Divvy CmdDivvy `cmd help:"Divvy the users in the bagel-chats channel or with a specific tag"`
Sync CmdSync `cmd help:"Sy... |
package blankhost
import (
"context"
"io"
ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr"
peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer"
pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore"
inet "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGo... |
// +build !linux linux,arm
package journald
type journald struct {
}
|
package kvs
import "fmt"
// MkdirError is an a kvs mkdir error.
type MkdirError struct {
Dir string
Err error
}
func (mde *MkdirError) Error() string {
return fmt.Sprintf("could not create %q directory: %v", mde.Dir, mde.Err)
}
// KVError is a general kvs error.
type KVError struct {
Key string
Err error
}
fu... |
package pollster
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
)
type DateEstimates []struct {
Date string `json:"date"`
Estimates []struct {
Choice string `json:"choice"`
Value float32 `json:"value"`
} `json:"estimates"`
}
type Estimates []struct {
Choice string `js... |
package nv7haven
import (
"encoding/json"
"fmt"
"time"
"github.com/gofiber/fiber/v2"
)
type eodStats struct {
refreshTime time.Time
Labels []string `json:"labels"`
Found []int `json:"found"`
Elemcnt []int `json:"elemcnt"`
Categorized []int `json:"categorized"`
Combcnt []int `json:"combcnt"`
... |
package local
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"os"
"path/filepath"
"github.com/10gen/realm-cli/internal/cloud/realm"
)
const (
maxDirectoryContainSearchDepth = 8
)
const (
// BackendPath is the relative path to write app contents to when we have templates
BackendPath = "backend"
// ... |
//
// Copyright (c) 2016 Intel Corporation
//
// 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... |
package middleware
import (
"github.com/google/uuid"
"net/http"
)
const CorrelationKey string = "x-correlation-id"
func CorrelationManager(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
correlationId := r.Header.Get(CorrelationKey)
if correlationId ==... |
package util
import (
log "github.com/sirupsen/logrus"
"os"
)
func SetupLogger(logFile string) error {
log.SetFormatter(&log.JSONFormatter{})
file, err := os.OpenFile(logFile, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
if err == nil {
log.SetOutput(file)
defer file.Close()
}
log.Info("Started")
return err... |
package conf
import (
"pcps/internal/setting"
"time"
)
//GetString 获取string类型的全局配置文件 这种做法较low 暂时先这样
func GetString(name string) string {
switch name {
case "jwt_secret":
return setting.PCPSSetting.JwtSecret
case "port":
return setting.ServerSetting.HttpPort
default:
return ""
}
}
//GetTime 时间类型的配置
func ... |
package main
import (
"fmt"
"os"
"io"
)
func getCpArgs(args []string) (bool, string, string, string) {
isValid := false
var command, sourceFileName, destinationFileName string
if len(args) == 1 {
fmt.Println("%s: missing file operand", args[0] )
os.Exit(-1)
} else if len(args) == 2 {
fmt.Println("%s: mi... |
package main
import (
"io/ioutil"
"net/http"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
const (
gimeiNameYamlURL = "https://raw.githubusercontent.com/willnet/gimei/master/lib/data/names.yml"
gimeiAddressYamlURL = "https://raw.githubusercontent.com/willnet/gimei/master/lib/data/addresses.yml"
)
type gimei... |
package main
import "fmt"
func main() {
// 声明一个含有10个元素元素类型为byte的数组
var ar = [10]byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}
// 声明两个含有byte的slice
var a, b []byte
// a指向数组的第3个元素开始,并到第五个元素结束,
a = ar[2:5]
//现在a含有的元素: ar[2]、ar[3]和ar[4]
// b是数组ar的另一个slice
b = ar[3:5]
// b的元素是:ar[3]和a... |
package database
import (
"context"
"crypto/sha256"
"fmt"
"time"
"gorm.io/gorm"
)
const QUERY_KEY = "QUERY_KEY_DB_GORM"
func NewQueryContext(ctx context.Context, db *gorm.DB) context.Context {
h := sha256.New()
h.Write([]byte(fmt.Sprintf("%v", time.Now().UTC())))
privateKey := fmt.Sprintf("%x", h.Sum(nil))
... |
// 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 controllers
import (
"go.mongodb.org/mongo-driver/bson/primitive"
"context"
"encoding/json"
"fmt"
"net/http"
"rank-server-pikachu/app/functions"
"rank-server-pikachu/app/models"
"rank-server-pikachu/app/util"
"strconv"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
... |
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2017
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package tsl2561
import (
sensors "github.com/djthorpe/sensors"
)
///////////////////////////////////////... |
// Copyright 2017 The Upspin 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 openstack implements a storage backend that saves
// data to an OpenStack container, e.g., OVH Object Storage.
package openstack // import "opens... |
package db
import (
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
log "github.com/sirupsen/logrus"
"github.com/johnull/mop-ng/internal/db/model"
"github.com/johnull/mop-ng/internal/algoutil"
)
const (
defaultMaxOpenConn = 50
defaultMaxIdleConn = 20
)
var engine *xorm.Engine
var DB *core.DB
func MustSta... |
// gomm-online main
package main
import (
"time"
"flag"
"strings"
"math/rand"
"net/http"
"libs/log"
"room"
)
const (
HOST_PORT = "127.0.0.1:80"
)
var host_port *string = flag.String("h", HOST_PORT, "host:port for HTTP service Listen to.")
var level *string = flag.String("l", "[debug|... |
package refresh
import (
"net/http"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/lcsphantom/savenote-server/api"
"github.com/lcsphantom/savenote-server/db"
)
// Refresh user token
func Refresh(context *gin.Context) {
// Get user data to this struct
var... |
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"sync"
"time"
"github.com/pkg/errors"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
)
const (
apiHost = "http://127.0.0.1:8001"
certEndpoint = "/apis/stable.k8s.psg.io/v1/namespaces/%s/certif... |
package language
import "strings"
var tc = LangSet{
"managers": "管理員管理",
"name": "用戶名",
"nickname": "暱稱",
"role": "角色",
"createdat": "創建時間",
"updatedat": "更新時間",
"path": "路徑",
"submit": "提交",
"filter": "篩選",
"new": "新建",
"action": "操作",
"toggle dropdown": "下拉",... |
/*****************************************************************
* Copyright©,2020-2022, email: 279197148@qq.com
* Version: 1.0.0
* @Author: yangtxiang
* @Date: 2020-08-14 14:17
* Description:
*****************************************************************/
package gcontext
import (
"bytes"
"fmt"
)
func (p *TW... |
package database
import (
"encoding/json"
"errors"
"log"
_ "github.com/go-sql-driver/mysql"
_ "github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
_ "github.com/jinzhu/inflection"
"github.com/motonary/Fortuna/entity"
)
func CreateUser(user *entity.User) (*entity.User, error) {
DB.Create(&user... |
package expect
import (
"fmt"
"reflect"
"time"
)
type request string
const (
patchRequest request = "PatchData"
putRequest request = "PutData"
insertPolicyRequest request = "InsertPolicy"
deletePolicyRequest request = "DeletePolicy"
noRequest request = "Nothing"
)
// Request repres... |
package main
import "sort"
func minPairSum(nums []int) int {
sort.Ints(nums)
res := 0
for i, j := 0, len(nums)-1; i < j; {
res = max(res, nums[i]+nums[j])
i++
j--
}
return res
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
|
package server
type Server interface {
Run()
ListenError() <-chan error
}
|
package main
import "fmt"
func main() {
r := longestSubstringWithoutRepeatingChars("abcbd")
fmt.Println(r) // 3
r = longestSubstringWithoutRepeatingChars("abcabcbb")
fmt.Println(r) // 3
r = longestSubstringWithoutRepeatingChars("abcab")
fmt.Println(r) // 3
r = longestSubstringWithoutRepeatingChars("aaaaa")
... |
package postgis
import (
"encoding/json"
"fmt"
"github.com/geodan/gost/src/sensorthings/entities"
"database/sql"
"errors"
gostErrors "github.com/geodan/gost/src/errors"
"github.com/geodan/gost/src/sensorthings/odata"
"strings"
)
func thingParamFactory(values map[string]interface{}) (entities.Entity, error)... |
package system
import (
"github.com/layer5io/meshkit/errors"
)
const (
ErrHealthCheckFailedCode = "1000"
ErrInvalidAdapterCode = "1001"
ErrDownloadFileCode = "1002"
)
func ErrHealthCheckFailed(err error) error {
return errors.New(ErrHealthCheckFailedCode, errors.Alert, []string{"Health checks failed"}, ... |
package common
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
"github.com/pkprzekwas/fakeApp/config"
)
type Database struct {
*gorm.DB
}
var DB *gorm.DB
func buildConnString(config *config.DBConfig) string {
return fmt.Sprintf(
"host=%s user=%s dbname=%s sslmode=disable... |
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/authelia/authelia/v4/internal/model"
)
func newGitHubCmd() *cobra.Command {
cmd := &cobra.Command{
Use: cmdUseGitHub,
Short: "Generate GitHub files",
RunE: rootSubCommandsRunE,
DisableAutoGe... |
package util
import (
"bytes"
"fmt"
"path/filepath"
"runtime"
)
const fileLinePrefixFormat string = "%s:%d: "
// StackError represents an error with an associated stack trace.
type StackError interface {
CallsiteError
Stack() []byte
}
type stackError struct {
Message string
filename string
function ... |
// consider the line below as "black magic" first
package main;
// add in the functionality to show stuff on the console
import "fmt"
// all Go program begins in within this func main block
func main() {
// just having a single value by itself is legit code but does nothing, and is considered as an error
// 4
//... |
package game
import (
"github.com/tanema/amore/gfx"
)
var (
background *gfx.Image // our background image (loaded below)
sprites *gfx.Image // our spritesheet (loaded below)
backgrounds = map[string]*gfx.Quad{}
spriteSheet = map[string]*gfx.Quad{}
billboards = []*gfx.Quad{}
plants = []*gfx.Qua... |
package nes
import (
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/canvas"
"fyne.io/fyne/driver/desktop"
"fyne.io/fyne/widget"
"github.com/vfreex/gones/pkg/emulator/joypad"
"github.com/vfreex/gones/pkg/emulator/ppu"
"image"
"image/color"
"math/rand"
"time"
)
// resolution 256x240
const (
SCREEN_WIDTH ... |
package fslm
import (
"bytes"
"encoding/gob"
"github.com/kho/word"
)
type xqwEntry struct {
Key word.Id
Value StateWeight
}
type xqwMap struct {
buckets xqwBuckets
numEntries, threshold int
}
func newXqwMap(initNumBuckets int, maxUsed float64) *xqwMap {
if initNumBuckets == 0 {
initNumBuc... |
package query
import (
"fmt"
"path"
"testing"
"github.com/stretchr/testify/assert"
"core"
)
func makeTarget(g *core.BuildGraph, packageName string, labelName string, outputs []string) *core.BuildTarget {
l := core.ParseBuildLabel(fmt.Sprintf("//%s:%s", packageName, labelName), "")
t := core.NewBuildTarget(l)... |
// 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... |
/*
Alienese refers to two "languages" in the show Futurama. In actuality, they are two ciphers of English text with a pictographic alphabet.
The first is a simple substitution cipher, but the second is slightly more complex. The second is a type of autokey cipher that follows these steps:
Take a word to be encrypted,... |
package factory
import (
"fmt"
"reflect"
"cloudfreexiao/ant-graphql/backend-go/dao/mysqldb"
"cloudfreexiao/ant-graphql/backend-go/lib/logapi"
)
//定义注册结构map
type SchemasStructMap struct {
maps map[string]reflect.Type
}
var schemasMap *SchemasStructMap = &SchemasStructMap{make(map[string]reflect.Type)}
//根据名字注... |
package db
import (
"database/sql"
"fmt"
// Postgresql Driver
_ "github.com/lib/pq"
"s3-web-browser/server/go/setting"
)
// Connection is a function that get backend db
func Connection() (*sql.DB, error) {
stg := setting.ServerSetting
host := stg.DBHost
port := stg.DBPort
user := stg.DBUser
pass := ... |
/**
* Author: Admiral Helmut
* Created: 12.06.2019
*
* (C)
**/
package routes
import (
"github.com/efi4st/efi4st/dbprovider"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/kataras/iris/v12"
"os"
"strconv"
"strings"
)
func RelevantApps(ctx iris.Context) {
relevantApps := dbpr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.