text stringlengths 11 4.05M |
|---|
// Empty file containing instructions for “go generate” on how to rebuild the
// capnproto generated code.
package proto
//go:generate protoc types.proto snapshot.proto --gofast_out=.
|
package main
import (
"fmt"
"github.com/jackytck/projecteuler/tools"
)
func next(n int) int {
var c int
for _, d := range tools.Digits(n) {
c += d * d
}
return c
}
func solve(bound int) int {
var cnt int
m1 := make(map[int]bool)
m89 := make(map[int]bool)
for i := 2; i < bound; i++ {
t := i
for t != ... |
package fdfs_client
import cfgWs "configs/web_server"
type config struct {
trackerAddr []string
maxConns int
}
func newConfig() (*config, error) {
config := &config{}
config.trackerAddr = append(config.trackerAddr, cfgWs.TrackerServerAddr)
config.maxConns = cfgWs.MaxConn
return config, nil
}
|
package http
import (
"encoding/json"
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
"net/http"
"github.com/go-chi/chi"
chimiddleware "github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/render"
"github.com/owncloud/ocis-hello/pkg/assets"
"github.com/owncloud/ocis-hello/pkg/proto/v0"
"github.com/owncloud/oc... |
// Written by Andres Erbsen, distributed under GPLv3
package main
import (
"bytes"
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/binary"
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
)
func Exists(name string) bool {
if _, err := os.Stat(name); err ... |
package rtrclient
type RtrClientStartModel struct {
Server string `json:"server"`
Port string `json:"port"`
}
type RtrClientSerialQueryModel struct {
SessionId uint16 `json:"sessionId"`
SerialNumber uint32 `json:"serialNumber"`
}
|
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
var redisAddr = "192.168.3.158:6379"
func main() {
c, err := redis.Dial("tcp", redisAddr)
if err != nil {
fmt.Println("connect to redispt error:", err)
return
}
defer c.Close()
key := "test1"
_, err = c.Do("SET", key, "super")
if err != n... |
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"os"
"encoding/json"
"fmt"
)
type BaseInfo struct {
Id int `json:"id"`
CompanyName string `json:"company_name"`
}
var db *sql.DB
func init() {
db, erro := sql.Open("mysql", "root:root@tcp(localhost:3306)/test?charset=utf8")
... |
package inventoryd
// DLTS1.2における以下の要求は現時点では実装しない
// Handshakeの再送
// Handshakeの並び替え
// Handshakeの断片化の対応
import (
"context"
"crypto/aes"
"crypto/cipher"
"encoding/binary"
"errors"
"math/rand"
"net"
"time"
)
// 暗号スイートはTLS_PSK_WITH_AES_128_CCM_8で固定
// Lwm2mで最低限サポートしなければならない暗号スイートとして規定されている
// OMA-TS-Lightweight... |
// Copyright 2021 Google LLC
//
// 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 ... |
package linkedin
import (
"encoding/json"
"golang.org/x/oauth2"
ln "golang.org/x/oauth2/linkedin"
"io/ioutil"
"net/http"
)
type Linkedin struct {
}
// Create of the new access for linkedin
func New(appId, appSecret, redirect string, scopes []string) {
lnConfig := &oauth2.Config {
ClientID: appId,... |
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"os"
)
var (
RootCmd = cobra.Command{}
)
func Excute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
// viper
}
|
package voteutil
import "errors"
import "sort"
import "strconv"
import "net/url"
type NameRating struct {
Name string
Rating float64
}
//type NameVote map[string] float64
//type IndexVote map[int] float64
type NameVote []NameRating
// IndexVote is perhaps excessively optimized to pack nicely.
//
// You might th... |
package main
import (
"fmt"
)
//有缓冲,可以打印出Go Go Go。
//func main() {
// c := make(chan bool, 1)
// go func() {
// fmt.Println("GO GO GO!")
// c <- true
// }()
// goroutine在buffered channel为空时读取会阻塞。所以这里会等待buffered channel有值写入后再读取。
// 等待goroutine完成,所以无论如何都会打印出Go Go GO!
// <-c
//}
//不会打印Go Go Go。
//func main() {
// c ... |
package redis
import (
"fmt"
redis "gopkg.in/redis.v5"
)
// Sort performs a sort redis operations
func Sort() error {
conn, err := Setup()
if err != nil {
return err
}
listkey := "list"
if err := conn.LPush(listkey, 1).Err(); err != nil {
return err
}
// this will clean up the list key if any of the su... |
package object
import (
"fmt"
"time"
)
// Timestamp is a UNIX timestamp in ISO 1806 format
type Timestamp struct {
time.Time
}
// MarshalJSON implements serialization for a timestamp
func (t Timestamp) MarshalJSON() ([]byte, error) {
s := fmt.Sprintf("\"%s\"", t.Format(time.RFC3339Nano))
return []byte(s), nil
}... |
// Package service must implement the generated proto's server interface
package service
import (
"context"
"strings"
"time"
proto "github.com/ankurs/Feed/Feed/Feed_proto"
"github.com/ankurs/Feed/Feed/service/store"
"github.com/ankurs/Feed/Feed/service/store/db"
"github.com/carousell/Orion/utils/errors"
"gith... |
package phases
import (
"mobingi/ocean/pkg/constants"
"mobingi/ocean/pkg/tools/machine"
cmdutil "mobingi/ocean/pkg/util/cmd"
"path/filepath"
)
func MasterPrepareJob(certs map[string][]byte, kubeconfs map[string][]byte) *machine.Job {
j := machine.NewJob("master-prepare")
writeMasterPKI(j, certs)
writeMasterKub... |
package pgeo
import (
"database/sql/driver"
"errors"
"fmt"
"regexp"
)
var closedPathRegexp = regexp.MustCompile(`^\(\(`)
// Path is represented by lists of connected points.
// Paths can be open, where the first and last points in the list are considered not connected,
// or closed, where the first and last poin... |
package main
import (
"errors"
"flag"
"fmt"
"image"
"image/jpeg"
"image/png"
"io"
"log"
"math"
"os"
"path"
"strings"
"github.com/nfnt/resize"
"github.com/zekroTJA/slicerdicer/pkg/slicerdicer"
)
var (
flagImageFile = flag.String("i", "", "imput image file")
flagSlicesPerSide = flag.Int("s", 2, "am... |
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
//demo()
//timeAfter()
//timeAfterFor()
timeAfterForFixed()
}
// normal case (no loop)
func timeAfter() {
ch := make(chan string)
go func() {
time.Sleep(3 * time.Second)
ch <- "haha"
}()
select {
case x := <-ch:
fmt.Println(x)
case <-tim... |
package db
import (
log "github.com/sirupsen/logrus"
"github.com/johnull/mop-ng/internal/db/model"
)
func QueryRechargeList(offset, count int, agentId int64, isSuperadmin bool) ([]model.Recharge, int64, error) {
var bean = &model.Recharge{AgentId: agentId}
if isSuperadmin {
bean = &model.Recharge{}
}
var rech... |
package dushengchen
/*
Submission:
https://leetcode.com/submissions/detail/282698341/
*/
var roman2intMap = map[byte]int{
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000,
}
func romanToInt(s string) int {
ret := 0
for i:=0; i < len(s); i++ {
num, ok := ... |
package queue
import (
"fmt"
)
// 自定义 Queue
type Queue struct {
data []int
front, tail int
}
func (q *Queue) String() string {
if q.front == q.tail {
return "nothing"
}
return fmt.Sprint("front: ", q.data, " tail")
}
func NewQueue() Queue {
return Queue{
data: make([]int, 0),
front: 0,
tail: ... |
package main
import (
"context"
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"io"
"net"
"time"
"github.com/labstack/gommon/log"
"github.com/wexel-nath/grpc-go-course/greet/greetpb"
"google.golang.org/grpc"
)
type server struct {}
func (*server) Greet(ctx context.Context, req *greet... |
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"github.com/kouame-florent/axone-cx/internal/ui"
)
func main() {
app := app.NewWithID("axone-cx")
win := app.NewWindow("Axone")
win.Resize(fyne.NewSize(1280, 480))
//grpcCli, conn := svc.GrpcClient()
auth := ui.NewAuth(app, win)
auth.MakeUI()
... |
// This file was generated for SObject ForecastShare, API Version v43.0 at 2018-07-30 03:47:37.018617875 -0400 EDT m=+23.362100922
package sobjects
import (
"fmt"
"strings"
)
type ForecastShare struct {
BaseSObject
AccessLevel string `force:",omitempty"`
CanSubmit bool `force:",omitempty"`
Id ... |
package pegawai
import (
"fmt"
"math/rand"
"os"
"pegawaimicroservice/model"
"time"
"github.com/gin-gonic/gin"
"github.com/imroc/req"
"github.com/jinzhu/gorm"
"github.com/joho/godotenv"
"go.opencensus.io/trace"
)
type Pegawai struct {
DB *gorm.DB
}
type Units struct {
Unit []Unit `json:"data"`
}
type Uni... |
/*
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
*/
// 'dfcloader' is a load generator for DFC.
// It sends HTTP requests to a proxy server fronting targets.
// Run with -help for usage information.
// Examples:
// 1. No put or get, just clean up:
// dfcloader -bucket=liding-dfc -duration 0s -to... |
package day05
/*
参见
1.https://golang.org/cmd/go/
2.Ctrl + F 搜索tool
1.Run specified go tool
Demo
1.生成CPU profile: go test -bench=. -cpuprofile cpu.out
1.查看画像
1.交互模式
1.go tool pprof fabonacci.test.exe cpu.out
1.top10 查看top N
2.web
1.go tool pprof -http=:80 cpu.out
2.go tool pprof -web cpu.o... |
package epdcolor
import (
"image"
"testing"
)
func TestGray3Image(t *testing.T) {
img := NewGray3Image(image.Rectangle{image.Point{0, 0}, image.Point{4, 1}})
img.Set(0, 0, Gray3Gray)
img.Set(1, 0, Gray3White)
img.Set(2, 0, Gray3Black)
img.Set(3, 0, Gray3Gray)
if c := img.At(0, 0); c != Gray3Gray {
t.Errorf(... |
package utils
import (
"backend/src/global"
"os"
"path/filepath"
)
// 获取文件名
func GetFileName(filePath string) string {
_, file := filepath.Split(filePath)
return file
}
func GetWd() string {
wd, _ := os.Getwd()
return wd
}
// 获取父目录
func GetParentDir(filePath string) string {
parentDir, _ := filepath.Split(f... |
package main
import (
"experiments/experiments/evolvingpictures/apt"
"github.com/veandco/go-sdl2/sdl"
"math/rand"
"time"
)
const (
windowWidth = 1200
windowHeight = 800
windowDepth = 100
)
type audioState struct {
explosionBytes []byte
deviceId sdl.AudioDeviceID
audiSpec *sdl.AudioSpec
}
typ... |
package futures
import (
"testing"
"github.com/stretchr/testify/suite"
)
type userStreamServiceTestSuite struct {
baseTestSuite
}
func TestUserStreamService(t *testing.T) {
suite.Run(t, new(userStreamServiceTestSuite))
}
func (s *userStreamServiceTestSuite) TestStartUserStream() {
data := []byte(`{
"l... |
package main
import (
"fmt"
)
func main() {
tal("Sunandan", "Sarkar", "Novi", "Sarkar")
boo("Jesmine", 4, 6, 8, 10, 12)
//final argument(l ...string) or (bm ...int) is assignable to a slice type []T
Greeting("nobody")
//1st call,within Greeting, who will have the value nil in the first call
Greeting("hello:", ... |
package middleware
import (
// log "github.com/coupa/foundation-go/logging"
"github.com/gin-gonic/gin"
"github.com/satori/go.uuid"
"net/http"
)
const correlationHeader = "X-CORRELATION-ID"
func Correlation() gin.HandlerFunc {
return func(c *gin.Context) {
SetCorrelation(c.Request, c.Writer)
c.Next()
}
}
f... |
package main
import (
"fmt"
"strconv"
)
func main() {
a := 25379.0 - 10.0
b := 25379.0
c := a / b
fmt.Println(c)
c100 := c * 100
rateStr := strconv.FormatFloat(c100, 'f', 1, 64) + "%"
fmt.Println(rateStr)
rateStr2 := fmt.Sprintf("%.1F%%\n", c100)
fmt.Println(rateStr2)
rateStr3 := fmt.Sprintf("%.2f%%\n... |
package rest
import (
"net/http"
"sync"
"time"
"github.com/GoPracPro/src/local/platform/rest/errors"
"github.com/GoPracPro/src/local/platform/rest/util"
)
var once sync.Once
var instance ClientWrapper
//ClientWrapper for rest client implementaion
type ClientWrapper interface {
/**Execute method will invoke un... |
func permute(nums []int) [][]int {
return sol1(nums)
}
type x struct {
res []int
rest []int
}
// time: O(n!), space: O(n!)
func sol1(nums []int) [][]int {
if len(nums) == 1 {
return [][]int{nums}
}
var result [][]int
q := make([]x, 0)
for i, n := range nums {
rest := ma... |
package adapter
import (
"fmt"
"github.com/giantswarm/microerror"
"github.com/giantswarm/aws-operator/service/controller/clusterapi/v30/key"
)
const (
// Default values for health checks.
healthCheckHealthyThreshold = 2
healthCheckInterval = 5
healthCheckTimeout = 3
healthCheckUnhealt... |
/*
Wikipedia: Zeno's Dichotomy Paradox
An infinite number of mathematicians walk into a bar. The first one orders a beer. The second one orders half a beer. The third one orders a fourth of a beer. The bartender stops them, pours two beers and says, "You're all a bunch of idiots."
Reddit
Print the following... |
package providers
import "github.com/ccutch/webapp/pages"
// PageProvider is a generalized implementation of a provider which renders pages.
type PageProvider struct {
Pages []pages.Page
}
func NewPageProvider(...pages Page) *PageProvider {
p := &PageProvider{
Pages: pages,
}
return p
}
func (p *PageProv... |
package httpServ
import (
"net/http"
"sub_account_service/fabric_server/api"
"github.com/gin-gonic/contrib/gzip"
"github.com/gin-gonic/gin"
"github.com/golang/glog"
)
func Handler(f func(c *gin.Context)) func(c *gin.Context) {
return func(c *gin.Context) {
defer func() {
if err := recover(); err != nil {... |
package cmd
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"io/ioutil"
"os"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
)
var cfgFile string
var confName = ".atcoder.toml"
var debugFlag bool
var version string
// rootCmd represents the base command when called wit... |
/**
* blog_handler
* @author liuzhen
* @Description
* @version 1.0.0 2021/1/29 17:43
*/
package handler
import (
"backend/src/module"
"backend/src/service"
"github.com/gin-gonic/gin"
)
// 保存博客
func AddBlog(ctx *gin.Context) {
var param module.Blog
_ = ctx.ShouldBind(¶m)
WrapperResponseBody(ctx, servic... |
// Package inmemory contains an in-memory implementation of the databroker backend.
package inmemory
import (
"context"
"fmt"
"sort"
"sync"
"sync/atomic"
"time"
"github.com/google/btree"
"github.com/rs/zerolog"
"golang.org/x/exp/maps"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/kno... |
package table
import "fmt"
type Table struct {
data []interface{}
width int
height int
}
func New(width int, height int) Table {
return Table{
data: make([]interface{}, width*height),
width: width,
height: height,
}
}
func (table *Table) Fill(value interface{}) {
for i := range table.data {
tabl... |
// Copyright 2018 Andrew Bates
//
// 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 wri... |
package main
import "fmt"
func main() {
var val int
fmt.Scan(&val)
fmt.Print(val * 2)
}
// OK --:02:00
|
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/canvas", handleCanvas)
log.Printf("server start on localhost:%d\n", 18080)
err := http.ListenAndServe(":18080", nil)
if err != nil {
log.Fatal("ListenAndServe:", err)
}
}
func handleCanvas(w http.ResponseWriter, r *http.Request) {
log... |
func countBattleships(board [][]byte) int {
count := 0
for r := 0; r < len(board); r++ {
for c := 0; c < len(board[r]); c++ {
if board[r][c] == 88 && !isAlreadyCounted(board, []int{r, c}) {
count += 1
}
}
}
return count
}
func isAlreadyCounted(board [][]byte, pos []int) bool {
up := pos[0] != 0 && b... |
package util
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
// Pretty print structure
// anything - any interface
func PrettyPrint(anything interface{}, indent bool) {
var b []byte
var err error
if indent {
b, err = json.MarshalIndent(anything, "", "\t")
} else {
b, err = json.Marshal(anyt... |
package main
// TODO : Can become a standalone package
// TODO : Can be splitted into Entity / Specialized packages (description config files)
import (
"time"
"fmt"
"crypto/md5"
"encoding/hex"
"strconv"
"reflect"
)
/* Voir pour faire des structures de sortie un peu moins gores... */
type User ... |
package rest
import "github.com/sparkymat/webdsl/http"
type Action string
const Create Action = "create"
const New Action = "new"
const Update Action = "update"
const Edit Action = "edit"
const Index Action = "index"
const Show Action = "show"
const Destroy Action = "destroy"
func (action Action) Method() http.Meth... |
package main
import (
"errors"
"fmt"
//"github.com/emicklei/hopwatch"
"bytes"
"log"
"runtime"
"time"
)
// source https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/C24fRw8HDmI
// from David Wright
type ErrorTrace struct {
err error
trace string
}
func NewErrorTrace(v ...inte... |
package config
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/instructure-bridge/muss/testutil"
)
func TestConfigLoad(t *testing.T) {
testutil.WithTempDir(t, func(tmpdir string) {
testutil.WriteFile(t, defaultProjectFile, `project_name: stinky`)
testutil.WriteFile(t, defaultUserF... |
package main
//package server
import (
"net/rpc"
"net/http"
"net"
"log"
"fmt"
"tribproto"
"flag"
"time"
"strconv"
"strings"
"storageserver"
"storagerpc"
"math/rand"
)
type Tribserver struct {
ss *storageserver.Storageserver
createUserChan chan string
createUserReplyChan chan... |
package device
// #include <SoapySDR/Device.h>
// #include <SoapySDR/Formats.h>
// #include <SoapySDR/Types.h>
import "C"
import (
"fmt"
"github.com/pothosware/go-soapy-sdr/pkg/sdrerror"
)
// Direction is the direction of the Data in the device TX and RX
type Direction int
const (
// DirectionTX represents the tr... |
package sleepy
type SequenceBuffer struct {
latest uint16
entries []uint32
}
func NewSequenceBuffer(cap uint16) SequenceBuffer {
s := SequenceBuffer{entries: make([]uint32, cap, cap)}
s.Reset()
return s
}
func (s *SequenceBuffer) Reset() {
s.latest = 0
resetSequenceBuffer(s.entries)
}
func (s *SequenceBuff... |
package main
import "time"
// NewDateIndexCollector returns a new date index collector.
func NewDateIndexCollector() *DateIndexCollector {
return &DateIndexCollector{
ByYear: map[int]int{},
ByMonth: map[int]map[time.Month]int{},
ByDay: map[int]map[time.Month]map[int]int{},
}
}
// DateIndexCollector return... |
package main
import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/andywow/golang-lessons/lesson-calendar/internal/calendar/config"
"github.com/andywow/golang-lessons/lesson-calendar/internal/calendar/logconfig"
"github.com/andy... |
package amazonpa
// Endpoints are the Amazon API endpoints by region
var Endpoints = map[string]string{
"BR": "webservices.amazon.com.br",
"CA": "webservices.amazon.ca",
"CN": "webservices.amazon.cn",
"DE": "webservices.amazon.de",
"ES": "webservices.amazon.es",
"FR": "webservices.amazon.fr",
"IN": "webservices... |
package main
import (
//"fmt"
"github.com/liangdas/mqant"
"github.com/liangdas/mqant/module/modules"
"server/gate"
"server/webapp"
)
func main() {
app:= mqant.CreateApp()
app.Run(true,
modules.MasterModule(),
gateAlpha.Module(), //这是默认网关模块,是必须的支持 TCP,websocket,MQTT协议
//game.Module(),
//login.Module(... |
package main
import (
"context"
"log"
"net/http"
"github.com/graphql-go/graphql"
"github.com/graphql-go/handler"
"./app/models"
"./app/types"
)
func main() {
// setup db handle
db, err := models.NewDB("./app/types/test.db")
if err != nil {
log.Panic(err)
return
}
// the context we want to pass
// i... |
// Package match contains a high-level parser for demos.
package match
import (
"log"
"math"
"os"
"sort"
"strconv"
"time"
"github.com/cheggaaa/pb/v3"
common "github.com/linus4/csgoverview/common"
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
demoinfo "github.com/markus-wa/demoinfocs-golang/... |
// Copyright © 2019 mg
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, ... |
package main
import (
"github.com/danjacques/pixelproxy/applications/pixelproxy"
)
func main() {
pixelproxy.Execute()
}
|
package admin
import (
"bytes"
"crypto/md5"
"cwengo.com/models"
"fmt"
"github.com/astaxie/beego"
"io"
)
type LoginController struct {
beego.Controller
}
func (this *LoginController) Get() {
this.TplNames = "admin/signin.html"
}
func (this *LoginController) Post() {
this.TplNames = "admin/signin.html"
user... |
// Created at 10/21/2021 2:33 PM
// Developer: trungnq2710 (trungnq2710@gmail.com)
package go_apns
const (
StatusCodeSuccess = 200
StatusCodeBadRequest = 400
StatusCodeErrorCertificateOrToken = 403
StatusCodeInvalidPath = 404
StatusCodeMethodUnsupported = 405
Statu... |
package resolver
import (
"github.com/taktakty/netlabi/models"
genModels "github.com/taktakty/netlabi/models/generated"
"context"
)
type hostOSResolver struct{ *Resolver }
func (r *queryResolver) GetHostOs(ctx context.Context, input genModels.GetIDInput) (*models.HostOS, error) {
var hostos models.HostOS
hostos... |
package logger
import (
"context"
"os"
log "github.com/sirupsen/logrus"
)
func GetLoggerWithCtx(ctx context.Context) *log.Entry {
return log.WithField(os.Getenv("APP_REQUEST_ID"), ctx.Value(os.Getenv("APP_REQUEST_ID")).(string))
}
|
package event
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// Provider returns a terraform.ResourceProvider.
func Provider() terraform.ResourceProvider {
return &schema.Provider{
ResourcesMap: map[string]*schema.Resource{
"vkg_1on1": oneOnOne(),
... |
package irisutil
import (
"reflect"
"fmt"
"gopkg.in/kataras/iris.v6"
"strconv"
)
//FormRequest form
func FormRequest(ctx *iris.Context, request interface{}, callback func() (interface{}, error)) (interface{}, error) {
formValues := ctx.FormValues()
if formValues == nil {
panic(fmt.Sprintf("[FormRequest] fail... |
// Copyright 2020 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
package main
import (
"fmt"
"goproject/myproject/driver"
"net/http"
"os"
ph "goproject/myproject/handler/http"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
func main() {
dbName := "products"
dbPass := "docker"
dbHost := "localhost"
dbPort := "... |
package server
type certificatesStrategy string
const (
certificatesStrategyInstaller certificatesStrategy = "installerGeneratedCA"
certificatesStrategyUser certificatesStrategy = "userProvidedCA"
)
type metrics struct {
// what was the platform submitted to the installer?
installerPlatform string
// what ... |
// Package vsphere contains vSphere-specific structures for installer
// configuration and management.
package vsphere
// Name is name for the vsphere platform.
const Name string = "vsphere"
|
package loadbalancer_api
type PathInfo struct {
PathId int `json:"pathId"`
EdgeInfos []EdgeInfo `json:"edgeInfos,omitempty"`
}
type EdgeInfo struct {
StartIp string `json:"startIp"`
StartNodeId string `json:"startNodeId"`
EndIp string `json:"endIp"`
EndNodeId string `json:"endNodeId"`
}
ty... |
package main
import "fmt"
func main() {
slice := []float64{8,6,4,3,2,1}
fmt.Println(avgSlice(slice)) // 4
fmt.Println(sortNumber(5, 10)) // 5 10
var stack1 stack
stack1.push(1)
fmt.Printf("%v\n", stack1) // {1, [1]}
stack1.push(2)
fmt.Printf("%v\n", stack1) // {2, [1 2]}
stack1.pop()
fmt.P... |
package auth
import (
"fmt"
"os"
"github.com/go-redis/redis/v8"
)
// DBAuth ...
type DBAuth struct {
Auth AuthenticationInterface
DB *redis.Client
}
// NewDBAuth ...
func NewDBAuth() *DBAuth {
HOST := os.Getenv("AUTH_HOST")
PORT := os.Getenv("AUTH_PORT")
PASSWORD := os.Getenv("AUTH_PASSWORD")
db := redis... |
// package docker implements a docker launchable type
package docker
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
"gopkg.in/yaml.v2"
"github.com/docker/docker/api/types/filters"
"github.com/square/p2/pkg/cgroups"
"github.com/square/p2/pkg/launch"
"gi... |
package api
import (
"github.com/devfeel/dotweb"
"github.com/devfeel/middleware/cors"
)
func InitRoute(router dotweb.Router){
router.GET("/login", LoginViewHander)//.Use(CustomCROS())
router.GET("/main", MainViewHander)//.Use(CustomCROS())
}
func CustomCROS()dotweb.Middleware{
option:=cors.NewConfig()
optio... |
package gozoo
// #include <zookeeper/zookeeper.h>
import "C"
type ZookeeperEvent int
type ZookeeperError int
type ZookeeperState int
type ZookeeperCreateFlag int
const (
ZooCreatedEvent ZookeeperEvent = iota
ZooDeletedEvent
ZooChangedEvent
ZooChildEvent
ZooSessionEvent
ZooNotWatchingEvent
ZooUnknownEvent
)
c... |
package REPL
import (
"fmt"
"skillz_cli/modules"
"strings"
)
type Shell struct {
*prompt
module modules.Executor
}
func NewShell() *Shell {
return &Shell{
prompt: NewPrompt(""),
module: nil,
}
}
func (sh *Shell) Run() {
defer sh.Close()
for {
sh.Display()
input := strings.TrimSuffix(sh.GetInput(),... |
// 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 state
import (
"github.com/pobo380/network-games/card-game/server/websocket/game/model"
"math/rand"
"time"
)
type State struct {
// Config
rand *rand.Rand
Config model.Config
// GameMaster
PlayOrder model.PlayOrder
// Player
Players []model.Player
// Table
Deck model.Deck
Discards model.... |
package common
import (
hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/pkg/apis/hco/v1beta1"
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
)
var (
HcoConditionTypes = []conditionsv1.ConditionType{
hcov1beta1.ConditionReconcileComplete,
conditionsv1.ConditionAvailable... |
// This file is subject to a 1-clause BSD license.
// Its contents can be found in the enclosed LICENSE file.
package evdev
import "unsafe"
// KeymapEntry.Flags values.
// They specify how the kernel should handle a keymap request.
const (
// Kernel should perform lookup in keymap by @index instead of @scancode
In... |
package main
import (
"fmt"
"os"
"path/filepath"
"time"
"github.com/mndrix/tap-go"
rspecs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/specerror"
"github.com/opencontainers/runtime-tools/validation/util"
"github.com/google/uuid"
)
var signals = []string{
"TERM"... |
package api_test
import (
"context"
"net/http"
"reflect"
"strings"
"testing"
"github.com/chanioxaris/go-datagovgr/api"
"github.com/chanioxaris/go-datagovgr/datagovgrtest"
"github.com/jarcoal/httpmock"
)
func TestHealth_COVID19VaccinationStatistics_Success(t *testing.T) {
ctx := context.Background()
fixture... |
package recommendation
import (
"database/sql"
"github.com/eecs4314prismbreak/WheyPal/user"
_ "github.com/lib/pq"
)
type RecommendationRepo interface {
getRecommendations(userID int) ([]*user.User, error)
monoMatchHandle(userID, targetUserID int, resp RecommendationResponse) error
saveMatch(userID, targetUserI... |
// 3dtd nano game server
// AQ <aq@okaq.com>
// 2020-06-14
package main
import (
"fmt"
"net/http"
"time"
)
const (
INDEX = "3dtd.html"
NANO = "nano/"
)
func motd() {
fmt.Println(time.Now().String())
fmt.Println("web serve localhost:8080")
}
func TowerHandler(w http.ResponseWriter, r *http.Request) {
fmt.Pri... |
package _875_Koko_Eating_Bananas
import "math"
func minEatingSpeed(piles []int, H int) int {
var (
min = 1
max = math.MaxInt32
mid int
)
for mid != (min+max)>>1 {
mid = (min + max) >> 1
if eatOver(piles, mid, H) {
max = mid
} else {
min = mid + 1
}
}
return mid
}
func eatOver(piles []int, k,... |
package auth
import (
"crypto/rsa"
"io/ioutil"
"os"
"path/filepath"
"github.com/dgrijalva/jwt-go"
"github.com/sirupsen/logrus"
"github.com/vitorfhc/heimdall/gql"
)
var pKey *rsa.PrivateKey
func init() {
privateKeyPath, ok := os.LookupEnv("HEIMDALL_PRIVATE_KEY")
if !ok {
logrus.Fatal("Environemnt variable... |
package main
import "fmt"
func main() {
fmt.Println(largestRectangleArea([]int{
2, 1, 5, 6, 2, 3,
}))
}
func largestRectangleArea(heights []int) int {
heights = append([]int{0}, heights...)
heights = append(heights, 0)
var stack []int
max := 0
for i := 0; i < len(heights); i++ {
for len(stack) > 0 &... |
package store
import (
"fmt"
"github.com/anmaslov/nec-parser/config"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
type MongoStore struct {
Session *mgo.Session
Db string
}
// NewMongo новое подключение к монго
func NewMongo(server *config.Db) (*MongoStore, error) {
conn := &mgo.DialInfo{
Addrs: ... |
// Command-line program next-task-time parses an argument for a simulated time
// and expects a "cron-style" config as input. It returns where the given
// configured tasks will run next
package main
import (
"bufio"
"flag"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
func main() {
defer func() {
if r := recover... |
// 由res2go自动生成。
// 在这里写你的事件。
package main
import (
"github.com/Unknwon/goconfig"
"github.com/satori/go.uuid"
"github.com/ying32/govcl/vcl"
"strconv"
"strings"
)
//::private::
type TNewProxyServerFormFields struct {
}
func (f *TNewProxyServerForm) OnFormCreate(sender vcl.IObject) {
}
func (f *TNewProxyServerF... |
package main
import (
"flag"
"os"
"testing"
)
func TestMain(m *testing.M) {
flag.Parse()
os.Exit(m.Run())
}
func TestPoolCC(t *testing.T) {
tests := []struct {
Input string
Expected string
Ok bool
}{
{"pool.ntp.org", "", false},
{"2.pool.ntp.org", "", false},
{"us.pool.ntp.org", "us", tru... |
package eventing
import (
"strings"
"time"
v1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"go.uber.org/zap"
"github.com/kyma-incubator/reconciler/pkg/reconciler/kubernetes/progress"
"githu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.